?? login.frm
字號:
VERSION 5.00
Begin VB.Form login
AutoRedraw = -1 'True
BackColor = &H00C0C0C0&
BorderStyle = 3 'Fixed Dialog
Caption = "登錄"
ClientHeight = 2355
ClientLeft = 6750
ClientTop = 5895
ClientWidth = 4410
Icon = "login.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
Picture = "login.frx":12532
ScaleHeight = 1391.412
ScaleMode = 0 'User
ScaleWidth = 4140.751
ShowInTaskbar = 0 'False
Begin VB.CommandButton Command2
Caption = "取消"
Height = 375
Left = 2520
TabIndex = 5
Top = 1800
Width = 1215
End
Begin VB.CommandButton Command1
Caption = "登錄"
Height = 375
Left = 840
TabIndex = 4
Top = 1800
Width = 1215
End
Begin VB.TextBox txtUserName
BackColor = &H00FFFFFF&
Height = 288
Left = 1800
TabIndex = 0
Top = 600
Width = 1845
End
Begin VB.TextBox txtPassword
BackColor = &H00FFFFFF&
Height = 288
IMEMode = 3 'DISABLE
Left = 1800
PasswordChar = "*"
TabIndex = 1
Top = 1080
Width = 1845
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 = &H00C0C0C0&
Height = 180
Index = 3
Left = 600
TabIndex = 3
Top = 1080
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 = &H00C0C0C0&
Height = 180
Index = 2
Left = 600
TabIndex = 2
Top = 720
Width = 795
End
End
Attribute VB_Name = "login"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Public LoginSucceeded As Boolean
Private Sub Command1_Click()
Static loginno As Integer
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 txtUserName.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 學號 =" & "'" & txtUserName.Text & "'")
If rs.EOF Then
MsgBox "無效密碼或用戶名請重試!", 32, "登錄"
loginno = loginno + 1
txtPassword.SetFocus
SendKeys "{Home}+{End}"
If loginno > 2 Then
MsgBox "對不起,您不能使用該系統!", 64, "登錄失敗"
Unload Me
Exit Sub
End If
Else
rs.Close
UserType = False
LoginSucceeded = True
Unload Me
Load FrmMain
End If
Exit Sub
errh:
MsgBox Err.Description
End Sub
Private Sub Command2_Click()
LoginSucceeded = False
Unload Me
End Sub
Private Sub Form_Load()
Dim s As String
MakeCenter login
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
Private Sub txtPassword_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Call Command1_Click
End If
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -