?? frmlogin.frm
字號:
VERSION 5.00
Begin VB.Form DlgLogin
BackColor = &H00FFC0C0&
BorderStyle = 3 'Fixed Dialog
Caption = "登陸"
ClientHeight = 2745
ClientLeft = 3630
ClientTop = 2355
ClientWidth = 4575
ForeColor = &H0080FFFF&
Icon = "frmLogin.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 1621.836
ScaleMode = 0 'User
ScaleWidth = 4295.677
StartUpPosition = 2 '屏幕中心
WhatsThisHelp = -1 'True
Begin VB.Timer Timer1
Enabled = 0 'False
Left = 0
Top = 2160
End
Begin VB.CommandButton cmdCancel
BackColor = &H0080C0FF&
Caption = "退出"
BeginProperty Font
Name = "宋體"
Size = 9
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 300
Left = 2640
Style = 1 'Graphical
TabIndex = 5
Top = 2040
Width = 1095
End
Begin VB.CommandButton cmdOK
BackColor = &H0080C0FF&
Caption = "登陸"
BeginProperty Font
Name = "宋體"
Size = 9
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 300
Left = 960
Style = 1 'Graphical
TabIndex = 4
Top = 2040
Width = 1095
End
Begin VB.TextBox txtUserName
BackColor = &H00C0E0FF&
Height = 288
Left = 1560
TabIndex = 0
Top = 840
Width = 1845
End
Begin VB.TextBox txtPassword
BackColor = &H00C0E0FF&
Height = 288
IMEMode = 3 'DISABLE
Left = 1560
PasswordChar = "*"
TabIndex = 1
Top = 1320
Width = 1845
End
Begin VB.Image Image1
Height = 480
Left = 3600
Picture = "frmLogin.frx":0CCA
Top = 360
Width = 480
End
Begin VB.Label Label2
BackStyle = 0 'Transparent
Caption = "00"
BeginProperty Font
Name = "宋體"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H000000FF&
Height = 255
Left = 3720
TabIndex = 7
Top = 1080
Width = 255
End
Begin VB.Label Label1
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "歡迎登陸"
BeginProperty Font
Name = "宋體"
Size = 15
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H000000FF&
Height = 300
Left = 1560
TabIndex = 6
Top = 120
Width = 1260
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.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.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 = 795
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
End
Attribute VB_Name = "DlgLogin"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim hours As Integer
Dim Minutes As Integer
Dim Seconds As Integer
Dim Time As Date
Public LoginSucceeded As Boolean
Private Sub cmdCancel_Click()
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()
Timer1.Enabled = True
Timer1.Interval = 1000
hours = 0
Minutes = 0
Seconds = 10
Time = TimeSerial(hours, Minutes, Seconds)
Label2.Caption = Format$(Time, "ss")
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
Private Sub Timer1_Timer()
If (Format$(Time, "ss")) <> "00" Then
Time = DateAdd("s", -1, Time)
Label2.Visible = False
Label2.Caption = Format$(Time, "ss")
Label2.Visible = True
Timer1.Enabled = True
Else
Timer1.Enabled = False
Beep
Beep
Unload Me
End If
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -