📄 frmtselectinfo.frm
字号:
Height = 450
Left = 360
Picture = "frmtselectinfo.frx":3863
Top = 0
Width = 285
End
Begin VB.Image imgTitleLeft
Height = 450
Left = 0
Picture = "frmtselectinfo.frx":3FAD
Top = 0
Width = 285
End
Begin VB.Image imgWindowRight
Height = 450
Left = 720
Picture = "frmtselectinfo.frx":46F7
Stretch = -1 'True
Top = 480
Width = 285
End
Begin VB.Image imgWindowLeft
Height = 450
Left = 1080
Picture = "frmtselectinfo.frx":4E41
Stretch = -1 'True
Top = 480
Width = 285
End
End
Attribute VB_Name = "frmtselectinfo"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'定义数据库变量
Dim sqlstr As String
Dim MsgTxt As String
Dim rs As New ADODB.Recordset
Dim i As Integer
Private Sub Form_Load()
MakeWindow Me
Label3.Visible = False
Combo2.Visible = False
End Sub
Private Sub imgTitleclose_Click()
intNumField = -2
Unload Me
End Sub
Private Sub imgTitleLeft_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
DoDrag Me
End Sub
Private Sub imgTitleMain_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
DoDrag Me
End Sub
Private Sub imgTitleMinimize_Click()
Me.WindowState = 1
End Sub
Private Sub imgTitleRight_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
DoDrag Me
End Sub
Private Sub Label4_Click()
frmmain.Show
End Sub
Private Sub lblTitle_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
DoDrag Me
End Sub
Private Sub Combo1_Click()
MSFlexGrid1.Clear
Select Case Combo1.Text
Case "查询所有课程"
Label3.Visible = False
Combo2.Visible = False
Case "查询所教课程"
Label3.Visible = False
Combo2.Visible = False
Case "查询所教课程的学生信息"
Label3.Visible = True
Combo2.Visible = True
Label3.Caption = "请选择所教的课程"
sqlstr = "select course.cname from course,T_choose where course.cno=T_choose.cno and T_choose.tno='" & Trim(user_name) & "'"
Set rs = MyDB.ExecuteSQL(sqlstr, MsgTxt)
For i = 0 To rs.RecordCount - 1
Combo2.AddItem rs.Fields(0)
rs.MoveNext
Next i
End Select
End Sub
Private Sub SmartNetXpButton1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Select Case Combo1.Text
Case ""
MsgBox "请输入查询类型"
Case "查询所有课程"
MSFlexGrid1.Clear
sqlstr = "select * from course "
Set rs = MyDB.ExecuteSQL(sqlstr, MsgTxt)
With MSFlexGrid1
.Rows = 2
.CellAlignment = 4
.TextMatrix(1, 1) = "课程号"
.TextMatrix(1, 2) = "课程名"
.TextMatrix(1, 3) = "学时"
.TextMatrix(1, 4) = "学分"
Do While Not rs.EOF
.Rows = .Rows + 1
.CellAlignment = 4
.TextMatrix(.Rows - 1, 1) = rs.Fields(0)
.TextMatrix(.Rows - 1, 2) = rs.Fields(1)
.TextMatrix(.Rows - 1, 3) = rs.Fields(2)
.TextMatrix(.Rows - 1, 4) = rs.Fields(3)
rs.MoveNext
Loop
End With
rs.Close
Case "查询所教课程"
MSFlexGrid1.Clear
sqlstr = "select course.cno,course.cname,course.ctime,course.cpoint from course ,T_choose where course.cno=T_choose.cno and t_choose.tno='" & user_name & "'"
Set rs = MyDB.ExecuteSQL(sqlstr, MsgTxt)
With MSFlexGrid1
.Rows = 2
.CellAlignment = 4
.TextMatrix(1, 1) = "课程号"
.TextMatrix(1, 2) = "课程名"
.TextMatrix(1, 3) = "学时"
.TextMatrix(1, 4) = "学分"
Do While Not rs.EOF
.Rows = .Rows + 1
.CellAlignment = 4
.TextMatrix(.Rows - 1, 1) = rs.Fields(0)
.TextMatrix(.Rows - 1, 2) = rs.Fields(1)
.TextMatrix(.Rows - 1, 3) = rs.Fields(2)
.TextMatrix(.Rows - 1, 4) = rs.Fields(3)
rs.MoveNext
Loop
End With
rs.Close
Case "查询所教课程的学生信息"
If Combo2.Text = "" Then
MsgBox "请选择所教的课程"
End If
MSFlexGrid1.Clear
sqlstr = "select * from student where sno in (select S_choose.sno from s_choose,course,T_choose where course.cno=T_choose.cno and t_choose.cno=S_choose.cno and course.cname='" & Trim(Combo2.Text) & " ' and t_choose.Tno='" & Trim(user_name) & " ')"
Set rs = MyDB.ExecuteSQL(sqlstr, MsgTxt)
With MSFlexGrid1
.Rows = 2
.CellAlignment = 4
.TextMatrix(1, 1) = "学号"
.TextMatrix(1, 2) = "姓名"
.TextMatrix(1, 3) = "性别"
.TextMatrix(1, 4) = "出生日期"
.TextMatrix(1, 5) = "院别"
.TextMatrix(1, 6) = "年级"
.TextMatrix(1, 7) = "专业"
.TextMatrix(1, 8) = "联系方式"
.TextMatrix(1, 9) = "地址"
.TextMatrix(1, 10) = "备注"
Do While Not rs.EOF
.Rows = .Rows + 1
.CellAlignment = 4
.TextMatrix(.Rows - 1, 1) = rs.Fields(0)
.TextMatrix(.Rows - 1, 2) = rs.Fields(1)
.TextMatrix(.Rows - 1, 3) = rs.Fields(2)
.TextMatrix(.Rows - 1, 4) = rs.Fields(3)
.TextMatrix(.Rows - 1, 5) = rs.Fields(4)
.TextMatrix(.Rows - 1, 6) = rs.Fields(5)
.TextMatrix(.Rows - 1, 7) = rs.Fields(6)
.TextMatrix(.Rows - 1, 8) = rs.Fields(7)
.TextMatrix(.Rows - 1, 9) = rs.Fields(8)
.TextMatrix(.Rows - 1, 10) = rs.Fields(9)
rs.MoveNext
Loop
End With
End Select
End Sub
Private Sub SmartNetXpButton2_Click()
Unload Me
End Sub
Private Sub SmartNetXpButton3_Click()
Dim i As Integer, j As Integer
Dim MsgText As String
Dim expworkbook As Excel.Workbook
Dim expexcel As Excel.Application
Dim mrc As ADODB.Recordset
Set expexcel = New Excel.Application
expexcel.Visible = True
expexcel.SheetsInNewWorkbook = 1
Set expworkbook = expexcel.Workbooks.Add
Set mrc = MyDB.ExecuteSQL(sqlstr, MsgTxt)
On Error Resume Next
For i = 0 To mrc.Fields.Count - 1
expexcel.Cells(2, i + 1) = mrc.Fields(i).Name
Next
mrc.MoveFirst
For j = 1 To MSFlexGrid1.Rows
For i = 0 To mrc.Fields.Count - 1
expexcel.Cells(j + 2, i + 1) = CStr(mrc.Fields(i))
Next
mrc.MoveNext
If mrc.EOF Then Exit For
Next
Set expexcel = Nothing
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -