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

📄 frmlogin.vb

📁 这是一个关于图书仓库管理系统的程序源代码。是我的毕业设计的作品
💻 VB
字号:
Imports System.Data.SqlClient

Public Class frmLogin
    Inherits System.Windows.Forms.Form

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

    Public Sub New()
        MyBase.New()

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

        '在 InitializeComponent() 调用之后添加任何初始化

    End Sub

    '窗体重写处置以清理组件列表。
    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 txtUserID As System.Windows.Forms.TextBox
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents btnOK As System.Windows.Forms.Button
    Friend WithEvents btnCancel As System.Windows.Forms.Button
    Friend WithEvents txtPassword As System.Windows.Forms.TextBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.Label1 = New System.Windows.Forms.Label()
        Me.txtUserID = New System.Windows.Forms.TextBox()
        Me.Label2 = New System.Windows.Forms.Label()
        Me.txtPassword = New System.Windows.Forms.TextBox()
        Me.btnOK = New System.Windows.Forms.Button()
        Me.btnCancel = New System.Windows.Forms.Button()
        Me.SuspendLayout()
        '
        'Label1
        '
        Me.Label1.AutoSize = True
        Me.Label1.Location = New System.Drawing.Point(64, 24)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(48, 14)
        Me.Label1.TabIndex = 0
        Me.Label1.Text = "用户ID:"
        '
        'txtUserID
        '
        Me.txtUserID.Location = New System.Drawing.Point(112, 24)
        Me.txtUserID.Name = "txtUserID"
        Me.txtUserID.Size = New System.Drawing.Size(112, 21)
        Me.txtUserID.TabIndex = 1
        Me.txtUserID.Text = ""
        '
        'Label2
        '
        Me.Label2.AutoSize = True
        Me.Label2.Location = New System.Drawing.Point(64, 64)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(35, 14)
        Me.Label2.TabIndex = 2
        Me.Label2.Text = "密码:"
        '
        'txtPassword
        '
        Me.txtPassword.Location = New System.Drawing.Point(112, 64)
        Me.txtPassword.Name = "txtPassword"
        Me.txtPassword.PasswordChar = Microsoft.VisualBasic.ChrW(35)
        Me.txtPassword.Size = New System.Drawing.Size(112, 21)
        Me.txtPassword.TabIndex = 3
        Me.txtPassword.Text = ""
        '
        'btnOK
        '
        Me.btnOK.Location = New System.Drawing.Point(72, 120)
        Me.btnOK.Name = "btnOK"
        Me.btnOK.Size = New System.Drawing.Size(64, 24)
        Me.btnOK.TabIndex = 4
        Me.btnOK.Text = "确定"
        '
        'btnCancel
        '
        Me.btnCancel.Location = New System.Drawing.Point(152, 120)
        Me.btnCancel.Name = "btnCancel"
        Me.btnCancel.Size = New System.Drawing.Size(64, 24)
        Me.btnCancel.TabIndex = 5
        Me.btnCancel.Text = "取消"
        Me.btnCancel.TextAlign = System.Drawing.ContentAlignment.BottomCenter
        '
        'frmLogin
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.ClientSize = New System.Drawing.Size(296, 165)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.btnCancel, Me.btnOK, Me.txtPassword, Me.Label2, Me.Label1, Me.txtUserID})
        Me.MaximizeBox = False
        Me.MinimizeBox = False
        Me.Name = "frmLogin"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "登录"
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
        If txtUserID.Text.Trim = "" Or txtPassword.Text.Trim = "" Then
            MsgBox("请填写用户名和密码", MsgBoxStyle.Exclamation)
            Exit Sub
        End If

        Dim Params() As SqlParameter = {New SqlParameter("@UserID", SqlDbType.VarChar), _
                                        New SqlParameter("@Password", SqlDbType.VarChar)}
        Params(0).Value = txtUserID.Text.Trim
        Params(1).Value = txtPassword.Text.Trim

        myDataObj.ExecuteSP("sp_CheckPassword", Params, drSqlServer)

        '检验用户的登录信息:用户名和密码
        If drSqlServer.Read Then
            strUserType = drSqlServer("UserType")
            MsgBox("欢迎您:" & txtUserID.Text, MsgBoxStyle.Information)
            STRUSERID = txtUserID.Text
            Select Case strUserType
                Case 1 '系统管理员
                    MDIMain.MenuSys.Enabled = True

                    MDIMain.MenuGoods.Enabled = False
                    MDIMain.MenuTrans.Enabled = False
                Case 2 '图书库存管理员
                    MDIMain.MenuSys.Enabled = False
                    MDIMain.MenuCategory.Enabled = True
                    MDIMain.MenuGoodsTrans.Enabled = True
                    MDIMain.MenuGoods.Enabled = True
                    MDIMain.MenuTrans.Enabled = False
                Case 3 '交易管理员
                    MDIMain.MenuSys.Enabled = False

                    MDIMain.MenuGoods.Enabled = True
                    MDIMain.MenuCategory.Enabled = False
                    MDIMain.MenuGoodsTrans.Enabled = False
                    MDIMain.MenuTrans.Enabled = True

            End Select

            Me.Close()

        Else
            MsgBox("用户ID或者密码错误!", MsgBoxStyle.Exclamation)
        End If

        drSqlServer.Close()

    End Sub

    Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        Me.Close()
    End Sub

End Class

⌨️ 快捷键说明

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