You are on page 1of 3

txtcodar.Text = txtidar.

Text
txtnombrear.Text = txtnombre.Text
txtdesc.Text = txtdescripcion.Text
txtcant.Text = txtcantidad.Text
txtpreccompra.Text = txtprecio.Text
txttipoarticulo.Text = tipoar.Text
txtmarcaar.Text = marca.Text
txtganancia.Text = Val(txtprecventa.Text) - Val(txtpreccompra.Text)

txtpreccompra.Text = txtprecio.Text
Me.dgtdetalle.Rows.Add(txtidco.Text, txtidar.Text, txtidpro.Text,
txtnombre.Text, marca.Text, tipoar.Text, txtdescripcion.Text, txtcantidad.Text,
txtitbis.Text, txtprecio.Text, txttotalprecio.Text, fechacompra.Text)

marca.Text = Nothing
tipoar.Text = Nothing
txtdescripcion.Text = ""
txtcantidad.Text = ""
txtprecio.Text = ""
txtitbis.Text = ""
txttotalprecio.Text = ""

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Me.dtgarticulos.Rows.Add(txtcodar.Text, txtnombrear.Text,
txttipoarticulo.Text, txtmarcaar.Text, txtcant.Text, txtdesc.Text,
txtpreccompra.Text, txtprecventa.Text, txtganancia.Text)

txtcodar.Text = ""
txtnombrear.Text = ""
txttipoarticulo.Text = ""
txtmarcaar.Text = ""
txtdesc.Text = ""
txtcant.Text = ""
txtpreccompra.Text = ""
txtprecventa.Text = ""
txtganancia.Text = ""
___________________________________________________________________________________
_________________________________________
btnguardar
If Me.dgtdetalle.Rows.Count = 0 Then
MessageBox.Show(" Ingrese los Datos que corresponden al DataGrid. ",
"AVISO", MessageBoxButtons.OK, MessageBoxIcon.Information)
Return
End If

If Me.dtgarticulos.Rows.Count = 0 Then
MessageBox.Show(" Ingrese los Datos que corresponden al DataGrid. ",
"AVISO", MessageBoxButtons.OK, MessageBoxIcon.Information)
Return
End If
If pedido.Checked = True Then

ssql = "Update Tab_Pedidos set Est_Ped ='" & True & "' where Cod_Ped=
'" & codpedido.Text & "'"
oComando = New SqlClient.SqlCommand(ssql, oConexion)
oConexion.Open()
oComando.ExecuteNonQuery()
oConexion.Close()

End If

Try
ssql = "INSERT INTO Tab_Enc_Compra (Cod_Comp, Tot_Art, Tot_Itbis,
Sub_Total, Tot_Desc, Tot_Neto, Tot_Pagar ) values ('" & txtidco.Text & "','" &
totalarticulo.Text & "','" & totalitbis.Text & "','" & subtotal.Text & _
"','" & descuento.Text & "','" & totalneto.Text & "','" & totalpagar.Text
& "')"
oComando = New SqlClient.SqlCommand(ssql, oConexion)
oConexion.Open()
oComando.ExecuteNonQuery()
oConexion.Close()
MessageBox.Show("registro guardado correctamente", "AVISO", _
MessageBoxButtons.OK, MessageBoxIcon.Information)

If dgtdetalle.Rows.Count > 0 Then


For i As Integer = 0 To dgtdetalle.Rows.Count - 1

ssql = " INSERT INTO Tab_Detal_Compra(Cod_Comp, Cod_Art,


Cod_Prov, Nom_Art, Marc_Art, Tipo_Art, Desc_Art, Cant_Art, Itbis_Art, Prec_Uni_Art,
Prec_Total, Fech_Comp ) Values ( '" & _
txtidco.Text & "','" & dgtdetalle.Rows(i).Cells(1).Value & "','" &
dgtdetalle.Rows(i).Cells(2).Value & "','" & dgtdetalle.Rows(i).Cells(3).Value &
"','" & dgtdetalle.Rows(i).Cells(4).Value & "','" &
dgtdetalle.Rows(i).Cells(5).Value & "','" & dgtdetalle.Rows(i).Cells(6).Value &
"','" & dgtdetalle.Rows(i).Cells(7).Value & "','" &
dgtdetalle.Rows(i).Cells(8).Value & "','" & dgtdetalle.Rows(i).Cells(9).Value &
"','" & dgtdetalle.Rows(i).Cells(10).Value & "','" &
dgtdetalle.Rows(i).Cells(11).Value & "')"
oComando = New SqlClient.SqlCommand(ssql, oConexion)
oConexion.Open()
oComando.ExecuteNonQuery()
oConexion.Close()
MessageBox.Show("registro guardado correctamente", "AVISO", _
MessageBoxButtons.OK, MessageBoxIcon.Information)

Next

End If

If dtgarticulos.Rows.Count > 0 Then


For i As Integer = 0 To dtgarticulos.Rows.Count - 1

ssql = " INSERT INTO Tab_Articulo(Cod_Art, Nom_Art, Tip_Art,


Marc_Art, Cant_Art, Descr_Art, Prec_Compra_Art, Prec_Vent_Art, Gana_Art ) Values
( '" & _
dtgarticulos.Rows(i).Cells(0).Value & "','" &
dtgarticulos.Rows(i).Cells(1).Value & "','" & dtgarticulos.Rows(i).Cells(2).Value &
"','" & dtgarticulos.Rows(i).Cells(3).Value & "','" &
dtgarticulos.Rows(i).Cells(4).Value & "','" & dtgarticulos.Rows(i).Cells(5).Value &
"','" & dtgarticulos.Rows(i).Cells(6).Value & "','" &
dtgarticulos.Rows(i).Cells(7).Value & "','" & dtgarticulos.Rows(i).Cells(8).Value &
"')"
oComando = New SqlClient.SqlCommand(ssql, oConexion)
oConexion.Open()
oComando.ExecuteNonQuery()
oConexion.Close()
MessageBox.Show("registro guardado correctamente", "AVISO", _
MessageBoxButtons.OK, MessageBoxIcon.Information)

Next

End If

Catch oExep As Exception


MessageBox.Show("error al conectar con base de datos" &
ControlChars.CrLf & _
oExep.Message)

End Try

You might also like