⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmsystemlogon.frm

📁 自测考试系统
💻 FRM
字号:
VERSION 5.00
Begin VB.Form systemlogon 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "系统登陆"
   ClientHeight    =   2490
   ClientLeft      =   45
   ClientTop       =   435
   ClientWidth     =   4200
   ControlBox      =   0   'False
   LinkTopic       =   "Form2"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   Picture         =   "frmsystemlogon.frx":0000
   ScaleHeight     =   2490
   ScaleWidth      =   4200
   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            =   1560
      TabIndex        =   7
      Text            =   "Combo1"
      Top             =   1320
      Width           =   1695
   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          =   315
      IMEMode         =   3  'DISABLE
      Left            =   1560
      PasswordChar    =   "*"
      TabIndex        =   6
      Text            =   "Text2"
      Top             =   840
      Width           =   1695
   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          =   315
      Left            =   1560
      TabIndex        =   5
      Text            =   "Text1"
      Top             =   360
      Width           =   1695
   End
   Begin VB.CommandButton cmdcancel 
      Caption         =   "退出"
      Height          =   375
      Left            =   2280
      TabIndex        =   4
      Top             =   1920
      Width           =   975
   End
   Begin VB.CommandButton cmdok 
      Caption         =   "确定"
      Default         =   -1  'True
      Height          =   375
      Left            =   720
      TabIndex        =   3
      Top             =   1920
      Width           =   1095
   End
   Begin VB.Label Label3 
      BackStyle       =   0  'Transparent
      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             =   1320
      Width           =   735
   End
   Begin VB.Label Label2 
      BackStyle       =   0  'Transparent
      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             =   840
      Width           =   615
   End
   Begin VB.Label Label1 
      BackStyle       =   0  'Transparent
      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           =   735
   End
End
Attribute VB_Name = "systemlogon"
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 cmdcancel_Click()
If MsgBox("您选择了退出系统登陆,退出后将不能启动管理系统!" & vbCrLf & "是否真的退出?", vbYesNo + vbQuestion, "登陆验证") = vbYes Then
Unload Me
End If
End Sub

Private Sub cmdok_Click()
'静态的常量intlogtimes用于保存用户请求验证的次数
Static intlogtimes As Integer
intlogtimes = intlogtimes + 1
If intlogtimes > maxlogtimes Then
MsgBox "你已经超过允许的登陆验证次数!" & vbCr & "应用程序结束!", vbCritical, "登陆验证"
End
End If
'检验是否输入用户名
If Trim(txtName) = "" Then
MsgBox "请输入用户名!", 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 = objstudent.Clone
Case "阅卷教师"
      Set objlog = objTeacher.Clone
Case "系统管理员"
      Set objlog = objadmin.Clone
End Select
Dim strpwdfield As String
With objlog '检验用户名和口令的合法性
If .RecordCount > 0 Then
    .MoveFirst
    Select Case cmbtype
           Case "学生"
           .Find "姓名='" & Trim(txtName) & "'"
           strpwdfield = "考号"
           studentcode = .Fields(strpwdfield)
           Case "阅卷教师"
           .Find "姓名='" & Trim(txtName) & "'"
           strpwdfield = "口令"
            Case "系统管理员"
           .Find "用户名='" & Trim(txtName) & "'"
           strpwdfield = "口令"
    End Select
    If .EOF Then
    MsgBox "用户名输入错误,请检查输入和登陆身份的正确性!", vbCritical, "登陆验证"
    txtName.SetFocus
    txtName.SelStart = 0
    txtName.SelLength = Len(txtName)
    ElseIf .Fields(strpwdfield) <> Trim(txtpwd) Then
    MsgBox "口令输入错误,请检查输入和登陆身份的正确性!", vbCritical, "登陆验证"
    txtpwd.SetFocus
    txtpwd = ""
    Else
    '保存用户信息
    currentusername = Trim(txtName)
    currentuserpassword = Trim(txtpwd)
    currentuserstatus = cmbtype
    MsgBox "欢迎使用自测考试系统!", vbInformation, "登录成功"
    Unload Me
    mdisystemmain.Show
    End If
End If
End With
Set objlog = Nothing
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;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

Private Sub Form_Unload(Cancel As Integer)
Set objadmin = Nothing
Set objstudent = Nothing
Set objTeacher = Nothing
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -