Detalle Factura
Tengo un problema trabajo en VB6 y SQL 2000, he realizado una form factura que esta ok, pero ahora necesito crear un editar factura la verdad he logrado que cargue los campor de la cabnecera pero no tengo ni la menor igea de como debo hacer para que colo que el detalle, solo he logrado que ponga un solo producto, nada más. Si alguien ya ha trabajado en esto o tieneun código que me pueda brinadr se los agradeceres, aquí les anexo mi código. Primero seleccio en un datacombo una tienda en otro datcombo en tipo de documento y dados estos en un tercer datcombo se cargan solo aquellos que tengas las coincidencias anteriores y al hacer click de bee cargarme todo en el form
' Registro de Detalle de Factura
Type RegDetalleFactura
IdArticulo As String * 7
Prefijo As String * 3
DesArticulo As String * 30
PreVenta As Currency
dscto As Currency
Cantidad As Integer
SubTotal As Currency
Cancel As Boolean
Accion As String * 6
End Type
' Variable del tipo Detalle de Factura
Public DetFactura As RegDetalleFactura
Private Sub dbcboNumero_Click(Area As Integer)
Dim rs As New ADODB.Recordset
If Area <> 2 Then Exit Sub
NoChange = True
With rs
.ActiveConnection = cn
.CursorType = adOpenStatic
.CursorLocation = adUseClient
.Source = "SELECT * FROM Cabecera WHERE CodDoc='" & dbcboNumero.BoundText & "'"
.Open
End With
If rs.RecordCount = 0 Then
MsgBox "No hay Documentos"
GoTo DestroyRS
End If
lblNumero.Caption = rs!NumDoc
txtFecha.Text = rs!FecCab
Dim strCliente As String
strCliente = rs!CodCli
Dim rsC As New ADODB.Recordset
With rsC
.ActiveConnection = cn
.CursorType = adOpenStatic
.CursorLocation = adUseClient
.Source = "SELECT * FROM Cliente WHERE CodCli='" & strCliente & "'"
.Open
End With
If rsC.RecordCount = 0 Then
MsgBox "No hay Clientes"
GoTo DestroyRSC
End If
txtCliente.Text = rsC!NomCli
txtRUC.Text = rsC!RUCCli
txtDNI.Text = rsC!DNICli
dbcboVendedor.BoundText = rs!CodVen
txtMonto.Text = rs!subtot
txtIGV.Text = rs!IGvcab
txtTotal.Text = rs!totcab
For Row = 1 To flxDetalle.Rows - 1
' Inserta el Detalle de Documento
Dim rsD As New ADODB.Recordset
With rsD
.ActiveConnection = cn
.CursorType = adOpenStatic
.CursorLocation = adUseClient
.Source = "SELECT * FROM Detalle WHERE CodDoc='" & dbcboNumero.BoundText & "' "
.Open
End With
If rs.RecordCount = 0 Then
MsgBox "No hay DEtalles"
GoTo DestroyRS
End If
flxDetalle.TextMatrix(Row, 1) = rsD!CodPro
'flxDetalle.TextMatrix(Row, 2) = rsD!PrePro
flxDetalle.TextMatrix(Row, 3) = rsD!CanPro
flxDetalle.TextMatrix(Row, 4) = rsD!PreUniPro
flxDetalle.TextMatrix(Row, 5) = rsD!DesDet
flxDetalle.TextMatrix(Row, 6) = rsD!ImpDet
Next
NoChange = False
Exit Sub
DestroyRS:
rs.Close
Set rs = Nothing
DestroyRSC:
rsC.Close
Set rsC = Nothing
TrataError:
MsgBox "Se ha producido un error en la Base de Datos:" & vbCrLf & vbCrLf & Err.Description, _
vbCritical + vbOKOnly, "Error Nro. " & Err.Number
End Sub
Les agradeceré su ayuda
' Registro de Detalle de Factura
Type RegDetalleFactura
IdArticulo As String * 7
Prefijo As String * 3
DesArticulo As String * 30
PreVenta As Currency
dscto As Currency
Cantidad As Integer
SubTotal As Currency
Cancel As Boolean
Accion As String * 6
End Type
' Variable del tipo Detalle de Factura
Public DetFactura As RegDetalleFactura
Private Sub dbcboNumero_Click(Area As Integer)
Dim rs As New ADODB.Recordset
If Area <> 2 Then Exit Sub
NoChange = True
With rs
.ActiveConnection = cn
.CursorType = adOpenStatic
.CursorLocation = adUseClient
.Source = "SELECT * FROM Cabecera WHERE CodDoc='" & dbcboNumero.BoundText & "'"
.Open
End With
If rs.RecordCount = 0 Then
MsgBox "No hay Documentos"
GoTo DestroyRS
End If
lblNumero.Caption = rs!NumDoc
txtFecha.Text = rs!FecCab
Dim strCliente As String
strCliente = rs!CodCli
Dim rsC As New ADODB.Recordset
With rsC
.ActiveConnection = cn
.CursorType = adOpenStatic
.CursorLocation = adUseClient
.Source = "SELECT * FROM Cliente WHERE CodCli='" & strCliente & "'"
.Open
End With
If rsC.RecordCount = 0 Then
MsgBox "No hay Clientes"
GoTo DestroyRSC
End If
txtCliente.Text = rsC!NomCli
txtRUC.Text = rsC!RUCCli
txtDNI.Text = rsC!DNICli
dbcboVendedor.BoundText = rs!CodVen
txtMonto.Text = rs!subtot
txtIGV.Text = rs!IGvcab
txtTotal.Text = rs!totcab
For Row = 1 To flxDetalle.Rows - 1
' Inserta el Detalle de Documento
Dim rsD As New ADODB.Recordset
With rsD
.ActiveConnection = cn
.CursorType = adOpenStatic
.CursorLocation = adUseClient
.Source = "SELECT * FROM Detalle WHERE CodDoc='" & dbcboNumero.BoundText & "' "
.Open
End With
If rs.RecordCount = 0 Then
MsgBox "No hay DEtalles"
GoTo DestroyRS
End If
flxDetalle.TextMatrix(Row, 1) = rsD!CodPro
'flxDetalle.TextMatrix(Row, 2) = rsD!PrePro
flxDetalle.TextMatrix(Row, 3) = rsD!CanPro
flxDetalle.TextMatrix(Row, 4) = rsD!PreUniPro
flxDetalle.TextMatrix(Row, 5) = rsD!DesDet
flxDetalle.TextMatrix(Row, 6) = rsD!ImpDet
Next
NoChange = False
Exit Sub
DestroyRS:
rs.Close
Set rs = Nothing
DestroyRSC:
rsC.Close
Set rsC = Nothing
TrataError:
MsgBox "Se ha producido un error en la Base de Datos:" & vbCrLf & vbCrLf & Err.Description, _
vbCritical + vbOKOnly, "Error Nro. " & Err.Number
End Sub
Les agradeceré su ayuda
1 Respuesta
Respuesta de emperador20
1