📄 reles_info.frm
字号:
Exit Sub
End If
txtSQL = "select Stu_name,Stu_class from Stu_info where Stu_no = " & "'" & Trim(Text1.Text) & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
If mrc.EOF Then
MsgBox "数据库内不存在该学号对应的记录!", 0 + 48, "注意!"
Text1.SetFocus
SendKeys "{home}+{end}"
mrc.Close
Exit Sub
End If
Frame3.Visible = True
Text2(0).Text = mrc.Fields(0)
Text2(1).Text = mrc.Fields(1)
mrc.Close
txtSQL = "select Cou_info.Cou_name,Reles_info.Reles_cj,Reles_info.Reles_sum, " & _
" Reles_info.Reles_bz from Reles_info,Cou_info where " & _
" Reles_info.Cou_no= Cou_info.Cou_no and Reles_info.Stu_no= " & "'" & Trim(Text1.Text) & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
If mrc.EOF Then
MsgBox "没有该学生的重修记录!", 0 + 48, "注意!"
Text1.SetFocus
SendKeys "{home}+{end}"
mrc.Close
Exit Sub
End If
mrc.MoveFirst
With myFlexGrid1
.Rows = 1
While Not mrc.EOF
.Rows = .Rows + 1
For i = 0 To 3
If Not IsNull(mrc.Fields(i)) Then
myFlexGrid1.TextMatrix(.Rows - 1, i) = mrc.Fields(i)
End If
Next i
mrc.MoveNext
Wend
End With
Command1.Enabled = False
Command2.Enabled = True
Command5.Enabled = True '结果导出有效
End Sub
Private Sub Command2_Click() '重置按钮(单个学生)
Text2(0).Text = ""
Text2(1).Text = ""
Frame3.Visible = False
Text1.Text = ""
myFlexGrid1.Rows = 1
Command1.Enabled = True
Command2.Enabled = False
Command5.Enabled = False '结果导出无效
End Sub
Private Sub Command3_Click() '确定按钮(选课整体)
myFlexGrid2.Rows = 1
If Combo1(0).Text = "" Then
MsgBox "请选择学期!", 0 + 48, "注意!"
Combo1(0).SetFocus
Exit Sub
End If
If (Combo1(2).Text <> "" And Combo1(1).Text = "") Or (Combo1(1).Text <> "" And Combo1(2).Text = "") Then
MsgBox "课程名和教师姓名必须结合使用!", 0 + 48, "注意!"
Combo1(1).SetFocus
Exit Sub
End If
txtSQL = "select Les_info.Stu_no,Stu_info.Stu_name,Cou_info.Cou_name," & _
" Les_info.Les_tna,Les_info.Les_cj from Stu_info,Cou_info, " & _
" Les_info where Les_info.Stu_no=Stu_info.Stu_no " & _
" and Les_info.Cou_no=Cou_info.Cou_no and Les_info.Les_cj < 60 " & _
" and Les_info.Les_term = " & "'" & Trim(Combo1(0).Text) & "'"
If Combo1(1).Text <> "" Then
txtSQL = txtSQL + " and Cou_info.Cou_name = " & "'" & Trim(Combo1(1).Text) & "'"
End If
If Combo1(2).Text <> "" Then
txtSQL = txtSQL + " and Les_info.Les_tna = " & "'" & Trim(Combo1(2).Text) & "'"
End If
Set mrc = ExecuteSQL(txtSQL, MsgText)
If mrc.EOF Then
MsgBox "没有符合条件的重修名单!", 0 + 48, "注意!"
Combo1(0).SetFocus
Exit Sub
End If
With myFlexGrid2
.Rows = 1
While Not mrc.EOF
.Rows = .Rows + 1
For i = 0 To 4
If IsNull(mrc.Fields(i)) = False Then
.TextMatrix(.Rows - 1, i) = mrc.Fields(i)
End If
Next i
mrc.MoveNext
Wend
End With
Command3.Enabled = False
Command4.Enabled = True
Command6.Enabled = True
End Sub
Private Sub Command4_Click() '重置按钮(选课整体)
For i = 0 To 2
Combo1(i).Text = ""
Next i
myFlexGrid2.Rows = 1
Command3.Enabled = True
Command4.Enabled = False
Command6.Enabled = False
End Sub
Private Sub Command5_Click() '查询结果导出按钮(单个学生)
Dim colnum As Integer '用来存储字段数
Dim row As Integer '用来记录写入表内的当前行
Dim Fieldlen() As Integer
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Add
Set xlSheet = xlApp.Worksheets(1)
If mrc.RecordCount = 0 Then
MsgBox "查询结果为空,请重新查询!", 0 + 48, "注意!"
Command2.SetFocus
Exit Sub
End If
colnum = myFlexGrid1.Cols
ReDim Fieldlen(colnum)
'写入标题
xlSheet.Cells(1, 2).Value = "单个学生重修记录表"
xlSheet.Cells(3, 1).Value = "学号:" & Text1.Text
xlSheet.Cells(3, 3).Value = "姓名:" & Text2(0).Text
xlSheet.Cells(3, 4).Value = "班级:" & Text2(1).Text
'写入字段名
For i = 0 To colnum - 1
xlSheet.Cells(5, i + 1).Value = myFlexGrid1.TextMatrix(0, i)
Fieldlen(i) = LenB(myFlexGrid1.TextMatrix(0, i))
xlSheet.Columns(i + 1).ColumnWidth = Fieldlen(i)
Next i
row = 6
mrc.MoveFirst
While Not mrc.EOF
For i = 0 To colnum - 1
If IsNull(mrc.Fields(i)) = False Then
xlSheet.Cells(row, i + 1).Value = mrc.Fields(i)
If LenB(mrc.Fields(i)) > Fieldlen(i) Then
Fieldlen(i) = LenB(mrc.Fields(i))
xlSheet.Columns(i + 1).ColumnWidth = Fieldlen(i)
End If
End If
Next i
mrc.MoveNext
row = row + 1
Wend
With xlSheet
.Cells(1, 2).Font.Name = "黑体" '设标题为黑体字
.Cells(1, 2).Font.Size = 24 '标题字体大小为24
.Range(.Cells(5, 1), .Cells(row - 1, colnum)).Borders.LineStyle = xlContinuous
'设表格边框样式
End With
xlApp.Visible = True '显示表格
'xlBook.Save
Set xlApp = Nothing '控制权交还给excel
End Sub
Private Sub Command6_Click() '导出查询结果(选课整体)
Dim colnum As Integer '用来存储字段数
Dim row As Integer '用来记录写入表内的当前行
Dim Fieldlen() As Integer
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Add
Set xlSheet = xlApp.Worksheets(1)
If mrc.RecordCount = 0 Then
MsgBox "查询结果为空,请重新查询!", 0 + 48, "注意!"
Command2.SetFocus
Exit Sub
End If
colnum = myFlexGrid2.Cols
ReDim Fieldlen(colnum)
'写入标题
xlSheet.Cells(1, 2).Value = "选课整体重修名单"
xlSheet.Cells(3, 1).Value = "学期:" & Combo1(0).Text
If Combo1(1).Text <> "" Then
xlSheet.Cells(3, 2).Value = "课程名:" & Combo1(1).Text
End If
If Combo1(1).Text <> "" Then
xlSheet.Cells(3, 4).Value = "教师姓名:" & Combo1(2).Text
End If
'写入字段名
For i = 0 To colnum - 1
xlSheet.Cells(5, i + 1).Value = myFlexGrid2.TextMatrix(0, i)
Fieldlen(i) = LenB(myFlexGrid2.TextMatrix(0, i))
xlSheet.Columns(i + 1).ColumnWidth = Fieldlen(i)
Next i
row = 6
mrc.MoveFirst
While Not mrc.EOF
For i = 0 To colnum - 1
If IsNull(mrc.Fields(i)) = False Then
xlSheet.Cells(row, i + 1).Value = mrc.Fields(i)
If LenB(mrc.Fields(i)) > Fieldlen(i) Then
Fieldlen(i) = LenB(mrc.Fields(i))
xlSheet.Columns(i + 1).ColumnWidth = Fieldlen(i)
End If
End If
Next i
mrc.MoveNext
row = row + 1
Wend
With xlSheet
.Cells(1, 2).Font.Name = "黑体" '设标题为黑体字
.Cells(1, 2).Font.Size = 24 '标题字体大小为24
.Range(.Cells(5, 1), .Cells(row - 1, colnum)).Borders.LineStyle = xlContinuous
'设表格边框样式
End With
xlApp.Visible = True '显示表格
'xlBook.Save '保存
Set xlApp = Nothing '控制权交还给excel
End Sub
Private Sub Form_Load()
With myFlexGrid1 '初始化重修信息显示表(单个学生)
.Rows = 1
.TextMatrix(0, 0) = "重修课程名"
.TextMatrix(0, 1) = "最新重修成绩"
.TextMatrix(0, 2) = "重修次数"
.TextMatrix(0, 3) = "历次重修信息"
.ColWidth(0) = 1500
.ColWidth(1) = 1200
.ColWidth(3) = 2000
For i = 0 To 3
.ColAlignment(i) = 3
Next i
End With
With myFlexGrid2 '初始化重修名单显示(选课整体)
.Rows = 1
.TextMatrix(0, 0) = "学生学号"
.TextMatrix(0, 1) = "学生姓名"
.TextMatrix(0, 2) = "重修课程"
.TextMatrix(0, 3) = "授课教师"
.TextMatrix(0, 4) = "成绩"
.ColWidth(1) = 1100
.ColWidth(2) = 1500
.ColWidth(3) = 1100
For i = 0 To 4
.ColAlignment(i) = 3
Next i
End With
'初始化学期选择框(选课整体)
txtSQL = "select distinct Les_term from Les_info order by Les_term "
Set mrc = ExecuteSQL(txtSQL, MsgText)
While Not mrc.EOF
Combo1(0).AddItem mrc.Fields(0)
mrc.MoveNext
Wend
mrc.Close
'初始化课程名称选择框(选课整体)
txtSQL = "select distinct Cou_name from Cou_info "
Set mrc = ExecuteSQL(txtSQL, MsgText)
While Not mrc.EOF
Combo1(1).AddItem mrc.Fields(0)
mrc.MoveNext
Wend
mrc.Close
'初始化教师名选择框(选课整体)
txtSQL = "select distinct Les_tna from Les_info "
Set mrc = ExecuteSQL(txtSQL, MsgText)
While Not mrc.EOF
Combo1(2).AddItem mrc.Fields(0)
mrc.MoveNext
Wend
mrc.Close
'初始化按钮(单个学生)
Command1.Enabled = True
Command2.Enabled = False
'初始化按钮(选课整体)
Command3.Enabled = True
Command4.Enabled = False
End Sub
Private Sub Option1_Click(Index As Integer)
If Index = 0 Then
Option1(0).Value = True
Option1(1).Value = False
Frame2(0).Visible = True
Frame2(1).Visible = False
Else
Option1(1).Value = True
Option1(0).Value = False
Frame2(1).Visible = True
Frame2(0).Visible = False
End If
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
Call Command1_Click
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -