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
|
Dim cmd As New OleDbCommand("select * from achat_inst", cn)
Dim Adaptateur As New OleDbDataAdapter(cmd)
Dim MonDataSet As New DataSet
Adaptateur.Fill(MonDataSet, "achat_inst")
Dim a, b, c As Integer
Dim cmdz As New OleDbCommand("select [N°] from achat_inst", cn)
a = cmdz.ExecuteScalar.ToString
For Each Ligne As DataRow In MonDataSet.Tables("achat_inst").Rows()
Dim cmdf As New OleDbCommand("select [N°] from achat_inst", cn)
If cmdf.ExecuteScalar.ToString = a Then
Dim cmdb As New OleDbCommand("select [Code Article] from achat_inst where [N°]=@c1", cn)
With cmdb.Parameters
.Add("@c1", OleDbType.Char).Value = a
End With
Dim cmdv As New OleDbCommand("select [Quantité] from achat_inst where [N°]=@c1", cn)
With cmdv.Parameters
.Add("@c1", OleDbType.Char).Value = a
End With
Dim cmdc As New OleDbCommand("UPDATE Stock set [Qte en stock] = [Qte en stock] +'" & cmdv.ExecuteScalar.ToString & "' where [Code Article]=@c1", cn)
With cmdc.Parameters
.Add("@c1", OleDbType.Char).Value = cmdb.ExecuteScalar.ToString
End With
cmdc.ExecuteScalar()
' Archiver cette Achat :
Dim cmdh As New OleDbCommand("select [Code Article],[Quantité],[Désignation],[Prix Unitaire HT],[Remise],[TVA],[NET_HT],[MONTANT_TVA],[Net_TTC] from achat_inst where [N°]=@l1", cn)
With cmdh.Parameters
.Add("l1", OleDbType.Char).Value = a
End With
Dim dra As OleDbDataReader = cmdh.ExecuteReader
Do While dra.Read
Dim cmdr As New OleDbCommand("INSERT INTO achat_detaile ([Type De Document],[Numero De Document],[Date D'achat],[Fournisseur],[Code Fournisseur],[Code Article],[Désignation],[Quantité],[Prix UHT],[Remise],[TVA],[NET_HT],[Montant TVA],[NET_TTC]) values( '" & Label30.Text & "','" & TextBox10.Text & "','" & CDate(DateTimePicker1.Text) & "','" & ComboBox3.Text & "','" & ComboBox2.Text & "','" & dra.GetString(0) & "', '" & dra.GetString(2) & "','" & dra.GetValue(1) & "','" & dra.GetValue(3) & "','" & dra.GetValue(4) & "','" & dra.GetValue(5) & "','" & dra.GetValue(6) & "','" & dra.GetValue(7) & "','" & dra.GetValue(8) & "')", cn)
cmdr.ExecuteScalar()
Loop
b = a + 1
a = 0
Else
Dim cmdb As New OleDbCommand("select [Code Article] from achat_inst where [N°]=@c1", cn)
With cmdb.Parameters
.Add("@c1", OleDbType.Char).Value = b
End With
Dim cmdv As New OleDbCommand("select [Quantité] from achat_inst where [N°]=@c1", cn)
With cmdv.Parameters
.Add("@c1", OleDbType.Char).Value = b
End With
Dim cmdc As New OleDbCommand("UPDATE Stock set [Qte en stock] = [Qte en stock] +'" & cmdv.ExecuteScalar.ToString & "' where [Code Article]=@c1", cn)
With cmdc.Parameters
.Add("@c1", OleDbType.Char).Value = cmdb.ExecuteScalar.ToString
End With
cmdc.ExecuteScalar()
' Archiver cette Achat :
Dim cmdh As New OleDbCommand("select [Code Article],[Quantité],[Désignation],[Prix Unitaire HT],[Remise],[TVA],[NET_HT],[MONTANT_TVA],[Net_TTC] from achat_inst where [N°]=@l1", cn)
With cmdh.Parameters
.Add("l1", OleDbType.Char).Value = b
End With
Dim dra As OleDbDataReader = cmdh.ExecuteReader
Do While dra.Read
Dim cmdr As New OleDbCommand("INSERT INTO achat_detaile ([Type De Document],[Numero De Document],[Date D'achat],[Fournisseur],[Code Fournisseur],[Code Article],[Désignation],[Quantité],[Prix UHT],[Remise],[TVA],[NET_HT],[Montant TVA],[NET_TTC]) values( '" & Label30.Text & "','" & TextBox10.Text & "','" & CDate(DateTimePicker1.Text) & "','" & ComboBox3.Text & "','" & ComboBox2.Text & "','" & dra.GetString(0) & "', '" & dra.GetString(2) & "','" & dra.GetValue(1) & "','" & dra.GetValue(3) & "','" & dra.GetValue(4) & "','" & dra.GetValue(5) & "','" & dra.GetValue(6) & "','" & dra.GetValue(7) & "','" & dra.GetValue(8) & "')", cn)
cmdr.ExecuteScalar()
Loop
b = b + 1
End If
Next |