Private Sub forgotpawwordform_Load(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles MyBase.Load txtuser.Clear() txtnameofuser.Clear() cbosecurityquestion.Items.Clear() txtsecurityanswer.Clear() txtpass.Clear() cbstatus.Checked = False cbstatus.Text = "Show Password" txtpass.PasswordChar = "●" forgotpassmod() End Sub
Private Sub txtusername_TextChanged(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles txtuser.TextChanged Dim usernameval As String txtuser.Text = Replace(txtuser.Text, "'", "`") txtuser.Text = UCase$(txtuser.Text) txtuser.SelectionStart = Len(txtuser.Text) con.Connection = connectionserver con.CommandText = "SELECT username FROM tbl_user where username = '" & txtuser.Text & "'" usernameval = con.ExecuteScalar
If usernameval <> txtuser.Text Then
txtnameofuser.Clear() ElseIf txtuser.Text = "" Then txtnameofuser.Clear() Else With con con.Connection = connectionserver con.CommandText = "SELECT nameofuser from tbl_user where username = '" & txtuser.Text & "'" txtnameofuser.Text = con.ExecuteScalar End With End If End Sub
Private Sub txtsecurityanswer_TextChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles txtsecurityanswer.TextChanged txtsecurityanswer.Text = Replace(txtsecurityanswer.Text, "'", "`") txtsecurityanswer.SelectionStart = Len(txtsecurityanswer.Text) End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click Dim usernameval As String con.Connection = connectionserver con.CommandText = "SELECT username FROM tbl_user where username = '" & txtuser.Text & "'" usernameval = con.ExecuteScalar
If usernameval <> txtuser.Text Then
MsgBox("Please provide valid username!", MsgBoxStyle.Exclamation, "Username") txtpass.Clear() cbstatus.Checked = False cbstatus.Text = "Show Password" txtpass.PasswordChar = "●" Exit Sub Else If cbosecurityquestion.Text = "" Then MsgBox("Security Question is required!", MsgBoxStyle.Exclamation, "") txtpass.Clear() cbstatus.Checked = False cbstatus.Text = "Show Password" txtpass.PasswordChar = "●" Exit Sub ElseIf txtsecurityanswer.Text = "" Then MsgBox("Security Answer is required!", MsgBoxStyle.Exclamation, "") txtpass.Clear() cbstatus.Checked = False cbstatus.Text = "Show Password" txtpass.PasswordChar = "●" Exit Sub Else Dim securityquestionval, secanswerval As String con.Connection = connectionserver con.CommandText = "select securityquestion from tbl_user where username = '" & txtuser.Text & "'" securityquestionval = con.ExecuteScalar con.CommandText = "select answer from tbl_user where username = '" & txtuser.Text & "'" secanswerval = con.ExecuteScalar If cbosecurityquestion.Text <> securityquestionval Then MsgBox("Security Question and answer is invalid!", MsgBoxStyle.Exclamation, "") txtpass.Clear() cbstatus.Checked = False cbstatus.Text = "Show Password" txtpass.PasswordChar = "●" Exit Sub ElseIf secanswerval <> txtsecurityanswer.Text Then MsgBox("Security Question and answer is invalid!", MsgBoxStyle.Exclamation, "") txtpass.Clear() cbstatus.Checked = False cbstatus.Text = "Show Password" txtpass.PasswordChar = "●" Exit Sub Else con.Connection = connectionserver con.CommandText = "select password from tbl_user where username = '" & txtuser.Text & "'" txtpass.Text = con.ExecuteScalar With con .Connection = connectionserver .CommandText = "Update tbl_user Set attemp = '" & "0" & "' where username = '" & txtuser.Text & "'" con.ExecuteNonQuery() End With MsgBox("Congrats! your successfully retreived your password", MsgBoxStyle.Information, "Retreive") cbstatus.Checked = False cbstatus.Text = "Show Password" txtpass.PasswordChar = "●" Exit Sub End If End If End If End Sub
Private Sub Btnexit_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Btnexit.Click Me.Close() Exit Sub End Sub
Private Sub cbstatus_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles cbstatus.Click If cbstatus.Checked = True Then cbstatus.Text = "Show Password" txtpass.PasswordChar = "" Exit Sub ElseIf cbstatus.Checked = False Then cbstatus.Text = "Show Password" txtpass.PasswordChar = "●" Exit Sub End If End Sub End Class