⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dispfrm.frm

📁 guan yu pai ke xi tong de ruan jian
💻 FRM
📖 第 1 页 / 共 3 页
字号:
            For ColIndex = 8 To TemDataSet.Tables(8).Fields.FieldCount - 1
                TemDataSet.Tables(8).Rows(RowIndex).Items(ColIndex).Value = 0
            Next
        Next
        Me.PageRefresh
    Case 2: '确定.
        '将公用数据集指向修改后的数据.
        Set MyDataSet = New MDD_Data: Set MyDataSet = TemDataSet
        MyDataSet.Updatable = True '表示数据已经修改。
        Unload Me
    Case 3: '取消.
        Unload Me
    Case 4: '停止处理.
        Me.Timer1.Enabled = False
        TemDataSet.DispStop
    End Select
End Sub

Private Sub DispPage_DblClick()
    Dim RowIndex As Long
    Dim ColIndex As Long
    Dim TemNum As Long
    Dim ForIndex As Long
    Dim DispNum As Long  '从索引0开始分别表示教学日,时段,节数。
    If SelectUp.X <= 0 Or SelectUp.Y <= 0 Then Exit Sub
    '检测当前是否已经选择一个表格。如果没有,则不进行操作。
    If Option1(0).Value = True And Combo1(0).ListIndex < 0 Or Option1(1).Value = True And Combo1(1).ListIndex < 0 Then
        MsgBox "请先选择一个班级或一名教师的课表", vbOKOnly, "没有课表..."
        Exit Sub
    End If
    '先清除该节的标志.
    TemNum = SelectUp.X * 100 + SelectUp.Y * 10 + SelectUp.Z
    DispNum = 0
    If Me.Option1(0).Value = True Then
        DispNum = TemDataSet.SumLocation(Me.Combo1(0).ListIndex, -1, -1, -1, TemNum)
    Else
        DispNum = TemDataSet.SumLocation(-1, Me.Combo1(1).ListIndex, -1, -1, TemNum)
    End If
    If DispNum > 0 Then
        MsgBox "发现该节已经排了课!" & Chr(13) & "只有先将其删除才能排其它课!", vbOKOnly, "错误..."
        Exit Sub
    End If
    '收集列表.
    Me.List1.Clear
    For RowIndex = 0 To TemDataSet.Tables(8).RowCount - 1
        If TemDataSet.Tables(8).Rows(RowIndex).Items(Abs(Me.Option1(1).Value)).Value = Me.Combo1(Abs(Me.Option1(1).Value)).ListIndex Then
            DispNum = 0
            For ColIndex = 8 To 27
                If TemDataSet.Tables(8).Rows(RowIndex).Items(ColIndex).Value > 0 Then DispNum = DispNum + 1
            Next
            '该记录尚未处理完成,则将科目名称加入列表之中.
            If DispNum < TemDataSet.Tables(8).Rows(RowIndex).Items(6).Value Then
                For ColIndex = 0 To Me.List1.ListCount - 1
                    If Me.List1.List(ColIndex) = TemDataSet.Tables(2).Rows(TemDataSet.Tables(8).Rows(RowIndex).Items(2).Value).Items(0).Value Then Exit For
                Next
                If ColIndex >= Me.List1.ListCount Then
                    Me.List1.AddItem TemDataSet.Tables(2).Rows(TemDataSet.Tables(8).Rows(RowIndex).Items(2).Value).Items(0).Value
                End If
            End If
        End If
    Next
    If Me.List1.ListCount > 0 Then
        Me.List1.ListIndex = -1
        Me.List1.Left = Me.DispPage.Left + CurrXY.X
        Me.List1.Top = Me.DispPage.Top + CurrXY.Y
        Me.List1.Visible = True
    Else
        Me.List1.Visible = False
        MsgBox "发现<" & TemDataSet.Tables(Abs(Me.Option1(1).Value)).Rows(Me.Combo1(Abs(Me.Option1(1).Value)).ListIndex).Items(0).Value & ">的课已经处理完毕!" & Chr(13) & "如果要更改课程计划,请转到<课程计划>窗口中,添加一条排课记录!", vbOKOnly, "没有未处理的课程记录..."
    End If
    '根据排课条件给出建议提示。
    
    
    
End Sub

Private Sub DispPage_KeyUp(KeyCode As Integer, Shift As Integer)
    Dim ColIndex As Long
    Dim RowIndex As Long
On Error Resume Next
    '判断是否在有效数据区。
    Select Case KeyCode
    Case 46: 'DEL键删除。
        If SelectUp.X > 0 And SelectUp.Y > 0 And SelectUp.Z > 0 Then
            If SelectUp.X <= TemDataSet.Tables(6).RowCount Then
                If SelectUp.Y <= 5 Then
                    If SelectUp.Z <= TemDataSet.Tables(7).Rows(0).Items(SelectUp.Y - 1).Value Then
                        For RowIndex = 0 To TemDataSet.Tables(8).RowCount - 1
                            If Shift = 1 Then 'Shift+Del全部清空(所有课表)。
                                For ColIndex = 8 To 27
                                    TemDataSet.Tables(8).Rows(RowIndex).Items(ColIndex).Value = 0
                                Next
                            Else
                                If TemDataSet.Tables(8).Rows(RowIndex).Items(1 - Abs(Me.Option1(0).Value)).Value = Me.Combo1(1 - Abs(Me.Option1(0).Value)).ListIndex Then
                                    For ColIndex = 8 To 27
                                        If Shift = 0 Then '未按组合键,只删除该节。
                                            If TemDataSet.Tables(8).Rows(RowIndex).Items(ColIndex).Value = SelectUp.X * 100 + SelectUp.Y * 10 + SelectUp.Z Then
                                                TemDataSet.Tables(8).Rows(RowIndex).Items(ColIndex).Value = 0
                                            End If
                                        Else '按Ctrl+Del全部删除(该班或该教师)。
                                            If Shift = 2 Then
                                                TemDataSet.Tables(8).Rows(RowIndex).Items(ColIndex).Value = 0
                                            End If
                                        End If
                                    Next
                                End If
                            End If
                        Next
                    End If
                End If
            End If
        End If
    Case 37: '向左移。
        If SelectUp.X > 1 Then SelectUp.X = SelectUp.X - 1
    Case 38: '向上移。
        If SelectUp.Z > 1 Then
            SelectUp.Z = SelectUp.Z - 1
        Else
            If SelectUp.Y > 1 Then
                SelectUp.Y = SelectUp.Y - 1
                SelectUp.Z = TemDataSet.Tables(7).Rows(0).Items(SelectUp.Y - 1).Value
            End If
        End If
    Case 39: '向右移。
        If SelectUp.X < TemDataSet.Tables(6).RowCount Then SelectUp.X = SelectUp.X + 1
    Case 40: '向下移。
        If SelectUp.Z < TemDataSet.Tables(7).Rows(0).Items(SelectUp.Y - 1).Value Then
            SelectUp.Z = SelectUp.Z + 1
        Else
            If SelectUp.Y < 5 Then
                SelectUp.Y = SelectUp.Y + 1
                SelectUp.Z = 1
            End If
        End If
    Case 13: '回车键相当于双击页面进行手动排课。
        DispPage_DblClick
    End Select
    Me.PageRefresh
End Sub

Private Sub DispPage_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Dim ForIndex As Long
    Dim DispNum As Integer
    CurrXY.X = X: CurrXY.Y = Y
    SelectDown.X = 0: SelectDown.Y = 0: SelectDown.Z = 0
    If X \ ColWidth > 0 And Y \ RowHeight > 0 Then
        SelectDown.X = X \ ColWidth '教学日。
        DispNum = 0
        For ForIndex = 0 To 4
            If (Y \ RowHeight) > DispNum And (Y \ RowHeight) <= DispNum + TemDataSet.Tables(7).Rows(0).Items(ForIndex).Value Then
                '找到相应时段代号。
                SelectDown.Y = ForIndex + 1 '保存时段值。
                SelectDown.Z = Y \ RowHeight - DispNum '保存节号值。
                Exit For
            End If
            DispNum = DispNum + TemDataSet.Tables(7).Rows(0).Items(ForIndex).Value
        Next
    End If
    List1.Visible = False
End Sub

Private Sub DispPage_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Dim ForIndex As Long
    Dim DispNum As Integer
    Dim RowIndex As Long
    Dim ColIndex As Long
    Dim RowSelectIndex As Long
    Dim TemNum As Long
    SelectUp.X = 0: SelectUp.Y = 0: SelectUp.Z = 0
    If X \ ColWidth > 0 And Y \ RowHeight > 0 Then
        '确定当前操作位置。
        SelectUp.X = X \ ColWidth '保存教学日。
        DispNum = 0
        For ForIndex = 0 To 4
            If (Y \ RowHeight) > DispNum And (Y \ RowHeight) <= DispNum + TemDataSet.Tables(7).Rows(0).Items(ForIndex).Value Then
                '找到相应时段代号。
                SelectUp.Y = ForIndex + 1 '保存时段值。
                SelectUp.Z = Y \ RowHeight - DispNum '保存节号值。
                Exit For
            End If
            DispNum = DispNum + TemDataSet.Tables(7).Rows(0).Items(ForIndex).Value
        Next
        '收集可用科目列表?
        Me.List1.Clear
        For RowIndex = 0 To TemDataSet.Tables(8).RowCount - 1
            If TemDataSet.Tables(8).Rows(RowIndex).Items(Abs(Me.Option1(1).Value)).Value = Me.Combo1(Abs(Me.Option1(1).Value)).ListIndex Then
                DispNum = 0
                For ColIndex = 8 To 27
                    If TemDataSet.Tables(8).Rows(RowIndex).Items(ColIndex).Value > 0 Then DispNum = DispNum + 1
                Next
                '该记录尚未处理完成,则将科目名称加入列表之中.
                If DispNum < TemDataSet.Tables(8).Rows(RowIndex).Items(6).Value Then
                    For ColIndex = 0 To Me.List1.ListCount - 1
                        If Me.List1.List(ColIndex) = TemDataSet.Tables(2).Rows(TemDataSet.Tables(8).Rows(RowIndex).Items(2).Value).Items(0).Value Then Exit For
                    Next
                    If ColIndex >= Me.List1.ListCount Then
                        Me.List1.AddItem TemDataSet.Tables(2).Rows(TemDataSet.Tables(8).Rows(RowIndex).Items(2).Value).Items(0).Value
                    End If
                End If
            End If
        Next
        For RowIndex = 1 To kemu.Count - 1 Step 1
            Unload kemu(RowIndex)
        Next
        For RowIndex = 0 To Me.List1.ListCount - 1
            If RowIndex > 0 Then Load kemu(RowIndex)
            kemu(RowIndex).Caption = Me.List1.List(RowIndex)
        Next
        '可用的班级列表和教师列表。
        If TemDataSet.Tables(0).RowCount > 0 Or TemDataSet.Tables(1).RowCount > 0 Then PopMenus(0).Enabled = True Else PopMenus(0).Enabled = False
        If TemDataSet.Tables(0).RowCount > 0 Then
            SelectClasA.Enabled = True
            For RowIndex = 1 To BanList.Count - 1 Step 1
                Unload BanList(RowIndex)
            Next
            For RowIndex = 0 To TemDataSet.Tables(0).RowCount - 1
                If RowIndex > 0 Then Load BanList(RowIndex)
                BanList(RowIndex).Caption = TemDataSet.Tables(0).Rows(RowIndex).Items(0).Value
                '确定时否当前课表。
                If RowIndex = Me.Combo1(0).ListIndex And Me.Option1(0).Value = True Then BanList(RowIndex).Checked = True Else BanList(RowIndex).Checked = False
            Next
        Else
            SelectClasA.Enabled = False
        End If
        If TemDataSet.Tables(1).RowCount > 0 Then
            SelectClasB.Enabled = True
            For RowIndex = 1 To ShiList.Count - 1 Step 1
                Unload ShiList(RowIndex)
            Next
            For RowIndex = 0 To TemDataSet.Tables(1).RowCount - 1
                If RowIndex > 0 Then Load ShiList(RowIndex)
                ShiList(RowIndex).Caption = TemDataSet.Tables(1).Rows(RowIndex).Items(0).Value
                '确定时否当前课表。
                If RowIndex = Me.Combo1(1).ListIndex And Me.Option1(1).Value = True Then ShiList(RowIndex).Checked = True Else ShiList(RowIndex).Checked = False
            Next
        Else
            SelectClasB.Enabled = False
        End If
        '右键弹出菜单。
        If Button = 2 Then
            Me.PageRefresh
            '判断当前课表被选中的单元格是否已经排了课。
            If Me.Option1(0).Value = True Then
                '班级课表
                If TemDataSet.SumLocation(Me.Combo1(0).ListIndex, -1, -1, -1, SelectUp.X * 100 + SelectUp.Y * 10 + SelectUp.Z) < 1 Then
                    '没有排课。
                    If Me.List1.ListCount > 0 Then PopMenus(1).Enabled = True Else PopMenus(1).Enabled = False
                    PopMenus(2).Enabled = False
                Else
                    PopMenus(1).Enabled = False
                    PopMenus(2).Enabled = True
                End If
            Else
                '教师课表。
                If TemDataSet.SumLocation(-1, Me.Combo1(1).ListIndex, -1, -1, SelectUp.X * 100 + SelectUp.Y * 10 + SelectUp.Z) < 1 Then
                    '没有排课。
                    If Me.List1.ListCount > 0 Then PopMenus(1).Enabled = True Else PopMenus(1).Enabled = False
                    PopMenus(2).Enabled = False
                Else
                    PopMenus(1).Enabled = False
                    PopMenus(2).Enabled = True
                End If
            End If
            '收集可用的代课教师列表。
            For RowIndex = 1 To teachers.Count - 1 Step 1
                Unload teachers(RowIndex)
            Next
            If TemDataSet.Tables(1).RowCount < 2 Then '有两名以上的教师才可以代课。
                PopMenus(1).Enabled = False
            Else
                DispNum = 0
                For RowIndex = 0 To TemDataSet.Tables(1).RowCount - 1
                    ' 判断该教师该节课是否有空。
                    If TemDataSet.SumLocation(-1, RowIndex, -1, -1, SelectUp.X * 100 + SelectUp.Y * 10 + SelectUp.Z) < 1 Then
                        If DispNum > 0 Then Load teachers(DispNum)
                        teachers(DispNum).Caption = TemDataSet.Tables(1).Rows(RowIndex).Items(0).Value
                        DispNum = DispNum + 1
                    End If
                Next
            End If
            PopupMenu PopMenu
        End If
        '左键拖动操作。
        If Button = 1 And (SelectUp.X > 0 And SelectUp.Y > 0 And SelectUp.Z > 0) And (SelectDown.X > 0 And SelectDown.Y > 0 And SelectDown.Z > 0) And (SelectDown.X <> SelectUp.X Or SelectDown.Y <> SelectUp.Y Or SelectDown.Z <> SelectUp.Z) Then
            '检测当前是否已经选择一个表格。如果没有,则不进行操作。
            If Option1(0).Value = True And Combo1(0).ListIndex < 0 Or Option1(1).Value = True And Combo1(1).ListIndex < 0 Then Exit Sub
            '进行交换操作.
            TemDataSet.SwapClasNumber 1 - Abs(Me.Option1(0).Value), Me.Combo1(1 - Abs(Me.Option1(0).Value)).ListIndex, SelectDown.X * 100 + SelectDown.Y * 10 + SelectDown.Z, SelectUp.X * 100 + SelectUp.Y * 10 + SelectUp.Z, 0
        End If
    End If
    Me.PageRefresh
End Sub

Private Sub Form_Load()

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -