Vous êtes sur la page 1sur 30

AO DE LA CONSOLIDACIN DEL MAR DE GRAU

PROYECTO: SISTEMA FARMACUTICO


BASE DE DATOS I
Gonzales Len Karen Lizeth
Taqui Wajuyat Flor

16

UNIVERSIDAD POLITCNICA AMAZNICA

1. Diseo Orientado a Objetos


1.1. Diseo de la Base de Datos
1.1.1. Modelo E-R

1.1.2. Modelo Lgico


CATEGORIA
ARTICULO
codArticulo
codCliente (FK)
CodCategoria (FK)
Descripcion
Costo
Precio
Stock
Vencimiento
Estado

PROVEEDOR
Proveedor_Id
DNI_RUC
Nombre
Direccion
Lugar
Telefono
CuentaBancaria
Estado

P gina |1

COMPROBANTE

CodCategoria

TipoComprobante

Nombre
Estado

Serie
Numero

DETALLE_VENTA
Tipo (FK)
Serie (FK)
Numero (FK)
Costo
Precio
Cantidad

CLIENTE
codCliente
DocIdentidad
Nombre
Direccion
Telefono
Estado

VENTAS
Tipo
Serie
Numero
Fecha
Estado
codCliente (FK)

UNIVERSIDAD POLITCNICA AMAZNICA

1.1.3. Modelo Fsico


CATEGORIA
ARTICULO
codArticulo: varchar(20)
codCliente: varchar(20) (FK)
CodCategoria: varchar(20) (FK)
Descripcion: varchar(30)
Costo: numeric(8,2)
Precio: smallmoney
Stock: integer
Vencimiento: datetime
Estado: char(1)

PROVEEDOR

COMPROBANTE

DNI_RUC: varchar(11)
Nombre: varchar(20)
Direccion: varchar(30)
Lugar: varchar(20)
Telefono: numeric(9)
CuentaBancaria: varchar(16)
Estado: char(1)

Nombre: varchar(20)
Estado: char(1)

Serie: numeric(8)
Numero: integer

DETALLE_VENTA
Tipo: varchar(20) (FK)
Serie: numeric(8) (FK)
Numero: integer (FK)
Costo: integer
Precio: integer
Cantidad: integer

CLIENTE

Proveedor_Id: varchar(20)

CodCategoria: varchar(20)

TipoComprobante: varchar(20)

codCliente: varchar(20)
DocIdentidad: numeric(11)
Nombre: varchar(20)
Direccion: varchar(30)
Telefono: numeric(9)
Estado: char(1)

VENTAS
Tipo: varchar(20)
Serie: numeric(8)
Numero: integer
Fecha: datetime
Estado: char(1)
codCliente: varchar(20) (FK)

1.1.4. Diseo e Implementacin de la Base de Datos (Tablas,


procedimientos Almacenados, etc.)

PROCEDIMIENTOS
Comprobante
ALTER PROCEDURE [dbo].[Comprobante_pa]
AS
begin
SELECT *FROM comprobantes
End

Consultar
ALTER PROCEDURE [dbo].[consultar_PA]
AS
SELECT descripcion FROM Articulos

P gina |2

UNIVERSIDAD POLITCNICA AMAZNICA

Detalle Venta
ALTER procedure [dbo].[Detalleventa_p]
@Tipo varchar(50),
@serie char(3),
@numero char(6),
@codArticulo int,
@costo money,
@precio money,
@cantidad int
as
begin
insert into VENTADETALLEE (TIPO ,SERIE ,NUMERO ,CODARTICULO,COSTO ,PRECIO
,CANTIDAD )values(@Tipo,@serie ,@numero ,@codArticulo ,@costo ,@precio
,@cantidad )
update ARTICULOS_COMPRA set STOCK =STOCK -@cantidad where CODIGO =@codArticulo
end

Grabar Detalle
ALTER PROCEDURE [dbo].[Grabardetalle]
@tipo varchar(50),
@serie varchar(3),
@numero varchar(6),
@codarticulo int,
@costo money,
@precioreal money,
@precioventa money,
@cantidad int
as
begin
INSERT INTO DetalleVenta(tipo,serie,numero
,codarticulo,costo,precioreal,precioventa,cantidad)
VALUES
(@tipo,@serie,@numero,@codarticulo,@costo,@precioreal,@precioventa,@canti
dad)
end
update Articulos set stock=stock-@cantidad where codigo=@codarticulo
end

Grabar Venta
ALTER procedure [dbo].[grabarventa_pa]
@tipo varchar(50),
@serie char(3),
@numero char(6),
@fecha datetime,
@codCliente int
as
begin
insert into VENTASS(TIPO ,SERIE ,NUMERO ,FECHA ,CODCLIENTE )values(@tipo,@serie
,@numero ,@fecha ,@codCliente)
update COMPROBANTE_COMPRA set NUMERO =NUMERO +1 where TIPO =@tipo
end

Ingresar Proveedor
ALTER procedure [dbo].[IngresarProveedor_PA]
@nombre VARCHAR(50),

P gina |3

UNIVERSIDAD POLITCNICA AMAZNICA


@direccion VARCHAR(50),
@telefono varchar(50),
@lugar varchar(50),
@correoelectronico varchar(50),
@cuentabancaria varchar(50),
@estado char(1)
as
begin
INSERT INTO proveedores (nombre,direccion,telefono,lugar,
correoelectronico,cuentabancaria,estado)
values (@nombre,@direccion,@telefono,@lugar,
@correoelectronico,@cuentabancaria,@estado )
end

Insertar Articulos
ALTER PROCEDURE [dbo].[insert_ARTICULOS_pa]
@descr nchar(100),
@cost money,
@prec money,
@sto int,
@venci datetime,
@esta nchar(1)
as
begin
insert into ARTICULOS_COMPRA(DESCRIPCION,COSTO ,PRECIO ,STOCK
,ESTADO)values(@descr,@cost ,@prec ,@sto ,@venci,@esta )
end

,VENCIMIENTO

Insertar Cliente
ALTER PROCEDURE [dbo].[insert_Cliente]
@documento varchar(8),
@nombre varchar(50),
@direccin varchar(100),
@telefono int,
@esta char(1)
as
begin
insert into CLIENTE (DOCUMENTOIDENTIDAD ,NOMBRE
,ESTADO)values(@documento ,@nombre
,@direccin

,DIRECCION ,TELEFONO
,@telefono ,@esta )

Registrar Venta
ALTER PROCEDURE [dbo].[RegistrarVenta_PA]
@tipo varchar(50),
@serie varchar(3),
@numero varchar(6),
@fecha datetime,
@codcliente int
as
begin
insert into Ventas (tipo,serie,numero,fecha,codcliente,estado) values
(@tipo,@serie,@numero,@fecha,@codcliente,'A')
-----para k cuente el numero de serie de 1 en 1
update comprobantes set numero=numero+1 where tipo=@tipo
end

P gina |4

UNIVERSIDAD POLITCNICA AMAZNICA

1.2. Diseo del Sistema


1.2.1. Formas de Acceso

1.2.2. Diseo de Men

P gina |5

UNIVERSIDAD POLITCNICA AMAZNICA

1.2.3. Diseos de Entradas de Datos (Mantenimiento,


Movimientos, Etc.)
FORMULARIO DE VENTAS

FORMULARIO DE INGRESO DE PROVEEDOR

P gina |6

UNIVERSIDAD POLITCNICA AMAZNICA

FORMULARIO DE REGISTRO DEL CLIENTE

FORMULARIO AGREGAR ARTICULO

P gina |7

UNIVERSIDAD POLITCNICA AMAZNICA

FORMULARIO ACTUALIZAR

1.2.4. Diseos de Salidas de Datos (Consultas, Reportes, Etc.)


LISTADO DE VENTAS

P gina |8

UNIVERSIDAD POLITCNICA AMAZNICA

LISTADO DE ARTICULOS

2. Arquitectura tecnolgica Requerida


2.1.1. Requerimiento de Hardware y Software
PROYECTO VISUAL (FARMACIA)
Se ha utilizado el siguiente espacio (16.3 MB)

P gina |9

UNIVERSIDAD POLITCNICA AMAZNICA

PROYECTO BASE DE DATOS (FARMACIA)


Se ha utilizado el siguiente espacio (4MB)

3. Implementacin del Sistema


3.1.1. Pantallas del Sistema
Formulario Acceso

P g i n a | 10

UNIVERSIDAD POLITCNICA AMAZNICA

Formulario Venta

Formulario Men Principal

Formulario Registrar Cliente

P g i n a | 11

UNIVERSIDAD POLITCNICA AMAZNICA

Formulario Agregar Artculo

Formulario Listado

P g i n a | 12

UNIVERSIDAD POLITCNICA AMAZNICA

Formulario Listado Cliente

Formulario Listado Venta

3.1.2. Cdigo de la Aplicacin


CODIGO: Formulario Acceso
Imports System.Data.SqlClient
Imports System.Data
Public Class ACCESO
Public a As New SqlConnection
Public b As New SqlCommand
Dim ds As New DataSet
Dim da As New SqlDataAdapter
Public c As SqlDataReader
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
btningesar.Click
Abrir()
b.CommandText = "Select * From USUARIO Where NOMBREACCESO = '" &
txtusuario.Text & "' And CONTRASEA = '" & Trim(txtclave.Text) & "'
AND ESTADO='A'"
c = b.ExecuteReader
If c.Read Then
P g i n a | 13

UNIVERSIDAD POLITCNICA AMAZNICA


CodigoDeUsuario = c("CODIGO")
'FRMPRINCIPAL.Lbl_Vendedor.Text = " USUARIO: " & c("NOMBRECOMPLETO")
Usuario = c("NOMBRECOMPLETO")
PRINCIPAL.LBLUSUARIO.Text = c("NOMBRECOMPLETO")
If c("NIVEL") = "B" Then
PRINCIPAL.ToolStripButton3.Visible = False
PRINCIPAL.CLIENTEToolStripMenuItem1.Visible = False
PRINCIPAL.REGISTROSToolStripMenuItem.Visible = False
PRINCIPAL.ToolStripButton5.Visible = False
End If
Cerrar()
PRINCIPAL.Show()
'Me.Hide()
Else
Cerrar()
MsgBox("USUARIO O CONTRASEA INCORRECTO", 16, "ACCESO DENEGADO")
txtclave.Text = ""
txtusuario.Text = ""
txtusuario.Focus()
End If
End Sub
Public Sub Abrir()
a.ConnectionString = "Database=EXAMEN_PARCIAL_RECUPERACION;Integrated
Security=SSPI;Data Source=KAREN\SQLEXPRESS"
a.Open()
b.Connection = a
End Sub
Public Sub Cerrar()
a.Close()
End Sub

CODIGO: Formulario Venta


Imports System.Data.SqlClient
Imports System.Data
Public Class FRM_VENTA
Dim cn As New SqlConnection
Dim cmd As New SqlCommand
Dim da As New SqlDataAdapter
Dim ds As New DataSet
Dim sql As String
Private Sub FRM_VENTA_Load(sender As Object, e As EventArgs) Handles
MyBase.Load
cn.ConnectionString = "DATABASE =
EXAMEN_PARCIAL_RECUPERACION;Integrated Security=SSPI;Data
Source=KAREN\SQLEXPRESS"
cmd.Connection = cn
'Con Vistas
cmd.CommandText = "Select DESCRIPCION from Articulo_V order by
DESCRIPCION"
da.SelectCommand = cmd

P g i n a | 14

UNIVERSIDAD POLITCNICA AMAZNICA


da.Fill(ds, "NOMBRE")
cboarticulo.DataSource = ds.Tables("NOMBRE")
cboarticulo.DisplayMember = "DESCRIPCION"
Titulolista()
'sin Vistas
cmd.CommandText = "Select NOMBRE from CLIENTE order by NOMBRE"
'Atributo que se quiere que muestre
da.SelectCommand = cmd
da.Fill(ds, "lista")
cbocliente.DataSource = ds.Tables("Lista")
cbocliente.DisplayMember = "NOMBRE"
cmd.CommandText = "Select TIPO from COMPROBANTE_COMPRA order by TIPO"
da.SelectCommand = cmd
da.Fill(ds, "COMPROBANTE")
cboComprobante.DataSource = ds.Tables("COMPROBANTE")
cboComprobante.DisplayMember = "TIPO"
cbocliente.Text = "TRANSEUNTE"
End Sub
Private Sub cboarticulo_KeyPress(sender As Object, e As
KeyPressEventArgs) Handles cboarticulo.KeyPress
If Asc(e.KeyChar) = 13 Then
Me.txtcantidad.Focus()
End If
End Sub
Private Sub cboarticulo_SelectedIndexChanged(sender As Object, e As
EventArgs) Handles cboarticulo.SelectedIndexChanged
Dim dt As New DataTable
cmd.CommandText = "Select*from Articulo_v where DESCRIPCION='" &
cboarticulo.Text & "' "
da.SelectCommand = cmd
da.Fill(dt)
If dt.Rows.Count > 0 Then
lblcodigo.Text = dt.Rows(0).Item("CODIGO")
lbldescripcion.Text = dt.Rows(0).Item("DESCRIPCION")
lblcosto.Text = Format(dt.Rows(0).Item("COSTO"), "##,##0.00")
lblprecio.Text = Format(dt.Rows(0).Item("PRECIO"), "##,##0.00")
txtvendidoa.Text = Format(dt.Rows(0).Item("PRECIO"), "##,##0.00")
lblstock.Text = dt.Rows(0).Item("STOCK")
dtvencimiento.Value = dt.Rows(0).Item("VENCIMIENTO")
lblestado.Text = dt.Rows(0).Item("ESTADO")
End If
End Sub
Private Sub txtcantidad_KeyPress(sender As Object, e As
KeyPressEventArgs) Handles txtcantidad.KeyPress
If Asc(e.KeyChar) = 27 Then
cboarticulo.Focus()
Exit Sub
End If
If Asc(e.KeyChar) = 13 Then
If Val(txtcantidad.Text) > Val(lblstock.Text) Then
MsgBox("Excede el Stock", 16, "No se Puede Vender")

P g i n a | 15

UNIVERSIDAD POLITCNICA AMAZNICA


