otro problema de datagridview
Publicado por Pablo (7 intervenciones) el 04/06/2019 05:21:22
buenas noches , yo de nuevo , se me presenta una inquietud yo lleno un datagridview haciendo una consulta a un datareader , hasta ahi todo perfecto , pero mi duda empieza cuando quiero llenar ese datagrid al momento de querer facturar un codigo que no esta cargado y ahi se me quemaron los papeles , como podria seguir agregando filas al datagrid ??? dejo el codigo
desde ya muchas gracias
desde ya muchas gracias
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
Private Sub txtcod_LostFocus(sender As Object, e As EventArgs) Handles txtcod.LostFocus
If Me.txtcod.Text <> "" Then
Dim A As String = Me.txtcod.Text
If A.IndexOf("*") > 0 Then
cantidad = (A.Substring(0, A.IndexOf("*")))
txtcod.Text = (A.Substring(A.IndexOf("*") + 1))
End If
consultarplu(Me.txtcod.Text)
If dr.Read Then
Me.txtnombre.Text = dr(0).ToString
Me.txtprecio.Text = dr(6).ToString
Dim suma As Double
suma = Val(cantidad) * Val(txtprecio.Text)
DataGridView2.Rows.Add(txtcod.Text, txtnombre.Text, cantidad, suma)
Dim linea As DataGridViewRow
Dim valor As Double = 0
Dim N As Double
For Each linea In DataGridView2.Rows
If Double.TryParse(linea.Cells(3).Value, N) Then
valor = valor + N
End If
Next
txttotal.Text = "$ " & FormatNumber(valor, 2)
Me.txtcod.Text = ""
Me.txtnombre.Text = ""
Me.txtprecio.Text = ""
Me.txtcod.Focus()
Else
MsgBox("Articulo no encontrado")
End If
Else
End If
dr.Close()
End SubPrivate Sub txtcod_LostFocus(sender As Object, e As EventArgs) Handles txtcod.LostFocus
If Me.txtcod.Text <> "" Then
Dim A As String = Me.txtcod.Text
If A.IndexOf("*") > 0 Then
cantidad = (A.Substring(0, A.IndexOf("*")))
txtcod.Text = (A.Substring(A.IndexOf("*") + 1))
End If
consultarplu(Me.txtcod.Text)
If dr.Read Then
Me.txtnombre.Text = dr(0).ToString
Me.txtprecio.Text = dr(6).ToString
Dim suma As Double
suma = Val(cantidad) * Val(txtprecio.Text)
DataGridView2.Rows.Add(txtcod.Text, txtnombre.Text, cantidad, suma)
Dim linea As DataGridViewRow
Dim valor As Double = 0
Dim N As Double
For Each linea In DataGridView2.Rows
If Double.TryParse(linea.Cells(3).Value, N) Then
valor = valor + N
End If
Next
txttotal.Text = "$ " & FormatNumber(valor, 2)
Me.txtcod.Text = ""
Me.txtnombre.Text = ""
Me.txtprecio.Text = ""
Me.txtcod.Focus()
Else
MsgBox("Articulo no encontrado")
End If
Else
End If
dr.Close()
End Sub
Valora esta pregunta


0