?? frmlogin.frm
字號:
VERSION 5.00
Begin VB.Form DlgLogin
BackColor = &H00C0FFFF&
BorderStyle = 3 'Fixed Dialog
Caption = "登陸"
ClientHeight = 2580
ClientLeft = 3630
ClientTop = 2355
ClientWidth = 4575
Icon = "frmLogin.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 1524.349
ScaleMode = 0 'User
ScaleWidth = 4295.677
ShowInTaskbar = 0 'False
Begin VB.CommandButton cmdCancel
Height = 300
Left = 3120
Picture = "frmLogin.frx":058A
Style = 1 'Graphical
TabIndex = 5
Top = 2040
Width = 1095
End
Begin VB.CommandButton cmdOK
Height = 300
Left = 1560
Picture = "frmLogin.frx":0AE5
Style = 1 'Graphical
TabIndex = 4
Top = 2040
Width = 1095
End
Begin VB.TextBox txtUserName
BackColor = &H00FFFFC0&
Height = 288
Left = 1560
TabIndex = 0
Top = 840
Width = 1845
End
Begin VB.TextBox txtPassword
BackColor = &H00FFFFC0&
Height = 288
IMEMode = 3 'DISABLE
Left = 1560
PasswordChar = "*"
TabIndex = 1
Top = 1320
Width = 1845
End
Begin VB.Line Line5
X1 = 4056.246
X2 = 4056.246
Y1 = 354.5
Y2 = 1063.499
End
Begin VB.Line Line4
X1 = 3605.552
X2 = 4056.246
Y1 = 354.5
Y2 = 354.5
End
Begin VB.Image Image3
Height = 480
Left = 3600
Picture = "frmLogin.frx":10BC
Top = 1200
Width = 480
End
Begin VB.Image Image2
Height = 480
Left = 3600
Picture = "frmLogin.frx":14FE
Top = 720
Width = 480
End
Begin VB.Line Line3
X1 = 112.673
X2 = 4056.246
Y1 = 1063.499
Y2 = 1063.499
End
Begin VB.Line Line2
X1 = 112.673
X2 = 112.673
Y1 = 354.5
Y2 = 1063.499
End
Begin VB.Line Line1
BorderColor = &H00000000&
X1 = 112.673
X2 = 3718.225
Y1 = 354.5
Y2 = 354.5
End
Begin VB.Image Image4
Height = 480
Left = 120
Picture = "frmLogin.frx":1940
Top = 1920
Width = 480
End
Begin VB.Image Image1
Height = 480
Index = 1
Left = 3840
Picture = "frmLogin.frx":1D82
Top = 0
Width = 480
End
Begin VB.Label lblLabels
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "密碼:"
BeginProperty Font
Name = "宋體"
Size = 9
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 180
Index = 3
Left = 360
TabIndex = 3
Top = 1320
Width = 600
End
Begin VB.Label lblLabels
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "用戶名:"
BeginProperty Font
Name = "宋體"
Size = 9
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 180
Index = 2
Left = 360
TabIndex = 2
Top = 960
Width = 795
End
Begin VB.Image Image1
Height = 480
Index = 0
Left = 240
Picture = "frmLogin.frx":21C4
Top = 0
Width = 480
End
End
Attribute VB_Name = "DlgLogin"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Public LoginSucceeded As Boolean
Private Sub cmdCancel_Click()
'set the global var to false
'to denote a failed login
LoginSucceeded = False
Unload Me
End Sub
Private Sub cmdOK_Click()
On Error GoTo errh:
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
Set rs = cn.Execute("SELECT UserName , Password FROM 超級用戶 ")
If rs.EOF Then
rs.Close
Set rs = Nothing
Unload Me
Load FrmMain
Exit Sub
End If
rs.MoveFirst
Dim i As Integer
'校驗是否為超級用戶
Do
If rs.Fields("UserName") = txtUserName.Text Then
If rs.Fields("Password") = txtPassword.Text Then
UserType = True
LoginSucceeded = True
rs.Close
If txtPassword.Text = "Admin" Then IsAdmin = True
Unload Me
Load FrmMain
Exit Sub
Exit Do
End If
End If
rs.MoveNext
Loop Until rs.EOF
'校驗是否為普通用戶
Set rs = cn.Execute("SELECT 學號 FROM 學生 WHERE 學號 =" & "'" & txtPassword.Text & "'")
If rs.EOF Then
MsgBox "無效密碼或用戶名請重試!", , "Login"
txtPassword.SetFocus
SendKeys "{Home}+{End}"
Else
rs.Close
UserType = False
LoginSucceeded = True
Unload Me
Load FrmMain
End If
Exit Sub
errh:
MsgBox Err.Description
End Sub
Private Sub Form_Load()
Dim s As String
MakeCenter DlgLogin
s = MakeConnection() '創建全局ADO連接
If s <> "OK" Then
MsgBox s, , "錯誤!"
Unload Me
LoginSucceeded = False
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
If Not LoginSucceeded Then '如果登陸失敗
cn.Close '釋放連接
Set cn = Nothing
End If
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -