Réponse acceptée !
C'est bon g trouvé la solution voilà le truc :
Dim test As String = ""
Dim i As Integer
Dim tb As TextBox
Dim Id_consommable As String
Dim Qte As String
'Requête pour insérer une nouvelle commande
GetConnection()
Dim Req_new_com As String = "INSERT INTO COMMANDE(Date_commande, Id_service) values('" & Now() & "','" & DropDownList_nom_service.SelectedValue & "')"
Dim myCommand_new As New OleDbCommand(Req_new_com, myConnection)
myCommand_new.ExecuteNonQuery()
'Requête pour selectionner la dernière commande
Dim T_new As New TextBox
Dim myCommand_max As New OleDbCommand("SELECT Max(Id_commande)FROM COMMANDE", myConnection)
T_new.Text = myCommand_max.ExecuteScalar()
For i = 0 To GridView_commande.Rows.Count - 1
Dim j As Integer
For j = 0 To GridView_commande.Rows(i).Cells.Count - 1
'On récupére l'id_consommable
If i <= GridView_commande.Rows.Count - 1 And j = 0 Then
Id_consommable = GridView_commande.Rows(i).Cells(j).Text.ToString()
End If
Dim k As Integer
For k = 0 To GridView_commande.Rows(i).Cells(j).Controls.Count() - 1
If GridView_commande.Rows(i).Cells(j).Controls(k).ID() = "qte" Then
tb = GridView_commande.Rows(i).Cells(j).Controls(k)
test = test + ":" + tb.Text() + "<br>"
'On récupére la qte
If i <= GridView_commande.Rows.Count - 1 And j = 2 Then
Qte = tb.Text.Replace("'", "''")
End If
End If
Next
If GridView_commande.Rows(i).Cells(j).Controls.Count() = 0 Then
test = test + " : " + GridView_commande.Rows(i).Cells(j).Text.ToString() + "<BR>"
End If
Next
'requête pour insérer des consommable
Dim Id_commande As String = T_new.Text.Replace("'", "''")
'Sécurité pour ne pas enregistrer des consommables qui n'ont pas de qté
If Qte <> "" Then
GetConnection()
Dim Req_modif_com As String = "INSERT INTO Commander(Id_consommable, Id_commande, Qté) values('" & Id_consommable & "','" & Id_commande & "', '" & Qte & "')"
Dim myCommand_modif As New OleDbCommand(Req_modif_com, myConnection)
myCommand_modif.ExecuteNonQuery()
L_message.Text = "Votre commande est bien passée elle porte le n° "
L_resultat.Text = Id_commande
End If
Next