📄 systemlogon.frm
字号:
VERSION 5.00
Begin VB.Form Form2
BorderStyle = 3 'Fixed Dialog
Caption = "系统登陆"
ClientHeight = 2940
ClientLeft = 45
ClientTop = 435
ClientWidth = 5280
ControlBox = 0 'False
LinkTopic = "Form2"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2940
ScaleWidth = 5280
ShowInTaskbar = 0 'False
StartUpPosition = 2 '屏幕中心
Begin VB.ComboBox cmbtype
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 330
Left = 2040
TabIndex = 7
Text = "Combo1"
Top = 1560
Width = 2055
End
Begin VB.TextBox txtpwd
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
IMEMode = 3 'DISABLE
Left = 2040
PasswordChar = "*"
TabIndex = 6
Text = "Text2"
Top = 960
Width = 2055
End
Begin VB.TextBox txtname
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 2040
TabIndex = 5
Text = "Text1"
Top = 240
Width = 2055
End
Begin VB.CommandButton cmdcancel
Caption = "退出"
Height = 375
Left = 2760
TabIndex = 4
Top = 2400
Width = 1215
End
Begin VB.CommandButton cmdok
Caption = "确定"
Default = -1 'True
Height = 375
Left = 960
TabIndex = 3
Top = 2400
Width = 1215
End
Begin VB.Label Label3
Caption = "身份"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 720
TabIndex = 2
Top = 1680
Width = 975
End
Begin VB.Label Label2
Caption = "口令"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 720
TabIndex = 1
Top = 1080
Width = 975
End
Begin VB.Label Label1
Caption = "用户名"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 720
TabIndex = 0
Top = 360
Width = 975
End
End
Attribute VB_Name = "Form2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Const maxlogtimes As Integer = 3
Dim objadmin As Recordset
Dim objstudent As Recordset
Dim objteacher As Recordset
Private Sub cmdok_Click()
'静态的常量intlogtimes用于保存用户请求验证的次数
Static intlogtimes As Integer
intlogtimes = intlogtimes + 1
If intlogtimes > maxlogtimes Then
MsgBox "你已经超过允许的登陆验证次数!", vbCritical, "应用程序结束!", vbCritical, "登陆验证"
End
End If
'检验是否输入用户名
If Trim(txtname) = "" Then
msg "请输入用户名!", vbExclamation, "登陆验证"
txtname.SetFocus
Exit Sub
End If
'检验是否输入登陆口令
If Trim(txtpwd) = "" Then
MsgBox "请输入登陆口令!", vbExclamation, "登陆验证"
txtpwd = ""
txtpwd.SetFocus
Exit Sub
End If
'根据用户身份创建用于检验用户名和口令的合法性的recorset对象
Dim objlog As New Recordset
Select Case cmbtype
Case "学生"
set objlog
End Sub
Private Sub Form_Load()
'清空用户名和口令文本框
txtname = ""
txtpwd = ""
'创建设分列表
cmbtype.AddItem "学生"
cmbtype.AddItem "教师"
cmbtype.AddItem "系统管理员"
cmbtype.ListIndex = 2
'创建与数据库的连接
Dim objcn As New Connection
With objcn
.Provider = "sqloledb"
.ConnectionString = "user id=sa;pse=123;data source=(local);" & _
"initial catalog=自测系统"
.Open
End With
'访问数据库获得管理员登陆信息
Set objadmin = New Recordset
With objadmin
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.Open "select*from 管理员", objcn
Set .ActiveConnection = Nothing
End With
'访问数据库获得学生登陆信息
Set objstudent = New Recordset
With objstudent
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.Open "select 学号,考号 from 学生信息", objcn
Set .ActiveConnection = Nothing
End With
'访问数据库获得教师登陆信息
Set objteacher = New Recordset
With objteacher
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.Open "select 姓名,口令 from 阅卷教师", objcn
Set .ActiveConnection = Nothing
End With
objcn.Close
Set objcn = Nothing
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -