
problema al recorrer un datagridview con un for each
Publicado por daniel (1 intervención) el 11/03/2017 21:14:25
tengo un problema al recorrer un datagridview con un FOR EACH porque tengo varios articulos ejemplo: caja de lapiz, cantidad 3, caja de lapicero, cantidad 5 y en mi DB hay 10 cajas de lapiz y 15 caja de lapiceros me deberia actualizar a caja de lapiz 7 y caja de lapiceros 10 pero me guarda en ambas el mismo valor es decir, caja de lapiz cantidad 7, caja de lapicero 7
si me pueden decir que estoy haciendo mal se los agradeceria
este es el codigo del botton que hace la actualizacion:
si me pueden decir que estoy haciendo mal se los agradeceria
este es el codigo del botton que hace la actualizacion:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
Private Sub btnGuardarFact_Click(sender As Object, e As EventArgs) Handles btnGuardarFact.Click
If Not TypeOf cmbCodigo.SelectedValue Is DataRowView Then
Dim fila As DataRowView = DirectCast(cmbCodigo.SelectedItem, DataRowView)
If txtRIF.Text = "" Or txtCliente.Text = "" Or dateFecha.Value > Date.Now Or cmbTipoCompra.Text = "Seleccionar..." Or txtPorcenDescuento.Text = "" Or txtPorcenIVA.Text = "" Then
MsgBox("Rellene Todos Los Campos y/ó Fecha De Factura Mayor A La Actual", MsgBoxStyle.Information, "INFORMACION")
Else
guardar_factVenta()
guardar_detVenta()
' ACTUALIZA EN LA BD LA CANTIDAD REAL DE ARTICULOS DISPONIBLES'
Dim cantidad As New Integer
Dim filadgw As DataGridViewRow
For Each filadgw In dgwLista.Rows
If cmbTipoCompra.Text = "DETAL" Then
cantidad = fila.Item("EXISTDETAL_ART") - filadgw.Cells("Cantidad").Value
actualizar_existencias(filadgw.Cells("Codigo").Value, cantidad, cmbTipoCompra.Text)
ElseIf cmbTipoCompra.Text = "MAYOR" Then
cantidad = fila.Item("EXISTMAYOR_ART") - filadgw.Cells("Cantidad").Value
actualizar_existencias(filadgw.Cells("Codigo").Value, cantidad, cmbTipoCompra.Text)
End If
Next
MsgBox("Actualizacion Realizada con Exito", MsgBoxStyle.Information, "INFORMACION")
limpiar()
txtNroFactura.Text += 1
End If
End If
end sub
Valora esta pregunta


0