Public Class frmKassenbuchPWD

    Public PERSONAL As cPersonal = Nothing

    Sub New(PERSONAL As cPersonal)
        InitializeComponent()
        Me.PERSONAL = PERSONAL
        If PERSONAL.PasswortChanged Is Nothing Then
            Label4.Visible = True
        End If
    End Sub

    Private Sub btnSpeichern_Click(sender As Object, e As EventArgs) Handles btnSpeichern.Click
        If PERSONAL Is Nothing Then
            MsgBox("Altes Passwort falsch!")
            Exit Sub
            Me.Close()
        End If
        
        Me.DialogResult = Windows.Forms.DialogResult.None
        If PERSONAL.Kennwort <> txtPwdOld.Text Then
            MsgBox("Altes Passwort falsch!")
            Exit Sub
        End If

        If txtPwdNew1.Text <> "" Then
            If txtPwdNew1.Text = txtPwdNew2.Text Then

                If txtPwdNew1.Text = PERSONAL.Kennwort Then
                    MsgBox("Das neue Passwort muss sich vom alten unterscheiden!")
                    Exit Sub
                End If

                If txtPwdNew1.Text.Length <= 3 Then
                    MsgBox("Das Passwort muss mehr als 3 Zeichen haben!")
                    Exit Sub
                End If

                Dim sql As New VERAG_PROG_ALLGEMEIN.SQL
                If sql.doSQL("UPDATE Personal SET Kennwort='" & txtPwdNew1.Text & "', PasswortChanged=GETDATE() WHERE ID = '" & PERSONAL.ID & "'", "FMZOLL") Then
                    Me.DialogResult = Windows.Forms.DialogResult.OK
                End If
            Else
                MsgBox("Neue Passwörter stimmen nicht überein!")
                Exit Sub
            End If
        End If
    End Sub
End Class