📄 c考生分配.frm
字号:
VERSION 5.00
Begin VB.Form C考生分配
Caption = "考生分配"
ClientHeight = 6915
ClientLeft = 60
ClientTop = 450
ClientWidth = 7905
LinkTopic = "Form1"
ScaleHeight = 6915
ScaleWidth = 7905
StartUpPosition = 3 '窗口缺省
Begin VB.Frame Frame5
Caption = "选择考场"
Height = 735
Left = 120
TabIndex = 1
Top = 120
Width = 7575
Begin VB.TextBox txtNum
Appearance = 0 'Flat
BackColor = &H80000000&
ForeColor = &H00FF0000&
Height = 375
Left = 6360
TabIndex = 7
Text = "Text2"
Top = 240
Width = 975
End
Begin VB.TextBox txttime
Appearance = 0 'Flat
BackColor = &H80000000&
ForeColor = &H00FF0000&
Height = 375
Left = 3960
TabIndex = 5
Text = "Text2"
Top = 240
Width = 1455
End
Begin VB.ComboBox CboKao
BeginProperty Font
Name = "MS Sans Serif"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 360
Left = 1080
Style = 2 'Dropdown List
TabIndex = 3
Top = 240
Width = 1695
End
Begin VB.Label Label2
Caption = "考试人数:"
Height = 255
Index = 1
Left = 5520
TabIndex = 6
Top = 360
Width = 975
End
Begin VB.Label Label2
Caption = "开考时间:"
Height = 255
Index = 2
Left = 3120
TabIndex = 4
Top = 360
Width = 975
End
Begin VB.Label Label2
Caption = "选择考试:"
Height = 255
Index = 0
Left = 120
TabIndex = 2
Top = 360
Width = 1095
End
End
Begin VB.Frame Frame1
Caption = "分配考生"
Height = 5895
Left = 120
TabIndex = 0
Top = 960
Width = 7575
Begin VB.CommandButton CmdExit
Caption = "退出"
Height = 375
Left = 2880
TabIndex = 26
Top = 4300
Width = 1575
End
Begin VB.CommandButton CmdEnd
Caption = "分配完毕"
Height = 375
Left = 2880
TabIndex = 25
Top = 3910
Width = 1575
End
Begin VB.Frame Frame3
Caption = "未分配考生查询结果"
Height = 4695
Left = 480
TabIndex = 17
Top = 1080
Width = 2055
Begin VB.ListBox List1
Height = 3660
Left = 120
TabIndex = 18
Top = 240
Width = 1815
End
Begin VB.Label Label5
BorderStyle = 1 'Fixed Single
Caption = "0个"
ForeColor = &H000000FF&
Height = 375
Left = 1200
TabIndex = 22
Top = 4080
Width = 735
End
Begin VB.Label Label4
Caption = "未分配人数:"
Height = 255
Index = 1
Left = 120
TabIndex = 21
Top = 4200
Width = 1095
End
End
Begin VB.CommandButton CmdFen
Caption = "分配"
Height = 375
Index = 0
Left = 2860
TabIndex = 13
Top = 2760
Width = 1575
End
Begin VB.CommandButton CmdFen
Caption = "取消分配"
Height = 375
Index = 1
Left = 2860
TabIndex = 12
Top = 3140
Width = 1575
End
Begin VB.CommandButton CmdFen
Caption = "全部分配"
Height = 375
Index = 2
Left = 2860
TabIndex = 11
Top = 2370
Width = 1575
End
Begin VB.CommandButton CmdFen
Caption = "全部取消分配"
Height = 375
Index = 3
Left = 2860
TabIndex = 10
Top = 3525
Width = 1575
End
Begin VB.Frame Frame4
Caption = "已分配考生"
Height = 4695
Left = 4800
TabIndex = 9
Top = 1080
Width = 2055
Begin VB.ListBox List2
Height = 3660
Left = 120
TabIndex = 24
Top = 240
Width = 1815
End
Begin VB.Label Label6
BorderStyle = 1 'Fixed Single
Caption = "0个"
ForeColor = &H000000FF&
Height = 375
Left = 1200
TabIndex = 23
Top = 4080
Width = 735
End
Begin VB.Label Label4
Caption = "已分配人数:"
Height = 255
Index = 0
Left = 120
TabIndex = 20
Top = 4200
Width = 1095
End
End
Begin VB.Frame Frame2
Caption = "查询未分配考生"
Height = 735
Left = 360
TabIndex = 8
Top = 240
Width = 6615
Begin VB.TextBox txtStuNum
Appearance = 0 'Flat
Height = 375
Left = 1200
MaxLength = 6
TabIndex = 15
Text = "输入考生考号"
Top = 240
Width = 1815
End
Begin VB.CommandButton CmdQuery
Caption = "查询"
Height = 375
Left = 5040
TabIndex = 14
Top = 240
Width = 855
End
Begin VB.Label Label3
Caption = "(支持模式匹配)"
Height = 255
Left = 3120
TabIndex = 19
Top = 280
Width = 1695
End
Begin VB.Label Label1
Caption = "考生考号:"
Height = 255
Left = 240
TabIndex = 16
Top = 360
Width = 975
End
End
End
End
Attribute VB_Name = "C考生分配"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim rs As ADODB.Recordset
Dim rst As ADODB.Recordset
Dim SQL As String
Dim msg As String
Dim Index As Integer
Private Sub Form_Load()
'初始化考试代码ComboBox
SQL = "select * from 考试信息表 a where 考试标志='新建考试' order by 开考时间"
Set rst = SelectSQL(SQL, msg)
If rst.RecordCount = 0 Then
MsgBox "没有考试信,请先建立考试信!"
Exit Sub
Else
Do While Not rst.BOF And Not rst.EOF
'添加到ComboBox列表
Me.CboKao.AddItem (rst.Fields("考试代码"))
rst.MoveNext '指向下一条记录
Loop
rst.MoveFirst
CboKao.listindex = 0 '默认ComboBox
txttime.Text = rst.Fields("开考时间") '显示该场考试的开考时间
txtNum.Text = rst.Fields("考试人数") & "个" '显示该场考试的考试人数
End If
'清空List
List1.Clear
List2.Clear
End Sub
Private Sub CmdQuery_Click()
'查询未分配的考生
Dim txtValue As String '保存查询的值
txtValue = txtStuNum.Text
'查询未进行分配的考生
SQL = "select 考生号,姓名 from 考生信息表 where 考生号 like '" & txtValue & "%'"
SQL = SQL & " and 考生号 not in ( select 考生号 from 成绩信息表 )"
Set rs = SelectSQL(SQL, msg)
List1.Clear '清空未分配考生里面数据
If rs.RecordCount <> 0 Then
Do Until rs.EOF
'添加到List列表
List1.AddItem rs.Fields("考生号") & rs.Fields("姓名")
rs.MoveNext
Loop
List1.listindex = 0 '默认第一条记录
Label5.Caption = rs.RecordCount & " 个" '计算未分配的人数
Call CmdEnable '控制移动考生按钮的Enable
Else
MsgBox "没有你要查询的结果!"
End If
End Sub
Private Sub CmdFen_Click(Index As Integer)
'分配考生操作
Select Case Index
Case 0: '如果单就“分配”按钮
List2.AddItem List1.list(List1.listindex)
List1.RemoveItem List1.listindex
Case 1: '如果单就“取消分配”按钮
List1.AddItem List2.list(List2.listindex)
List2.RemoveItem List2.listindex
Case 2: '如果单就“全部分配”按钮
For Index = 0 To List1.ListCount - 1
List2.AddItem List1.list(Index)
Next Index
List1.Clear
Case 3: '如果单就“全部取消分配”按钮
For Index = 0 To List2.ListCount - 1
List1.AddItem List2.list(Index)
Next Index
List2.Clear
End Select
Label5.Caption = List1.ListCount & " 个" '计算未分配人数
Label6.Caption = List2.ListCount & " 个" '计算已分配人数
Call CmdEnable '控制移动考生按钮的Enable
End Sub
Private Sub CmdEnable()
'控制移动考生按钮的Enable
For Index = 0 To 3
CmdFen(Index).Enabled = False
Next Index
'当未分配考生里面还有数据时,向左移动的按钮可用
If List1.ListCount > 0 Then
CmdFen(0).Enabled = True
CmdFen(2).Enabled = True
End If
'当已分配考生里面还有数据时,向右移动的按钮可用
If List2.ListCount > 0 Then
CmdFen(1).Enabled = True
CmdFen(3).Enabled = True
End If
End Sub
Private Sub CmdEnd_Click()
'分配完毕操作,每分配完一场考试,必须单就此按钮
If List2.ListCount > 0 And List2.ListCount <= Val(txtNum.Text) Then
'把选择的考生分别全部都写入成绩信息表中
For Index = 0 To List2.ListCount - 1
SQL = " insert into 成绩信息表(考生号,姓名,试卷状态,考试代码,评卷教师ID)"
SQL = SQL & "values ('" & Left(List2.list(Index), 6)
SQL = SQL & "','" & Right(List2.list(Index), Len(List2.list(Index)) - 6)
SQL = SQL & "','未阅','" & CboKao.Text & "','000001')"
Call ExecuteSQL(SQL, msg)
Next Index
MsgBox "分配完毕!", vbOKOnly, "提示"
List2.Clear '清空已分配考生里面的数据
List1.Clear '清空未分配考生里面的数据
Else
MsgBox "分配结果有问题,请认真核对!"
End If
End Sub
Private Sub CboKao_Click()
'选择不同考试
rst.MoveFirst
'定位于当前选择的考试
rst.Find ("考试代码='" & Trim(Me.CboKao.Text) & "'")
txttime.Text = rst.Fields("开考时间") '显示该场考试的开考时间
txtNum.Text = rst.Fields("考试人数") & "个" '显示该场考试的考试人数
End Sub
Private Sub CmdExit_Click()
'退出操作
工作人员管理.Enabled = True
Unload Me
End Sub
Private Sub Form_Unload(Cancel As Integer)
'退出操作
工作人员管理.Enabled = True
Unload Me
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -