Imports System.Data.OleDb
Imports System.Data


Public Class ChangePassword
    Dim Pass2Connection As OleDbConnection
    Dim Pass2Command As OleDbCommand
    Dim Pass2Table As New DataTable
    Dim Pass2Adapter As OleDbDataAdapter
    Dim Pass2Manager As CurrencyManager



    Private Sub BtnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Me.Hide()
    End Sub

    Private Sub PasswordBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Me.Validate()
        Me.PasswordBindingSource.EndEdit()
        Me.TableAdapterManager.UpdateAll(Me.PasswordDataSet1)

    End Sub

    Private Sub Loggin_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Pass2Connection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\Pass2.mdb")
        Pass2Connection.Open()
        Pass2Command = New OleDbCommand("SELECT * FROM Pass2 ORDER BY Passe", Pass2Connection)
        Pass2Adapter = New OleDbDataAdapter()
        Pass2Adapter.SelectCommand = Pass2Command
        Pass2Table = New DataTable()
        Pass2Adapter.Fill(Pass2Table)
        Password.DataBindings.Add("Text", Pass2Table, "Passe")
        UserName.DataBindings.Add("Text", Pass2Table, "UserName")
        Password.Text = Nothing
        UserName.Text = Nothing


        Pass2Manager = DirectCast(Me.BindingContext(Pass2Table), CurrencyManager)


    End Sub

    Private Sub BtnEnter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnEnter.Click
        Dim SavedItem As String = Password.Text
        Dim SavedRow As Integer
        Pass2Manager.EndCurrentEdit()

        Pass2Table.DefaultView.Sort = "Passe"
        SavedRow = Pass2Table.DefaultView.Find(SavedItem)
        Pass2Manager.Position = SavedRow
        Try
            'save the update  table
            Dim TarifeAdapterCommands As New OleDbCommandBuilder(Pass2Adapter)
            Pass2Adapter.Update(Pass2Table)
            MsgBox("Le mot de Passe a été changé", MsgBoxStyle.Information)
            Me.Hide()
        Catch ex As Exception
            MessageBox.Show(ex.Message, "Erreur de base de données Sauvegarde", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
        'close the connection
        'dispose of the objects
        Pass2Command.Dispose()
        Pass2Adapter.Dispose()
        Pass2Table.Dispose()




    End Sub

    Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
        If RadioButton1.Checked = True Then
            Password.PasswordChar = ""




        End If
    End Sub
End Class