📄 login.vb
字号:
Public Class Login
Inherits System.Windows.Forms.Form
#Region " Windows 窗体设计器生成的代码 "
Public Sub New()
MyBase.New()
System.Windows.Forms.Application.EnableVisualStyles()
'该调用是 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 LabelName As System.Windows.Forms.Label
Friend WithEvents LabelPwd As System.Windows.Forms.Label
Friend WithEvents TextBoxPwd As System.Windows.Forms.TextBox
Friend WithEvents ButtonRest As System.Windows.Forms.Button
Friend WithEvents ButtonLogin As System.Windows.Forms.Button
Friend WithEvents LinkLabelAbout As System.Windows.Forms.LinkLabel
Friend WithEvents ButtonNew As System.Windows.Forms.Button
Friend WithEvents ComboBoxName As System.Windows.Forms.ComboBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.LabelName = New System.Windows.Forms.Label
Me.LabelPwd = New System.Windows.Forms.Label
Me.TextBoxPwd = New System.Windows.Forms.TextBox
Me.ButtonRest = New System.Windows.Forms.Button
Me.LinkLabelAbout = New System.Windows.Forms.LinkLabel
Me.ButtonLogin = New System.Windows.Forms.Button
Me.ButtonNew = New System.Windows.Forms.Button
Me.ComboBoxName = New System.Windows.Forms.ComboBox
Me.SuspendLayout()
'
'LabelName
'
Me.LabelName.Font = New System.Drawing.Font("宋体", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.LabelName.Location = New System.Drawing.Point(16, 24)
Me.LabelName.Name = "LabelName"
Me.LabelName.Size = New System.Drawing.Size(80, 24)
Me.LabelName.TabIndex = 0
Me.LabelName.Text = "用户名:"
Me.LabelName.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'LabelPwd
'
Me.LabelPwd.Font = New System.Drawing.Font("宋体", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.LabelPwd.Location = New System.Drawing.Point(16, 64)
Me.LabelPwd.Name = "LabelPwd"
Me.LabelPwd.Size = New System.Drawing.Size(80, 24)
Me.LabelPwd.TabIndex = 1
Me.LabelPwd.Text = "密 码:"
Me.LabelPwd.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'TextBoxPwd
'
Me.TextBoxPwd.Font = New System.Drawing.Font("宋体", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.TextBoxPwd.Location = New System.Drawing.Point(88, 64)
Me.TextBoxPwd.MaxLength = 12
Me.TextBoxPwd.Name = "TextBoxPwd"
Me.TextBoxPwd.PasswordChar = Microsoft.VisualBasic.ChrW(42)
Me.TextBoxPwd.Size = New System.Drawing.Size(160, 21)
Me.TextBoxPwd.TabIndex = 1
Me.TextBoxPwd.Text = ""
'
'ButtonRest
'
Me.ButtonRest.FlatStyle = System.Windows.Forms.FlatStyle.System
Me.ButtonRest.Location = New System.Drawing.Point(194, 104)
Me.ButtonRest.Name = "ButtonRest"
Me.ButtonRest.Size = New System.Drawing.Size(64, 23)
Me.ButtonRest.TabIndex = 8
Me.ButtonRest.Text = "退出(&C)"
'
'LinkLabelAbout
'
Me.LinkLabelAbout.Location = New System.Drawing.Point(232, 144)
Me.LinkLabelAbout.Name = "LinkLabelAbout"
Me.LinkLabelAbout.Size = New System.Drawing.Size(56, 16)
Me.LinkLabelAbout.TabIndex = 10
Me.LinkLabelAbout.TabStop = True
Me.LinkLabelAbout.Text = "关于软件"
Me.LinkLabelAbout.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'ButtonLogin
'
Me.ButtonLogin.FlatStyle = System.Windows.Forms.FlatStyle.System
Me.ButtonLogin.Location = New System.Drawing.Point(32, 104)
Me.ButtonLogin.Name = "ButtonLogin"
Me.ButtonLogin.Size = New System.Drawing.Size(64, 23)
Me.ButtonLogin.TabIndex = 7
Me.ButtonLogin.Text = "登陆(&0)"
'
'ButtonNew
'
Me.ButtonNew.FlatStyle = System.Windows.Forms.FlatStyle.System
Me.ButtonNew.Location = New System.Drawing.Point(112, 104)
Me.ButtonNew.Name = "ButtonNew"
Me.ButtonNew.Size = New System.Drawing.Size(64, 23)
Me.ButtonNew.TabIndex = 9
Me.ButtonNew.Text = "新用户(&N)"
'
'ComboBoxName
'
Me.ComboBoxName.Location = New System.Drawing.Point(88, 24)
Me.ComboBoxName.Name = "ComboBoxName"
Me.ComboBoxName.Size = New System.Drawing.Size(160, 20)
Me.ComboBoxName.TabIndex = 11
'
'Login
'
Me.AutoScale = False
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(292, 191)
Me.ControlBox = False
Me.Controls.Add(Me.ComboBoxName)
Me.Controls.Add(Me.ButtonNew)
Me.Controls.Add(Me.LinkLabelAbout)
Me.Controls.Add(Me.ButtonRest)
Me.Controls.Add(Me.ButtonLogin)
Me.Controls.Add(Me.TextBoxPwd)
Me.Controls.Add(Me.LabelPwd)
Me.Controls.Add(Me.LabelName)
Me.KeyPreview = True
Me.MaximizeBox = False
Me.MaximumSize = New System.Drawing.Size(300, 199)
Me.MinimumSize = New System.Drawing.Size(300, 199)
Me.Name = "Login"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "小鱼流水帐 V1.0—登陆"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Login_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'MsgBox(Application.StartupPath())
ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Application.StartupPath() & "\MyData.dll;Persist Security Info=False" '用户设置数据库路径
End Sub
Private Sub Login_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
'快捷键盘Alt+O登陆
If e.Alt = True And e.KeyCode = Keys.O Then
ButtonLogin.PerformClick()
End If
'快捷键盘Alt+C清楚
If e.Alt = True And e.KeyCode = Keys.C Then
ButtonRest.PerformClick()
End If
'快捷键盘Alt+N新用户
If e.Alt = True And e.KeyCode = Keys.N Then
ButtonNew.PerformClick()
End If
End Sub
Private Sub ButtonLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonLogin.Click
'检查用户名和密码是否正确
Dim S As New S_AdminInfo
S.LoginName = Trim(Me.ComboBoxName.Text)
S.LoginPwd = Trim(Me.TextBoxPwd.Text)
'将参数传递给操作类D_AdminInfo
With New D_AdminInfo
Dim Stemp As New S_AdminInfo
Stemp = .LoginCheck(S, ErrStr)
If Not Stemp Is Nothing Then
If Stemp.LoginPwd = Trim(Me.TextBoxPwd.Text) Then
AdminName = S.LoginName '将有效用户名传递给ModuleIndex中的全局变量AdminName
AdminPwd = S.LoginPwd '将有效密码传递给ModuleIndex中的全局变量AdminPwd
Dim ProcessBar As New ProcessBar
ProcessBar.Show()
Me.Hide()
Else
MsgBox("对不起,你输入的密码不正确!", MsgBoxStyle.Exclamation)
End If
Else
MsgBox("对不起,用户名输入错误!", MsgBoxStyle.Exclamation)
End If
End With
End Sub
'关闭窗体
Private Sub ButtonRest_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonRest.Click
Me.Close()
End Sub
Private Sub Login_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles MyBase.KeyPress
'用回车代替Tab
If e.KeyChar = Chr(13) Then
e.Handled = True
Me.ButtonLogin.PerformClick()
'SendKeys.Send("{TAB}")
End If
End Sub
'显示版本信息
Public FAbout As About
Private Sub LinkLabelAbout_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabelAbout.LinkClicked
FAbout = New About
FAbout.ShowDialog()
End Sub
'新用户
Private Sub ButtonNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonNew.Click
Dim FGuest As Guest
FGuest = New Guest
FGuest.ShowDialog()
End Sub
'下拉菜单
Private Sub ComboBoxName_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBoxName.MouseEnter
Dim Stemp As New DataSet
Dim i As Integer
With New D_AdminInfo
Stemp = .SelectGuest(ErrStr)
Me.ComboBoxName.Items.Clear()
For i = 0 To Stemp.Tables(0).Rows.Count - 1
Me.ComboBoxName.Items.Add(Stemp.Tables(0).Rows(i)("LoginName"))
Next
End With
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -