loginform.vb

来自「管理毕业设计的管理系统 VB+SQL2000....」· VB 代码 · 共 91 行

VB
91 行
字号
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 + =
减小字号Ctrl + -
显示快捷键?