📄 formlogin.vb
字号:
Imports CommonDB
Imports CommonSystem
Public Class FormLogin
Inherits System.Windows.Forms.Form
'Private oUser As User
#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 Panel1 As System.Windows.Forms.Panel
Friend WithEvents Panel2 As System.Windows.Forms.Panel
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 cmbUserLevel As System.Windows.Forms.ComboBox
Friend WithEvents txtUserName As System.Windows.Forms.TextBox
Friend WithEvents txtPassword As System.Windows.Forms.TextBox
Friend WithEvents btnLogin As System.Windows.Forms.Button
Friend WithEvents btnExit As System.Windows.Forms.Button
Friend WithEvents btnReset As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Panel1 = New System.Windows.Forms.Panel
Me.txtPassword = New System.Windows.Forms.TextBox
Me.txtUserName = New System.Windows.Forms.TextBox
Me.cmbUserLevel = New System.Windows.Forms.ComboBox
Me.Label2 = New System.Windows.Forms.Label
Me.Label1 = New System.Windows.Forms.Label
Me.Label3 = New System.Windows.Forms.Label
Me.Panel2 = New System.Windows.Forms.Panel
Me.btnExit = New System.Windows.Forms.Button
Me.btnReset = New System.Windows.Forms.Button
Me.btnLogin = New System.Windows.Forms.Button
Me.Panel1.SuspendLayout()
Me.Panel2.SuspendLayout()
Me.SuspendLayout()
'
'Panel1
'
Me.Panel1.Controls.Add(Me.txtPassword)
Me.Panel1.Controls.Add(Me.txtUserName)
Me.Panel1.Controls.Add(Me.cmbUserLevel)
Me.Panel1.Controls.Add(Me.Label2)
Me.Panel1.Controls.Add(Me.Label1)
Me.Panel1.Controls.Add(Me.Label3)
Me.Panel1.Location = New System.Drawing.Point(8, 16)
Me.Panel1.Name = "Panel1"
Me.Panel1.Size = New System.Drawing.Size(272, 112)
Me.Panel1.TabIndex = 0
'
'txtPassword
'
Me.txtPassword.Location = New System.Drawing.Point(112, 80)
Me.txtPassword.Name = "txtPassword"
Me.txtPassword.PasswordChar = Global.Microsoft.VisualBasic.ChrW(42)
Me.txtPassword.Size = New System.Drawing.Size(144, 21)
Me.txtPassword.TabIndex = 4
Me.txtPassword.Text = "admin"
'
'txtUserName
'
Me.txtUserName.Location = New System.Drawing.Point(112, 48)
Me.txtUserName.Name = "txtUserName"
Me.txtUserName.Size = New System.Drawing.Size(144, 21)
Me.txtUserName.TabIndex = 3
Me.txtUserName.Text = "admin"
'
'cmbUserLevel
'
Me.cmbUserLevel.Location = New System.Drawing.Point(112, 16)
Me.cmbUserLevel.Name = "cmbUserLevel"
Me.cmbUserLevel.Size = New System.Drawing.Size(144, 20)
Me.cmbUserLevel.TabIndex = 2
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(8, 48)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(100, 23)
Me.Label2.TabIndex = 1
Me.Label2.Text = "用户名"
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(8, 16)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(100, 23)
Me.Label1.TabIndex = 0
Me.Label1.Text = "用户级别"
'
'Label3
'
Me.Label3.Location = New System.Drawing.Point(8, 80)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(100, 23)
Me.Label3.TabIndex = 1
Me.Label3.Text = "密 码"
'
'Panel2
'
Me.Panel2.Controls.Add(Me.btnExit)
Me.Panel2.Controls.Add(Me.btnReset)
Me.Panel2.Controls.Add(Me.btnLogin)
Me.Panel2.Location = New System.Drawing.Point(8, 144)
Me.Panel2.Name = "Panel2"
Me.Panel2.Size = New System.Drawing.Size(272, 40)
Me.Panel2.TabIndex = 0
'
'btnExit
'
Me.btnExit.DialogResult = System.Windows.Forms.DialogResult.Cancel
Me.btnExit.Location = New System.Drawing.Point(184, 8)
Me.btnExit.Name = "btnExit"
Me.btnExit.Size = New System.Drawing.Size(75, 23)
Me.btnExit.TabIndex = 2
Me.btnExit.Text = "退 出"
'
'btnReset
'
Me.btnReset.Location = New System.Drawing.Point(96, 8)
Me.btnReset.Name = "btnReset"
Me.btnReset.Size = New System.Drawing.Size(75, 23)
Me.btnReset.TabIndex = 1
Me.btnReset.Text = "重 置"
'
'btnLogin
'
Me.btnLogin.Location = New System.Drawing.Point(8, 8)
Me.btnLogin.Name = "btnLogin"
Me.btnLogin.Size = New System.Drawing.Size(75, 23)
Me.btnLogin.TabIndex = 0
Me.btnLogin.Text = "登 录"
'
'FormLogin
'
Me.AcceptButton = Me.btnLogin
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.CancelButton = Me.btnExit
Me.ClientSize = New System.Drawing.Size(292, 198)
Me.ControlBox = False
Me.Controls.Add(Me.Panel1)
Me.Controls.Add(Me.Panel2)
Me.Name = "FormLogin"
Me.Opacity = 0.8
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "用户登录"
Me.TopMost = True
Me.Panel1.ResumeLayout(False)
Me.Panel1.PerformLayout()
Me.Panel2.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub InitialData()
Dim dsUserLevel As DataSet = DbBase.DataInterface.Execute4DS("select id,role from user_level")
cmbUserLevel.DataSource = dsUserLevel.Tables(0).DefaultView
cmbUserLevel.DisplayMember = "role"
cmbUserLevel.ValueMember = "id"
End Sub
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
Me.Close()
End Sub
Private Sub btnReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReset.Click
cmbUserLevel.SelectedIndex = 0
txtUserName.Text = ""
txtPassword.Text = ""
End Sub
Private Sub FormLogin_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
InitialData()
End Sub
Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
If User.CheckUser(txtUserName.Text, txtPassword.Text, cmbUserLevel.SelectedValue) Then
Dim oForm As New FormMain
oForm.Show()
'Application.Run(New FormMain)
'Me.Close()
Me.Hide()
Else
MessageBox.Show("用户名、密码错误!")
txtUserName.Text = ""
txtPassword.Text = ""
txtUserName.Focus()
End If
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -