📄 loginform.vb
字号:
Public Class LoginForm
'记录用户名或密码错误的次数
Private i As Integer
Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonOK.Click
Dim strUser As String = TextUser.Text.Trim()
Dim strKey As String = TextKey.Text.Trim()
If StudentRadioButton.Checked Then
Dim strSQL As String = "select * from student where suser='" + strUser + "' and skey='" + strKey + "'"
Dim UserTable As DataTable = DBOperation.Search(strSQL)
If UserTable.Rows.Count > 0 Then
StudentForm.Show()
Me.Finalize()
Else
MsgBox("用户名或密码输入不正确,请重试!", MsgBoxStyle.Exclamation, "登入出错")
i = i + 1
If i > 2 Then
MsgBox("您输入的用户名或密码错误已经超过三次,您无权登入此系统!", MsgBoxStyle.Exclamation, "登入出错")
Me.Close()
End If
Exit Sub
End If
End If
If TeacherRadioButton.Checked Then
Dim strSQL As String = "select * from teacher where tuser='" + strUser + "' and tkey='" + strKey + "'"
Dim UserTable As DataTable = DBOperation.Search(strSQL)
If UserTable.Rows.Count > 0 Then
TeacherForm.Show()
Me.Finalize()
Else
MsgBox("用户名或密码输入不正确,请重试!", MsgBoxStyle.Exclamation, "登入出错")
i = i + 1
If i > 2 Then
MsgBox("您输入的用户名或密码错误已经超过三次,您无权登入此系统!", MsgBoxStyle.Exclamation, "登入出错")
Me.Close()
End If
Exit Sub
End If
End If
If EduRadioButton.Checked Then
Dim strSQL As String = "select * from edu where euser='" + strUser + "' and ekey='" + strKey + "'"
Dim UserTable As DataTable = DBOperation.Search(strSQL)
If UserTable.Rows.Count > 0 Then
EduForm.Show()
Me.Finalize()
Else
MsgBox("用户名或密码输入不正确,请重试!", MsgBoxStyle.Exclamation, "登入出错")
i = i + 1
If i > 2 Then
MsgBox("您输入的用户名或密码错误已经超过三次,您无权登入此系统!", MsgBoxStyle.Exclamation, "登入出错")
Me.Close()
End If
Exit Sub
End If
End If
If AdminRadioButton.Checked Then
Dim strSQL As String = "select * from admin where auser='" + strUser + "' and akey='" + strKey + "'"
Dim UserTable As DataTable = DBOperation.Search(strSQL)
If UserTable.Rows.Count > 0 Then
AdminForm.Show()
Me.Finalize()
Else
MsgBox("用户名或密码输入不正确,请重试!", MsgBoxStyle.Exclamation, "登入出错")
i = i + 1
If i > 2 Then
MsgBox("您输入的用户名或密码错误已经超过三次,您无权登入此系统!", MsgBoxStyle.Exclamation, "登入出错")
Me.Close()
End If
Exit Sub
End If
End If
End Sub
Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonCancel.Click
Dim response As Integer = MsgBox("确定退出系统?", vbOKCancel + vbQuestion, "退出")
If response = 1 Then
End
End If
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -