【VB开源代码栏目提醒】:本文主要为网学会员提供C课程分配.frm,希望对需要C课程分配.frm网友有所帮助,学习一下!
VERSION 5.00
Begin VB.Form frmCourseDistritute
Caption = "课程分配"
ClientHeight = 3735
ClientLeft = 4950
ClientTop = 3585
ClientWidth = 6855
LinkTopic = "Form1"
ScaleHeight = 3735
ScaleWidth = 6855
Begin VB.ComboBox CboQuery
Height = 315
Index = 1
Left = 4320
TabIndex = 7
Top = 120
Width = 2295
End
Begin VB.ComboBox CboQuery
Height = 315
Index = 0
Left = 960
TabIndex = 6
Top = 120
Width = 2295
End
Begin VB.ComboBox CboQuery
Height = 315
Index = 2
Left = 960
TabIndex = 5
Top = 600
Width = 2295
End
Begin VB.ComboBox CboQuery
Height = 315
Index = 3
Left = 4320
TabIndex = 4
Top = 600
Width = 2295
End
Begin VB.TextBox txtItem
Height = 375
Index = 0
Left = 960
TabIndex = 3
Top = 1080
Width = 2295
End
Begin VB.TextBox txtItem
Height = 1275
Index = 1
Left = 960
MultiLine = -1 'True
TabIndex = 2
Top = 1560
Width = 5655
End
Begin VB.CommandButton CmdDivide
Caption = "分配"
Height = 435
Left = 2340
TabIndex = 1
Top = 3000
Width = 1215
End
Begin VB.CommandButton CmdExit
Caption = "退出"
Height = 435
Left = 4620
TabIndex = 0
Top = 3000
Width = 1095
End
Begin VB.Label Label9
Caption = "系:"
Height = 240
Left = 3960
TabIndex = 13
Top = 120
Width = 495
End
Begin VB.Label Label8
Caption = ":"
Height = 255
Index = 0
Left = 360
TabIndex = 12
Top = 120
Width = 735
End
Begin VB.Label Label1
Caption = "分配班级:"
Height = 255
Left = 0
TabIndex = 11
Top = 480
Width = 975
End
Begin VB.Label LblCourse
Caption = "全系课程:"
Height = 375
Index = 1
Left = 3360
TabIndex = 10
Top = 600
Width = 1335
End
Begin VB.Label Label2
Caption = "任课教师:"
Height = 375
Left = 0
TabIndex = 9
Top = 1080
Width = 1095
End
Begin VB.Label Label3
Caption = "备注:"
Height = 255
Left = 120
TabIndex = 8
Top = 1800
Width = 735
End
End
Attribute VB_Name = "frmCourseDistritute"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim SQLStr As String
Dim msg As String
Private Sub Form_Load()
'首先需要初始化ComboBox、系ComboBox、分配班级ComboBox和全系课程ComboBox
Dim rst As ADODB.Recordset
Dim strItem As String
'初始化ComboBox
SQLStr = " select collegeID,nameC from 院信息表 order by collegeID"
Set rst = SelectSQL(SQLStr, msg)
If rst.RecordCount > 0 Then '如果存在院信息
Do While Not rst.EOF
strItem = rst.Fields(0) & " " & rst.Fields(1)
CboQuery(0).AddItem (strItem)
rst.MoveNext
Loop
rst.Close
CboQuery(0).ListIndex = 0
Else '如果不存在院信息
MsgBox ("请先创建院信息!") '如果没有院信息不能使用
CboQuery(0).Enabled = False
CboQuery(1).Enabled = False
CboQuery(2).Enabled = False
Exit Sub
End If
Call SelectData(0) '初始化系ComboBox
If CboQuery(1).ListCount > 0 Then
Call SelectData(1) '初始化班级ComboBox
End If
End Sub
Private Sub SelectData(Index As Integer)
'初始化系ComboBox,班级ComboBox
Dim rst As ADODB.Recordset
Dim strItem As String
If Index = 0 Then '如果是选择院,初始化系ComboBox
SQLStr = " select departmentID,nameD from 系信息表 where collegeID='"
SQLStr = SQLStr & Left(Trim(CboQuery(0).Text), 2) & "' order by departmentID"
Set rst = SelectSQL(SQLStr, msg)
CboQuery(1).Clear
If rst.RecordCount > 0 Then '如果存在系信息
Do While Not rst.EOF
strItem = rst.Fields(0) & " " & rst.Fields(1)
CboQuery(1).AddItem (strItem)
rst.MoveNext
Loop
rst.Close
CboQuery(1).ListIndex = 0
Call FixData '在comboBox载入课程列表
Else '如果不存在系信息,退出过程
Exit Sub
End If
ElseIf Index = 1 Then '如果是选择系,初始化班级ComboBox
SQLStr = " select classID,classname from 班级信息表 where departmentID='"
SQLStr = SQLStr & Left(Trim(CboQuery(1).Text), 4) & "' order by classID"
Set rst = SelectSQL(SQLStr, msg)
CboQuery(2).Clear
If rst.RecordCount > 0 Then '如果存在班级信息
Do While Not rst.EOF
strItem = rst.Fields(0) & " " & rst.Fields(1)
CboQuery(2).AddItem (strItem)
rst.MoveNext
Loop
rst.Close
CboQuery(2).ListIndex = 0
Call FixData '在comboBox载入课程列表
Else '如果不存在班级信息,退出过程
Exit Sub
End If
End If
End Sub
Private Sub FixData()
'在ComboBox载入课程列表
Dim rst As ADODB.Recordset
Dim strItem As String
SQLStr = " select courseID,nameCourse from 课程信息表 where departmentID='"
SQLStr = SQLStr & Left(Trim(CboQuery(1).Text), 4) & "' order by courseID"
Set rst = SelectSQL(SQLStr, msg)
CboQuery(3).Clear
If rst.RecordCount > 0 Then '如果存在课程信息
Do While Not rst.EOF
strItem = rst.Fields(0) & " " & rst.Fields(1)
CboQuery(3).AddItem (strItem)
rst.MoveNext
Loop
rst.Close
CboQuery(3).ListIndex = 0
Else '如果不存在课程信息退出
Exit Sub
End If
End Sub
Private Sub CboQuery_Click(Index As Integer)
If Index = 0 Then
Call SelectData(0) '得到系列表
ElseIf Index = 1 Then
If CboQuery(1).ListCount > 0 Then
Call SelectData(1) '得到班级列表
End If
End If
End Sub
Private Sub CmdDivide_Click()
'将课程分配到具体的班级
Dim rst As ADODB.Recordset
Dim classNo As String
Dim courseNo As String
Dim divDate As String
classNo = Left(Trim(CboQuery(2).Text), 6) '得到班号
courseNo = Left(Trim(CboQuery(3).Text), 6) '得到课程号
divDate = Format(Now, "yyyy-mm-dd") '得到分配日期
If Not CheckData(classNo, courseNo) Then '检查是否已经被分配
Exit Sub
End If
'得到课程分配信息记录集
SQLStr = "select * from 课程分配信息表 where classID='" & strClassNo & "'"
Set rst = SelectSQL(SQLStr, msg)
If CboQuery(3).ListCount > 0 Then '如果存在课程信息
msg = MsgBox("你确认分配吗?", vbYesNo)
If msg = vbYes Then
rst.AddNew
rst.Fields("courseID") = courseNo
rst.Fields("classID") = classNo
rst.Fields("distributionDate") = divDate
rst.Fields("teacherT") = Trim(txtItem(0).Text)
rst.Fields("remarkcourse") = Trim(txtItem(1).Text)
rst.Update
MsgBox ("分配成功!")
txtItem(0).Text = ""
上一篇:
C联系人统计.frm
下一篇:
非常好用的串口跟踪程序c++语言实验已通过