⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 passwdwin.vb

📁 强大的教务考勤系统数据库
💻 VB
字号:
Public Class PasswdWin
    Inherits System.Windows.Forms.Form
    Private stat As Boolean

#Region " Windows 窗体设计器生成的代码 "

    Public Sub New()
        MyBase.New()

        '该调用是 Windows 窗体设计器所必需的。
        InitializeComponent()
        stat = False
        '在 InitializeComponent() 调用之后添加任何初始化

    End Sub

    '窗体重写 dispose 以清理组件列表。
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Windows 窗体设计器所必需的
    Private components As System.ComponentModel.IContainer

    '注意: 以下过程是 Windows 窗体设计器所必需的
    '可以使用 Windows 窗体设计器修改此过程。
    '不要使用代码编辑器修改它。
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents tbID As System.Windows.Forms.TextBox
    Friend WithEvents tbPasswd As System.Windows.Forms.TextBox
    Friend WithEvents GroupBox As System.Windows.Forms.GroupBox
    Friend WithEvents btExit As System.Windows.Forms.Button
    Friend WithEvents btYes As System.Windows.Forms.Button
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.tbID = New System.Windows.Forms.TextBox
        Me.tbPasswd = New System.Windows.Forms.TextBox
        Me.Label1 = New System.Windows.Forms.Label
        Me.Label2 = New System.Windows.Forms.Label
        Me.GroupBox = New System.Windows.Forms.GroupBox
        Me.btExit = New System.Windows.Forms.Button
        Me.btYes = New System.Windows.Forms.Button
        Me.GroupBox.SuspendLayout()
        Me.SuspendLayout()
        '
        'tbID
        '
        Me.tbID.Location = New System.Drawing.Point(80, 32)
        Me.tbID.Name = "tbID"
        Me.tbID.Size = New System.Drawing.Size(144, 21)
        Me.tbID.TabIndex = 1
        Me.tbID.Text = ""
        '
        'tbPasswd
        '
        Me.tbPasswd.Location = New System.Drawing.Point(80, 80)
        Me.tbPasswd.Name = "tbPasswd"
        Me.tbPasswd.PasswordChar = Microsoft.VisualBasic.ChrW(42)
        Me.tbPasswd.Size = New System.Drawing.Size(144, 21)
        Me.tbPasswd.TabIndex = 2
        Me.tbPasswd.Text = ""
        '
        'Label1
        '
        Me.Label1.Location = New System.Drawing.Point(16, 32)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(48, 24)
        Me.Label1.TabIndex = 4
        Me.Label1.Text = "用户名"
        Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
        '
        'Label2
        '
        Me.Label2.Location = New System.Drawing.Point(16, 80)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(48, 24)
        Me.Label2.TabIndex = 5
        Me.Label2.Text = "密码"
        Me.Label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
        '
        'GroupBox
        '
        Me.GroupBox.Controls.Add(Me.tbID)
        Me.GroupBox.Controls.Add(Me.tbPasswd)
        Me.GroupBox.Controls.Add(Me.Label1)
        Me.GroupBox.Controls.Add(Me.Label2)
        Me.GroupBox.Location = New System.Drawing.Point(24, 8)
        Me.GroupBox.Name = "GroupBox"
        Me.GroupBox.Size = New System.Drawing.Size(248, 120)
        Me.GroupBox.TabIndex = 5
        Me.GroupBox.TabStop = False
        '
        'btExit
        '
        Me.btExit.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.btExit.Location = New System.Drawing.Point(168, 144)
        Me.btExit.Name = "btExit"
        Me.btExit.TabIndex = 7
        Me.btExit.Text = "退出"
        '
        'btYes
        '
        Me.btYes.Location = New System.Drawing.Point(56, 144)
        Me.btYes.Name = "btYes"
        Me.btYes.TabIndex = 6
        Me.btYes.Text = "确定"
        '
        'PasswdWin
        '
        Me.AcceptButton = Me.btYes
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.CancelButton = Me.btExit
        Me.ClientSize = New System.Drawing.Size(292, 198)
        Me.ControlBox = False
        Me.Controls.Add(Me.btExit)
        Me.Controls.Add(Me.btYes)
        Me.Controls.Add(Me.GroupBox)
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
        Me.Name = "PasswdWin"
        Me.Text = "登陆"
        Me.GroupBox.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region

    Public ReadOnly Property getStat() As Boolean
        Get
            Return stat
        End Get
    End Property

    Private Sub btYes_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btYes.Click
        If tbID.Text = "" Then
            MsgBox("用户名不能为空!", , "")
            Exit Sub
        End If

        If tbPasswd.Text = "" Then
            MsgBox("密码不能为空!", , "")
            Exit Sub
        End If

        If mycon.State = ConnectionState.Closed Then mycon.Open()
        Dim str As String
        Dim mycom As SqlCommand

        str = "select ID from password where ID='" & tbID.Text & "'"
        mycom = New SqlCommand(str, mycon)
        If mycom.ExecuteScalar() <> "" Then
            operid = tbID.Text
        Else
            MsgBox("用户名不存在!", , "")
            tbID.Text = ""
            tbPasswd.Text = ""
            Exit Sub
        End If

        str = "select iden from password where ID='" & tbID.Text & "' and password='" & tbPasswd.Text & "'"
        mycom = New SqlCommand(str, mycon)
        If mycom.ExecuteScalar() <> "" Then
            operiden = mycom.ExecuteScalar().ToString()
            passwd = tbPasswd.Text
        Else
            MsgBox("密码错误!", , "")
            tbPasswd.Text = ""
            Exit Sub
        End If

        Select Case operiden
            Case "admin"
                opername = "管理员"
                Me.Close()
            Case "teacher"
                str = "select tName from teacher where tID='" & operid & "'"
            Case "student"
                str = "select sName from student where sID='" & operid & "'"
        End Select
        mycom = New SqlCommand(str, mycon)
        opername = mycom.ExecuteScalar()
        stat = True
        Me.Close()
    End Sub
End Class

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -