📄 frmscoreq.frm
字号:
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Begin VB.Form frmScoreQ
BorderStyle = 1 'Fixed Single
Caption = "学员成绩查询"
ClientHeight = 4560
ClientLeft = 45
ClientTop = 330
ClientWidth = 7905
Icon = "frmScoreQ.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MDIChild = -1 'True
MinButton = 0 'False
ScaleHeight = 4560
ScaleWidth = 7905
Begin VB.CommandButton cmdLast
Caption = ">>"
Enabled = 0 'False
Height = 350
Left = 1320
TabIndex = 21
Top = 1300
Width = 360
End
Begin VB.CommandButton cmdPrevious
Caption = "<"
Enabled = 0 'False
Height = 350
Left = 600
TabIndex = 20
Top = 1300
Width = 360
End
Begin VB.CommandButton cmdFirst
Caption = "<<"
Enabled = 0 'False
Height = 350
Left = 240
TabIndex = 19
Top = 1300
Width = 360
End
Begin VB.CommandButton cmdNext
Caption = ">"
Enabled = 0 'False
Height = 350
Left = 960
TabIndex = 18
Top = 1300
Width = 360
End
Begin MSFlexGridLib.MSFlexGrid MSFlxStuInfo
Height = 2775
Left = 105
TabIndex = 10
ToolTipText = "所有符合条件的学员成绩"
Top = 1725
Width = 7695
_ExtentX = 13573
_ExtentY = 4895
_Version = 393216
Rows = 3
Cols = 8
FixedRows = 2
FocusRect = 0
AllowUserResizing= 1
End
Begin VB.CommandButton Command1
Caption = "检索学员"
Default = -1 'True
Height = 350
Left = 6540
TabIndex = 9
ToolTipText = "检索符合条件的学员"
Top = 1300
Width = 1215
End
Begin VB.Frame Frame1
Caption = "查询条件"
Height = 1095
Left = 120
TabIndex = 0
Top = 120
Width = 7695
Begin VB.TextBox txtScoreEnd
Height = 320
Left = 2205
TabIndex = 15
Top = 665
Width = 645
End
Begin VB.TextBox txtScoreBeg
Height = 320
Left = 1056
TabIndex = 14
Top = 665
Width = 645
End
Begin VB.OptionButton OptRigor
Caption = "精确查找"
Height = 180
Left = 6405
TabIndex = 12
ToolTipText = "按AND查询"
Top = 730
Width = 1095
End
Begin VB.OptionButton OptDark
Caption = "模糊查找"
Height = 180
Left = 5145
TabIndex = 11
ToolTipText = "按OR查询"
Top = 735
Value = -1 'True
Width = 1095
End
Begin VB.TextBox txtTeacher
Height = 320
Left = 4590
TabIndex = 8
Top = 255
Width = 975
End
Begin VB.TextBox txtCourseName
Height = 320
Left = 6540
TabIndex = 7
Top = 255
Width = 975
End
Begin VB.TextBox txtStudentNo
Height = 320
Left = 2643
TabIndex = 6
Top = 255
Width = 975
End
Begin VB.TextBox txtClassNo
Height = 320
Left = 1056
TabIndex = 5
Top = 255
Width = 975
End
Begin VB.Label Label7
AutoSize = -1 'True
Caption = "成绩 从"
Height = 180
Left = 240
TabIndex = 17
Top = 735
Width = 720
End
Begin VB.Label Label6
AutoSize = -1 'True
Caption = "到"
Height = 180
Left = 1863
TabIndex = 16
Top = 735
Width = 180
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "查找模式:"
Height = 180
Left = 3990
TabIndex = 13
Top = 735
Width = 900
End
Begin VB.Label Label5
AutoSize = -1 'True
Caption = "任课老师"
Height = 180
Left = 3774
TabIndex = 4
Top = 325
Width = 720
End
Begin VB.Label Label4
AutoSize = -1 'True
Caption = "课程名称"
Height = 180
Left = 5721
TabIndex = 3
Top = 325
Width = 720
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "学号"
Height = 180
Left = 2187
TabIndex = 2
Top = 325
Width = 360
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "班级编号"
Height = 180
Left = 240
TabIndex = 1
Top = 325
Width = 720
End
End
End
Attribute VB_Name = "frmScoreQ"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'****************************************************'
'将学员基本信息表、学员成绩表进行连接。可供查询的条件'
'有班级编号、学号、课程名称、任课教师等。查询方式为组'
'合查询。 '
'****************************************************'
'班级编号 姓名 课程名称 任课老师 考试日期 成绩 备注
'MSFlexStuInfo
Option Explicit
Private Sub Command1_Click()
Dim intIndex As Integer
Dim StrAnd As String
Dim strOr As String
StrAnd = ""
strOr = ""
On Error GoTo ErrLab
Do While MsflxStuInfo.Rows > 3 '以下8行为清空列表
MsflxStuInfo.RemoveItem MsflxStuInfo.Rows - 1
Loop
MsflxStuInfo.Row = 2
For intIndex = 0 To 7
MsflxStuInfo.Col = intIndex
MsflxStuInfo.Text = Empty
Next intIndex
Set Rst = Nothing
If Fun_Rst("select * from studentinfo as A join ScoreInfo as B on A.StudentNo=b.StudentNo") Then
If Rst.BOF = True And Rst.EOF = True Then
MsgBox "没有任何记录....", vbInformation + vbOKOnly, "检索记录"
End If
Else
MsgBox "信息检索失败....", vbCritical + vbOKOnly, "信息检索"
End If
If txtClassNo <> "" Then
StrAnd = StrAnd & "classNo='" & txtClassNo & "'"
strOr = strOr & "classNo='" & txtClassNo & "'"
End If
If txtStudentNo <> "" Then
If StrAnd <> "" And strOr <> "" Then
StrAnd = StrAnd & "And "
strOr = strOr & "OR "
End If
StrAnd = StrAnd & "studentNo='" & txtStudentNo & "'"
strOr = strOr & "studentNo='" & txtStudentNo & "'"
End If
If txtTeacher <> "" Then
If StrAnd <> "" And strOr <> "" Then
StrAnd = StrAnd & "And "
strOr = strOr & "OR "
End If
StrAnd = StrAnd & "teacher like '%" & txtTeacher & "%'"
strOr = strOr & "teacher like '%" & txtTeacher & "%'"
End If
If txtCourseName <> "" Then
If StrAnd <> "" And strOr <> "" Then
StrAnd = StrAnd & "And "
strOr = strOr & "OR "
End If
StrAnd = StrAnd & "coursename like '%" & txtCourseName & "%'"
strOr = strOr & "coursename like '%" & txtCourseName & "%'"
End If
If txtScoreBeg <> "" And txtScoreEnd <> "" Then
If StrAnd <> "" And strOr <> "" Then
StrAnd = StrAnd & "And "
strOr = strOr & "OR "
End If
StrAnd = StrAnd & "score>=" & txtScoreBeg & " and " & "score<=" & txtScoreEnd
strOr = strOr & "(score>=" & txtScoreBeg & " and " & "score<=" & txtScoreEnd & ")"
End If
If OptRigor.Value = True Then
Rst.Filter = (StrAnd)
Else
Rst.Filter = (strOr)
End If
Call Search
'MsgBox "信息检索成功....", vbInformation + vbOKOnly, "信息检索"
Exit Sub
ErrLab:
If Err.Number = 94 Then
Resume Next
Else
MsgBox "未知错误:" & Err.Description & vbCrLf & "错误代号:" & Err.Number, vbCritical + vbOKOnly, "未知错误"
End If
End Sub
Sub Search()
If Rst.EOF = True And Rst.BOF = True Then
MsgBox "没有任何记录..", vbInformation + vbOKOnly, "记录不存在"
Else
Do While Rst.EOF = False
MsflxStuInfo.Row = MsflxStuInfo.Rows - 1
MsflxStuInfo.Col = 0
MsflxStuInfo.Text = MsflxStuInfo.Rows - 2 '序号
MsflxStuInfo.Col = 1
MsflxStuInfo.Text = Rst.Fields("ClassNo")
MsflxStuInfo.Col = 2
MsflxStuInfo.Text = Rst.Fields("name")
MsflxStuInfo.Col = 3
MsflxStuInfo.Text = Rst.Fields("coursename")
MsflxStuInfo.Col = 4
MsflxStuInfo.Text = Rst.Fields("teacher")
MsflxStuInfo.Col = 5
MsflxStuInfo.Text = Rst.Fields("examdate")
MsflxStuInfo.Col = 6
MsflxStuInfo.Text = Rst.Fields("score")
MsflxStuInfo.Col = 7
If Rst.Fields("remark") <> Null Then
MsflxStuInfo.Text = Rst.Fields("remark")
Else
MsflxStuInfo.Text = Empty
End If
Rst.MoveNext
If Rst.EOF = False Then
MsflxStuInfo.AddItem Empty
End If
Loop
cmdLast.Enabled = True
cmdFirst.Enabled = True
cmdPrevious.Enabled = True
cmdNext.Enabled = True
MsflxStuInfo.Row = 2
Call MSFlxStuInfo_Click
MsgBox "信息检索成功....", vbInformation + vbOKOnly, "信息检索"
End If
End Sub
Private Sub Form_Load()
Dim intIndex As Integer
MsflxStuInfo.MergeCells = flexMergeFree
MsflxStuInfo.Rows = 3
MsflxStuInfo.FixedRows = 2
MsflxStuInfo.Row = 0
MsflxStuInfo.ColWidth(0) = 600
For intIndex = 1 To MsflxStuInfo.Cols - 1
MsflxStuInfo.Col = intIndex
MsflxStuInfo.Text = "学员成绩信息列表"
MsflxStuInfo.ColWidth(intIndex) = 1200
Next intIndex
MsflxStuInfo.MergeRow(0) = True
MsflxStuInfo.Row = 1
MsflxStuInfo.Col = 0
MsflxStuInfo.Text = "序号"
MsflxStuInfo.Col = 1
MsflxStuInfo.Text = "班级编号"
MsflxStuInfo.Col = 2
MsflxStuInfo.Text = "姓名"
MsflxStuInfo.Col = 3
MsflxStuInfo.Text = "课程名称"
MsflxStuInfo.Col = 4
MsflxStuInfo.Text = "任课老师"
MsflxStuInfo.Col = 5
MsflxStuInfo.Text = "考试日期"
MsflxStuInfo.Col = 6
MsflxStuInfo.Text = "成绩"
MsflxStuInfo.Col = 7
MsflxStuInfo.Text = "备注"
End Sub
Private Sub MSFlxStuInfo_Click()
Dim intCol As Integer
Dim intRow As Integer
Dim TmpRow As Integer
TmpRow = MsflxStuInfo.Row
For intRow = 2 To MsflxStuInfo.Rows - 1
MsflxStuInfo.Row = intRow
If TmpRow = intRow Then
For intCol = 1 To MsflxStuInfo.Cols - 1
MsflxStuInfo.Col = intCol
MsflxStuInfo.CellForeColor = vbYellow
MsflxStuInfo.CellBackColor = &H8000000D
Next intCol
Else
For intCol = 1 To MsflxStuInfo.Cols - 1
MsflxStuInfo.Col = intCol
MsflxStuInfo.CellBackColor = vbWhite
MsflxStuInfo.CellForeColor = vbBlack
Next intCol
End If
Next intRow
MsflxStuInfo.Row = TmpRow
End Sub
Private Sub cmdLast_Click()
MsflxStuInfo.Row = MsflxStuInfo.Rows - 1
Call MSFlxStuInfo_Click
End Sub
Private Sub cmdNext_Click()
If MsflxStuInfo.Row < MsflxStuInfo.Rows - 1 Then
MsflxStuInfo.Row = MsflxStuInfo.Row + 1
Call MSFlxStuInfo_Click
End If
End Sub
Private Sub cmdPrevious_Click()
If MsflxStuInfo.Row > 2 Then
MsflxStuInfo.Row = MsflxStuInfo.Row - 1
Call MSFlxStuInfo_Click
End If
End Sub
Private Sub cmdFirst_Click()
MsflxStuInfo.Row = 2
Call MSFlxStuInfo_Click
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -