示例#1
0
        public override void doit()
        {
            _roomLabel.Text       = _newRoom.getName();
            _roomLabel.Tag        = _newRoom;
            _courseAndRoomPair[1] = _newRoom;

            if (_course.getCoursesToHoldTogetherList().Count > 0)
            {
                foreach (Course courseHT in _course.getCoursesToHoldTogetherList())
                {
                    EduProgram epHT = (EduProgram)courseHT.Parent;
                    ArrayList [,] myttHT = epHT.getTimetable();
                    ArrayList lessonsInOneTimeSlotHT = myttHT[_indexRow, _indexCol];
                    foreach (Object [] courseAndRoomPairHT in lessonsInOneTimeSlotHT)
                    {
                        Course courseFromModelHT = (Course)courseAndRoomPairHT[0];
                        if (courseFromModelHT == courseHT)
                        {
                            courseAndRoomPairHT[1] = _newRoom;
                            break;
                        }
                    }
                }
            }
        }
        public override void undo()
        {
            foreach (Object [] oneItem in _forUndoRedoList)
            {
                Course course = (Course)oneItem[0];

                EduProgram thisEP = (EduProgram)course.Parent;
                ArrayList [,] mytt = thisEP.getTimetable();
                ArrayList lessonsInOneTimeSlot = mytt[_indexRow, _indexCol];
                lessonsInOneTimeSlot.Remove(oneItem);
            }

            if (AppForm.getAppForm().getTreeTabControl().SelectedIndex != 1)
            {
                AppForm.getAppForm().getTreeTabControl().SelectedIndexChanged -= new System.EventHandler(AppForm.getAppForm().treeTabControl_SelectedIndexChanged);
                AppForm.getAppForm().getTreeTabControl().SelectedIndex         = 1;
                AppForm.getAppForm().getTreeTabControl().SelectedIndexChanged += new System.EventHandler(AppForm.getAppForm().treeTabControl_SelectedIndexChanged);
            }

            AppForm.getAppForm().getTeachersTreeView().AfterSelect -= new System.Windows.Forms.TreeViewEventHandler(AppForm.getAppForm().teachersTreeView_AfterSelect);
            AppForm.getAppForm().getTeachersTreeView().SelectedNode = _selectedNode;
            AppForm.getAppForm().getTeachersTreeView().AfterSelect += new System.Windows.Forms.TreeViewEventHandler(AppForm.getAppForm().teachersTreeView_AfterSelect);

            AppForm.getAppForm().ttvRefreshTimetablePanel(_selectedNode, false);
        }
示例#3
0
        public ArrayList getTimeSlotsOfMyAllocatedLessons()
        {
            ArrayList atsList = new ArrayList();

            EduProgram ep = (EduProgram)this.Parent;

            int numOfAlreadyAllocatedLessons = this.getNumberOfLessonsPerWeek() - this.getNumberOfUnallocatedLessons();

            //if (this.getReportName() == "MATEMATIKA 2 - gr. 1") Console.WriteLine("MAT FIXED " + numOfAlreadyAllocatedLessons);

            ArrayList[,] epTimetable = ep.getTimetable();
            int foundCounter = 0;

            int numOfSlotsPerRoom = AppForm.CURR_OCTT_DOC.getNumberOfDays() * AppForm.CURR_OCTT_DOC.IncludedTerms.Count;
            int wtutsEp           = 0;

            for (int k = 0; k < AppForm.CURR_OCTT_DOC.getNumberOfDays(); k++)
            {
                for (int j = 0; j < AppForm.CURR_OCTT_DOC.IncludedTerms.Count; j++)
                {
                    wtutsEp++;

                    ArrayList lessonsInOneTimeSlot = epTimetable[j, k];

                    if (lessonsInOneTimeSlot != null && lessonsInOneTimeSlot.Count > 0)
                    {
                        IEnumerator enumerator = lessonsInOneTimeSlot.GetEnumerator();

                        for (int step = 0; step < lessonsInOneTimeSlot.Count; step++)
                        {
                            enumerator.MoveNext();
                            Object[] courseAndRoomPair = (Object[])enumerator.Current;
                            Course   course            = (Course)courseAndRoomPair[0];
                            if (course == this)
                            {
                                foundCounter++;
                                Room room      = (Room)courseAndRoomPair[1];
                                int  roomIndex = AppForm.CURR_OCTT_DOC.RoomsRootNode.Nodes.IndexOf(room);
                                int  cts       = roomIndex * numOfSlotsPerRoom + wtutsEp;
                                atsList.Add(cts);
                                //if (this.getReportName() == "MATEMATIKA 2 - gr. 1") Console.WriteLine("FOUND " + cts);

                                if (foundCounter == numOfAlreadyAllocatedLessons)
                                {
                                    break;
                                }
                            }
                        }
                    }
                }
            }


            return(atsList);
        }
示例#4
0
        private void roomLabelForTeacherView_DoubleClick(object sender, System.EventArgs e)
        {
            Label       roomLabel  = (Label)sender;
            IEnumerator enumerator = _allSubLabels.GetEnumerator();

            enumerator.MoveNext();
            Label[]    oneSubLabel  = (Label [])enumerator.Current;
            Label      courseLabel1 = oneSubLabel[0];
            Course     course       = (Course)courseLabel1.Tag;
            EduProgram ep           = (EduProgram)course.Parent;

            ArrayList [,] mytt = ep.getTimetable();
            ArrayList lessonsInOneTimeSlot = mytt[_indexRow, _indexCol];

            Object [] courseAndRoomPair = null;
            foreach (Object [] courseAndRoomPairCC in lessonsInOneTimeSlot)
            {
                Course courseCheck = (Course)courseAndRoomPairCC[0];
                if (courseCheck == course)
                {
                    courseAndRoomPair = courseAndRoomPairCC;
                    break;
                }
            }

            Room      currRoom     = (Room)roomLabel.Tag;
            ArrayList allowedRooms = calculateAllAllowedRooms(course, _indexRow, _indexCol);

            allowedRooms.Add(currRoom);

            roomLabel.BackColor = System.Drawing.Color.DarkOrange;

            RoomSelectionForm cu = new RoomSelectionForm(roomLabel, allowedRooms, currRoom, course, courseAndRoomPair);

            cu.ShowDialog(AppForm.getAppForm());
            if (cu.DialogResult == DialogResult.OK)
            {
                Room newRoom = cu.getSelectedRoom();

                ChooseRoomTSPTeachersViewCmd cuCmd = new ChooseRoomTSPTeachersViewCmd(courseAndRoomPair, course, currRoom, newRoom, roomLabel, _indexRow, _indexCol);
                CommandProcessor.getCommandProcessor().doCmd(cuCmd);
            }

            cu.Dispose();
            roomLabel.BackColor = System.Drawing.SystemColors.ControlLight;
        }
示例#5
0
        private void courseLabelForRoom_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            Label label = (Label)sender;

            DRAG_DROP_START_PANEL = this;

            Course     courseForMove = (Course)label.Tag;
            EduProgram epInMove      = (EduProgram)courseForMove.Parent;

            ArrayList [,] mytt = epInMove.getTimetable();
            ArrayList lessonsInOneTimeSlot = mytt[_indexRow, _indexCol];

            Object [] courseAndRoomPair = null;
            foreach (Object [] courseAndRoomPairInList in lessonsInOneTimeSlot)
            {
                Course thisCourse = (Course)courseAndRoomPairInList[0];
                if (thisCourse == courseForMove)
                {
                    courseAndRoomPair = courseAndRoomPairInList;
                    break;
                }
            }

            CURR_ROOM = (Room)courseAndRoomPair[1];
            Course       dragedCourse = (Course)courseAndRoomPair[0];
            ListViewItem lvi          = new ListViewItem();

            lvi.Tag = dragedCourse;

            ArrayList notAllowedTimeSlots = HardConstraintChecks.findAllFreeTimeSlotsForRoomsView(dragedCourse, CURR_ROOM);

            //if drag-drop was successfull, delete label from old location
            if (DragDropEffects.Move == label.DoDragDrop(lvi, DragDropEffects.Move))
            {
                TSPRoomsViewDragDropSuccessfullCmd uddsCmd = new TSPRoomsViewDragDropSuccessfullCmd(dragedCourse, this, lessonsInOneTimeSlot, courseAndRoomPair);
                DRAG_DROP_MACRO_CMD.addInList(uddsCmd);
                CommandProcessor.getCommandProcessor().doCmd(DRAG_DROP_MACRO_CMD);
            }

            DRAG_DROP_START_PANEL = null;
            AppForm.getAppForm().doBackTimeSlotPanelGUI(notAllowedTimeSlots);
        }
示例#6
0
        public override void doit()
        {
            _forUndoRedoList = new ArrayList();

            _lessonsInOneTimeSlot.Remove(_courseAndRoomPair);

            _forUndoRedoList.Add(_courseAndRoomPair);

            _tsp.Controls.Clear();
            _tsp.getAllSubLabels().Clear();

            _tsp.putLabelsOnThePanel();

            if (_dragedCourse.getCoursesToHoldTogetherList().Count > 0)
            {
                foreach (Course courseHT in _dragedCourse.getCoursesToHoldTogetherList())
                {
                    EduProgram epHT = (EduProgram)courseHT.Parent;
                    ArrayList [,] myttHT = epHT.getTimetable();
                    ArrayList lessonsInOneTimeSlotHT = myttHT[_indexRow, _indexCol];
                    if (lessonsInOneTimeSlotHT != null)
                    {
                        Object[] courseAndRoomPairForDel = null;
                        foreach (Object[] courseAndRoomPairHT in lessonsInOneTimeSlotHT)
                        {
                            Course courseToCheck = (Course)courseAndRoomPairHT[0];
                            if (courseToCheck == courseHT)
                            {
                                courseAndRoomPairForDel = courseAndRoomPairHT;
                                break;
                            }
                        }
                        if (courseAndRoomPairForDel != null)
                        {
                            lessonsInOneTimeSlotHT.Remove(courseAndRoomPairForDel);

                            _forUndoRedoList.Add(courseAndRoomPairForDel);
                        }
                    }
                }
            }
        }
示例#7
0
        public override void undo()
        {
            foreach (Object [] oneItem in _forUndoRedoList)
            {
                Course course = (Course)oneItem[0];

                EduProgram thisEP = (EduProgram)course.Parent;
                ArrayList [,] mytt = thisEP.getTimetable();
                ArrayList lessonsInOneTimeSlot;
                if (mytt[_indexRow, _indexCol] == null)
                {
                    lessonsInOneTimeSlot = new ArrayList();
                }
                else
                {
                    lessonsInOneTimeSlot = mytt[_indexRow, _indexCol];
                }

                lessonsInOneTimeSlot.Add(oneItem);
                mytt[_indexRow, _indexCol] = lessonsInOneTimeSlot;
            }
        }
        private void checkChangeEduProgram(CancelEventArgs e)
        {
            EduProgram ep = (EduProgram)_workingObject;

            ArrayList [,] mytt = ep.getTimetable();
            bool allowed = true;

            foreach (Label edotlW in _mainPanel.Controls)
            {
                if (edotlW.GetType().FullName == "OpenCTT.EnableDisableOneTermLabel")
                {
                    EnableDisableOneTermLabel edotl = (EnableDisableOneTermLabel)edotlW;
                    if (!edotl.getIsTermEnabled())
                    {
                        if (!(mytt[edotl.getIndexRow(), edotl.getIndexCol()] == null || mytt[edotl.getIndexRow(), edotl.getIndexCol()].Count == 0))
                        {
                            allowed = false;
                            break;
                        }
                    }
                }
            }

            if (!allowed)
            {
                e.Cancel = true;
                string message1 = RES_MANAGER.GetString("checkChangeEduProgram.msb.notsuccessfull.message");
                string caption1 = RES_MANAGER.GetString("checkChangeEduProgram.msb.notsuccessfull.caption");

                MessageBoxButtons buttons1 = MessageBoxButtons.OK;

                MessageBox.Show(this, message1, caption1, buttons1,
                                MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
            }
            else
            {
                e.Cancel = false;
            }
        }
示例#9
0
        public override void undo()
        {
            if (AppForm.getAppForm().getTreeTabControl().SelectedIndex != 1)
            {
                AppForm.getAppForm().getTreeTabControl().SelectedIndexChanged -= new System.EventHandler(AppForm.getAppForm().treeTabControl_SelectedIndexChanged);
                AppForm.getAppForm().getTreeTabControl().SelectedIndex         = 1;
                AppForm.getAppForm().getTreeTabControl().SelectedIndexChanged += new System.EventHandler(AppForm.getAppForm().treeTabControl_SelectedIndexChanged);
            }

            AppForm.getAppForm().getTeachersTreeView().AfterSelect -= new System.Windows.Forms.TreeViewEventHandler(AppForm.getAppForm().teachersTreeView_AfterSelect);
            AppForm.getAppForm().getTeachersTreeView().SelectedNode = _selectedNode;
            AppForm.getAppForm().getTeachersTreeView().AfterSelect += new System.Windows.Forms.TreeViewEventHandler(AppForm.getAppForm().teachersTreeView_AfterSelect);

            _courseAndRoomPair[1] = _oldRoom;

            if (_course.getCoursesToHoldTogetherList().Count > 0)
            {
                foreach (Course courseHT in _course.getCoursesToHoldTogetherList())
                {
                    EduProgram epHT = (EduProgram)courseHT.Parent;
                    ArrayList [,] myttHT = epHT.getTimetable();
                    ArrayList lessonsInOneTimeSlotHT = myttHT[_indexRow, _indexCol];
                    foreach (Object [] courseAndRoomPairHT in lessonsInOneTimeSlotHT)
                    {
                        Course courseFromModelHT = (Course)courseAndRoomPairHT[0];
                        if (courseFromModelHT == courseHT)
                        {
                            courseAndRoomPairHT[1] = _oldRoom;
                            break;
                        }
                    }
                }
            }

            AppForm.getAppForm().ttvRefreshTimetablePanel(_selectedNode, false);
        }
        public override void doit()
        {
            _forUndoRedoList = new ArrayList();

            ArrayList possibleRooms = _tsp.calculateAllAllowedRooms(_dropedCourse, _indexRow, _indexCol);

            IEnumerator puEnum          = possibleRooms.GetEnumerator();
            Room        minCapacityRoom = null;

            for (int n = 0; n < possibleRooms.Count; n++)
            {
                puEnum.MoveNext();
                Room room = (Room)puEnum.Current;
                if (n == 0)
                {
                    minCapacityRoom = room;
                }
                else
                {
                    if (room.getRoomCapacity() < minCapacityRoom.getRoomCapacity())
                    {
                        minCapacityRoom = room;
                    }
                }
            }

            _tsp.makeSubLabel(_dropedCourse, minCapacityRoom);

            EduProgram thisEP = (EduProgram)_dropedCourse.Parent;

            ArrayList [,] mytt = thisEP.getTimetable();

            ArrayList lessonsInOneTimeSlot;

            if (mytt[_indexRow, _indexCol] == null)
            {
                lessonsInOneTimeSlot = new ArrayList();
            }
            else
            {
                lessonsInOneTimeSlot = mytt[_indexRow, _indexCol];
            }


            Object [] courseAndRoomPair = new Object[2];
            courseAndRoomPair[0] = _dropedCourse;
            courseAndRoomPair[1] = minCapacityRoom;

            lessonsInOneTimeSlot.Add(courseAndRoomPair);
            mytt[_indexRow, _indexCol] = lessonsInOneTimeSlot;

            _forUndoRedoList.Add(courseAndRoomPair);

            if (_dropedCourse.getCoursesToHoldTogetherList().Count > 0)
            {
                foreach (Course courseHT in _dropedCourse.getCoursesToHoldTogetherList())
                {
                    EduProgram epHT = (EduProgram)courseHT.Parent;
                    ArrayList [,] myttHT = epHT.getTimetable();

                    ArrayList lessonsInOneTimeSlotHT;
                    if (myttHT[_indexRow, _indexCol] == null)
                    {
                        lessonsInOneTimeSlotHT = new ArrayList();
                    }
                    else
                    {
                        lessonsInOneTimeSlotHT = myttHT[_indexRow, _indexCol];
                    }


                    Object [] courseAndRoomPairHT = new Object[2];

                    courseAndRoomPairHT[0] = courseHT;
                    courseAndRoomPairHT[1] = minCapacityRoom;

                    lessonsInOneTimeSlotHT.Add(courseAndRoomPairHT);
                    myttHT[_indexRow, _indexCol] = lessonsInOneTimeSlotHT;
                    _tsp.makeSubLabel(courseHT, minCapacityRoom);

                    _forUndoRedoList.Add(courseAndRoomPairHT);
                }
            }
        }
示例#11
0
        public override void doit()
        {
            _forUndoRedoList = new ArrayList();

            _tsp.makeSubLabel(_dropedCourse, _dropedCourse.getTeacher());

            EduProgram thisEP = (EduProgram)_dropedCourse.Parent;

            ArrayList [,] mytt = thisEP.getTimetable();

            ArrayList lessonsInOneTimeSlot;

            if (mytt[_indexRow, _indexCol] == null)
            {
                lessonsInOneTimeSlot = new ArrayList();
            }
            else
            {
                lessonsInOneTimeSlot = mytt[_indexRow, _indexCol];
            }


            Object [] courseAndRoomPair = new Object[2];
            courseAndRoomPair[0] = _dropedCourse;
            courseAndRoomPair[1] = _currRoom;

            lessonsInOneTimeSlot.Add(courseAndRoomPair);
            mytt[_indexRow, _indexCol] = lessonsInOneTimeSlot;

            _forUndoRedoList.Add(courseAndRoomPair);

            if (_dropedCourse.getCoursesToHoldTogetherList().Count > 0)
            {
                foreach (Course courseHT in _dropedCourse.getCoursesToHoldTogetherList())
                {
                    EduProgram epHT = (EduProgram)courseHT.Parent;
                    ArrayList [,] myttHT = epHT.getTimetable();

                    ArrayList lessonsInOneTimeSlotHT;
                    if (myttHT[_indexRow, _indexCol] == null)
                    {
                        lessonsInOneTimeSlotHT = new ArrayList();
                    }
                    else
                    {
                        lessonsInOneTimeSlotHT = myttHT[_indexRow, _indexCol];
                    }


                    Object [] courseAndRoomPairHT = new Object[2];

                    courseAndRoomPairHT[0] = courseHT;
                    courseAndRoomPairHT[1] = _currRoom;

                    lessonsInOneTimeSlotHT.Add(courseAndRoomPairHT);
                    myttHT[_indexRow, _indexCol] = lessonsInOneTimeSlotHT;
                    _tsp.makeSubLabel(courseHT, courseHT.getTeacher());

                    _forUndoRedoList.Add(courseAndRoomPairHT);
                }
            }
        }
示例#12
0
        private void acceptTheBestSolution()
        {
            /*foreach (ACourse ac in _aglobal._allACourses)
             * {
             *  Console.WriteLine("------------");
             *  Console.WriteLine(ac.Name);
             *  foreach (ALessonNode aln in ac.MyAllLessonNodesForAllocation)
             *  {
             *      Console.WriteLine(aln.PositionInGlobalBestSolution);
             *  }
             *
             * }*/

            if (_isRunFromEmptySolution)
            {
                foreach (EduProgramGroup epg in AppForm.CURR_OCTT_DOC.CoursesRootNode.Nodes)
                {
                    foreach (EduProgram ep in epg.Nodes)
                    {
                        ep.setTimetable(new ArrayList[AppForm.CURR_OCTT_DOC.IncludedTerms.Count, AppForm.CURR_OCTT_DOC.getNumberOfDays()]);

                        AppForm.CURR_OCTT_DOC.TotalNumberOfUnallocatedLessons = 0;
                        ep.setUnallocatedLessonsList(new ArrayList());
                    }
                }
            }


            foreach (EduProgramGroup epg in AppForm.CURR_OCTT_DOC.CoursesRootNode.Nodes)
            {
                foreach (EduProgram ep in epg.Nodes)
                {
                    foreach (Course course in ep.Nodes)
                    {
                        int epgIndex    = AppForm.CURR_OCTT_DOC.CoursesRootNode.Nodes.IndexOf(epg);
                        int epIndex     = epg.Nodes.IndexOf(ep);
                        int courseIndex = ep.Nodes.IndexOf(course);

                        ACourse ac = (ACourse)_coursesMapping[epgIndex + "," + epIndex + "," + courseIndex];
                        if (ac != null && !ac.IsHTCourse)
                        {
                            foreach (ALessonNode aln in ac.MyAllLessonNodesForAllocation)
                            {
                                //Console.WriteLine(aln.PositionInBestSolution);
                                int indexRow, indexCol, roomIndex;
                                this.convertNumberOfTimeSlotToRowColumnAndRoom(aln.PositionInGlobalBestSolution, out indexRow, out indexCol, out roomIndex);
                                Room room = (Room)_sortedRoomsRelCapacityList[roomIndex];

                                ArrayList[,] mytt = ep.getTimetable();
                                ArrayList lessonsInOneTimeSlot;
                                if (mytt[indexRow, indexCol] == null)
                                {
                                    lessonsInOneTimeSlot = new ArrayList();
                                }
                                else
                                {
                                    lessonsInOneTimeSlot = mytt[indexRow, indexCol];
                                }


                                Object[] courseAndRoomPair = new Object[2];
                                courseAndRoomPair[0] = course;
                                courseAndRoomPair[1] = room;

                                lessonsInOneTimeSlot.Add(courseAndRoomPair);
                                mytt[indexRow, indexCol] = lessonsInOneTimeSlot;

                                //
                                if (!_isRunFromEmptySolution)
                                {
                                    ep.removeOneLessonFromUnallocatedLessonsModel(course);
                                    AppForm.CURR_OCTT_DOC.decrUnallocatedLessonsCounter(1);
                                }
                                //

                                if (course.getCoursesToHoldTogetherList().Count > 0)
                                {
                                    foreach (Course courseHT in course.getCoursesToHoldTogetherList())
                                    {
                                        EduProgram epHT = (EduProgram)courseHT.Parent;
                                        ArrayList[,] myttHT = epHT.getTimetable();

                                        ArrayList lessonsInOneTimeSlotHT;
                                        if (myttHT[indexRow, indexCol] == null)
                                        {
                                            lessonsInOneTimeSlotHT = new ArrayList();
                                        }
                                        else
                                        {
                                            lessonsInOneTimeSlotHT = myttHT[indexRow, indexCol];
                                        }

                                        Object[] courseAndRoomPairHT = new Object[2];

                                        courseAndRoomPairHT[0] = courseHT;
                                        courseAndRoomPairHT[1] = room;

                                        lessonsInOneTimeSlotHT.Add(courseAndRoomPairHT);
                                        myttHT[indexRow, indexCol] = lessonsInOneTimeSlotHT;

                                        //
                                        if (!_isRunFromEmptySolution)
                                        {
                                            epHT.removeOneLessonFromUnallocatedLessonsModel(courseHT);
                                        }
                                        //
                                    }
                                }
                            }
                        }
                    }
                }
            }

            //

            _acceptBestSolutionButton.Enabled = false;
            AppForm.getAppForm().getStatusBarPanel2().Text = AppForm.CURR_OCTT_DOC.getNumOfUnallocatedLessonsStatusText();
            AppForm.getAppForm().getCommandProcessor().emptyAllStacks();
            AppForm.getAppForm().getCommandProcessor().setUnReButtonState();

            int      tabIndex    = AppForm.getAppForm().getTreeTabControl().SelectedIndex;
            TreeNode workingNode = null;

            if (tabIndex == 0)
            {
                workingNode = AppForm.getAppForm().getCoursesTreeView().SelectedNode;
                if (workingNode == null)
                {
                    workingNode = AppForm.CURR_OCTT_DOC.CoursesRootNode;
                }
                AppForm.CURR_OCTT_DOC.CTVSelectedNode = workingNode;
                AppForm.getAppForm().ctvRefreshTimetablePanel(workingNode, true, true);

                AppForm.getAppForm().getCoursesTreeView().AfterSelect -= new System.Windows.Forms.TreeViewEventHandler(AppForm.getAppForm().coursesTreeView_AfterSelect);
                AppForm.getAppForm().getCoursesTreeView().SelectedNode = workingNode;
                AppForm.getAppForm().getCoursesTreeView().AfterSelect += new System.Windows.Forms.TreeViewEventHandler(AppForm.getAppForm().coursesTreeView_AfterSelect);
            }
            else if (tabIndex == 1)
            {
                workingNode = AppForm.getAppForm().getTeachersTreeView().SelectedNode;
                if (workingNode == null)
                {
                    workingNode = AppForm.CURR_OCTT_DOC.TeachersRootNode;
                }
                AppForm.getAppForm().getTeachersTreeView().AfterSelect -= new System.Windows.Forms.TreeViewEventHandler(AppForm.getAppForm().teachersTreeView_AfterSelect);
                AppForm.getAppForm().getTeachersTreeView().SelectedNode = workingNode;
                AppForm.getAppForm().getTeachersTreeView().AfterSelect += new System.Windows.Forms.TreeViewEventHandler(AppForm.getAppForm().teachersTreeView_AfterSelect);

                AppForm.CURR_OCTT_DOC.TTVSelectedNode = workingNode;
                AppForm.getAppForm().ttvRefreshTimetablePanel(workingNode, true);
            }
            else if (tabIndex == 2)
            {
                workingNode = AppForm.getAppForm().getRoomsTreeView().SelectedNode;
                if (workingNode == null)
                {
                    workingNode = AppForm.CURR_OCTT_DOC.RoomsRootNode;
                }
                AppForm.getAppForm().getRoomsTreeView().AfterSelect -= new System.Windows.Forms.TreeViewEventHandler(AppForm.getAppForm().roomsTreeView_AfterSelect);
                AppForm.getAppForm().getRoomsTreeView().SelectedNode = workingNode;
                AppForm.getAppForm().getRoomsTreeView().AfterSelect += new System.Windows.Forms.TreeViewEventHandler(AppForm.getAppForm().roomsTreeView_AfterSelect);

                AppForm.CURR_OCTT_DOC.RTVSelectedNode = workingNode;
                AppForm.getAppForm().rtvRefreshTimetablePanel(workingNode, true);
            }
        }
        public override void doit()
        {
            _forUndoRedoList = new ArrayList();

            //find all rooms which are possible
            //for this lection (capacity, are they free in the term,...)
            ArrayList possibleRooms = _tsp.calculateAllAllowedRooms(_dropedCourse, _tsp.getIndexRow(), _tsp.getIndexCol());

            //i take the room which has the first bigger capacity than
            //the number of enrolled students for the course(s) that is draged
            IEnumerator prEnum          = possibleRooms.GetEnumerator();
            Room        minCapacityRoom = null;

            for (int n = 0; n < possibleRooms.Count; n++)
            {
                prEnum.MoveNext();
                Room room = (Room)prEnum.Current;
                if (n == 0)
                {
                    minCapacityRoom = room;
                }
                else
                {
                    if (room.getRoomCapacity() < minCapacityRoom.getRoomCapacity())
                    {
                        minCapacityRoom = room;
                    }
                }
            }

            _tsp.makeSubLabel(_dropedCourse, minCapacityRoom);

            EduProgram thisEP = (EduProgram)_dropedCourse.Parent;

            ArrayList [,] mytt = thisEP.getTimetable();
            ArrayList lessonsInOneTimeSlot;

            if (mytt[_indexRow, _indexCol] == null)
            {
                lessonsInOneTimeSlot = new ArrayList();
            }
            else
            {
                lessonsInOneTimeSlot = mytt[_indexRow, _indexCol];
            }


            Object [] courseAndRoomPair = new Object[2];
            courseAndRoomPair[0] = _dropedCourse;
            courseAndRoomPair[1] = minCapacityRoom;

            lessonsInOneTimeSlot.Add(courseAndRoomPair);
            mytt[_indexRow, _indexCol] = lessonsInOneTimeSlot;

            _forUndoRedoList.Add(courseAndRoomPair);

            if (_dropedCourse.getCoursesToHoldTogetherList().Count > 0)
            {
                foreach (Course courseHT in _dropedCourse.getCoursesToHoldTogetherList())
                {
                    EduProgram epHT = (EduProgram)courseHT.Parent;
                    ArrayList [,] myttHT = epHT.getTimetable();

                    ArrayList lessonsInOneTimeSlotHT;
                    if (myttHT[_indexRow, _indexCol] == null)
                    {
                        lessonsInOneTimeSlotHT = new ArrayList();
                    }
                    else
                    {
                        lessonsInOneTimeSlotHT = myttHT[_indexRow, _indexCol];
                    }


                    Object [] courseAndRoomPairHT = new Object[2];

                    courseAndRoomPairHT[0] = courseHT;
                    courseAndRoomPairHT[1] = minCapacityRoom;

                    lessonsInOneTimeSlotHT.Add(courseAndRoomPairHT);
                    myttHT[_indexRow, _indexCol] = lessonsInOneTimeSlotHT;

                    _forUndoRedoList.Add(courseAndRoomPairHT);
                }
            }
        }
示例#14
0
        public static ArrayList getPdfSharpReportDataTablesList(ArrayList listForPrint, int reportType)
        {
            Cursor.Current = Cursors.WaitCursor;

            ArrayList reportTablesList = new ArrayList();

            ///
            int rowCount = AppForm.CURR_OCTT_DOC.IncludedTerms.Count;

            int columnCount = AppForm.CURR_OCTT_DOC.getNumberOfDays();


            foreach (Object obj in listForPrint)
            {
                Object [] reportGroupAndTable = new object[2];

                DataTable gdt = new DataTable();
                for (int dd = 0; dd < columnCount; dd++)
                {
                    gdt.Columns.Add("Day" + (dd + 1));
                }


                ArrayList [,] mytt = null;
                Teacher teacher = null;
                Room    room    = null;
                string  grName  = null;

                if (obj is EduProgram)
                {
                    EduProgram ep = (EduProgram)obj;
                    mytt   = ep.getTimetable();
                    grName = ep.getReportTitle();
                }
                else if (obj is Teacher)
                {
                    teacher = (Teacher)obj;
                    grName  = teacher.getReportTitle();
                }
                else if (obj is Room)
                {
                    room   = (Room)obj;
                    grName = room.getReportTitle();
                }

                reportGroupAndTable[0] = grName;

                int foundInOneTSForTeacherAndRoom;

                for (int j = 0; j < rowCount; j++)
                {
                    DataRow dr = gdt.NewRow();

                    for (int k = 0; k < columnCount; k++)
                    {
                        string timeSlotText = "";
                        dr["Day" + (k + 1)] = timeSlotText;

                        foundInOneTSForTeacherAndRoom = 1;

                        if (reportType == 1)
                        {
                            ArrayList lessonsInOneTimeSlot = mytt[j, k];
                            if (lessonsInOneTimeSlot != null && lessonsInOneTimeSlot.Count != 0)
                            {
                                int helpCounter = 1;
                                foreach (Object [] courseAndRoomPair in lessonsInOneTimeSlot)
                                {
                                    Room room11 = (Room)courseAndRoomPair[1];

                                    Course  course      = (Course)courseAndRoomPair[0];
                                    Teacher tcr         = course.getTeacher();
                                    string  teacherText = tcr.getName().Substring(0, 1) + ". " + tcr.getLastName();

                                    //string courseName=course.getReportName();

                                    string courseName;
                                    if (Settings.TTREP_COURSE_FORMAT == 1)
                                    {
                                        courseName = course.getFullName();
                                    }
                                    else
                                    {
                                        courseName = course.getReportName();
                                    }

                                    string roomName = room11.getName();

                                    if (helpCounter == 1)
                                    {
                                        timeSlotText += courseName + " @ " + roomName;
                                    }
                                    else
                                    {
                                        timeSlotText += "\n" + courseName + " @ " + roomName;
                                    }

                                    if (Settings.TTREP_PRINT_TEACHER_IN_TS == 1)
                                    {
                                        timeSlotText += " (" + teacherText + ")";
                                    }

                                    helpCounter++;
                                }

                                dr["Day" + (k + 1)] = timeSlotText;
                            }
                        }
                        else if (reportType == 2)
                        {
                            string lastUsedCourseName2 = null;

                            foreach (EduProgramGroup epg in AppForm.CURR_OCTT_DOC.CoursesRootNode.Nodes)
                            {
                                foreach (EduProgram ep in epg.Nodes)
                                {
                                    ArrayList [,] myttT = ep.getTimetable();
                                    ArrayList lessonsInOneTimeSlot = myttT[j, k];
                                    if (lessonsInOneTimeSlot != null && lessonsInOneTimeSlot.Count != 0)
                                    {
                                        foreach (Object [] courseAndRoomPair in lessonsInOneTimeSlot)
                                        {
                                            Course  course           = (Course)courseAndRoomPair[0];
                                            Teacher teacherFromModel = course.getTeacher();
                                            if (teacherFromModel == teacher)
                                            {
                                                Room room2 = (Room)courseAndRoomPair[1];
                                                //string courseName=course.getReportName();
                                                string courseName;
                                                if (Settings.TTREP_COURSE_FORMAT == 1)
                                                {
                                                    courseName = course.getFullName();
                                                }
                                                else
                                                {
                                                    courseName = course.getReportName();
                                                }


                                                string roomName = room2.getName();

                                                if (foundInOneTSForTeacherAndRoom == 1)
                                                {
                                                    timeSlotText += courseName + " @ " + roomName;
                                                }
                                                else
                                                {
                                                    if (courseName != lastUsedCourseName2)
                                                    {
                                                        timeSlotText += "\n" + courseName + " @ " + roomName;
                                                    }
                                                }

                                                lastUsedCourseName2 = courseName;

                                                foundInOneTSForTeacherAndRoom++;
                                            }
                                        }

                                        dr["Day" + (k + 1)] = timeSlotText;
                                    }
                                }
                            }
                        }
                        else if (reportType == 3)
                        {
                            string lastUsedCourseName3 = null;

                            foreach (EduProgramGroup epg in AppForm.CURR_OCTT_DOC.CoursesRootNode.Nodes)
                            {
                                foreach (EduProgram ep in epg.Nodes)
                                {
                                    ArrayList [,] myttR = ep.getTimetable();
                                    ArrayList lessonsInOneTimeSlot = myttR[j, k];
                                    if (lessonsInOneTimeSlot != null && lessonsInOneTimeSlot.Count != 0)
                                    {
                                        foreach (Object [] courseAndRoomPair in lessonsInOneTimeSlot)
                                        {
                                            Room roomFromModel = (Room)courseAndRoomPair[1];

                                            if (roomFromModel == room)
                                            {
                                                Course  course      = (Course)courseAndRoomPair[0];
                                                Teacher tcr         = course.getTeacher();
                                                string  teacherText = tcr.getName().Substring(0, 1) + ". " + tcr.getLastName();

                                                EduProgram ep3        = (EduProgram)course.Parent;
                                                string     codeAndSem = ep3.getCode() + "/" + ep3.getSemester();

                                                //string courseName=course.getReportName();
                                                string courseName;
                                                if (Settings.TTREP_COURSE_FORMAT == 1)
                                                {
                                                    courseName = course.getFullName();
                                                }
                                                else
                                                {
                                                    courseName = course.getReportName();
                                                }

                                                if (foundInOneTSForTeacherAndRoom == 1)
                                                {
                                                    timeSlotText += courseName + " @ " + codeAndSem;
                                                }
                                                else
                                                {
                                                    if (courseName == lastUsedCourseName3)
                                                    {
                                                        timeSlotText += ", " + codeAndSem;
                                                    }
                                                    else
                                                    {
                                                        timeSlotText += "\n" + courseName + " @ " + codeAndSem;
                                                    }
                                                }

                                                if (Settings.TTREP_PRINT_TEACHER_IN_TS == 1)
                                                {
                                                    timeSlotText += " (" + teacherText + ")";
                                                }

                                                lastUsedCourseName3 = courseName;

                                                foundInOneTSForTeacherAndRoom++;
                                            }
                                        }

                                        dr["Day" + (k + 1)] = timeSlotText;
                                    }
                                }
                            }
                        }
                    }

                    gdt.Rows.Add(dr);
                }

                reportGroupAndTable[1] = gdt;

                reportTablesList.Add(reportGroupAndTable);
            }


            return(reportTablesList);
        }
示例#15
0
        public override void doit()
        {
            _numOfUnallocatedLessonsUndoRedoCounter = 0;
            _epAndLviForUndoRedoList = new ArrayList();

            ArrayList [,] mytt = _ep.getTimetable();
            for (int j = 0; j < AppForm.CURR_OCTT_DOC.IncludedTerms.Count; j++)
            {
                for (int k = 0; k < AppForm.CURR_OCTT_DOC.getNumberOfDays(); k++)
                {
                    ArrayList lessonsInOneTimeSlot = mytt[j, k];
                    if (lessonsInOneTimeSlot != null)
                    {
                        for (int step = 0; step < lessonsInOneTimeSlot.Count;)
                        {
                            IEnumerator enumerator = lessonsInOneTimeSlot.GetEnumerator();
                            enumerator.MoveNext();
                            Object [] courseAndRoomPair = (Object [])enumerator.Current;
                            Course    course            = (Course)courseAndRoomPair[0];
                            lessonsInOneTimeSlot.Remove(courseAndRoomPair);

                            AppForm.CURR_OCTT_DOC.incrUnallocatedLessonsCounter(1);
                            _numOfUnallocatedLessonsUndoRedoCounter++;

                            ListViewItem lvi = new ListViewItem();
                            lvi.Tag = course;
                            _ep.getUnallocatedLessonsList().Add(lvi);

                            //prepare for redo
                            Object [] onePair = new Object[4];
                            onePair[0] = _ep;
                            onePair[1] = lvi;
                            onePair[2] = lessonsInOneTimeSlot;
                            onePair[3] = courseAndRoomPair;

                            _epAndLviForUndoRedoList.Add(onePair);


                            if (course.getCoursesToHoldTogetherList().Count > 0)
                            {
                                foreach (Course courseHT in course.getCoursesToHoldTogetherList())
                                {
                                    EduProgram epHT = (EduProgram)courseHT.Parent;
                                    ArrayList [,] myttHT = epHT.getTimetable();
                                    ArrayList   lessonsInOneTimeSlotHT = myttHT[j, k];
                                    IEnumerator enumeratorIP           = lessonsInOneTimeSlotHT.GetEnumerator();
                                    foreach (Object [] courseAndRoomPairHT in lessonsInOneTimeSlotHT)
                                    {
                                        enumeratorIP.MoveNext();
                                        Course courseFromListHT = (Course)courseAndRoomPairHT[0];
                                        if (courseFromListHT == courseHT)
                                        {
                                            break;
                                        }
                                    }

                                    Object [] courseAndRoomPairHTForDel = (Object [])enumeratorIP.Current;
                                    lessonsInOneTimeSlotHT.Remove(courseAndRoomPairHTForDel);

                                    ListViewItem lviNew = new ListViewItem();

                                    lviNew.Tag = courseHT;
                                    epHT.getUnallocatedLessonsList().Add(lviNew);

                                    //prepare for redo
                                    Object [] onePairIP = new Object[4];
                                    onePairIP[0] = epHT;
                                    onePairIP[1] = lviNew;
                                    onePairIP[2] = lessonsInOneTimeSlotHT;
                                    onePairIP[3] = courseAndRoomPairHTForDel;
                                    _epAndLviForUndoRedoList.Add(onePairIP);
                                }
                            }
                        }
                    }
                }
            }


            foreach (TimeSlotPanel tsp in AppForm.getAppForm().getMainTimetablePanel().Controls)
            {
                tsp.Controls.Clear();
                tsp.getAllSubLabels().Clear();
                tsp.putLabelsOnThePanel();

                AppForm.getAppForm().getUnallocatedLessonsListView().BeginUpdate();
                AppForm.getAppForm().getUnallocatedLessonsListView().Items.Clear();

                foreach (ListViewItem lvi in _ep.getUnallocatedLessonsList())
                {
                    Course    courseTag        = (Course)lvi.Tag;
                    Teacher   teacher          = courseTag.getTeacher();
                    string [] courseAndTeacher = new string[2];
                    courseAndTeacher[0] = courseTag.getFullName();
                    courseAndTeacher[1] = teacher.getLastName() + " " + teacher.getName();
                    ListViewItem newLvi = new ListViewItem(courseAndTeacher);
                    newLvi.Tag = courseTag;
                    AppForm.getAppForm().getUnallocatedLessonsListView().Items.Add(newLvi);
                }

                AppForm.getAppForm().getUnallocatedLessonsListView().EndUpdate();
            }

            AppForm.getAppForm().getStatusBarPanel2().Text = AppForm.CURR_OCTT_DOC.getNumOfUnallocatedLessonsStatusText();
        }
示例#16
0
        public static ArrayList findAllFreeTimeSlotsForRoomsView(Course dragedCourse, Room currRoom)
        {
            ArrayList notPossibleTimeSlots = new ArrayList();
            Teacher   dragedTeacher        = dragedCourse.getTeacher();

            EduProgram      currEP = (EduProgram)dragedCourse.Parent;
            EduProgramGroup epg    = (EduProgramGroup)currEP.Parent;

            ArrayList[,] currTimetable = currEP.getTimetable();

            ArrayList possibleRooms = new ArrayList();

            possibleRooms.Add(currRoom);


            foreach (TimeSlotPanel tsp in AppForm.getAppForm().getMainTimetablePanel().Controls)
            {
                //check if time slot is possible in relation with allowed time slots for EduProgramGroup
                markNotPossibleTimeSlotsRelEduProgramGroup(epg, tsp, notPossibleTimeSlots);
                if (dragedCourse.getCoursesToHoldTogetherList().Count > 0)
                {
                    foreach (Course edu_program_group in dragedCourse.getCoursesToHoldTogetherList())
                    {
                        EduProgram      epHT  = (EduProgram)edu_program_group.Parent;
                        EduProgramGroup epgHT = (EduProgramGroup)epHT.Parent;
                        markNotPossibleTimeSlotsRelEduProgramGroup(epgHT, tsp, notPossibleTimeSlots);
                    }
                }

                //check if time slot is possible in relation with allowed time slots for EduProgram
                markNotPossibleTimeSlotsRelEduProgram(currEP, tsp, notPossibleTimeSlots);
                if (dragedCourse.getCoursesToHoldTogetherList().Count > 0)
                {
                    foreach (Course edu_program_group in dragedCourse.getCoursesToHoldTogetherList())
                    {
                        EduProgram epHT = (EduProgram)edu_program_group.Parent;
                        markNotPossibleTimeSlotsRelEduProgram(epHT, tsp, notPossibleTimeSlots);
                    }
                }


                //check in relation with groups
                ArrayList lessonsInOneTimeSlot = currTimetable[tsp.getIndexRow(), tsp.getIndexCol()];
                markNotPossibleTimeSlotsRelGroup(lessonsInOneTimeSlot, tsp, dragedCourse, notPossibleTimeSlots);
                if (dragedCourse.getCoursesToHoldTogetherList().Count > 0)
                {
                    foreach (Course edu_program_group in dragedCourse.getCoursesToHoldTogetherList())
                    {
                        EduProgram epHT = (EduProgram)edu_program_group.Parent;
                        ArrayList[,] myttHT = epHT.getTimetable();
                        ArrayList lessonsInOneTimeSlotHT = myttHT[tsp.getIndexRow(), tsp.getIndexCol()];
                        markNotPossibleTimeSlotsRelGroup(lessonsInOneTimeSlotHT, tsp, edu_program_group, notPossibleTimeSlots);
                    }
                }


                //check if teacher is free for time slot
                markNotPossibleTimeSlotsRelTeacher(tsp, dragedTeacher, notPossibleTimeSlots);

                //check if there is any room with capacity greater than number
                //of enrolled students for draged course, that is free for this time slot,
                // and with time slot allowed in definition of allowed time slots for room
                markNotPossibleTimeSlotsRelRoom(tsp, possibleRooms, notPossibleTimeSlots);
            }
            return(notPossibleTimeSlots);
        }
        public override void doit()
        {
            _forUndoRedoList = new ArrayList();

            EduProgram ep = (EduProgram)_dragedCourse.Parent;

            ArrayList [,] mytt = ep.getTimetable();
            ArrayList   lessonsInOneTimeSlot = mytt[_tsp.getIndexRow(), _tsp.getIndexCol()];
            IEnumerator enumModel            = lessonsInOneTimeSlot.GetEnumerator();

            IEnumerator enumGUI = _tsp.getAllSubLabels().GetEnumerator();

            for (int n = 0; n <= _subIndex; n++)
            {
                enumModel.MoveNext();
                enumGUI.MoveNext();
            }

            Object [] courseAndRoomPair = (Object [])enumModel.Current;
            lessonsInOneTimeSlot.Remove(courseAndRoomPair);

            _forUndoRedoList.Add(courseAndRoomPair);


            Label[] oneSubLabel = (Label [])enumGUI.Current;
            Label   courseLabel = oneSubLabel[0];
            Label   roomLabel   = oneSubLabel[1];

            _tsp.getAllSubLabels().Remove(oneSubLabel);

            courseLabel.Parent = null;
            roomLabel.Parent   = null;

            _tsp.putLabelsOnThePanel();

            if (_dragedCourse.getCoursesToHoldTogetherList().Count > 0)
            {
                foreach (Course courseHT in _dragedCourse.getCoursesToHoldTogetherList())
                {
                    EduProgram epHT = (EduProgram)courseHT.Parent;
                    ArrayList [,] myttHT = epHT.getTimetable();
                    ArrayList lessonsInOneTimeSlotHT = myttHT[_tsp.getIndexRow(), _tsp.getIndexCol()];
                    if (lessonsInOneTimeSlotHT != null)
                    {
                        Object[] courseAndRoomPairForDel = null;
                        foreach (Object[] courseAndRoomPairHT in lessonsInOneTimeSlotHT)
                        {
                            Course courseToCheck = (Course)courseAndRoomPairHT[0];
                            if (courseToCheck == courseHT)
                            {
                                courseAndRoomPairForDel = courseAndRoomPairHT;
                                break;
                            }
                        }
                        if (courseAndRoomPairForDel != null)
                        {
                            lessonsInOneTimeSlotHT.Remove(courseAndRoomPairForDel);

                            _forUndoRedoList.Add(courseAndRoomPairForDel);
                        }
                    }
                }
            }
        }