Sistema de Control de Mercaderías Proyecto Sistema de Control de Compras y Ventas de Mercaderías Diseño del Menú Principal. Diseño de los formularios de Ingreso Programación botón Nuevo Private Sub NUEVO_Click() Data1.Recordset.AddNew ACTIVAR CANCELAR.Enabled = True GRABAR.Enabled = True REGRESAR.Enabled = False COD_CLI.SetFocus End Sub Botón Cancelar Private Sub CANCELAR_Click() DESACTIVAR CANCELAR.Enabled = False GRABAR.Enabled = False REGRESAR.Enabled = True COD_CLI.SetFocus If Len(COD_CLI) > 0 Then Data1.Recordset.Delete Data1.Recordset.MoveFirst End Sub Sistema de Control de Mercaderías Botón Grabar Private Sub GRABAR_Click() Data1.Recordset.Update DESACTIVAR CANCELAR.Enabled = False REGRESAR.Enabled = True REGRESAR.Enabled = True COD_CLI.SetFocus End Sub Private Sub REGRESAR_Click() Unload Me End Sub Validar cajas de texto para el ingreso deinformación Private Sub COD_CLI_KeyPress(KeyAscii As Integer) If NUEVO.Enabled = True Then Exit Sub Max = Len(COD_CLI) If KeyAscii = 13 Then If (Max) = 0 Then Exit Sub NOM_CLIENTE.SetFocus End If End Sub Private Sub NOM_CLIENTE_KeyPress(KeyAscii As Integer) If NUEVO.Enabled = True Then Exit Sub Max = Len(NOM_CLIENTE) If KeyAscii = 13 Then If (Max) = 0 Then Exit Sub DIR.SetFocus End If If KeyAscii >= 47 And KeyAscii <= 57 Then '# KeyAscii = 0 End If End Sub Private Sub DIR_KeyPress(KeyAscii As Integer) If NUEVO.Enabled = True Then Exit Sub Max = Len(DIR) If KeyAscii = 13 Then If (Max) = 0 Then Exit Sub CIU.SetFocus End If End Sub Private Sub CIU_KeyPress(KeyAscii As Integer) If NUEVO.Enabled = True Then Exit Sub Max = Len(CIU) If KeyAscii = 13 Then If (Max) = 0 Then Exit Sub PRO.SetFocus Sistema de Control de Mercaderías End If If KeyAscii >= 47 And KeyAscii <= 57 Then '# KeyAscii = 0 End If End Sub Private Sub PRO_KeyPress(KeyAscii As Integer) If NUEVO.Enabled = True Then Exit Sub Max = Len(PRO) If KeyAscii = 13 Then If (Max) = 0 Then Exit Sub TEL.SetFocus End If If KeyAscii >= 47 And KeyAscii <= 57 Then '# KeyAscii = 0 End If End Sub Private Sub TEL_KeyPress(KeyAscii As Integer) If NUEVO.Enabled = True Then Exit Sub Max = Len(PRO) If KeyAscii = 13 Then If (Max) = 0 Then Exit Sub TEL.SetFocus End If If TEL.Locked = False And KeyAscii = 13 Then If Len(COD_CLI) > 0 Then If Len(NOM_CLIENTE) > 0 Then If Len(DIR) > 0 Then If Len(CIU) > 0 Then If Len(PRO) > 0 Then If Len(TEL) > 0 Then GRABAR.Enabled = True GRABAR.SetFocus End If End If End If End If End If End If End If End Sub Sistema de Control de Mercaderías Formulario Modificar Clientes Private Sub MODIFICAR_Click() Data1.Recordset.Edit ACTIVAR CANCELAR.Enabled = True GRABAR.Enabled = True REGRESAR.Enabled = False COD_CLI.Locked = True NOM_CLIENTE.Locked = False NOM_CLIENTE.SetFocus End Sub Private Sub CANCELAR_Click() DESACTIVAR CANCELAR.Enabled = False GRABAR.Enabled = False REGRESAR.Enabled = True COD_CLI.SetFocus End Sub Private Sub GRABAR_Click() Data1.Recordset.Update DESACTIVAR CANCELAR.Enabled = False REGRESAR.Enabled = True REGRESAR.Enabled = True GRABAR.Enabled = False COD_CLI.SetFocus End Sub Private Sub REGRESAR_Click() Unload Me End Sub Private Sub BUSCAR_Click() BUS = (InputBox("CODIGO A BUSCAR")) With Data1 sw = 0 .Recordset.MoveFirst Do While Not .Recordset.EOF If (BUS = Me.COD_CLI) Then sw = 1 Exit Do End If .Recordset.MoveNext Loop If (sw = 0) Then MsgBox ("No se encontró") .Recordset.MoveFirst End If Sistema de Control de Mercaderías End With End Sub Validación cajas de texto Private Sub COD_CLI_Change() If MODIFICAR.Enabled = True Then Exit Sub Max = Len(COD_CLI) If KeyAscii = 13 Then If (Max) = 0 Then Exit Sub COD_CLIENTE.SetFocus End If r = KeyAscii If r = 8 Then Exit Sub If r < 65 Or r > 95 Then KeyAscii = 0 End Sub Private Sub NOM_CLIENTE_KeyPress(KeyAscii As Integer) If KeyAscii >= 47 And KeyAscii <= 57 Then '# KeyAscii = 0 End If End Sub Private Sub DIR_KeyPress(KeyAscii As Integer) If MODIFICAR.Enabled = True Then Exit Sub Max = Len(DIR) If KeyAscii = 13 Then If (Max) = 0 Then Exit Sub CIU.SetFocus End If End Sub Private Sub CIU_KeyPress(KeyAscii As Integer) If MODIFICAR.Enabled = True Then Exit Sub Max = Len(CIU) If KeyAscii = 13 Then If (Max) = 0 Then Exit Sub PRO.SetFocus End If If KeyAscii >= 47 And KeyAscii <= 57 Then '# KeyAscii = 0 End If End Sub Private Sub PRO_KeyPress(KeyAscii As Integer) If MODIFICAR.Enabled = True Then Exit Sub Max = Len(PRO) If KeyAscii = 13 Then If (Max) = 0 Then Exit Sub TEL.SetFocus End If If KeyAscii >= 47 And KeyAscii <= 57 Then '# KeyAscii = 0 End If Sistema de Control de Mercaderías End Sub Private Sub TEL_KeyPress(KeyAscii As Integer) If MODIFICAR.Enabled = True Then Exit Sub Max = Len(PRO) If KeyAscii = 13 Then If (Max) = 0 Then Exit Sub TEL.SetFocus End If If TEL.Locked = False And KeyAscii = 13 Then If Len(COD_CLI) > 0 Then If Len(COD_CLIENTE) > 0 Then If Len(DIR) > 0 Then If Len(CIU) > 0 Then If Len(PRO) > 0 Then If Len(TEL) > 0 Then GRABAR.Enabled = True GRABAR.SetFocus End If End If End If End If End If End If End If End Sub Private Sub ELIMINAR_Click() Dim Mensaje, Estilo, Título, Respuesta, MiCadena Mensaje = "¿Desea eliminar?" ' Define el mensaje. Estilo = vbYesNo + vbCritical + vbDefaultButton2 ' Define los botones. Título = "PROVEEDOR" ' Define el título. Respuesta = MsgBox(Mensaje, Estilo, Título) If Respuesta = vbYes Then ' El usuario eligió el botón Sí. Data1.Recordset.Delete Data1.Recordset.MoveLast Else ' El usuario eligió el botón No. End If Private Sub REGRESAR_Click() Unload Me End Sub Sistema de Control de Mercaderías Private Sub NUEVO_Click() Data1.Recordset.AddNew ACTIVAR CANCELAR.Enabled = True REGRESAR.Enabled = False GRABAR.Enabled = True cod_pro.SetFocus End Sub Private Sub CANCELAR_Click() DESACTIVAR CANCELAR.Enabled = False REGRESAR.Enabled = True GRABAR.Enabled = False cod_pro.SetFocus If Len(cod_pro) > 0 Then Data1.Recordset.Delete Data1.Recordset.MoveFirst End Sub Private Sub GRABAR_Click() Data1.Recordset.Update DESACTIVAR CANCELAR.Enabled = False REGRESAR.Enabled = True GRABAR.Enabled = False cod_pro.SetFocus End Sub Private Sub REGRESAR_Click() Unload Me End Sub VALIDACIÓN CAJAS DE TEXTO Private Sub cod_pro_KeyPress(KeyAscii As Integer) If NUEVO.Enabled = True Then Exit Sub Max = Len(cod_pro) If KeyAscii = 13 Then If (Max) = 0 Then Exit Sub NOM_EM.SetFocus End If End Sub Private Sub NOM_EM_KeyPress(KeyAscii As Integer) If NUEVO.Enabled = True Then Exit Sub Max = Len(NOM_EM) If KeyAscii = 13 Then If (Max) = 0 Then Exit Sub DIR.SetFocus Sistema de Control de Mercaderías End If If KeyAscii >= 47 And KeyAscii <= 57 Then '# KeyAscii = 0 End If End Sub Private Sub DIR_KeyPress(KeyAscii As Integer) If NUEVO.Enabled = True Then Exit Sub Max = Len(DIR) If KeyAscii = 13 Then If (Max) = 0 Then Exit Sub CIU.SetFocus End If End Sub Private Sub CIU_KeyPress(KeyAscii As Integer) If NUEVO.Enabled = True Then Exit Sub Max = Len(CIU) If KeyAscii = 13 Then If (Max) = 0 Then Exit Sub PRO.SetFocus End If If KeyAscii >= 47 And KeyAscii <= 57 Then '# KeyAscii = 0 End If End Sub Private Sub PRO_KeyPress(KeyAscii As Integer) If NUEVO.Enabled = True Then Exit Sub Max = Len(PRO) If KeyAscii = 13 Then If (Max) = 0 Then Exit Sub TEL.SetFocus End If If KeyAscii >= 47 And KeyAscii <= 57 Then '# KeyAscii = 0 End If End Sub Private Sub TEL_KeyPress(KeyAscii As Integer) If NUEVO.Enabled = True Then Exit Sub Max = Len(PRO) If KeyAscii = 13 Then If (Max) = 0 Then Exit Sub TEL.SetFocus End If If TEL.Locked = False And KeyAscii = 13 Then If Len(cod_pro) > 0 Then If Len(NOM_EM) > 0 Then If Len(DIR) > 0 Then If Len(CIU) > 0 Then If Len(PRO) > 0 Then Sistema de Control de Mercaderías If Len(TEL) > 0 Then GRABAR.Enabled = True GRABAR.SetFocus End If End If End If End If End If End If End If End Sub Private Sub NUEVO_Click() Data1.Recordset.AddNew ACTIVAR CANCELAR.Enabled = True CERRAR.Enabled = False GRABAR.Enabled = True cod_prod.SetFocus End Sub Private Sub CANCELAR_Click() DESACTIVAR CANCELAR.Enabled = False CERRAR.Enabled = True GRABAR.Enabled = False If Len(cod_prod.Text) > 0 Then Data1.Recordset.Delete cod_prod.SetFocus Data1.Recordset.MoveFirst End Sub Private Sub GRABAR_Click() Data1.Recordset.Update DESACTIVAR CANCELAR.Enabled = False CERRAR.Enabled = True GRABAR.Enabled = False cod_prod.SetFocus End Sub Private Sub CERRAR_Click() Unload Me End Sub Sistema de Control de Mercaderías VALIDACIÓN CAJAS DE TEXTO Private Sub DESCRIPCION_KeyPress(KeyAscii As Integer) If NUEVO.Enabled = True Then Exit Sub Max = Len(CIU) If KeyAscii = 13 Then If (Max) = 0 Then Exit Sub PRODUCTO.SetFocus End If If KeyAscii >= 47 And KeyAscii <= 57 Then '# KeyAscii = 0 End If End Sub Private Sub PRODUCTO_KeyPress(KeyAscii As Integer) If NUEVO.Enabled = True Then Exit Sub Max = Len(CIU) If KeyAscii = 13 Then If (Max) = 0 Then Exit Sub PRESENTACION.SetFocus End If If KeyAscii >= 47 And KeyAscii <= 57 Then '# KeyAscii = 0 End If End Sub Private Sub COSTO_KeyPress(KeyAscii As Integer) If NUEVO.Enabled = True Then Exit Sub Max = Len(CIU) If KeyAscii = 13 Then If (Max) = 0 Then Exit Sub PRECIO_V.SetFocus End If End Sub Private Sub PRECIO_V_KeyPress(KeyAscii As Integer) If NUEVO.Enabled = True Then Exit Sub Max = Len(CIU) If KeyAscii = 13 Then If (Max) = 0 Then Exit Sub STOCK.SetFocus End If End Sub Sistema de Control de Mercaderías Private Sub MODIFICAR_Click() Data1.Recordset.Edit ACTIVAR MODIFICAR.Enabled = False REGRESAR.Enabled = False GRABAR.Enabled = True DESCRIPCION.SetFocus COD_PROD.Locked = True End Sub Private Sub CANCELAR_Click() DESACTIVAR CANCELAR.Enabled = False REGRESAR.Enabled = True GRABAR.Enabled = False COD_PROD.SetFocus End Sub Private Sub GRABAR_Click() Data1.Recordset.Update DESACTIVAR CANCELAR.Enabled = False REGRESAR.Enabled = True REGRESAR.Enabled = True COD_PROD.SetFocus CANCELAR.Enabled = False End Sub Private Sub REGRESAR_Click() Unload Me End Sub VALIDACION CAJAS DE TEXTO Private Sub cod_prod_KeyPress(KeyAscii As Integer) If cod_prod.Enabled = False Then Exit Sub Max = Len(cod_prod) If KeyAscii = 13 Then If (Max) = 0 Then Exit Sub DESCRIPCION.SetFocus End If End Sub Private Sub DESCRIPCION_KeyPress(KeyAscii As Integer) If MODIFICAR.Enabled = False Then Exit Sub Max = Len(DESCRIPCION) If KeyAscii = 13 Then If (Max) = 0 Then Exit Sub PRODUCTO.SetFocus End If Sistema de Control de Mercaderías r = KeyAscii If r = 8 Or r = 32 Then Exit Sub If r < 65 Or r > 95 Then KeyAscii = 0 End Sub Private Sub PRODUCTO_KeyPress(KeyAscii As Integer) If MODIFICAR.Enabled = False Then Exit Sub Max = Len(PRODUCTO) If KeyAscii = 13 Then If (Max) = 0 Then Exit Sub PRESENTACION.SetFocus End If r = KeyAscii If r = 8 Or r = 32 Then Exit Sub If r < 65 Or r > 95 Then KeyAscii = 0 End Sub Private Sub PRESENTACION_KeyPress(KeyAscii As Integer) If MODIFICAR.Enabled = True Then Exit Sub Max = Len(PRESENTACION) If KeyAscii = 13 Then If (Max) = 0 Then Exit Sub COSTO.SetFocus End If r = KeyAscii If r = 8 Or r = 32 Then Exit Sub If r < 65 Or r > 95 Then KeyAscii = 0 End Sub Private Sub COSTO_KeyPress(KeyAscii As Integer) If MODIFICAR.Enabled = False Then Exit Sub Max = Len(COSTO) If KeyAscii = 13 Then If (Max) = 0 Then Exit Sub PRECIO_V.SetFocus End If r = KeyAscii If r = 8 Then Exit Sub If r > 48 And r < 57 Then Exit Sub If r <> 13 Then KeyAscii = 0 End Sub Private Sub PRECIO_V_KeyPress(KeyAscii As Integer) If MODIFICAR.Enabled = False Then Exit Sub Max = Len(PRECIO_V) If KeyAscii = 13 Then If (Max) = 0 Then Exit Sub STOCK.SetFocus End If r = KeyAscii Sistema de Control de Mercaderías If r = 8 Then Exit Sub If r > 48 And r < 57 Then Exit Sub If r <> 13 Then KeyAscii = 0 If r = 8 Then Exit Sub End Sub Private Sub STOCK_KeyPress(KeyAscii As Integer) If MODIFICAR.Enabled = False Then Exit Sub Max = Len(STOCK) r = KeyAscii If r = 8 Then Exit Sub If r > 48 And r < 57 Then Exit Sub If STOCK.Locked = False And KeyAscii = 13 Then If Len(cod_prod) > 0 Then If Len(PRODUCTO) > 0 Then If Len(DESCRIPCION) > 0 Then If Len(PRESENTACION) > 0 Then If Len(COSTO) > 0 Then If Len(PRECIO_V) > 0 Then If Len(STOCK) > 0 Then GRABAR.Enabled = True GRABAR.SetFocus End If End If End If End If End If End If End If End If End Sub Sistema de Control de Mercaderías Private Sub NUEVO_Click() n_fac = InputBox("Nueva Factura No.") With Data1 sw = 0 If .Recordset.RecordCount > 0 Then .Recordset.MoveFirst Do While Not .Recordset.EOF If Val(num_factura) = Val(n_fac) Then sw = 1 Exit Do End If .Recordset.MoveNext Loop If sw = 1 Then MsgBox ("REgistro ya existe") Else Frame3.Enabled = True Frame1.Enabled = True .Recordset.AddNew num_factura = n_fac NUEVO.Enabled = False fecha = Date CANCELAR.Enabled = True REGRESAR.Enabled = False fecha.SetFocus End If End With End Sub Private Sub CANCELAR_Click() Data1.Recordset.CancelUpdate CANCELAR.Enabled = False REGRESAR.Enabled = True NUEVO.Enabled = True If Data1.Recordset.RecordCount > 0 Then Data1.Recordset.MoveFirst Frame3.Enabled = False Frame1.Enabled = False GRABAR.Enabled = False detalle = "" End Sub Private Sub GRABAR_Click() NP = Val(PRECIO_V) NS = Val(STOCK) - Val(cantidad) NC = Val(COSTO) + Val(total) Data2.Recordset.Edit PRECIO_V = NP STOCK = NS COSTO = NP * NS Data2.Recordset.Update Data1.Recordset.Update Frame3.Enabled = False Frame1.Enabled = False Sistema de Control de Mercaderías REGRESAR.Enabled = True CANCELAR.Enabled = False NUEVO.Enabled = True GRABAR.Enabled = False End Sub Private Sub REGRESAR_Click() Unload Me End Sub VALIDACION CAJAS DE TEXTO Private Sub fecha_KeyPress(KeyAscii As Integer) r = KeyAscii If (r = 13) Then cod_cli.SetFocus End If End Sub Private Sub COD_CLI_KeyPress(KeyAscii As Integer) r = KeyAscii If r = 13 Then Data3.Recordset.MoveFirst BUS = Me.cod_cli DES = "" Do While Not Data3.Recordset.EOF If cod_prox = BUS Then DES = nombre_empresax señor = nombre_empresax direccion = direccionx telefono = telefonox Frame1.Enabled = True Exit Do End If Data3.Recordset.MoveNext Loop If DES = "" Then MsgBox ("Cliente no se encontro") cod_cli = "" Data3.Recordset.MoveFirst Else cod_prod.SetFocus End If End If End Sub Private Sub cod_prod_Change() BUS = cod_prod r = KeyAscii If NUEVO.Enabled = False Then Data2.Recordset.MoveFirst Do While Not Data2.Recordset.EOF 'MsgBox ("HOLA") If COD_PROD2 = BUS Then DES = PRODUCTO precio = Data2.Recordset!PRECIO_V Sistema de Control de Mercaderías Exit Do End If Data2.Recordset.MoveNext Loop If DES = "" Then 'MsgBox ("Prod. no se encontro") Else detalle = DES 'cantidad.SetFocus End If End If End Sub Private Sub CONSULTAR_Click() BUS = (InputBox("FACTURA A BUSCAR")) With Data1 sw = 0 .Recordset.MoveFirst Do While Not .Recordset.EOF If (BUS = Me.num_factura) Then sw = 1 Exit Do End If .Recordset.MoveNext Loop If (sw = 0) Then MsgBox ("No se encontró") If .Recordset.RecordCount > 0 Then .Recordset.MoveFirst End If End With End Sub Private Sub REGRESAR_Click() Unload Me End Sub Private Sub fecha_KeyPress(KeyAscii As Integer) r = KeyAscii If (r = 13) Then cod_pro.SetFocus End If End Sub Private Sub cod_pro_KeyPress(KeyAscii As Integer) r = KeyAscii If r = 13 Then Data3.Recordset.MoveFirst BUS = Me.cod_pro DES = "" Do While Not Data3.Recordset.EOF If cod_prox = BUS Then DES = nombre_empresax señor = nombre_empresax direccion = direccionx telefono = telefonox Frame1.Enabled = True Exit Do Sistema de Control de Mercaderías End If Data3.Recordset.MoveNext Loop If DES = "" Then MsgBox ("Proveedor no se encontro") cod_pro = "" Data3.Recordset.MoveFirst Else cod_prod.SetFocus End If End If End Sub Private Sub cod_prod_Change() BUS = cod_prod r = KeyAscii Data2.Recordset.MoveFirst DES = "" Do While Not Data2.Recordset.EOF If COD_PROD2 = BUS Then DES = PRODUCTO Exit Do End If Data2.Recordset.MoveNext Loop If DES = "" Then 'MsgBox ("Prod. no se encontro") Else detalle = DES End If End Sub NOTA: LAS CAJAS DE TEXTO ESTAN CONECTADAS A CADA CAMPO SEGÚN CADA DATA Private Sub CONSULTAR_Click() BUS = (InputBox("FACTURA A BUSCAR")) With Data1 sw = 0 .Recordset.MoveFirst Do While Not .Recordset.EOF If (BUS = Me.num_factura) Then sw = 1 Exit Do End If .Recordset.MoveNext Loop If (sw = 0) Then MsgBox ("No se encontró") If .Recordset.RecordCount > 0 Then .Recordset.MoveFirst End If End With End Sub Private Sub REGRESAR_Click() Unload Me End Sub Sistema de Control de Mercaderías Private Sub NUEVO_Click() n_fac = InputBox("Nueva Factura No.") With Data1 sw = 0 If .Recordset.RecordCount > 0 Then .Recordset.MoveFirst Do While Not .Recordset.EOF If Val(num_factura) = Val(n_fac) Then sw = 1 Exit Do End If .Recordset.MoveNext Loop If sw = 1 Then MsgBox ("REgistro ya existe") Else Frame3.Enabled = True Frame1.Enabled = True .Recordset.AddNew num_factura = n_fac NUEVO.Enabled = False fecha = Date CANCELAR.Enabled = True REGRESAR.Enabled = False fecha.SetFocus End If End With End Sub Private Sub CANCELAR_Click() Data1.Recordset.CancelUpdate CANCELAR.Enabled = False REGRESAR.Enabled = True NUEVO.Enabled = True If Data1.Recordset.RecordCount > 0 Then Data1.Recordset.MoveFirst Frame3.Enabled = False Frame1.Enabled = False GRABAR.Enabled = False detalle = "" End Sub Private Sub GRABAR_Click() NP = Val(PRECIO_V) NS = Val(STOCK) - Val(cantidad) NC = Val(COSTO) + Val(total) Data2.Recordset.Edit PRECIO_V = NP STOCK = NS COSTO = NP * NS Data2.Recordset.Update Data1.Recordset.Update Frame3.Enabled = False Frame1.Enabled = False REGRESAR.Enabled = True Sistema de Control de Mercaderías CANCELAR.Enabled = False NUEVO.Enabled = True GRABAR.Enabled = False End Sub Private Sub REGRESAR_Click() Unload Me End Sub VALIDACIÓN CAJAS DE TEXTO Private Sub fecha_KeyPress(KeyAscii As Integer) r = KeyAscii If (r = 13) Then COD_CLI.SetFocus End If End Sub Private Sub cod_prod_Change() BUS = cod_prod r = KeyAscii If NUEVO.Enabled = False Then Data2.Recordset.MoveFirst Do While Not Data2.Recordset.EOF 'MsgBox ("HOLA") If COD_PROD2 = BUS Then DES = PRODUCTO precio = Data2.Recordset!PRECIO_V Exit Do End If Data2.Recordset.MoveNext Loop If DES = "" Then 'MsgBox ("Prod. no se encontro") Else detalle = DES 'cantidad.SetFocus End If End If End Sub Reportes Sistema de Control de Mercaderías