Bonjour tous le monde,
SVP je besoin de vos aides
J’aimerai remplir une commande et details de commande automatiquement à l’aide de deux procedures
1er : procedure ajout commande :
2ème : procedure ajout dans details de commande:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 Public Sub AddCommande(ByVal NumCommande As Integer, ByVal DateCommande As Date, ByVal NumCLient As Integer, ByVal Description_Commande As String) If CN.State = ConnectionState.Closed Then CN.Open() End If Dim cmdCMDCLtPrdt As New OleDb.OleDbCommand cmdCMDCLtPrdt.Connection = CN cmdCMDCLtPrdt.CommandText = "insert into Commandes(NumCommande,DateCommande,NumClient,Description_Commande)" & _ "values('" & txtNCdclt.Text & "','" & dateCmdClt.Text & "','" & txtnumclient.Text & "','" & txtdescmdClt.Text & "')" cmdCMDCLtPrdt.ExecuteNonQuery() IdAutoCommandeCltPrdt() CN.Close() End Sub
3 ème : Appel de deux procedure par click sur une bouton:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 Public Sub AddDetailCommande(ByVal Reference As Integer, ByVal NumCommande As Integer, ByVal Prix_unitaire As Double, ByVal Quantite As Integer, ByVal PVenteHT As Double, ByVal taux As Integer, ByVal TVA As Integer, ByVal PrixVenteTTC As Double, ByVal Remise As Integer, ByVal MontantTotPrixVente As Double) If CN.State = ConnectionState.Closed Then CN.Open() End If Dim cmdDetailcd As New OleDb.OleDbCommand cmdDetailcd.Connection = CN cmdDetailcd.CommandText = "insert into Details_commandes(Reference,NumCommande,Prix_unitaire,Quantite,PVenteHT,Taux,TVA,PrixVenteTTC,Remise,MontantTotPrixVente)" & _ "values('" & txtIRefproduit.Text & "','" & txtNCdclt.Text & "','" & txtPrix.Text & "','" & txtQte.Text & "','" & txtPVHT.Text & "','" & txtTaux.Text & "','" & txtTVA.Text & "','" & txtPVTTC.Text & "','" & txtRemise.Text & "','" & txtTMntTTC.Text & "')" cmdDetailcd.ExecuteNonQuery() CN.Close() End Sub
Pour e premier procedure tous va bien et je peux vir les données sur la table commande. Mais pour le deuxième procedure j’ai reçu le probleme suivant :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 Private Sub btnAddCommande_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddCommande.Click 'ajouter donnée dans commande Dim i As Integer AddCommande(txtNCdclt.Text, dateCmdClt.Value, txtnumclient.Text, txtdescmdClt.Text) 'jouter dans details de commande For i = 0 To dgvProduits.Rows.Count - 1 AddDetailCommande(dgvProduits. Rows(i).Cells(0).Value, _ dgvProduits.Rows(i).Cells(2).Value, _ dgvProduits.CurrentRow.Cells(3).Value, _ dgvProduits.Rows(i).Cells(4).Value, _ dgvProduits.Rows(i).Cells(5).Value, _ dgvProduits.Rows(i).Cells(6).Value, _ dgvProduits.Rows(i).Cells(7).Value, _ dgvProduits.Rows(i).Cells(8).Value, _ dgvProduits.Rows(i).Cells(9).Value) Next MsgBox("Le commande a été ajouté avec succée !!!", vbInformation + vbOKOnly, "Information ") End Sub
La conversion de la chaîne "Anneau de dentition refrigerant " en type 'Integer' n'est pas valide.
Partager