📄 login.vb
字号:
Public Class LOGIN
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 Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents btok As System.Windows.Forms.Button
Friend WithEvents tbname As System.Windows.Forms.TextBox
Friend WithEvents tbpwd As System.Windows.Forms.TextBox
Friend WithEvents btcancel As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Label1 = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
Me.tbname = New System.Windows.Forms.TextBox
Me.tbpwd = New System.Windows.Forms.TextBox
Me.btok = New System.Windows.Forms.Button
Me.btcancel = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(32, 24)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(48, 23)
Me.Label1.TabIndex = 0
Me.Label1.Text = "用户名"
Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(24, 72)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(48, 23)
Me.Label2.TabIndex = 1
Me.Label2.Text = "密码"
Me.Label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight
'
'tbname
'
Me.tbname.Location = New System.Drawing.Point(88, 24)
Me.tbname.Name = "tbname"
Me.tbname.TabIndex = 2
Me.tbname.Text = ""
'
'tbpwd
'
Me.tbpwd.Location = New System.Drawing.Point(88, 72)
Me.tbpwd.Name = "tbpwd"
Me.tbpwd.PasswordChar = Microsoft.VisualBasic.ChrW(42)
Me.tbpwd.Size = New System.Drawing.Size(104, 21)
Me.tbpwd.TabIndex = 3
Me.tbpwd.Text = ""
'
'btok
'
Me.btok.DialogResult = System.Windows.Forms.DialogResult.OK
Me.btok.Location = New System.Drawing.Point(32, 112)
Me.btok.Name = "btok"
Me.btok.Size = New System.Drawing.Size(72, 23)
Me.btok.TabIndex = 4
Me.btok.Text = "登录"
'
'btcancel
'
Me.btcancel.DialogResult = System.Windows.Forms.DialogResult.Cancel
Me.btcancel.Location = New System.Drawing.Point(144, 112)
Me.btcancel.Name = "btcancel"
Me.btcancel.Size = New System.Drawing.Size(72, 23)
Me.btcancel.TabIndex = 7
Me.btcancel.Text = "取消"
'
'LOGIN
'
Me.AcceptButton = Me.btok
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.CancelButton = Me.btcancel
Me.ClientSize = New System.Drawing.Size(242, 151)
Me.Controls.Add(Me.btcancel)
Me.Controls.Add(Me.btok)
Me.Controls.Add(Me.tbpwd)
Me.Controls.Add(Me.tbname)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label1)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
Me.Name = "LOGIN"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent
Me.Text = "登录"
Me.ResumeLayout(False)
End Sub
#End Region
Public flag = False
Private Sub btok_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btok.Click
If Me.tbname.Text.Trim() = String.Empty Then
MessageBox.Show("姓名不能为空")
Me.tbname.Focus()
ElseIf Me.tbpwd.Text.Trim() = String.Empty Then
MessageBox.Show("密码不能为空")
Me.tbpwd.Focus()
Else
Dim sql As String = "SELECT * FROM USERINFO WHERE USERID = '" + Me.tbname.Text.Trim() + "' AND USERPWD = '" + Me.tbpwd.Text.Trim() + "'"
Dim dt As DataTable = GetDataTable(sql)
If dt.Rows.Count = 0 Then
MessageBox.Show("用户名不存在或密码不正确")
Me.tbpwd.Focus()
Else
UserRight = dt.Rows(0)("usertype")
UserID = Me.tbname.Text.Trim()
flag = True
Me.Close()
End If
End If
End Sub
Private Sub btcancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btcancel.Click
Application.Exit()
End Sub
Private Sub LOGIN_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -