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
| Private Sub ajouter_facture_Click()
Dim base As Database: Dim ligne As Recordset
Dim requete As String: Dim total As Integer: Dim total_achat As Integer
If (IsNumeric(qte_commandee.Value) And qte_commandee.Value > 0 And ref_produit.Value <> "") Then
If (Int(qte_commandee.Value) <= Int(Qte_stock.Value)) Then
total = Int(prix_unitaire.Value) * Int(qte_commandee.Value)
total_achat = 0
Set base = Application.CurrentDb
requete = "INSERT INTO Detail_temp (ref_det, qute_det,Designation,Prix_unitaire_HT,Prix_total_HT) VALUES ('" & ref_produit.Value & "'," & qte_commandee.Value & ",'" & designation.Value & "'," & prix_unitaire.Value & "," & total & ")"
base.Execute requete
Set ligne = base.OpenRecordset("SELECT Prix_total_HT FROM Detail_temp", dbOpenDynaset)
ligne.MoveFirst
Do
total_achat = total_achat + Int(ligne.Fields("Prix_total_HT").Value)
ligne.MoveNext
Loop Until ligne.EOF
total_commande.Value = total_achat
ligne.Close
base.Close
Set ligne = Nothing
Set base = Nothing
DoCmd.Requery
Else
MsgBox "La quantite commandee est superieure a la quantite en stock monsieur ", vbInformation
End If
Else
MsgBox "Pour ajouter un article à la commande, vous devez définir une quantité supérieure à 0"
End If
End Sub |
Partager