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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
|
Public Function fVerrouOBS(arg_table As String, arg_code As Variant, Optional arg_new As Boolean = False) As String
'Observe le verrouillage
Dim RS As Recordset
On Error GoTo fVerrouOBS_Error
gstr_sql = "SELECT * FROM T_verrou" _
& " WHERE table_en_cours = """ & arg_table & """" _
& " AND code_en_cours = """ & arg_code & """;"
Set RS = CurrentDb.OpenRecordset(gstr_sql, dbOpenDynaset)
If Not (RS.BOF And RS.EOF) Then
If arg_new = False Then fMsg Traduction_Text("X86"), Traduction_Text("X87"), 0
fVerrouOBS = "LOCK"
Else
fVerrouOBS = "UNLOCK"
End If
fVerrouOBS_Error:
Select Case err
Case 0
Case Else
fMsg err, err.Description, 3
End Select
End Function
Public Function fVerrouLOCK(arg_table As String, arg_code As Variant)
'Met un verrou
On Error GoTo fVerrouLOCK_Error
gstr_sql = "INSERT INTO T_verrou" _
& " VALUES(""" & CurrentUser & """, """ & arg_table & """,""" & arg_code & """);"
CurrentDb.Execute gstr_sql
fVerrouLOCK_Error:
Select Case err
Case 0
Case Else
fMsg err, err.Description, 3
End Select
End Function
Public Function fVerrouUNLOCK(arg_table As String, arg_code As Variant)
'Retire un verrou
On Error GoTo fVerrouUNLOCK_Error
gstr_sql = "DELETE * FROM T_verrou" _
& " WHERE login = """ & CurrentUser & """" _
& " AND table_en_cours = """ & arg_table & """" _
& " AND code_en_cours = """ & arg_code & """;"
CurrentDb.Execute gstr_sql
fVerrouUNLOCK_Error:
Select Case err
Case 0
Case Else
fMsg err, err.Description, 3
End Select
End Function
Public Function fVerrouDeverrouillerUtilisateur(arg_user As String, arg_message As Boolean)
'Permet de supprimer tous les enregistrements de la table T_verrou pour un utilisateur
'Paramètre : arg_user : utilisateur à "déverrouiller"
On Error GoTo fVerrouDeverrouillerUtilisateur_Error
If fFormsOuverts = True Then
fMsg "Vous devez fermer tous les formulaires avant d'effectuer cette opération.", "", 0
Else
If arg_message = True Then
If fMsg("Confirmez-vous la réinitialisation du verrouillage ?", "", 1) = vbYes Then
gstr_sql = "DELETE * FROM T_verrou" _
& " WHERE login = """ & arg_user & """"
CurrentDb.Execute gstr_sql
fMsg "Operation terminée.", "", 0
End If
Else
gstr_sql = "DELETE * FROM T_verrou" _
& " WHERE login = """ & arg_user & """"
CurrentDb.Execute gstr_sql
End If
End If
fVerrouDeverrouillerUtilisateur_Error:
Select Case err
Case 0
Case Else
fMsg err, err.Description, 3
End Select
End Function |
Partager