📄 login.vb
字号:
Public Class Login
'Declare variables
Private intAttemptCount As Integer = 0
Private blnAllowClosing As Boolean = False
Private Sub btnOK_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnOK.Click
'Initialize a new instance of the business logic component
Using objUsers As New WroxBusinessLogic.WBLUsers("Wrox", "Time Tracker Oracle")
'Validate the user and get their role
Dim objDataSet As Data.DataSet = objUsers.ValidateLogin( _
txtLoginName.Text, txtPassword.Text)
If objDataSet.Tables("User").Rows.Count > 0 Then
If objDataSet.Tables("User").Rows(0).Item("Status") Then
g_strUserRole = objDataSet.Tables("User").Rows(0).Item( _
"RoleName")
g_strUserID = objDataSet.Tables("User").Rows(0).Item( _
"UserID").ToString
g_strUserName = objDataSet.Tables("User").Rows(0).Item( _
"UserName").ToString
Else
MessageBox.Show("Your account has been suspended." & _
ControlChars.CrLf & "Please contact your administrator.", _
"Time Tracker", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
blnAllowClosing = True
Else
MessageBox.Show("Your credentials were not validated.", _
"Time Tracker", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
'Clean up
objDataSet.Dispose()
objDataSet = Nothing
'Increment attempt count
intAttemptCount += 1
End Using
End Sub
Private Sub btnCancel_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnCancel.Click
blnAllowClosing = True
Me.Close()
End Sub
Private Sub Login_FormClosing(ByVal sender As Object, _
ByVal e As System.Windows.Forms.FormClosingEventArgs) _
Handles Me.FormClosing
If Not blnAllowClosing Then
If intAttemptCount < 3 Then
e.Cancel = True
End If
End If
End Sub
Private Sub txtPassword_KeyUp(ByVal sender As Object, _
ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtPassword.KeyUp
If e.KeyCode = Keys.Enter Then
Call btnOK_Click(sender, e)
End If
If blnAllowClosing Then
Me.Close()
End If
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -