vb+SQL排课系统论文报告+算法+源码+答辩PPT 第6页
Call ExecuteSQL(SQL, msg)
rst2.MoveNext
Loop
rst2.MoveFirst
rst1.MoveNext
Loop
MsgBox ("已经生成了空课表!")
End If
End Sub
Private Sub setCourseToM_courseTable(strCourse As String, dayindex1 As Integer, dayindex2 As Integer, flag As Boolean)
'将课程写入到M_courseTable课表矩阵
Dim temp As Integer
Dim randIndex As Integer
M_colIndex = 0
M_rowIndex = 0
'1随机选择一日
Randomize '随机数种子
randIndex = Int(Rnd() * (dayindex2 - dayindex1)) + dayindex1
'2得到插入的位置
Call GetPosition(randIndex, dayindex2, flag) '在randIndex至dayindex2之间进行遍历
If M_rowIndex = 0 Then '如果没有找到,就从dayindex1至randIndex之间进行遍历
Call GetPosition(dayindex1, randIndex, flag)
End If
'3设置M_courseTable
If M_rowIndex = 0 Then '如果安排不下,报告排课条件错误
MsgBox ("排课条件设置有问题!" & strCourse & "无法排下!")
M_Flag = False
Else '如果可以安排,设置M_courseTable的值
If flag = True Then
M_courseTable(M_rowIndex, M_colIndex) = strCourse
本文来自辣文论文网原文请找QQ752018766 M_rowIndex, M_colIndex) = strCourse
End If
M_Flag = True
End If
End Sub 毕业论文
http://www.751com.cnPrivate Sub GetPosition(startIndex As Integer, endIndex As Integer, flag As Boolean)
'得到课程能够插入的位置
Dim temp As Integer
Dim randSegment As Integer
'1随机选择某一节号
Randomize '随机数种子
randSegment = Int(Rnd() * (M_segmentNum - 1)) + 1
'2遍历节,在startIndex至endIndex之间开始遍历
For temp = startIndex To endIndex
'在randSegment至M_segmentNum之间开始遍历
For index = randSegment To M_segmentNum
If flag = True Then '如果需要累排,检查是否能够累排两节课
If index + 1 <= M_segmentNum Then
If M_courseTable(index, temp) = "" And M_courseTable(index + 1, temp) = "" Then
M_rowIndex = index
M_colIndex = temp
End If
End If
Else '如果不需要累排,检查是否能够排一节课
If M_courseTable(index, temp) = "" Then
M_rowIndex = index
M_colIndex = temp
End If
End If
If M_rowIndex > 0 And TestAvialable(M_rowIndex, M_colIndex, flag) Then Exit Sub '如果找到了,就退出函数
Next index
'如果没有找到插入位置,在1到randSegment之内开始遍历
For index = 1 To randSegment
If flag = True Then '如果需要累排,检查是否能够累排两节课
If index + 1 <= M_segmentNum Then
If M_courseTable(index, temp) = "" And M_courseTable(index + 1, temp) = "" Then
M_rowIndex = index
M_colIndex = temp
End If
End If
Else '如果不需要累排,检查是否能够排一节课
If M_courseTable(index, temp) = "" Then
M_rowIndex = index
M_colIndex = temp
End If
End If
If M_rowIndex > 0 And TestAvialable(M_rowIndex, M_colIndex, flag) Then Exit Sub '如果找到了,就退出函数
Next index
Next temp
End Sub
Private Function TestAvialable(rowIndex As Integer, colIndex As Integer, flag As Boolean) As Boolean
'检测教师资源是否冲突
Dim rst1 As ADODB.Recordset
Dim rst2 As ADODB.Recordset
Dim teacher As String
Dim dayName As String
Dim count As Integer
dayName = GetDayName(colIndex)
count = 1
TestAvialable = True
'1得到当前课程的任毕业论文
http://www.751com.cn课教师
SQL = "select 任课教师 from 班级课程信息表 where 班级名称='" & M_class & "' and 课程名称='" & M_course & "'"
Set rst1 = SelectSQL(SQL, msg)
teacher = rst1.Fields("任课教师")
'2得到教师所有的授课班级
SQL = "select 班级名称 from 班级课程信息表 where 任课教师='" & teacher & "'"
Set rst1 = SelectSQL(SQL, msg)
'3遍历每一个班的课表,看看教师的授课时间是否冲突
Do While Not rst1.EOF
SQL = "SELECT 节号,星期一,星期二,星期三,星期四,星期五,星期辣,星期
上一页 [1] [2] [3] [4] [5] [6] [7] 下一页
vb+SQL排课系统论文报告+算法+源码+答辩PPT 第6页下载如图片无法显示或论文不完整,请联系qq752018766