En esta lección terminamos con el formulario de Kardex del curso Curso de Software de Ventas, ya con esto podemos ver un historial del producto
En este vídeo construimos la ventana del Kardex donde se visualizara el historial de producto seleccionado del inventario.
Primero se llenan los Datos del producto en la ventana del Kardex
Dim IdProductoSeleccionado
Sub DatosProducto()
If frmInventario.msGrid.Row > 0 Then
IdProductoSeleccionado = frmInventario.msGrid.TextMatrix(frmInventario.msGrid.Row, 1)
txtCodigoPro = frmInventario.msGrid.TextMatrix(frmInventario.msGrid.Row, 2)
txtNombrePro = frmInventario.msGrid.TextMatrix(frmInventario.msGrid.Row, 3)
End If
End Sub
Luego cargamos la información llenando el grid, podemos filtrar por mes y año o por un rango de Fechas
Sub Llenar_Grid()
Dim Filtro
Dim Sql As String
Dim Columnas As Integer
Filtro = ""
'Buscar por mes
If chkPorFecha.Value = 0 Then
Mes = cmdMeses.ListIndex + 1
Anio = txtAnio.Text
Filtro = " Month(Fecha) = " & Mes & " and Year(Fecha) = " & Anio
Else
'buscar por rango de fecha
Fecha1 = Format(DTFecha1.Value, "mm/dd/yyyy")
Fecha2 = Format(DTFecha2.Value, "mm/dd/yyyy")
Filtro = " Format(Fecha,'dd/mm/yyyy') Between #" & Fecha1 & "# and #" & Fecha2 & "#"
End If
Sql = "Select Format(Fecha,'dd/mm/yyyy H:mm:ss'), Detalle, D_C, Cantidad, Costo, Cant_Saldo From tblKardex Where " & Filtro & " and IdProducto = " & IdProductoSeleccionado & " Order by IdKardex ASC "
Columnas = 6
Call LlenarGrid(msGrid, Sql, Columnas)
msGrid.ColWidth(0) = 0
msGrid.ColWidth(1) = 2200
msGrid.ColWidth(2) = 5200
msGrid.ColWidth(3) = 700
msGrid.ColWidth(4) = 800
msGrid.ColWidth(5) = 1600
msGrid.ColWidth(6) = 900
msGrid.TextMatrix(0, 1) = "Fecha"
msGrid.TextMatrix(0, 2) = "Descripción"
msGrid.TextMatrix(0, 3) = "D_C"
msGrid.TextMatrix(0, 4) = "Cant"
msGrid.TextMatrix(0, 5) = "Costo"
msGrid.TextMatrix(0, 6) = "Saldo"
msGrid.Redraw = False
For I = 1 To msGrid.Rows - 1
msGrid.Row = I
msGrid.Col = 4
msGrid.CellAlignment = flexAlignCenterCenter
msGrid.Col = 6
msGrid.CellAlignment = flexAlignCenterCenter
msGrid.TextMatrix(I, 5) = Format(msGrid.TextMatrix(I, 5), "currency")
Next I
msGrid.Redraw = True
End Sub
Hay un control check para poder escoger entre filtrar por mes y año o por rango de fechas
Private Sub chkPorFecha_Click()
If chkPorFecha.Value = 1 Then
DTFecha1.Enabled = True
DTFecha2.Enabled = True
Else
DTFecha1.Enabled = False
DTFecha2.Enabled = False
End If
End Sub
El resto de los eventos
Private Sub cmdBuscar_Click()
Call Llenar_Grid
End Sub
Private Sub cmdCerrar_Click()
Unload Me
End Sub
Private Sub Form_Load()
cmdMeses.ListIndex = Format(Date, "mm") - 1
txtAnio.Text = Format(Date, "yyyy")
DTFecha1.Enabled = False
DTFecha2.Enabled = False
Call DatosProducto
Call Llenar_Grid
End Sub
Private Sub txtAnio_KeyPress(KeyAscii As Integer)
If SoloNumeros(KeyAscii) = False Then
KeyAscii = 0
End If
End Sub
Siguiente lección Curso de Software de Ventas Parte 25, Clientes
Total Page Visits: 8204 - Today Page Visits: 5


(1) Comment