?? 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 + -