tengo datos en el datagrid y necesito pasarlos a la base de datos .....
*digamso tengo una factura a la cual cada vez q agrego un producto se agrega en el datagrid ....
digamos que ya agregue 3 productos ahora necesito guardar esos 3 productos del datagrid a la base de datos ...... ???? como le ago ??
tengo algo asi de codigo
en el Private Sub btnterminar es donde creo que va el codigo para pasar lso datos del datagrid a la base de datos ..... gestor mysql trabajo desde vb2008
Public Class recibo
Dim numfactura As Integer
Dim i As Integer = 0
Dim total As Double
Dim conec As New conectorbd("root", "root123")
Dim query As String
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncerrar.Click
Me.Close()
menumorlis.Visible = True
End Sub
Private Sub txtidcliente_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtidcliente.KeyPress
If Char.IsDigit(e.KeyChar) Then
e.Handled = False
Else
e.Handled = True
End If
End Sub
Private Sub txtidcliente_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtidcliente.TextChanged
query = "select * from clientes where idclientes = '" & txtidcliente.Text & "' "
consul = conec.consulta(query)
While consul.Read
txtidcliente.Text = consul.GetValue(0).ToString
txtnombrecliente.Text = consul.GetValue(1).ToString
txtapellidocliente.Text = consul.GetValue(2).ToString
txttelefonocliente.Text = consul.GetValue(3).ToString
txtcelularcliente.Text = consul.GetValue(4).ToString
txtcedulacliente.Text = consul.GetValue(5).ToString
txtdireccioncliente.Text = consul.GetValue(6).ToString
End While
End Sub
Private Sub GroupBox5_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GroupBox5.Enter
End Sub
Private Sub txtvalor_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtvalor.KeyPress
If Char.IsDigit(e.KeyChar) Then
e.Handled = False
Else
e.Handled = True
End If
End Sub
Private Sub txtextra_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtextra.KeyPress
If Char.IsDigit(e.KeyChar) Then
e.Handled = False
Else
e.Handled = True
End If
End Sub
Private Sub txtprendas_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtprendas.KeyPress
If Char.IsDigit(e.KeyChar) Then
e.Handled = False
Else
e.Handled = True
End If
End Sub
Private Sub txtdescuento_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtdescuento.KeyPress
If Char.IsDigit(e.KeyChar) Then
e.Handled = False
Else
e.Handled = True
End If
End Sub
Private Sub recibo_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
query = "select max(idrecibo) from recibo"
consul = conec.consulta(query)
While consul.Read
numfactura = consul.GetValue(0).ToString
End While
numfactura = numfactura + 1
txtnrecibo.Text = numfactura
End Sub
Private Sub txttotal_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txttotal.KeyPress
If Char.IsDigit(e.KeyChar) Then
e.Handled = False
Else
e.Handled = True
End If
End Sub
Private Sub btningresar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btningresar.Click
With DataGridView1
.Rows.Add()
.Item(0, i).Value = txtnrecibo.Text
.Item(1, i).Value = txtidcliente.Text
.Item(2, i).Value = txtnombrecliente.Text
.Item(3, i).Value = txtapellidocliente.Text
.Item(4, i).Value = txttelefonocliente.Text
.Item(5, i).Value = txtcelularcliente.Text
.Item(6, i).Value = txtcedulacliente.Text
.Item(7, i).Value = txtdireccioncliente.Text
.Item(8, i).Value = cbtipo.Text
.Item(9, i).Value = cbcolor.Text
.Item(10, i).Value = txtmarca.Text
.Item(11, i).Value = cbmaterial.Text
.Item(12, i).Value = txtvalor.Text
.Item(13, i).Value = txtprendas.Text
.Item(14, i).Value = txtdescuento.Text
.Item(15, i).Value = txttotal.Text
.Item(16, i).Value = cbestado.Text
.Item(17, i).Value = DateTimePicker1.Text
.Item(18, i).Value = DateTimePicker2.Text
.Item(19, i).Value = txtempleado.Text
.Item(20, i).Value = horaentrega.Text
.Item(21, i).Value = fechaentrega.Text
End With
i += 1
'******************************+
txtextra.Text = ""
cbtipo.Text = ""
cbcolor.Text = ""
txtmarca.Text = ""
cbmaterial.Text = ""
txtvalor.Text = ""
txtprendas.Text = ""
txtdescuento.Text = ""
txttotal.Text = ""
cbestado.Text = ""
DateTimePicker1.Text = ""
DateTimePicker2.Text = ""
txtempleado.Text = ""
horaentrega.Text = ""
fechaentrega.Text = ""
End Sub
Private Sub btnterminar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnterminar.Click
?????????????????????????????????????????????????????????????????????? codigo porfa :)
End Sub
Private Sub txtempleado_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtempleado.TextChanged
End Sub
Private Sub txtnombrecliente_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtnombrecliente.TextChanged
txtempleado.Text = usu
End Sub
End Class
urgente ayuda con datagridview
Comenzado por
alcapone
, may 18 2013 06:03
1 respuesta en este tema