【VB开源代码栏目提醒】:网学会员VB开源代码为您提供B课表安排.frm参考,解决您在B课表安排.frm学习中工作中的难题,参考学习。
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Begin VB.Form frmtimetableSet
Caption = "课表安排"
ClientHeight = 5130
ClientLeft = 60
ClientTop = 345
ClientWidth = 8025
LinkTopic = "Form5"
ScaleHeight = 5130
ScaleWidth = 8025
StartUpPosition = 3 '窗口缺省
Begin VB.Frame Frame1
Caption = "班级课程信息"
Height = 4995
Left = 0
TabIndex = 0
Top = 0
Width = 7875
Begin VB.CommandButton CmdDo
BackColor = &H00C0C0C0&
Caption = "生成课表"
Height = 420
Left = 2160
Style = 1 'Graphical
TabIndex = 4
Top = 4320
Width = 1275
End
Begin VB.CommandButton CmdExit
BackColor = &H00C0C0C0&
Caption = "退出"
Height = 420
Left = 4860
Style = 1 'Graphical
TabIndex = 3
Top = 4320
Width = 915
End
Begin MSDataGridLib.DataGrid DataGrid1
Height = 2115
Left = 120
TabIndex = 2
Top = 1860
Width = 7575
_ExtentX = 13361
_ExtentY = 3731
_Version = 393216
HeadLines = 1
RowHeight = 15
BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ColumnCount = 2
BeginProperty Column00
DataField = ""
Caption = ""
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column01
DataField = ""
Caption = ""
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
SplitCount = 1
BeginProperty Split0
BeginProperty Column00
EndProperty
BeginProperty Column01
EndProperty
EndProperty
End
Begin MSComctlLib.ListView ListView1
Height = 1575
Left = 120
TabIndex = 1
Top = 240
Width = 7575
_ExtentX = 13361
_ExtentY = 2778
LabelWrap = -1 'True
HideSelection = -1 'True
_Version = 393217
Icons = "ImageList1"
ForeColor = -2147483640
BackColor = -2147483643
BorderStyle = 1
Appearance = 0
NumItems = 0
End
Begin MSComctlLib.ImageList ImageList1
Left = 120
Top = 360
_ExtentX = 1005
_ExtentY = 1005
BackColor = -2147483643
ImageWidth = 32
ImageHeight = 32
MaskColor = 12632256
_Version = 393216
BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628}
NumListImages = 1
BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "B课表安排.frx":0000
Key = ""
EndProperty
EndProperty
End
End
End
Attribute VB_Name = "frmtimetableSet"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim rs As ADODB.Recordset
Dim SQL As String
Dim msg As String
Dim index As Integer
Dim index2 As Integer
Dim flag As String '判断是新增记录还是修改记录
Dim M_courseTable(11, 8) As String '定义一张课表矩阵
Dim M_segmentNum As Integer
Dim M_Flag As Boolean '定义模块变量,判断条件设置是否合法
Dim M_rowIndex As Integer '定义模块变量,存放行序号
Dim M_colIndex As Integer '定义模块变量,存放列序号
Dim M_course As String '定义模块变量,存放课程名称
Dim M_class As String '定义模块变量,存放班级名称
Private Sub Form_Load()
Call LoadData '装载数据
Call ListView1_Click '显示班级课程信息
End Sub
Private Sub LoadData()
'装载数据
Dim list As ListItem
Dim key As String
Set rs = Nothing
'查询班级名称
SQL = "SELECT className FROM 班级信息表 ORDER BY className"
Set rs = SelectSQL(SQL, msg)
ListView1.ListItems.Clear '清空ListView
If rs.RecordCount > 0 Then '如果存在记录
rs.MoveFirst
Do Until rs.EOF
key = rs.Fields("className")
Set list = ListView1.ListItems.Add(, , key, 1)
rs.MoveNext
Loop
End If
End Sub
Private Sub ListView1_Click()
'在控件中显示班级信息
Dim key As String
If rs.RecordCount > 0 Then
key = Trim(ListView1.SelectedItem)
Call ShowData(key) '重新显示数据
End If
End Sub
Private Sub ShowData(key As String)
'显示班级课程信息
Dim rst As ADODB.Recordset
SQL = " SELECT courseName,totalNum,weekNum,courseAllocation,classroomTeacher FROM 班级课程信息表 "
SQL = SQL & "WHERE className='" & key & "'"
Set rst = SelectSQL(SQL, msg)
Set DataGrid1.DataSource = rst
DataGrid1.Refresh
End Sub
Private Sub CmdDo_Click()
'生成课表
msg = MsgBox("您确实要进行排课吗?", vbYesNo)
If msg = vbYes Then '如果选则“是”,进行排课
M_Flag = True '给模块变量赋值
'@1给每个班生成一张空的课程表
Call GenerateEmptyCT
'@2开始排课
Call GenerateRealCT
'@3如果排课条件设置错误,不进行排课
If M_Flag = False Then
MsgBox ("排课条件设置有问题,请重新设置!")
Exit Sub
End If
Else
Exit Sub
End If
End Sub
Private Sub GenerateEmptyCT()
' 给每个班生成一张空的课程表
Dim rst1 As ADODB.Recordset
Dim rst2 As ADODB.Recordset
Dim strClass As String '定义班级名称变量
Dim strSegment As String '定义节号变量
'@1删除排课信息表
SQL = " delete from 排课信息表"
Call ExecuteSQL(SQL, msg)
'@2得到班级名称集
SQL = " select className from 班级信息表 order by className"
Set rst1 = SelectSQL(SQL, msg)
'@3得到节号集
SQL = " select itemID from 时间段信息表 order by itemID"
Set rst2 = SelectSQL(SQL, msg)
M_segmentNum = rst2.RecordCount '得到每天教学节数
'@4生成空课表,遍历每一个班级
If rst1.RecordCount > 0 And rst2.RecordCount > 0 Then
Do While Not rst1.EOF
strClass = rst1.Fields("className")
'遍历所有节号,将初始排课信息插入到课表中
Do While Not rst2.EOF
strSegment = rst2.Fields("itemID")
SQL = "insert into 排课信息表(className,itemID,mondayN,tuesdayN,wednesdayN,thursdayN,fridayN,saturdayN,sundayN) "
SQL = SQL & " values ('" & strClass & "','" &
上一篇:
B花名册.frm
下一篇:
法律专业开题报告范文