Exit Sub
End If
If txtcantidad.Text = "" Then
MsgBox("Ingresa un Valor", 16, "No se puede Realizar la Operacion")
ElseIf Val(txtcantidad.Text) <= 0 Then
MsgBox("Ingrese un Valor Valido", 16, "No se puede Realizar la
Operacion")
Else
'dg.Rows.Count + 1 se coloca para que se unemere de una+1
dg.Rows.Add(lblcodigo.Text, lblcosto.Text, lblprecio.Text,
dg.Rows.Count + 1, txtcantidad.Text, lbldescripcion.Text,
txtvendidoa.Text, lblimporte.Text)
totalizar()
limpiar()
cboarticulo.Focus()
End If
End If
End Sub
Private Sub txtcantidad_TextChanged(sender As Object, e As EventArgs)
Handles txtcantidad.TextChanged
lblimporte.Text = Format(Val(txtcantidad.Text) *
Val(txtvendidoa.Text), "##,##0.00")
lblutilidad.Text = Format(Val(lblimporte.Text) (Val(txtcantidad.Text) * Val(lblcosto.Text)), "##,##0.00")
End Sub
Private Sub txtvendidoa_TextChanged(sender As Object, e As EventArgs)
Handles txtvendidoa.TextChanged
lblimporte.Text = Format(Val(txtcantidad.Text) *
Val(txtvendidoa.Text), "##,##0.00")
lblutilidad.Text = Format(Val(lblimporte.Text) (Val(txtcantidad.Text) * Val(lblcosto.Text)), "##,##0.00")
End Sub
Sub Titulolista()
Me.dg.ColumnCount = 0
'Aqui aparecen los titulos
Me.dg.Columns.Add("CODIGO", "CODIGO")
Me.dg.Columns.Add("COSTO", "COSTO")
Me.dg.Columns.Add("PRECIOREAL", "PRECIOREAL")
Me.dg.Columns.Add("ITEM", "ITEM")
Me.dg.Columns.Add("CANTIDAD", "CANTIDAD")
Me.dg.Columns.Add("DESCRIPCION", "DESCRIPCION")
Me.dg.Columns.Add("PRECIO", "PRECIO")
Me.dg.Columns.Add("IMPORTE", "IMPORTE")
'Para Ocultar los Columnas
Me.dg.Columns("CODIGO").Visible = False
Me.dg.Columns("COSTO").Visible = False
Me.dg.Columns("PRECIOREAL").Visible = False
'Dar Ubicacion a la derecha
Me.dg.Columns("PRECIO").DefaultCellStyle.Alignment =
DataGridViewContentAlignment.MiddleRight

P g i n a | 16

UNIVERSIDAD POLITCNICA AMAZNICA


Me.dg.Columns("IMPORTE").DefaultCellStyle.Alignment =
DataGridViewContentAlignment.MiddleRight
'Para dar el tamao
Me.dg.Columns("DESCRIPCION").Width = 200
Me.dg.Columns("ITEM").Width = 60
Me.dg.Columns("CANTIDAD").Width = 90
'Para no permitir Modifica el uso de readonly
Me.dg.Columns("ITEM").ReadOnly = True
Me.dg.Columns("DESCRIPCION").ReadOnly = True
Me.dg.Columns("IMPORTE").ReadOnly = True
End Sub
Sub totalizar()
Dim i As Integer
Dim total As Single
For i = 0 To dg.Rows.Count - 1
total = total + dg.Rows(i).Cells("IMPORTE").Value
Next
lbltotal.Text = Format(total, "##,##0.00")
End Sub
Private Sub txtbillete_KeyPress(sender As Object, e As
KeyPressEventArgs) Handles txtbillete.KeyPress
Dim billete As Double = Val(txtbillete.Text)
Dim total As Double = Val(lbltotal.Text)
Dim vuelto As Double = 0
If Asc(e.KeyChar) = 13 Then
If billete < total Then
MsgBox("DINERO INSUFICIENTE", 16, "AVISO")
Else
vuelto = billete - total
lblvuelto.Text = vuelto
End If
End If
End Sub
Private Sub txtbillete_TextChanged(sender As Object, e As EventArgs)
Handles txtbillete.TextChanged
End Sub
Sub limpiar()
Me.txtcantidad.Clear()
Me.txtvendidoa.Clear()
Me.lblimporte.Text = ""
Me.lblutilidad.Text = ""
End Sub
Private Sub dg_CellContentClick(sender As Object, e As
DataGridViewCellEventArgs) Handles dg.CellContentClick
End Sub
Private Sub dg_CellEndEdit(sender As Object, e As
DataGridViewCellEventArgs) Handles dg.CellEndEdit

P g i n a | 17

UNIVERSIDAD POLITCNICA AMAZNICA


dg.CurrentRow.Cells("IMPORTE").Value =
dg.CurrentRow.Cells("CANTIDAD").Value *
dg.CurrentRow.Cells("PRECIO").Value
totalizar()
End Sub
Private Sub BILLETEToolStripMenuItem_Click(sender As Object, e As
EventArgs) Handles BILLETEToolStripMenuItem.Click
txtbillete.Focus()
End Sub
Private Sub LIMPIARToolStripMenuItem_Click(sender As Object, e As
EventArgs) Handles LIMPIARToolStripMenuItem.Click
If dg.RowCount > 0 Then
Dim result As Integer = MessageBox.Show("Estas Seguro para Limpiar?",
"Sistema", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If result = DialogResult.Yes Then
dg.Rows.Clear()
lbltotal.Text = ""
lblvuelto.Text = ""
txtbillete.Clear()
'falta
ElseIf result = DialogResult.No Then
Exit Sub
End If
Else
MessageBox.Show("No existe Datos", "Sistema", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End If
End Sub
Private Sub cbocliente_SelectedIndexChanged(sender As Object, e As
EventArgs) Handles cbocliente.SelectedIndexChanged
Dim dt As New DataTable
cmd.CommandText = "Select*from CLIENTE where NOMBRE='" &
cbocliente.Text & "' "
da.SelectCommand = cmd
da.Fill(dt)
If dt.Rows.Count > 0 Then
lblcodigocliente.Text = dt.Rows(0).Item("CODIGO")
Else
lblcodigocliente.Text = ""
End If
End Sub
Private Sub cboComprobante_SelectedIndexChanged(sender As Object, e
As EventArgs) Handles cboComprobante.SelectedIndexChanged
Dim dt As New DataTable
cmd.CommandText = "Select*from COMPROBANTE_COMPRA where TIPO='" &
cboComprobante.Text & "' "
da.SelectCommand = cmd
da.Fill(dt)
If dt.Rows.Count > 0 Then
lblserie.Text = dt.Rows(0).Item("SERIE")

P g i n a | 18

UNIVERSIDAD POLITCNICA AMAZNICA


lblnumero.Text = Format(dt.Rows(0).Item("NUMERO"), "000000")
Else
lblserie.Text = ""
lblnumero.Text = ""
End If
End Sub
Private Sub btnGrabarVenta_Click(sender As Object, e As EventArgs)
Handles btnGrabarVenta.Click
cn.ConnectionString = "DATABASE =
EXAMEN_PARCIAL_RECUPERACION;Integrated Security=SSPI;Data
Source=KAREN\SQLEXPRESS"
sql = "grabarventa_pa"
cn.Open()
da.InsertCommand = New SqlCommand(sql, cn)
da.InsertCommand.CommandType = CommandType.StoredProcedure
da.InsertCommand.Parameters.AddWithValue("@Tipo",
cboComprobante.Text)
da.InsertCommand.Parameters.AddWithValue("@Serie", lblserie.Text)
da.InsertCommand.Parameters.AddWithValue("@numero", lblnumero.Text)
da.InsertCommand.Parameters.AddWithValue("@fecha", dtfecha.Value)
da.InsertCommand.Parameters.AddWithValue("@CodCliente",
lblcodigocliente.Text)
da.InsertCommand.ExecuteNonQuery()
'Grabar el Detalle Venta
For n = 0 To dg.Rows.Count - 1
sql = "Detalleventa_p"
da.InsertCommand = New SqlCommand(sql, cn)
da.InsertCommand.CommandType = CommandType.StoredProcedure
da.InsertCommand.Parameters.AddWithValue("@Tipo",
cboComprobante.Text)
da.InsertCommand.Parameters.AddWithValue("@Serie", lblserie.Text)
da.InsertCommand.Parameters.AddWithValue("@Numero", lblnumero.Text)
da.InsertCommand.Parameters.AddWithValue("@CodArticulo",
dg.Rows(n).Cells("CODIGO").Value)
da.InsertCommand.Parameters.AddWithValue("@costo",
dg.Rows(n).Cells("COSTO").Value)
da.InsertCommand.Parameters.AddWithValue("@precio",
dg.Rows(n).Cells("PRECIO").Value)
da.InsertCommand.Parameters.AddWithValue("@Cantidad",
dg.Rows(n).Cells("CANTIDAD").Value)
da.InsertCommand.ExecuteNonQuery()
Next
cn.Close()
MessageBox.Show("VENTA REGISTRADA CORRECTAMENTE", "Mensaje",
MessageBoxButtons.OK, MessageBoxIcon.Information)
limpiar()
dg.Rows.Clear()
'lblserie.Text = ""
'lblnumero.Text = ""
'lblcodigocliente.Text = ""
lbltotal.Text = ""
lblvuelto.Text = ""
txtbillete.Clear()
cboComprobante_SelectedIndexChanged(sender, e)

P g i n a | 19

UNIVERSIDAD POLITCNICA AMAZNICA


End Sub
Private Sub btnAgregarCliente_Click(sender As Object, e As EventArgs)
Handles btnAgregarCliente.Click
Close()
End Sub
Private Sub GroupBox1_Enter(sender As Object, e As EventArgs) Handles
GroupBox1.Enter
End Sub
Private Sub PrintDocument1_PrintPage(sender As Object, e As
Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
'e.Graphics.DrawImage(lblcodigocliente.Text, New Font("Arial", 18,
FontStyle.Bold), Brushes.Blue, 100, 200)
e.Graphics.DrawImage(PictureBox1.Image, 10, 10, 500, 650)
e.Graphics.DrawString(lblnumero.Text, New Font("Arial", 10,
FontStyle.Bold), Brushes.Blue, 430, 80)
'e.Graphics.DrawString(Microsoft.VisualBasic.Day(DtFecha.Value), New
Font("Arial", 12, FontStyle.Bold), Brushes.Blue, 800, 85)
'''' ------------------------------------------------------------------------------------isquierda 450, sube arriba 600
e.Graphics.DrawString(lbltotal.Text, New Font("Arial", 10,
FontStyle.Bold), Brushes.Blue, 450, 640)
e.Graphics.DrawString(cbocliente.Text, New Font("Arial", 10,
FontStyle.Bold), Brushes.Blue, 200, 190)
e.Graphics.DrawString(txtdireccion.Text, New Font("Arial", 10,
FontStyle.Bold), Brushes.Blue, 200, 230)
e.Graphics.DrawString(txtdni.Text, New Font("Arial", 10,
FontStyle.Bold), Brushes.Blue, 180, 250)
e.Graphics.DrawString(dtfecha.Text, New Font("Arial", 10,
FontStyle.Bold), Brushes.Blue, 320, 250)
'para el RUC
e.Graphics.DrawString(lblserie.Text, New Font("Arial", 10,
FontStyle.Bold), Brushes.Blue, 200, 210)
e.Graphics.DrawString(lblnumero.Text, New Font("Arial", 10,
FontStyle.Bold), Brushes.Blue, 230, 210)
'para la tbla
Dim n As Integer
For n = 0 To dg.Rows.Count - 1
e.Graphics.DrawString(dg.Text, New Font("Arial", 10, FontStyle.Bold),
Brushes.Blue, 100, 800)
e.Graphics.DrawString(dg.Rows(n).Cells("cantidad").Value, New
Font("Arial", 10, FontStyle.Bold), Brushes.Blue, 50, 330 + n * 20)
e.Graphics.DrawString(dg.Rows(n).Cells("descripcion").Value, New
Font("Arial", 10, FontStyle.Bold), Brushes.Blue, 100, 330 + n * 20)
e.Graphics.DrawString(dg.Rows(n).Cells("precio").Value, New
Font("Arial", 10, FontStyle.Bold), Brushes.Blue, 340, 330 + n * 20)
e.Graphics.DrawString(dg.Rows(n).Cells("importe").Value, New
Font("Arial", 10, FontStyle.Bold), Brushes.Blue, 450, 330 + n * 20)
Next
End Sub

P g i n a | 20

UNIVERSIDAD POLITCNICA AMAZNICA


Private Sub cboDireccion_SelectedIndexChanged(sender As Object, e As
EventArgs)
End Sub
Private Sub txtdireccion_KeyPress(sender As Object, e As
KeyPressEventArgs) Handles txtdireccion.KeyPress
If Asc(e.KeyChar) = 13 Then
txtdni.Focus()
Exit Sub
End If
End Sub
Private Sub txtdireccion_TextChanged(sender As Object, e As
EventArgs) Handles txtdireccion.TextChanged
End Sub
Private Sub txtdni_KeyPress(sender As Object, e As KeyPressEventArgs)
Handles txtdni.KeyPress
If Asc(e.KeyChar) = 13 Then
BTNiMPRIMIR.Focus()
Exit Sub
End If
End Sub
Private Sub txtdni_TextChanged(sender As Object, e As EventArgs)
Handles txtdni.TextChanged
End Sub
Private Sub BTNiMPRIMIR_Click(sender As Object, e As EventArgs)
Handles BTNiMPRIMIR.Click
PrintDocument1.Print()
End Sub
End Class

CODIGO: Formulario Registrar Cliente


Imports System.Data.SqlClient
Imports System.Data
Public Class REGISTRARCLIENTE
Dim cn As New SqlConnection
Dim da As New SqlDataAdapter
Dim sql As String
Private Sub btnguardar_Click(sender As Object, e As EventArgs)
Handles btnguardar.Click
cn.ConnectionString = "DATABASE =
EXAMEN_PARCIAL_RECUPERACION;Integrated Security=SSPI;Data
Source=KAREN\SQLEXPRESS"
sql = "insert_Cliente"
cn.Open()
da.InsertCommand = New SqlCommand(sql, cn)
da.InsertCommand.CommandType = CommandType.StoredProcedure
da.InsertCommand.Parameters.AddWithValue("@documento", txtdni.Text)
da.InsertCommand.Parameters.AddWithValue("@nombre", txtnombre.Text)

P g i n a | 21

UNIVERSIDAD POLITCNICA AMAZNICA


da.InsertCommand.Parameters.AddWithValue("@direccin",
txtdireccion.Text)
da.InsertCommand.Parameters.AddWithValue("@telefono",
txttelefono.Text)
da.InsertCommand.Parameters.AddWithValue("@esta", txtestado.Text)
da.InsertCommand.ExecuteNonQuery()
MessageBox.Show("CLIENTE REGISTRADO CORRECTAMENTE", "Mensaje",
MessageBoxButtons.OK, MessageBoxIcon.Information)
txtdni.Clear()
txtnombre.Clear()
txtdireccion.Clear()
txttelefono.Clear()
Dispose()
End Sub
Private Sub btnLimpiar_Click(sender As Object, e As EventArgs)
Handles btnLimpiar.Click
txtdni.Clear()
txtnombre.Clear()
txtdireccion.Clear()
txttelefono.Clear()
txtestado.Clear()
End Sub
Private Sub Habilitar(ByVal DATOS As Boolean)
txtdni.Enabled = DATOS
txtnombre.Enabled = DATOS
txtdireccion.Enabled = DATOS
txttelefono.Enabled = DATOS
txtestado.Enabled = DATOS
End Sub
Private Sub btnNuevo_Click(sender As Object, e As EventArgs)
Habilitar(True)
End Sub
Private Sub txtdni_KeyPress(sender As Object, e As KeyPressEventArgs)
Handles txtdni.KeyPress
If Asc(e.KeyChar) = 13 Then
txtnombre.Focus()
End If
If Char.IsNumber(e.KeyChar) Then
e.Handled = False
ElseIf Char.IsControl(e.KeyChar) Then
e.Handled = False
Else
e.Handled = True
MsgBox("SOLO INGRESE NUMEROS POR FAVOR", 16, "ERROR")
End If
End Sub
Private Sub txtdni_TextChanged(sender As Object, e As EventArgs)
Handles txtdni.TextChanged
End Sub

P g i n a | 22

UNIVERSIDAD POLITCNICA AMAZNICA

Private Sub txtnombre_KeyPress(sender As Object, e As


KeyPressEventArgs) Handles txtnombre.KeyPress
If Asc(e.KeyChar) = 13 Then
txtdireccion.Focus()
End If
'Pregunta si no es una letra mayuscula
If Not ((Asc(e.KeyChar) >= 65 And Asc(e.KeyChar) <= 90) Or
(Asc(e.KeyChar) >= 97 And Asc(e.KeyChar) <= 122)) And Asc(e.KeyChar)
<> 8 And Asc(e.KeyChar) <> 32 And Asc(e.KeyChar) <> 209 And
Asc(e.KeyChar) <> 241 Then
e.Handled = True
MsgBox("SOLO INGRESE LETRAS POR FAVOR", 16, "ERROR")
End If
End Sub
Private Sub txtestado_KeyPress(sender As Object, e As
KeyPressEventArgs) Handles txtestado.KeyPress
If Asc(e.KeyChar) = 13 Then
btnguardar.Focus()
End If
'Pregunta si no es una letra mayuscula
If Not ((Asc(e.KeyChar) >= 65 And Asc(e.KeyChar) <= 90) Or
(Asc(e.KeyChar) >= 97 And Asc(e.KeyChar) <= 122)) And Asc(e.KeyChar)
<> 8 And Asc(e.KeyChar) <> 32 And Asc(e.KeyChar) <> 209 And
Asc(e.KeyChar) <> 241 Then
e.Handled = True
MsgBox("SOLO INGRESE LETRAS POR FAVOR", 16, "ERROR")
End If
End Sub
Private Sub txtestado_TextChanged(sender As Object, e As EventArgs)
Handles txtestado.TextChanged
End Sub
Private Sub txtdireccion_KeyPress(sender As Object, e As
KeyPressEventArgs) Handles txtdireccion.KeyPress
If Asc(e.KeyChar) = 13 Then
txttelefono.Focus()
End If
End Sub
Private Sub txtdireccion_TextChanged(sender As Object, e As
EventArgs) Handles txtdireccion.TextChanged
End Sub
Private Sub txttelefono_KeyPress(sender As Object, e As
KeyPressEventArgs) Handles txttelefono.KeyPress
If Asc(e.KeyChar) = 13 Then
txtestado.Focus()
End If
If Char.IsNumber(e.KeyChar) Then
e.Handled = False
ElseIf Char.IsControl(e.KeyChar) Then
e.Handled = False

P g i n a | 23

UNIVERSIDAD POLITCNICA AMAZNICA


Else
e.Handled = True
MsgBox("SOLO INGRESE NUMEROS POR FAVOR", 16, "ERROR")
End If
End Sub
Private Sub txttelefono_TextChanged(sender As Object, e As EventArgs)
Handles txttelefono.TextChanged
End Sub
Private Sub btnsalir_Click(sender As Object, e As EventArgs) Handles
btnsalir.Click
Close()
End Sub
Private Sub txtnombre_TextChanged(sender As Object, e As EventArgs)
Handles txtnombre.TextChanged
End Sub
End Class

CODIGO: Formulario Agregar Artculo


Imports System.Data.SqlClient
Imports System.Data
Public Class AGREGAR_ARTICULO
Dim cn As New SqlConnection
Dim da As New SqlDataAdapter
Dim sql As String
Private Sub btnguardar_Click(sender As Object, e As EventArgs)
Handles btnguardar.Click
cn.ConnectionString = "DATABASE =
EXAMEN_PARCIAL_RECUPERACION;Integrated Security=SSPI;Data
Source=KAREN\SQLEXPRESS"
sql = "insert_ARTICULOS_pa"
cn.Open()
da.InsertCommand = New SqlCommand(sql, cn)
da.InsertCommand.CommandType = CommandType.StoredProcedure
da.InsertCommand.Parameters.AddWithValue("@descr",
txtdescripcion.Text)
da.InsertCommand.Parameters.AddWithValue("@cost", txtcosto.Text)
da.InsertCommand.Parameters.AddWithValue("@prec", txtprecio.Text)
da.InsertCommand.Parameters.AddWithValue("@sto ", txtstock.Text)
da.InsertCommand.Parameters.AddWithValue("@venci",
dtvencimiento.Value)
da.InsertCommand.Parameters.AddWithValue("@esta ", txtEstado.Text)
da.InsertCommand.ExecuteNonQuery()
MessageBox.Show("ARTCULO REGISTRADO CORRECTAMENTE", "Mensaje",
MessageBoxButtons.OK, MessageBoxIcon.Information)
txtdescripcion.Clear()
txtcosto.Clear()
txtprecio.Clear()
txtstock.Clear()
txtEstado.Clear()

P g i n a | 24

UNIVERSIDAD POLITCNICA AMAZNICA


cn.Close()
End Sub
Private Sub Habilitar(ByVal DATOS As Boolean)
txtdescripcion.Enabled = DATOS
txtcosto.Enabled = DATOS
txtprecio.Enabled = DATOS
txtstock.Enabled = DATOS
txtEstado.Enabled = DATOS
End Sub
Private Sub txtdescripcion_KeyPress(sender As Object, e As
KeyPressEventArgs) Handles txtdescripcion.KeyPress
If Asc(e.KeyChar) = 13 Then
txtcosto.Focus()
End If
End Sub
Private Sub txtdescripcion_TextChanged(sender As Object, e As
EventArgs) Handles txtdescripcion.TextChanged
End Sub
Private Sub txtcosto_KeyPress(sender As Object, e As
KeyPressEventArgs) Handles txtcosto.KeyPress
If Asc(e.KeyChar) = 13 Then
txtprecio.Focus()
End If
If Char.IsNumber(e.KeyChar) Then
e.Handled = False
ElseIf Char.IsControl(e.KeyChar) Then
e.Handled = False
Else
e.Handled = True
MsgBox("SOLO INGRESE NUMEROS POR FAVOR", 16, "ERROR")
End If
End Sub
Private Sub txtcosto_TextChanged(sender As Object, e As EventArgs)
Handles txtcosto.TextChanged
End Sub
Private Sub txtprecio_KeyPress(sender As Object, e As
KeyPressEventArgs) Handles txtprecio.KeyPress
If Asc(e.KeyChar) = 13 Then
txtstock.Focus()
End If
If Char.IsNumber(e.KeyChar) Then
e.Handled = False
ElseIf Char.IsControl(e.KeyChar) Then
e.Handled = False
Else
e.Handled = True
MsgBox("SOLO INGRESE NUMEROS POR FAVOR", 16, "ERROR")
End If

P g i n a | 25

UNIVERSIDAD POLITCNICA AMAZNICA


End Sub
Private Sub txtprecio_TextChanged(sender As Object, e As EventArgs)
Handles txtprecio.TextChanged
End Sub
Private Sub txtstock_KeyPress(sender As Object, e As
KeyPressEventArgs) Handles txtstock.KeyPress
If Asc(e.KeyChar) = 13 Then
txtEstado.Focus()
End If
If Char.IsNumber(e.KeyChar) Then
e.Handled = False
ElseIf Char.IsControl(e.KeyChar) Then
e.Handled = False
Else
e.Handled = True
MsgBox("SOLO INGRESE NUMEROS POR FAVOR", 16, "ERROR")
End If
End Sub
Private Sub txtstock_TextChanged(sender As Object, e As EventArgs)
Handles txtstock.TextChanged
End Sub
Private Sub txtEstado_KeyPress(sender As Object, e As
KeyPressEventArgs) Handles txtEstado.KeyPress
If Asc(e.KeyChar) = 13 Then
btnguardar.Focus()
End If
If Char.IsLetter(e.KeyChar) Then
e.Handled = False
ElseIf Char.IsControl(e.KeyChar) Then
e.Handled = False
Else
e.Handled = True
MsgBox("SOLO LETRA NUMEROS POR FAVOR", 16, "ERROR")
End If
End Sub
Private Sub txtEstado_TextChanged(sender As Object, e As EventArgs)
Handles txtEstado.TextChanged
End Sub
Private Sub AGREGAR_ARTICULO_Load(sender As Object, e As EventArgs)
Handles MyBase.Load
End Sub
Private Sub btnsalir_Click(sender As Object, e As EventArgs) Handles
btnsalir.Click
Close()
End Sub
End Class

P g i n a | 26

UNIVERSIDAD POLITCNICA AMAZNICA

CODIGO: Formulario Listado


Imports System.Data
Public Class LISTADOTODO
Dim CN As New SqlConnection
Dim CMD As New SqlCommand
Dim DA As New SqlDataAdapter
Dim DS As New DataSet
Private Sub LISTADOTODO_Load(sender As Object, e As EventArgs)
Handles MyBase.Load
CN.ConnectionString = "DATABASE =
EXAMEN_PARCIAL_RECUPERACION;Integrated Security=SSPI;Data
Source=KAREN\SQLEXPRESS"
CMD.Connection = CN
End Sub
Private Sub BTNMOSTAR_Click(sender As Object, e As EventArgs) Handles
BTNMOSTAR.Click
DS.Clear()
CMD.CommandText = "select * from listado_v"
DA.SelectCommand = CMD
DA.Fill(DS, "nombre")
DGVLISTAARTICULOS.DataSource = DS.Tables("nombre")
End Sub
Private Sub btnAgregarCliente_Click(sender As Object, e As EventArgs)
Handles btnAgregarCliente.Click
Close()
End Sub
End Class

CODIGO: Formulario Listado Cliente


Imports System.Data.SqlClient
Imports System.Data
Public Class LISTADO_CLIENTES
Dim CN As New SqlConnection
Dim CMD As New SqlCommand
Dim DA As New SqlDataAdapter
Dim DS As New DataSet
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
DS.Clear()
CMD.CommandText = "Select * From CLIENTE "
DA.SelectCommand = CMD
DA.Fill(DS, "CODIGO")
DGVLISTAARTICULOS.DataSource = DS.Tables("CODIGO")
End Sub
Private Sub LISTADO_CLIENTES_Load(sender As Object, e As EventArgs)
Handles MyBase.Load

P g i n a | 27

UNIVERSIDAD POLITCNICA AMAZNICA


CN.ConnectionString = "DATABASE =
EXAMEN_PARCIAL_RECUPERACION;Integrated Security=SSPI;Data
Source=KAREN\SQLEXPRESS"
CMD.Connection = CN
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles
Button2.Click
Hide()
End Sub
End Class

CODIGO: Formulario Listado Venta


Imports System.Data.SqlClient
Imports System.Data
Public Class LISTA_VENTAS
Dim CN As New SqlConnection
Dim CMD As New SqlCommand
Dim DA As New SqlDataAdapter
Dim DS As New DataSet
Private Sub btnMostrar_Click(sender As Object, e As EventArgs)
Handles btnMostrar.Click
DS.Clear()
'CMD.CommandText = "select * from Lista_Ventas" 'es para mostrar todo
CMD.CommandText = "select * from Lista_Ventas where fecha>='" &
Format(f1.Value, "dd-MM-yyyy") & "' and fecha<='" & Format(f2.Value,
"dd-MM-yyyy") & "' And DESCRIPCION Like '" & txtdescripcion.Text &
"%'"
DA.SelectCommand = CMD
DA.Fill(DS, "DESCRIPCION")
dgVentas.DataSource = DS.Tables("DESCRIPCION")
End Sub
Private Sub LISTA_VENTAS_Load(sender As Object, e As EventArgs)
Handles MyBase.Load
Dim DA As New SqlDataAdapter
Dim DS As New DataSet
cn.ConnectionString = "DATABASE =
EXAMEN_PARCIAL_RECUPERACION;Integrated Security=SSPI;Data
Source=KAREN\SQLEXPRESS"
cmd.Connection = cn
End Sub
Private Sub cboresumen_SelectedIndexChanged(sender As Object, e As
EventArgs) Handles cboresumen.SelectedIndexChanged
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
Hide()
End Sub
End Class

P g i n a | 28

UNIVERSIDAD POLITCNICA AMAZNICA

4. Conclusiones
Para la Farmacia, esperamos que reduzca sus necesidades, consolide una
disminucin de los gastos en gestin y facturacin de recetas y se garantice la
integracin, la seguridad y la fiabilidad de la informacin. Este sistema
esperemos que este en beneficio del ciudadano.
5. Recomendaciones
El sistema Farmacutico es una herramienta que garantiza a la Farmacia la
facilidad de acceder y hacer las respectivas ventas a sus clientes.
6. Glosario de Trminos
SqlDataAdapter: (Clase) Representa un conjunto de comandos de datos
y una conexin de base de datos que se utilizan para rellenar un DataSet y
actualizar una base de datos de SQL Server. Esta clase no puede
heredarse.
DataSet: es una representacin de datos residente en memoria que
proporciona una modelo de programacin relacional coherente
independientemente del origen de datos que contiene..
7. Bibliografa
http://www.academia.edu/9483556/PROYECTO_FARMACIA_CHARITO

8. Anexos(Ver en carpeta de documentos)

P g i n a | 29

Vous aimerez peut-être aussi