?? login.vb
字號:
Public Class frmLogin
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 Label3 As System.Windows.Forms.Label
Friend WithEvents btnLogin As System.Windows.Forms.Button
Friend WithEvents txtUserName As System.Windows.Forms.TextBox
Friend WithEvents txtPassword As System.Windows.Forms.TextBox
Friend WithEvents btnClose As System.Windows.Forms.Button
Friend WithEvents btnOK 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.Label3 = New System.Windows.Forms.Label
Me.btnLogin = New System.Windows.Forms.Button
Me.txtUserName = New System.Windows.Forms.TextBox
Me.txtPassword = New System.Windows.Forms.TextBox
Me.btnClose = New System.Windows.Forms.Button
Me.btnOK = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'Label1
'
Me.Label1.Font = New System.Drawing.Font("宋體", 21.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.Label1.ForeColor = System.Drawing.Color.FromArgb(CType(0, Byte), CType(0, Byte), CType(192, Byte))
Me.Label1.Location = New System.Drawing.Point(40, 16)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(208, 32)
Me.Label1.TabIndex = 0
Me.Label1.Text = "圖書借閱系統"
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(40, 80)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(48, 23)
Me.Label2.TabIndex = 0
Me.Label2.Text = "用戶名"
'
'Label3
'
Me.Label3.Location = New System.Drawing.Point(40, 112)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(48, 23)
Me.Label3.TabIndex = 0
Me.Label3.Text = "密碼"
'
'btnLogin
'
Me.btnLogin.Location = New System.Drawing.Point(40, 152)
Me.btnLogin.Name = "btnLogin"
Me.btnLogin.Size = New System.Drawing.Size(48, 23)
Me.btnLogin.TabIndex = 1
Me.btnLogin.Text = "登錄"
'
'txtUserName
'
Me.txtUserName.Location = New System.Drawing.Point(96, 80)
Me.txtUserName.MaxLength = 20
Me.txtUserName.Name = "txtUserName"
Me.txtUserName.Size = New System.Drawing.Size(104, 21)
Me.txtUserName.TabIndex = 2
Me.txtUserName.Text = "LI4"
'
'txtPassword
'
Me.txtPassword.Location = New System.Drawing.Point(96, 112)
Me.txtPassword.MaxLength = 20
Me.txtPassword.Name = "txtPassword"
Me.txtPassword.PasswordChar = Microsoft.VisualBasic.ChrW(42)
Me.txtPassword.Size = New System.Drawing.Size(104, 21)
Me.txtPassword.TabIndex = 2
Me.txtPassword.Text = "000000"
'
'btnClose
'
Me.btnClose.DialogResult = System.Windows.Forms.DialogResult.Cancel
Me.btnClose.Location = New System.Drawing.Point(168, 152)
Me.btnClose.Name = "btnClose"
Me.btnClose.Size = New System.Drawing.Size(48, 23)
Me.btnClose.TabIndex = 1
Me.btnClose.Text = "關閉"
'
'btnOK
'
Me.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK
Me.btnOK.Location = New System.Drawing.Point(168, 152)
Me.btnOK.Name = "btnOK"
Me.btnOK.Size = New System.Drawing.Size(40, 23)
Me.btnOK.TabIndex = 1
'
'frmLogin
'
Me.AcceptButton = Me.btnLogin
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.CancelButton = Me.btnClose
Me.ClientSize = New System.Drawing.Size(282, 197)
Me.Controls.Add(Me.txtUserName)
Me.Controls.Add(Me.btnLogin)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.txtPassword)
Me.Controls.Add(Me.btnClose)
Me.Controls.Add(Me.btnOK)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
Me.MaximizeBox = False
Me.Name = "frmLogin"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.ResumeLayout(False)
End Sub
#End Region
Dim DataReader As System.Data.OleDb.OleDbDataReader
Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
Me.Close()
End Sub
Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
Dim str As String
Dim filename As String = Application.ExecutablePath()
filename = filename.Substring(0, filename.LastIndexOf("\") + 1)
filename = filename & "library.mdb"
Try
If OleConn.AccessConnection(filename, "", "") Then '連接數據庫成功
str = "select logpwd from 管理員 where logname='" & txtUserName.Text & "'" '構造查詢字串
If OleConn.SelectQuery(str, DataReader) Then '執行查詢成功
If DataReader.HasRows Then '如果找到 指示是否包含一行或多行
While DataReader.Read '使datareader 前進到下一記錄
If DataReader.Item(0) = txtPassword.Text Then '如果密碼正確
UserName = txtUserName.Text
Password = txtPassword.Text
btnOK.PerformClick()
'回到主界面
Else '密碼不正確
MsgBox("密碼不正確,請檢查密碼")
End If
End While
Else '沒有找到記錄
MsgBox("找不到此用戶,請檢查用戶名")
End If
Else '執行查詢失敗
MsgBox("查詢數據庫失敗")
End If
Else '連接數據庫失敗
MsgBox("連接數據庫失敗")
End If
Catch ex As Exception
OleConn.DisplayError(ex)
Finally
DataReader.Close()
End Try
End Sub
Private Sub frmLogin_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 + -