Public TtT As ADODB.Recordset
Dim Compteur As Integer
Private Sub DTPicker_Debut_LostFocus()
If DTPicker_begin < DATebegin.Text Or DTPicker_end > DATeend.text Then
MsgBox "Begin date over exercice", vbCritical
DTPicker_begin = DATebegin.text
End If
End Sub
Private Sub DTPicker_Fin_LostFocus()
If DTPicker_Fin< DATebegin.Text Or DTPicker_Fin > DATeend.text Then
MsgBox "End date over exercice", vbCritical
DTPicker_end = DAtefin.text
End If
If DTPicker_Fin < DTPicker_Debut Then
MsgBox "Date fin inférieure A la date début", vbCritical
DTPicker_Fin = DTPicker_Debut
End If
End Sub
Private Sub Form_Load()
Set TtT = New ADODB.Recordset
With TtT
.CursorLocation = adUseClient
.CursorType = adOpenDynamic
.LockType = adLockOptimistic
.ActiveConnection = Ma_Connexion
.Source = "SELECT * FROM user"
.Open
End With
Me.DTPicker_Debut = PEriodbegin.text
Me.DTPicker_Fin = DATeend.text
Me.DTPicker_gegin.Enabled = False
Me.DTPicker_end.Enabled = False
End Sub
Private Sub Ok_Click()
Set TtT = New ADODB.Recordset
With TtT
.CursorLocation = adUseClient
.CursorType = adOpenDynamic
.LockType = adLockOptimistic
.ActiveConnection = Cnx
.Source = "SELECT * FROM user"
.Open
End With
TtT.MoveFirst
Do Until TtT.EOF
If UCase(Text_username) = TtT!username And UCase(Text_password) = TtT!password Then
Zcodeuser .text= TtT!Codeuser
Zusername.text= TtT!username
Zpassword.text = TtT!password
Zlevel.text = TtT!level
TtT.Close
TtT.Source = "UPDATE SYSTEMe set perdebut='" & DTPicker_Debut & "',perfin = '" & DTPicker_Fin & "'"
TtT.Open
Me.Hide
Effacer
Exit Sub
End If
TtT.MoveNext
Loop
Compteur = Compteur + 1
If Compteur < 4 Then
MsgBox "password invalid", vbCritical
Me.Text_username.SetFocus
Else
MsgBox "access denied", vbCritical
End
End If
End Sub
End Sub
With TtT
.CursorLocation = adUseClient
.CursorType = adOpenDynamic
.LockType = adLockOptimistic
.ActiveConnection = Ma_Connexion
.Source = "SELECT * FROM user"
.Open
End With
TtT.MoveFirst
Do Until TtT.EOF
If UCase(Text_username) = TtT!username And UCase(Text_password) = TtT!password Then
If TtT!level = "SUP" Or TtT!level = "ADM" Then
DTPicker_begin.Enabled = True
DTPicker_end.Enabled = True
Exit Sub
End If
End If
TtT.MoveNext
Loop
End Sub