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
| Private Sub Command3_Click()
Trans As Double
On Error GoTo err
'Instanciation de variable
Set rst = New ADODB.Recordset
Set cnx = New ADODB.Connection
'Procedure de connexion
Call Connexion(cnx)
rst.Open "INSERT INTO retrait(mat_ret, num_ret, type_ret, montant, date_ret, mat_mem, mat_cpt) VALUES ('" & Text8.Text & "', '" & Text9.Text & "', '" & Combo8.Text & "', '" & txtret(0).Text & "', '" & txtret(1).Text & "', '" & txtret(2).Text & "', '" & txtret(3).Text & "') ", cnx, adOpenKeyset, adLockOptimistic, adCmdText
If Combo8.Text = "Retrait Ordinaire" Then
rst.Open "SELECT * FROM compte", cnx, adOpenKeyset, adLockOptimistic, adCmdText
Trans = rst!solde - Val(txtret(0).Text)
rst.Close
'Met à jour solde apres calcul du nouveau solde
rst.Open "UPDATE compte SET solde = '" & Trans & "' WHERE mat_cpt = '" & txtret(3).Text & "' ", cnx, adOpenKeyset, adLockOptimistic, adCmdText
End If
'Ferme la connexion
cnx.Close
If MsgBox("Faire un autre Retrait ?", vbYesNo + vbExclamation, " NOUVEAU COMPTE !") = vbYes Then
RetForm.Show
Else
'Ferme la feuille courante
Unload Me
BonForm.Show
End If
err:
MsgBox "N° erreur:" & err.Number & vbLf & err.Description
End Sub |
Partager