ElseIf blnAdminUser _
And Not blnAccountLocked _
And txtUsername.Text.Trim = m_strUsername _
And txtPassword.Text.Trim = m_strPassword Then
'let the user in
LetUserIn()
'now lets check to see if the user is an administrator and if the account is locked
'then ask the administrator if they want to reset the accounts locked status. this
'is a bad thing if there is only one admin account and the account is locked because
'only admins can reset the locked status
ElseIf blnAdminUser _
And blnAccountLocked _
And txtUsername.Text.Trim = m_strUsername _
And txtPassword.Text.Trim = m_strPassword Then
If MessageBox.Show("We cannot log you into " & AppName() & "." & vbNewLine & vbNewLine & _
"Reason: Account is in locked status." & vbNewLine & _
"Solution: Account reset." & vbNewLine & vbNewLine & _
"Would you like to reset your account?", _
"Account Locked", _
MessageBoxButtons.YesNo, _
MessageBoxIcon.Question, _
MessageBoxDefaultButton.Button1, _
MessageBoxOptions.ServiceNotification, _
False) = Windows.Forms.DialogResult.Yes Then
'reset the administrators account
'first select the administrator
Dim objSelectAdminAccountCmd As New SqlClient.SqlCommand("SELECT Username, AccountLocked " & _
"FROM Users " & _
"WHERE Username = '" & m_strUsername & "' " & _
"AND IsAdmin = 1 " & _
"AND AccountLocked = 1", m_objCon)
'execute the command
objSelectAdminAccountCmd.ExecuteNonQuery()
'now reset the account locked status from 1 to 0
Dim objResetAdminAccountCmd As New SqlClient.SqlCommand("UPDATE Users " & _
"SET AccountLocked = 0 " & _
"WHERE Username = '" & m_strUsername & "' " & _
"AND IsAdmin = 1", m_objCon)
'execute the command
objResetAdminAccountCmd.ExecuteNonQuery()
End If
'now check to see if the user is an admin, the account isnt locked but the username doesnt match
ElseIf blnAdminUser _
And Not blnAccountLocked _
And Not txtUsername.Text.Trim = m_strUsername _
And txtPassword.Text.Trim = m_strPassword Then
If MessageBox.Show("We cannot log you into " & AppName() & "." & vbNewLine & vbNewLine & _
"Reason: Username mismatch." & vbNewLine & _
"Solution: Try again.", _
"Username Mismatch", _
MessageBoxButtons.OK, _
MessageBoxIcon.Exclamation, _
MessageBoxDefaultButton.Button1, _
MessageBoxOptions.ServiceNotification, _
False) = Windows.Forms.DialogResult.OK Then
'reset the form
ResetScreen(Me)
'reset the cursor focus
txtUsername.Focus()
End If
'now lets finally check to see if the user is an admin, the account isnt locked but the
'password doesnt match
ElseIf blnAdminUser _
And Not blnAccountLocked _
And txtUsername.Text.Trim = m_strUsername _
And Not txtPassword.Text.Trim = m_strPassword Then
If MessageBox.Show("We cannot log you into " & AppName() & "." & vbNewLine & vbNewLine & _
"Reason: Password mismatch." & vbNewLine & _
"Solution: Try again.", _
"Password Mismatch", _
MessageBoxButtons.OK, _
MessageBoxIcon.Exclamation, _
MessageBoxDefaultButton.Button1, _
MessageBoxOptions.ServiceNotification, _
False) = Windows.Forms.DialogResult.OK Then
'reset the form
ResetScreen(Me)
'reset the cursor focus
txtUsername.Focus()
End If
End If
End If
Catch ex As Exception
Finally
'now destroy all the data sets and data adapaters
objAdminUserDs.Dispose()
objRegularUserDs.Dispose()
objAdminUserDa.Dispose()
objRegularUserDa.Dispose()
'if the connection to the database is open, close it
If m_objCon.State = ConnectionState.Open Then
m_objCon.Close()
End If
End Try
End Sub