?? frmlogin.frm
字號:
VERSION 5.00
Begin VB.Form frmLogin
BorderStyle = 3 'Fixed Dialog
Caption = "請登錄"
ClientHeight = 2595
ClientLeft = 45
ClientTop = 435
ClientWidth = 4230
Icon = "frmLogin.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2595
ScaleWidth = 4230
ShowInTaskbar = 0 'False
StartUpPosition = 2 '屏幕中心
Begin VB.Frame frmLogin
Caption = "登錄"
Height = 1455
Left = 120
TabIndex = 3
Top = 960
Width = 3975
Begin VB.TextBox txtUser
Height = 345
Left = 1080
TabIndex = 7
Top = 360
Width = 1485
End
Begin VB.TextBox txtPwd
Height = 345
IMEMode = 3 'DISABLE
Left = 1080
PasswordChar = "*"
TabIndex = 6
Top = 885
Width = 1485
End
Begin VB.CommandButton cmdOK
Caption = "確定"
Default = -1 'True
Height = 390
Left = 2880
TabIndex = 5
Top = 360
Width = 900
End
Begin VB.CommandButton cmdCancel
Cancel = -1 'True
Caption = "取消"
Height = 390
Left = 2880
TabIndex = 4
Top = 840
Width = 900
End
Begin VB.Label lblLabels
AutoSize = -1 'True
Caption = "口 令:"
Height = 180
Index = 1
Left = 360
TabIndex = 9
Top = 915
Width = 720
End
Begin VB.Label lblLabels
AutoSize = -1 'True
Caption = "用戶名:"
Height = 195
Index = 0
Left = 360
TabIndex = 8
Top = 390
Width = 720
End
End
Begin VB.Frame fraUser
Caption = "選擇身份"
Height = 735
Left = 120
TabIndex = 0
Top = 120
Width = 3975
Begin VB.OptionButton optUserType
Caption = "教務管理人員"
Height = 375
Index = 0
Left = 360
TabIndex = 2
Top = 240
Width = 1455
End
Begin VB.OptionButton optUserType
Caption = "學生"
Height = 375
Index = 1
Left = 2280
TabIndex = 1
Top = 240
Width = 1095
End
End
End
Attribute VB_Name = "frmLogin"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'表示當前用戶登錄所選擇的身份,即用戶類型, 0-表示教務管理人員;1-表示學生
Dim mnUserType As Integer
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdOK_Click()
'取得用戶輸入的用戶名和密碼
Dim user As String, pwd As String
user = Trim(txtUser)
pwd = Trim(txtPwd)
'根據不同的身份,選擇不同的表用以查詢
Dim r As New ADODB.Recordset
Set r = DataEnv.rssqlSeek
Dim strSQL As String
Select Case mnUserType
Case 0: '若身份為管理員
strSQL = "select * from 系統人員表 where name='" & user & "' and pwd='" & pwd & "'"
Case 1: '若身份為學生
strSQL = "select * from 學生信息表 where name='" & user & "' and serial='" & pwd & "'"
End Select
On Error Resume Next
'查詢DataEnv.rssqlSeek的狀態,如果已經打開,則先關閉
If r.State = adStateOpen Then r.Close
r.Open strSQL '根據strSQL的內容刷新DataEnv.rssqlSeek
'用戶密碼錯誤的次數,如果錯誤次數超過3次,則退出系統
Static nTryCount As Integer
If r.EOF Then '登錄失敗
MsgBox "對不起,無此用戶或者密碼不正確!請重新輸入!!", vbCritical, "錯誤"
txtUser.SetFocus
txtUser.SelStart = 0
txtUser.SelLength = Len(txtUser)
nTryCount = nTryCount + 1
If nTryCount >= 3 Then
MsgBox "您無權操作本系統!", vbCritical, "錯誤"
Unload Me
End If
Else '登陸成功
'顯示MDI窗體, 并將用戶類型和用戶名傳到MDI窗體中的mnUserType, msUserName中
With frmMain
.mnUserType = mnUserType
.msUserName = user
End With
Load frmMain
frmMain.Show
Unload Me
End If
End Sub
Private Sub Form_Load()
optUserType(0).Value = True
End Sub
Private Sub optUserType_Click(Index As Integer)
mnUserType = Index
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -