Imports System.Data.OleDb
Imports System.Data
Public Class FLogging
    Dim Pass1Connection As OleDbConnection
    Dim Pass1Command As OleDbCommand
    Dim Pass1Table As New DataTable
    Dim Pass1Adapter As OleDbDataAdapter
    Dim Pass1Manager As CurrencyManager



    Dim NumTries As String ' This variable contains Number that the user will enter password

    Private Sub FLogging_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Pass1Connection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\Pass1.mdb")
        Pass1Connection.Open()
        Pass1Command = New OleDbCommand("SELECT * FROM Pass1 ORDER BY Pass", Pass1Connection)
        Pass1Adapter = New OleDbDataAdapter()
        Pass1Adapter.SelectCommand = Pass1Command
        Pass1Table = New DataTable()
        Pass1Adapter.Fill(Pass1Table)

    End Sub

    Private Sub BtnEnter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnEnter.Click
        NumTries += 1


        Pass1Table.DefaultView.Sort = "Pass"
        Dim FoundRow As Integer = Pass1Table.DefaultView.Find(Password.Text)

        Pass1Table.DefaultView.Sort = "UserName"
        Dim FindRow As Integer = Pass1Table.DefaultView.Find(UserName.Text)

        If FoundRow <> -1 And FindRow <> -1 Then
            ATarification.Show()
            Me.Hide()



        ElseIf NumTries < 3 Then
            MsgBox("Mot de Passe invalide!S'il vous plais essayer de nouveau" & vbCr & "ou le champ est vide.", MsgBoxStyle.Critical, )
            UserName.Text = ""
            Password.Text = ""
        ElseIf NumTries >= 3 Then
            Beep()
            MsgBox("Vous n'êtes pas Autorisé à utiliser ce programme!", MsgBoxStyle.Exclamation)
            UserName.Enabled = False
            Password.Enabled = False
            UserName.Text = ""
            Password.Text = ""
            BtnEnter.Enabled = False
            btnModify.Enabled = False
            Me.Hide()

        End If


    End Sub

    Private Sub btnModify_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnModify.Click
        Fedit.Show()
        Me.Hide()
    End Sub
End Class