UNIVERSITARIO : ROLANDO FREDDY QUISPE LLANQUE
CARRERA : CONTADURIA PÚBLICA
MATERIA : INFORMÁTICA
LICENCIADA : JULIE CARLA AGUIRRE MONTALVO
DISEÑO
Visual Basic
Menu Principal y formulario de ventas
CODIGO VISUAL BASCI FORMULARIO MENU PRINCIPAL
‘LLAMAMOS AL FORMULARIO VENTAS
Private Sub Command1_Click()
[Link] = False
[Link]
End Sub
‘#########################
Private Sub Form_Load()
' Centra el Formulario en la Pantalla
Move ([Link] - Width) / 2, ([Link] - Height) / 2
'Aplica la Apriencia al Formulario
[Link] [Link] & "\Skins\[Link]"
[Link] [Link]
'===================
[Link] = Format(Now, "mmm")
[Link] = Format(Now, "d")
[Link] = Format(Now, "ddd")
'====================
'abrimos las bases de datos en el origen del proyecto
'en la carpeta BD que contendra todas las bases de datos
'del sistema Pasteleria Katty
Open [Link] & "\BD\[Link]" For Random As #2 Len = Len(VentasDAT)
End Sub
CODIGO VISUAL BASIC FORMULARIO VENTAS
Dim SumTotal As Double
Dim Fila As Integer
Dim y, i, J, Cont As Integer
Dim t As Variant ' variable que se utilizará para convertirla en mayuscula
'El formatos para aplicar a la variable
'que mostrará el valor con solo 2 numeros decimales
Const moneda As String = "###,##0.00"
Private Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long,
ByVal wMsg As Long, ByVal waram As Long, ByVal lParam As Long) As Long
Private Sub Calendar1_Click()
[Link] = [Link]
End Sub
Private Sub Combo1_Click()
For i = 1 To LOF(1) \ Len(ProductosDAT)
Get #1, i, ProductosDAT
If [Link] = [Link] Then
[Link] = [Link]
[Link] = [Link]
Exit For
End If
Next i
'===================
'[Link]
End Sub
Private Sub Combo1_GotFocus()
Dim Resp As Long
Resp = SendMessageLong([Link], &H14F, True, 0)
[Link] = ""
[Link] = ""
[Link] = ""
[Link] = ""
[Link] = ""
End Sub
Private Sub Combo1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
[Link]
Call Combo1_Click
End If
End Sub
Private Sub Combo1_LostFocus()
If [Link] = "" Then
MsgBox "Porfavor Seleccione un porducto", vbInformation, "Pasteleria Katty"
[Link]
End If
End Sub
Private Sub Command1_Click()
Limpiar_Texts
Limpiar_Grilla
Desbloquear_Texts
SumTotal = 0
[Link] = True
[Link] = True
[Link]
[Link] = 0
'Deshabilitamos el Boton Nuevo
[Link] = False
'[Link] = True
End Sub
Private Sub Command2_Click()
If [Link] = "Vender" Then
If [Link] = "" Then
MsgBox "No Existen Productos para Vender, Porfavor Llene todos los Datos", vbInformation,
"Pasteleria Katty"
[Link]
Else
'habilitamos el text12
[Link] = True
[Link]
'Limpiamos el combo y lo volvemos a llenar los datos con
'la base de datos de Productos
[Link]
For i = 1 To LOF(1) \ Len(ProductosDAT)
Get #1, i, ProductosDAT
[Link] [Link]
Next i
'Limpiamos Los Text
' [Link] = ""
' [Link] = ""
' [Link] = ""
' [Link] = ""
' [Link] = ""
' [Link] = ""
' [Link] = ""
' [Link] = ""
' [Link] = ""
' Bloquear_Texts
[Link] = "Continuar"
Call Bloquear_Texts
[Link] = False
'[Link] = False
End If
Else
opcion = MsgBox("Desea Continuar agregando productos a la lista?", vbYesNo + vbInformation,
"Pasteleria Katty")
If opcion = vbYes Then
[Link] = "Vender"
' [Link] = False
' [Link] = True
' [Link] = True
' Limpiar_Texts
' Bloquear_Texts
' Limpiar_Grilla
' [Link] = 0
Call Desbloquear_Texts
[Link] = ""
[Link] = ""
[Link] = False
[Link]
Else
[Link]
End If
End If
End Sub
Private Sub Command3_Click()
Unload Me
[Link] = True
End Sub
Private Sub Command4_Click()
opcion = MsgBox("Está Seguro de Cancelar la Venta?", vbYesNo + vbExclamation, "Pasteleria Katty")
If opcion = vbYes Then
Limpiar_Texts
Limpiar_Grilla
Bloquear_Texts
[Link] = 0
[Link] = "Vender"
[Link] = False
[Link] = False
[Link] = True
[Link]
[Link]
For i = 1 To LOF(1) \ Len(ProductosDAT)
Get #1, i, ProductosDAT
[Link] [Link]
Next i
End If
End Sub
Private Sub Semana()
'Validamos la fecha del dia de hoy en el monthview
[Link] = Format(Now, "d / mmm / yyyy")
'Mostramos en el label20 el numero de semana al que corresponde
'la fecha del dia de hoy
[Link] = [Link]
End Sub
Private Sub Form_Load()
'Esto hace que el formulario se acomode en el centro de la pantalla
Move ([Link] - Width) / 2, ([Link] - Height) / 2
'==================================================
'Mostramos en el label20 el numero de semana al que corresponde la fecha de hoy
Call Semana
'
' Con esto podemos Saber la Cantidad de Registros que tiene
' nuestra Base de Datos
Cont = LOF(2) / Len(VentasDAT)
t=0
'Aqui pues vamos verificar el numero de venta(Recibo)que se añade
'al codigo de venta en la parte final, Codigo que se muestra en el Label4
If Cont = 0 Then
[Link] = 1
Else
For J = 1 To LOF(2) / Len(VentasDAT)
Get #2, J, VentasDAT
If J = Cont Then
[Link] = [Link]
[Link] = Val([Link]) + 1
End If
Next J
End If
'====================================================
'Limpiamos los text
Limpiar_Texts
'Intercalamos el color de las filas de la grilla
[Link] = &HE0E0E0
'Aplicamos la Apriencia al Formulario
[Link] [Link] & "\Skins\[Link]"
[Link] [Link]
' iniciamos la la variable SumoTal en 0 para la venta
SumTotal = 0
' Mostramos la fecha actual
[Link] = Format(Now, "ddd, d / mmm / yyyy")
' Mostramos en el label el codigo de control
[Link] = Format(Now, "yymmd-" & "V" & [Link]) '[Link])
'==============
' este valor es para un contador que almacena el dato para luego
' utilizarlo en el llenado de la grilla
[Link] = 0
[Link] = False
'=============
Bloquear_Texts
'Procedimiento para el combo1, Para mostrar la lista de productos
'que se tiene almacenado en una base de datos.
[Link]
For i = 1 To LOF(1) \ Len(ProductosDAT)
Get #1, i, ProductosDAT
[Link] [Link]
Next i
Fila = 1
End Sub
' Proceso para limpiar los cuadros de texto dek formulario
Private Sub Bloquear_Texts()
[Link] = False
[Link] = False
[Link] = False
[Link] = False
[Link] = False
[Link] = False
' [Link] = ""
' [Link] = ""
' [Link] = ""
[Link] = False
[Link] = False
'[Link] = False
'[Link] = False
[Link] = False
End Sub
Private Sub Desbloquear_Texts()
[Link] = True
[Link] = True
[Link] = True
[Link] = True
[Link] = True
[Link] = True
' [Link] = ""
' [Link] = ""
' [Link] = ""
[Link] = True
[Link] = True
'[Link] = True
' [Link] = True
[Link] = True
End Sub
Private Sub Limpiar_Texts()
[Link] = ""
[Link] = ""
[Link] = ""
[Link] = ""
[Link] = ""
[Link] = ""
' [Link] = ""
' [Link] = ""
' [Link] = ""
[Link] = ""
[Link] = ""
[Link] = ""
[Link] = ""
' [Link] = ""
[Link] = ""
[Link] = ""
End Sub
Private Sub Form_Unload(Cancel As Integer)
Unload Me
[Link] = True
End Sub
Private Sub Text1_Click()
'Hace Que se seleccione el texto que incluye
[Link] = 0
[Link] = Len(Text1)
If [Link] = "S/N" Then [Link] = ""
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If [Link] = "" Then
[Link] = "S/N"
[Link] = "S/N"
'[Link]
[Link]
beep: KeyAscii = 0
Else
[Link]
beep
End If
End If
End Sub
Private Sub Text1_LostFocus()
Dim Cadena, Chaa, pru As String
Dim i As Variant
Cadena = ""
Chaa = ""
Chaa = UCase(Mid([Link], 1, 1))
Cadena = Chaa
For i = 2 To Len([Link])
pru = LCase(Mid([Link], i, 1))
If pru Like " " Then
t=1
Cadena = Cadena & " "
Else
If t = 0 Then
Chaa = LCase(pru)
Cadena = Cadena + Chaa
Else
Chaa = UCase(pru)
Cadena = Cadena + Chaa
t=0
End If
End If
Next i
' Cadena = Cadena + Chaa
[Link] = Cadena
[Link] = Len([Link])
End Sub
Private Sub Text11_KeyPress(KeyAscii As Integer)
Dim prev As Double
Dim descu As Double
Dim totalv As Double
prev = 0
descu = Val([Link])
totalv = 0
If KeyAscii = 13 Then
' aqui estamos controlando que el valor del descuento
' no sea mayor que el precio de venta
If descu <= Val([Link]) Then
prev = [Link]
descu = Val([Link])
totalv = prev - descu
[Link] = totalv
Call Precio
LlenarGrilla_Venta
[Link]
Else
MsgBox "No puede el Descuento ser mayor que el precio de Venta", , "Error en Descuento"
[Link] = ""
[Link]
End If
End If
'Esta instruccion solo permite el ingreso de numeros y el punto decimal
If InStr("0123456789." & Chr(8), Chr(KeyAscii)) = 0 Then KeyAscii = 0
End Sub
Private Sub Text12_Change()
If [Link] = "" Then [Link] = ""
End Sub
Private Sub Text12_Click()
[Link] = 0
[Link] = Len(Text12)
End Sub
Private Sub Text12_KeyPress(KeyAscii As Integer)
Dim Cambio As Double
Dim Efectivo As Double
Dim TotalBs As Double
Efectivo = 0
Cambio = 0
TotalBs = 0
TotalBs = [Link]
If KeyAscii = 13 Then
' Aqui estamos verificando que el valor del precio a cobrtar
' no sea menor que el total de la venta a cobrar
If Val([Link]) >= [Link] Then
Efectivo = Val([Link])
Cambio = Efectivo - TotalBs
[Link] = Format$(Cambio, moneda)
[Link] = True
[Link]
beep: KeyAscii = 0
Else
MsgBox "Verifique porfavor, el Monto de Cobro no puede ser menor que el total a Cobrar",
vbInformation, "Pasteleria Katty"
[Link] = ""
[Link]
End If
End If
'Esta instruccion solo permite el ingreso de numeros y el punto decimal
If InStr("0123456789." & Chr(8), Chr(KeyAscii)) = 0 Then KeyAscii = 0
End Sub
Private Sub Text13_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
MsgBox "La Venta se realizo Exitosamente", vbInformation, "Pasteleria Katty"
Call Contador
Call Guardar_DatosGrilla
Limpiar_Texts
Limpiar_Grilla
Bloquear_Texts
[Link] = "Vender"
[Link] = False
[Link] = True
[Link] = True
[Link] = False
[Link] = False
[Link] = False
[Link]
' Con esto podemos Saber la Cantidad de Registros que tiene
' nuestra Base de Datos
'y = LOF(2) / Len(VentasDAT)
'[Link] = y + 1
[Link] = Val([Link]) + 1
' Mostramos en el label el codigo de control
[Link] = Format(Now, "yymmd-" & "V" & [Link])
End If
beep: KeyAscii = 0
End Sub
Private Sub Contador()
Cont = LOF(2) / Len(VentasDAT)
'[Link] = y + 1
If Cont = 0 Then
[Link] = 1
Else
For J = 1 To LOF(2) \ Len(VentasDAT)
Get #2, J, VentasDAT
If J = Cont Then
[Link] = [Link]
[Link] = Val([Link]) + 1
End If
Next J
End If
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If [Link] = "" Then
[Link] = "S/N"
[Link]
beep: KeyAscii = 0
Else
[Link]
End If
End If
If Chr(KeyAscii) < "0" Or Chr(KeyAscii) > "9" Then KeyAscii = 0
End Sub
Private Sub Text4_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If Val([Link]) <= 0 Then
MsgBox "Ingrese una cantidad mayor a cero porfavor", , "Error"
[Link] = ""
[Link] = ""
[Link]
Else
pu = [Link]
cant = Val([Link])
venta = pu * cant
[Link] = venta
[Link] = venta
[Link]
[Link] = [Link] * Val([Link])
beep: KeyAscii = 0
End If
End If
'Esta instruccion solo permite el ingreso de
'numeros y ademas de la tecla retroceso
If InStr("0123456789" & Chr(8), Chr(KeyAscii)) = 0 Then KeyAscii = 0
End Sub
Private Sub Precio()
a = [Link]
' Proceso para obtener el cobro total de un producto
' y mostrarlo en el text10'
SumTotal = SumTotal + a
'Mostramos el resultado con solo dos decimales
[Link] = Format$(SumTotal, moneda)
End Sub
Private Sub Timer1_Timer()
[Link] = Format(Now, "hh:mm:ss")
End Sub
'========= Llenar datos en el Flexgrid ==========
Private Sub LlenarGrilla_Venta()
Dim J, Fila As Integer
Fila = Val([Link])
With KlexGrid1
Fila = Fila + 1
.TextMatrix(Fila, 0) = Fila
.TextMatrix(Fila, 1) = [Link]
.TextMatrix(Fila, 2) = [Link]
.TextMatrix(Fila, 3) = [Link]
.TextMatrix(Fila, 4) = Val([Link])
.TextMatrix(Fila, 5) = [Link]
[Link] = Fila
'este proceso es para mostrar el precio base del producto a vender
[Link](Fila, 1) = [Link]
'si llego a llenar 28 productos en la lista procederá a grabar la venta
If Fila = 28 Then
MsgBox "Llego al Limite del listado, realise la venta porfavor", vbInformation, "Pasteleria Katty"
Call Command2_Click 'para que realise la venta
End If
End With
End Sub
'============ Limpiar KlexGrid1 ============
Private Sub Limpiar_Grilla()
c = Val([Link])
f=0
With KlexGrid1
For J = 1 To c
f=f+1
.TextMatrix(f, 0) = ""
.TextMatrix(f, 1) = ""
.TextMatrix(f, 2) = ""
.TextMatrix(f, 3) = ""
.TextMatrix(f, 4) = ""
.TextMatrix(f, 5) = ""
[Link](f, 1) = ""
Next
End With
End Sub
Private Sub Guardar_DatosGrilla()
'se almacena la cantidad de productos listados en el Flexgrid
a = Val([Link])
f=0
'With KlexGrid1
For J = 1 To a
f=f+1
'Datos que se guardaran de los texts
[Link] = [Link]
[Link] = [Link]
[Link] = [Link]
[Link] = Val([Link])
'===========================
'Datos que se copiaran de la Grilla
'valor = Val([Link](Val(klexSTSum), 0, 1, [Link] - 1, 1))
[Link] = [Link](f, 1)
[Link] = [Link](f, 2)
[Link] = [Link](f, 3)
[Link] = [Link](f, 4)
[Link] = [Link](f, 5)
[Link] = [Link](f, 1)
'===========================
'Datos que se guardaran de los texts
[Link] = [Link]
[Link] = [Link]
[Link] = [Link]
[Link] = [Link] 'Almacenamos el numero de semana
'Datos del flujo de efectivo
[Link] = Val([Link])
[Link] = [Link]
[Link] = [Link]
'Se añade los datos a la base de datos
TotalRegVentas = LOF(2) \ Len(VentasDAT)
Put #2, TotalRegVentas + 1, VentasDAT ' .TextMatrix(f, 0) = ""
' .TextMatrix(f, 1) = ""
' .TextMatrix(f, 2) = ""
' .TextMatrix(f, 3) = ""
' .TextMatrix(f, 4) = ""
' .TextMatrix(f, 5) = ""
Next
End Sub
CODIGO EN EL MODULO
Type Ventas
VCodigo As String * 15
VCliente As String * 60
VNit As String * 12
VProducto As String * 60
VCantidad As String * 5
VPrecioUnit As Double
VDescuento As Double
VPrecioVenta As Double
VFecha As String * 20
VHora As String * 10
VUsuario As String * 20
VEfectivo As Double
VCambio As Double
VTotal As Double
VCostoBase As Double
VNumerico As Integer
VSemana As String * 3
End Type
Global VentasDAT As Ventas
Global TotalRegVentas As Integer
Global XCod2 As Integer
CODIGO MODULO PRODUCTOS
Type Productos
NombreProducto As String * 40
PrecioBase As Double
PrecioVenta As Double
End Type
Global ProductosDAT As Productos
Global TotalRegProd As Integer
Global XCod1 As Integer