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
| Private Sub B_Valider_Click()
On Error GoTo Err_B_Valider_Click
Dim Ouv_Ordi As Integer
Dim Etat As String
Dim Con As ADODB.Connection
Dim Rst As ADODB.Recordset
Set Con = New ADODB.Connection
Set Rst = New Recordset
Con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;DataSource=G:\Projet\gestion_stock.mdb"
If IsNull(Me.Serial) Then
MsgBox " La saisie du numéro du numéro de série de l'ordinateur prété est obligatoire ", vbExclamation, " Attention "
ElseIf IsNull(Me.Date1) Then
MsgBox " La saisie de la date du prêt est obligatoire de l'ordinateur ", vbExclamation, " Attention "
ElseIf IsNull(Me.Date2) Then
MsgBox " La saisie de la date de retour de l'ordinateur est obligatoire ", vbExclamation, " Attention "
ElseIf IsNull(IPN) Then
MsgBox " La saisie de l'IPN de l'emprunteur est obligatoire ", vbExclamation, " Attention "
ElseIf DCount("[Serial]", "[T_Produit]", "[Serial] = '" & Me.Serial & "'") = 0 Then
MsgBox " Cet ordinateur n'est pas enregistré dans la base de donnée ", vbExclamation, " Attention "
Ouv_Ordi = MsgBox(" Souhaitez-vous l'enregistrer maintenant ", vbYesNo, " Information ")
ElseIf DLookup("[Etat]", "[T_Produit]", "[Serial] = '" & Me.Serial & "'") <> "Stock" Then
Etat = DLookup("[Etat]", "[T_Produit]", "[Serial] = '" & Me.Serial & "'")
MsgBox " Opération impossible car cet ordinateur est en état : '" & Etat & "'", vbExclamation, " Attention "
MsgBox " Merci de vérifier vos données ", vbOKOnly, " Information "
Else
Etat = DLookup("[Etat]", "[T_Produit]", "[Serial] = '" & Me.Serial & "'")
Con.Open
Rst.Open "Select [Etat] From [T_Produit] Where [Serial] = '" & Me.Serial & "'", Con, adOpenDynamic, adLockOptimistic
Rst.Fields(0) = "Pret"
Rst.Update
Rst.Close
Con.Close
DoCmd.GoToRecord , , acNewRec
MsgBox " Opération effectuée avec succès "
End If
Exit_B_Valider_Click:
Exit Sub |
Partager