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

📄 frmlogin.vb

📁 这是一个经典的学生管理的例程序欢迎使用偶
💻 VB
字号:
Public Class frmLogin
    Inherits System.Windows.Forms.Form

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

    Public Sub New()
        MyBase.New()

        '该调用是 Windows 窗体设计器所必需的。
        InitializeComponent()

        '在 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 grpboxMsg As System.Windows.Forms.GroupBox
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents Label3 As System.Windows.Forms.Label
    Friend WithEvents btnReset As System.Windows.Forms.Button
    Friend WithEvents btnLogin As System.Windows.Forms.Button
    Friend WithEvents txtUserpwd As System.Windows.Forms.TextBox
    Friend WithEvents txtUsername As System.Windows.Forms.TextBox
    Friend WithEvents cboType As System.Windows.Forms.ComboBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.grpboxMsg = New System.Windows.Forms.GroupBox
        Me.btnReset = New System.Windows.Forms.Button
        Me.btnLogin = New System.Windows.Forms.Button
        Me.txtUserpwd = New System.Windows.Forms.TextBox
        Me.Label3 = New System.Windows.Forms.Label
        Me.cboType = New System.Windows.Forms.ComboBox
        Me.Label2 = New System.Windows.Forms.Label
        Me.txtUsername = New System.Windows.Forms.TextBox
        Me.Label1 = New System.Windows.Forms.Label
        Me.grpboxMsg.SuspendLayout()
        Me.SuspendLayout()
        '
        'grpboxMsg
        '
        Me.grpboxMsg.BackColor = System.Drawing.Color.FromArgb(CType(192, Byte), CType(255, Byte), CType(255, Byte))
        Me.grpboxMsg.Controls.Add(Me.btnReset)
        Me.grpboxMsg.Controls.Add(Me.btnLogin)
        Me.grpboxMsg.Controls.Add(Me.txtUserpwd)
        Me.grpboxMsg.Controls.Add(Me.Label3)
        Me.grpboxMsg.Controls.Add(Me.cboType)
        Me.grpboxMsg.Controls.Add(Me.Label2)
        Me.grpboxMsg.Controls.Add(Me.txtUsername)
        Me.grpboxMsg.Controls.Add(Me.Label1)
        Me.grpboxMsg.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.grpboxMsg.Location = New System.Drawing.Point(8, 8)
        Me.grpboxMsg.Name = "grpboxMsg"
        Me.grpboxMsg.Size = New System.Drawing.Size(272, 192)
        Me.grpboxMsg.TabIndex = 0
        Me.grpboxMsg.TabStop = False
        Me.grpboxMsg.Text = "用户登录"
        '
        'btnReset
        '
        Me.btnReset.Location = New System.Drawing.Point(160, 152)
        Me.btnReset.Name = "btnReset"
        Me.btnReset.Size = New System.Drawing.Size(40, 23)
        Me.btnReset.TabIndex = 4
        Me.btnReset.Text = "重填"
        '
        'btnLogin
        '
        Me.btnLogin.Location = New System.Drawing.Point(64, 152)
        Me.btnLogin.Name = "btnLogin"
        Me.btnLogin.Size = New System.Drawing.Size(40, 23)
        Me.btnLogin.TabIndex = 3
        Me.btnLogin.Text = "登录"
        '
        'txtUserpwd
        '
        Me.txtUserpwd.Location = New System.Drawing.Point(104, 72)
        Me.txtUserpwd.MaxLength = 15
        Me.txtUserpwd.Name = "txtUserpwd"
        Me.txtUserpwd.PasswordChar = Microsoft.VisualBasic.ChrW(42)
        Me.txtUserpwd.Size = New System.Drawing.Size(120, 21)
        Me.txtUserpwd.TabIndex = 1
        Me.txtUserpwd.Text = ""
        '
        'Label3
        '
        Me.Label3.Location = New System.Drawing.Point(24, 80)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(72, 16)
        Me.Label3.TabIndex = 6
        Me.Label3.Text = "密    码:"
        '
        'cboType
        '
        Me.cboType.Items.AddRange(New Object() {"学生", "教师"})
        Me.cboType.Location = New System.Drawing.Point(104, 120)
        Me.cboType.Name = "cboType"
        Me.cboType.Size = New System.Drawing.Size(121, 20)
        Me.cboType.TabIndex = 2
        Me.cboType.Text = "请选择"
        '
        'Label2
        '
        Me.Label2.Location = New System.Drawing.Point(24, 120)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(72, 16)
        Me.Label2.TabIndex = 7
        Me.Label2.Text = "用户类型:"
        '
        'txtUsername
        '
        Me.txtUsername.Location = New System.Drawing.Point(104, 24)
        Me.txtUsername.MaxLength = 10
        Me.txtUsername.Name = "txtUsername"
        Me.txtUsername.Size = New System.Drawing.Size(120, 21)
        Me.txtUsername.TabIndex = 0
        Me.txtUsername.Text = ""
        '
        'Label1
        '
        Me.Label1.Location = New System.Drawing.Point(24, 32)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(72, 16)
        Me.Label1.TabIndex = 5
        Me.Label1.Text = "用 户 名:"
        '
        'frmLogin
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.BackColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.ClientSize = New System.Drawing.Size(288, 206)
        Me.Controls.Add(Me.grpboxMsg)
        Me.Name = "frmLogin"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "用户登录"
        Me.grpboxMsg.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region

    '创建cUser类的一个实例:objUser对象
    Dim objUser As New cUser

    Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click

        '给对象的属性赋值
        objUser.Name = txtUsername.Text
        objUser.Password = txtUserpwd.Text
        objUser.Type = cboType.SelectedItem

        Dim frmMain As New frmIndex
        Dim frmA As New frmSearchMarks

        '调用类的CheckUser方法
        Dim chrPower As Char = objUser.CheckUser(objUser.Name, objUser.Password, objUser.Type)

        Select Case chrPower
            Case "1" '1代表学生
                Me.Hide()
                If Not (Me.MdiParent Is Nothing) Then
                    Me.MdiParent.Hide()
                End If


                frmMain.mnuInsert.Enabled = False
                frmMain.mnuSearch.Enabled = True
                frmMain.tbrbtnAdd.Enabled = False
                frmMain.tbrSearch.Enabled = True

                frmMain.Show()
            Case "2" '2代表教师
                Me.Hide()
                If Not (Me.MdiParent Is Nothing) Then
                    Me.MdiParent.Hide()
                End If

                frmMain.mnuInsert.Enabled = True
                frmMain.mnuSearch.Enabled = True
                frmMain.tbrbtnAdd.Enabled = True
                frmMain.tbrSearch.Enabled = True


                frmMain.Show()
        End Select

    End Sub

    Private Sub btnReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReset.Click
        txtUsername.Text = ""
        txtUserpwd.Text = ""
        cboType.Text = ""
    End Sub

End Class

⌨️ 快捷键说明

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