?? 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 tbpwd As System.Windows.Forms.TextBox
Friend WithEvents tbname As System.Windows.Forms.TextBox
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents btcancel As System.Windows.Forms.Button
Friend WithEvents btpwd As System.Windows.Forms.Button
Friend WithEvents btok As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.tbpwd = New System.Windows.Forms.TextBox
Me.tbname = New System.Windows.Forms.TextBox
Me.Label2 = New System.Windows.Forms.Label
Me.Label1 = New System.Windows.Forms.Label
Me.btcancel = New System.Windows.Forms.Button
Me.btpwd = New System.Windows.Forms.Button
Me.btok = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'tbpwd
'
Me.tbpwd.Location = New System.Drawing.Point(150, 56)
Me.tbpwd.Name = "tbpwd"
Me.tbpwd.PasswordChar = Microsoft.VisualBasic.ChrW(42)
Me.tbpwd.Size = New System.Drawing.Size(120, 21)
Me.tbpwd.TabIndex = 7
Me.tbpwd.Text = ""
'
'tbname
'
Me.tbname.Location = New System.Drawing.Point(22, 56)
Me.tbname.Name = "tbname"
Me.tbname.TabIndex = 6
Me.tbname.Text = ""
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(150, 32)
Me.Label2.Name = "Label2"
Me.Label2.TabIndex = 5
Me.Label2.Text = "密碼"
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(22, 32)
Me.Label1.Name = "Label1"
Me.Label1.TabIndex = 4
Me.Label1.Text = "姓名"
'
'btcancel
'
Me.btcancel.DialogResult = System.Windows.Forms.DialogResult.Cancel
Me.btcancel.Location = New System.Drawing.Point(104, 104)
Me.btcancel.Name = "btcancel"
Me.btcancel.TabIndex = 10
Me.btcancel.Text = "取消"
'
'btpwd
'
Me.btpwd.Location = New System.Drawing.Point(184, 104)
Me.btpwd.Name = "btpwd"
Me.btpwd.TabIndex = 9
Me.btpwd.Text = "修改密碼"
'
'btok
'
Me.btok.DialogResult = System.Windows.Forms.DialogResult.OK
Me.btok.Location = New System.Drawing.Point(24, 104)
Me.btok.Name = "btok"
Me.btok.TabIndex = 8
Me.btok.Text = "登錄"
'
'Login
'
Me.AcceptButton = Me.btok
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.CancelButton = Me.btcancel
Me.ClientSize = New System.Drawing.Size(322, 192)
Me.Controls.Add(Me.btcancel)
Me.Controls.Add(Me.btpwd)
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
Dim sflag As Boolean = True
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
Try
Sample02.SqlCon.Open()
Catch
sflag = False
MessageBox.Show("數據庫連接不正常")
Finally
If Sample02.SqlCon.State = ConnectionState.Open Then
Sample02.SqlCon.Close()
End If
End Try
If sflag Then
Dim sql As String = "SELECT * FROM [USER] WHERE USERID = '" + Me.tbname.Text.Trim() + "' AND PWD = '" + Me.tbpwd.Text.Trim() + "'"
Dim dt As DataTable
Try
dt = Sample02.GetDataTable(sql)
If dt.Rows.Count = 0 Then
MessageBox.Show("用戶名不存在或密碼不正確")
Me.tbpwd.Focus()
Else
Sample02.UserId = Me.tbname.Text.Trim()
Sample02.Purview = dt.Rows(0)("PURVIEW").ToString().Trim()
flag = True
Me.Close()
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
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 btpwd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btpwd.Click
Dim ChangePwd As New ChangePwd
ChangePwd.ShowDialog()
End Sub
End Class
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -