Valores Nulos en DATAGRIND
Publicado por Marcela Soto (5 intervenciones) el 28/10/2014 00:42:21
Gracias a los que me han ayudado en el Temas anteriores ahora me encuentro con esto
Me sale que no controlo los nulos si dejo la casilla Numeros vacia lo corrego asi
Pero me gustario que si dejo el la una celda de numero vacida me asigne el valor de 0 a esa casilla me podria ayudar la verdad es que soy muy nueva en este lenguaje Gracias por su ayuda
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
Public Sub Insertar()
Dim Ultimo As Integer
Dim Fecha As String
Dim Grupo As String
Dim Lista As String
Dim Numero As String
Dim Monto As String
Dim Ticket As String
Dim Total As String
For Each row As DataGridViewRow In GrdVenta.Rows
If Not String.IsNullOrEmpty(row.Cells("Monto").FormattedValue.ToString()) Then
Ultimo = Convert.ToInt32(lblFinal.Text + 1)
Fecha = txtFecha.Text
Grupo = TxtGrupo.Text
Lista = TxtLista.Text
Monto = Convert.ToString(row.Cells("Monto").Value.ToString())
Numero = Convert.ToString(row.Cells("Numero").Value.ToString())
Dim valor As Integer = Numero
Numero = String.Format("{0:00}", valor)
Ticket = lblClave.Text
Total = Convert.ToInt32(lblTotal.Text)
Try
comandos = New OleDbCommand("INSERT INTO Venta (Ultimo,Fecha,Grupo,Lista, Numero, Monto,Ticket,Total)" & Chr(13) &
"VALUES (Ultimo,Fecha,Grupo,Lista, Numero, Monto,Ticket,Total)", conexion)
comandos.Parameters.AddWithValue("@Ultimo", Ultimo)
comandos.Parameters.AddWithValue("@Fecha", Fecha)
comandos.Parameters.AddWithValue("@Grupo", Grupo)
comandos.Parameters.AddWithValue("@Lista", Lista)
comandos.Parameters.AddWithValue("@Numero", Numero)
comandos.Parameters.AddWithValue("@Monto", Monto)
comandos.Parameters.AddWithValue("@Ticket", Ticket)
comandos.Parameters.AddWithValue("@Total", Total)
comandos.ExecuteNonQuery()
Catch ex As Exception
MsgBox("NO DEBE DEJAR EL NUMERO EN BLANCO", MsgBoxStyle.Critical)
GrdVenta.Focus()
End Try
End If
Next
End Sub
Me sale que no controlo los nulos si dejo la casilla Numeros vacia lo corrego asi
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
Public Sub Insertar()
Dim Ultimo As Integer
Dim Fecha As String
Dim Grupo As String
Dim Lista As String
Dim Numero As String
Dim Monto As String
Dim Ticket As String
Dim Total As String
For Each row As DataGridViewRow In GrdVenta.Rows
If Not String.IsNullOrEmpty(row.Cells("Monto").FormattedValue.ToString()) Then
If Not String.IsNullOrEmpty(row.Cells("Numero").FormattedValue.ToString()) Then
Ultimo = Convert.ToInt32(lblFinal.Text + 1)
Fecha = txtFecha.Text
Grupo = TxtGrupo.Text
Lista = TxtLista.Text
Monto = Convert.ToString(row.Cells("Monto").Value.ToString())
Numero = Convert.ToString(row.Cells("Numero").Value.ToString())
Dim valor As Integer = Numero
Numero = String.Format("{0:00}", valor)
Ticket = lblClave.Text
Total = Convert.ToInt32(lblTotal.Text)
Try
comandos = New OleDbCommand("INSERT INTO Venta (Ultimo,Fecha,Grupo,Lista, Numero, Monto,Ticket,Total)" & Chr(13) &
"VALUES (Ultimo,Fecha,Grupo,Lista, Numero, Monto,Ticket,Total)", conexion)
comandos.Parameters.AddWithValue("@Ultimo", Ultimo)
comandos.Parameters.AddWithValue("@Fecha", Fecha)
comandos.Parameters.AddWithValue("@Grupo", Grupo)
comandos.Parameters.AddWithValue("@Lista", Lista)
comandos.Parameters.AddWithValue("@Numero", Numero)
comandos.Parameters.AddWithValue("@Monto", Monto)
comandos.Parameters.AddWithValue("@Ticket", Ticket)
comandos.Parameters.AddWithValue("@Total", Total)
comandos.ExecuteNonQuery()
Catch ex As Exception
MsgBox("NO DEBE DEJAR EL NUMERO EN BLANCO", MsgBoxStyle.Critical)
GrdVenta.Focus()
End Try
Else
Numero = Convert.ToString(row.Cells("Numero").Value = 0)
End If
End If
Next
End Sub
Pero me gustario que si dejo el la una celda de numero vacida me asigne el valor de 0 a esa casilla me podria ayudar la verdad es que soy muy nueva en este lenguaje Gracias por su ayuda
Valora esta pregunta


0