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

📄 frmstudentlogin.frm

📁 本论文以“计算机考试系统”的开发为背景
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmStudentLogin 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "学生登陆"
   ClientHeight    =   2820
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   4440
   BeginProperty Font 
      Name            =   "宋体"
      Size            =   10.5
      Charset         =   134
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   2820
   ScaleWidth      =   4440
   ShowInTaskbar   =   0   'False
   StartUpPosition =   2  '屏幕中心
   Begin VB.CommandButton Command2 
      Caption         =   "放弃"
      Height          =   435
      Left            =   2400
      TabIndex        =   5
      Top             =   2190
      Width           =   1065
   End
   Begin VB.CommandButton Command1 
      Caption         =   "登陆"
      Height          =   435
      Left            =   1110
      TabIndex        =   4
      Top             =   2190
      Width           =   1065
   End
   Begin VB.TextBox Text2 
      Height          =   315
      Left            =   660
      TabIndex        =   3
      Top             =   1710
      Width           =   3255
   End
   Begin VB.TextBox Text1 
      Height          =   315
      Left            =   660
      TabIndex        =   1
      Top             =   930
      Width           =   3255
   End
   Begin VB.Image Image1 
      Height          =   480
      Left            =   180
      Picture         =   "frmStudentLogin.frx":0000
      Top             =   120
      Width           =   480
   End
   Begin VB.Label Label2 
      Caption         =   "考生姓名:"
      Height          =   210
      Left            =   630
      TabIndex        =   2
      Top             =   1410
      Width           =   945
   End
   Begin VB.Label Label1 
      Caption         =   "准考证号:"
      Height          =   210
      Left            =   630
      TabIndex        =   0
      Top             =   630
      Width           =   945
   End
End
Attribute VB_Name = "frmStudentLogin"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Sub Command1_Click()
Dim rst As Recordset
Dim rstAnswer As Recordset
Dim i       As Integer
    If Trim(Text1) = "" Then
        MsgBox "请输入准考证号!", vbInformation
        Text1.SetFocus
        GoTo Proc_Exit
    End If
    
    If Trim(Text2) = "" Then
        MsgBox "请输入考生姓名!", vbInformation
        Text2.SetFocus
        GoTo Proc_Exit
    End If
    
    Set rst = New Recordset
    rst.ActiveConnection = pCN
    rst.Source = "select * from 考生 where 准考证号='" & Text1 & "'"
    rst.CursorLocation = adUseClient
    rst.LockType = adLockBatchOptimistic
    rst.CursorType = adOpenStatic
    rst.Open
    
    
    ''如果该考生已经登陆
    If rst.RecordCount > 0 Then
        'If MsgBox("该考生已经考过了,你要重新开始做吗?", vbQuestion + vbYesNo) = vbNo Then GoTo Proc_Exit
        If rst![考生状态] = "已交卷" Then
            MsgBox "该考生已经交卷了,将不能再次进入考试!", vbInformation
            Unload Me
            GoTo Proc_Exit
        End If
        ''然后这里产生随机的试卷
        pintSetNumber = rst![考试套号]
    Else
        
        ''随机产生考试的套号
        'pintSetNumber = 1
        Call GetSetNumber
        
        
        ''往考生表中写入该考生的信息
        rst.AddNew
        rst![准考证号] = Text1
        rst![考生姓名] = Text2
        rst![考试套号] = pintSetNumber
        rst.UpdateBatch
        
        rst.Close
        rst.Source = "select * from 题库主表 where 题目套号=" & pintSetNumber
        rst.Open
            
        ''往学生答案表里加入抽到的试题
        Set rstAnswer = New Recordset
    
        rstAnswer.ActiveConnection = pCN
        rstAnswer.Source = "select * from 考生答案"
        rstAnswer.CursorLocation = adUseClient
        rstAnswer.LockType = adLockBatchOptimistic
        rstAnswer.CursorType = adOpenStatic
        rstAnswer.Open
        
        For i = 1 To rst.RecordCount
            rstAnswer.AddNew
            rstAnswer![准考证号] = Text1
            rstAnswer![题目编号] = rst![题目编号]
            
            rst.MoveNext
        Next i
     
        
        rstAnswer.UpdateBatch
    
    End If
    pudtStudent.考生姓名 = Text2
    pudtStudent.准考证号 = Text1
    
    Unload Me
    frmAnswer.Show 1
Proc_Exit:
    Set rst = Nothing
    Set rstAnswer = Nothing
End Sub

'设置随机的考试套号
Private Sub GetSetNumber()
Dim rst As Recordset
Dim intSetNumber As Integer
Dim rstMain As Recordset
    Set rst = New Recordset
    rst.ActiveConnection = pCN
    rst.CursorType = adOpenStatic
    rst.CursorLocation = adUseClient
    rst.LockType = adLockBatchOptimistic
    rst.Source = "select * from 系统设置"
    rst.Open
    
    intSetNumber = rst![考试套号]
    rst.Close
    rst.Source = "select Max(ID) from 套号"
    rst.Open
        
    Set rstMain = New Recordset
    rstMain.ActiveConnection = pCN
    rstMain.CursorType = adOpenStatic
    rstMain.CursorLocation = adUseClient
    rstMain.LockType = adLockBatchOptimistic
    rstMain.Source = "select * from 题库主表"
    rstMain.Open
        
    If intSetNumber = 0 Then ''这表示随机抽取
        Randomize Timer
        Do
            intSetNumber = Int((rst.Fields(0) * Rnd) + 1)
            rstMain.Filter = "题目套号=" & intSetNumber
            If rst.RecordCount > 0 Then
                Exit Do
            End If
        Loop
    End If
    pintSetNumber = intSetNumber
    
    Set rst = Nothing
    Set rstMain = Nothing
End Sub

Private Sub Command2_Click()
    Unload Me
End Sub

⌨️ 快捷键说明

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