Пример #1
0
        private void courseLabelForCoursesView_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            Label label = (Label)sender;

            DRAG_DROP_START_PANEL = this;
            int subIndex = this.getSubLabelIndex(label);

            Course       dragedCourse = (Course)label.Tag;
            ListViewItem lvi          = new ListViewItem();

            lvi.Tag = dragedCourse;

            ArrayList notAllowedTimeSlots = HardConstraintChecks.findAllFreeTimeSlots(dragedCourse);

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

            DRAG_DROP_START_PANEL = null;
            AppForm.getAppForm().doBackTimeSlotPanelGUI(notAllowedTimeSlots);
        }
Пример #2
0
        private static void markNotPossibleTimeSlotsRelRoom(TimeSlotPanel tsp, ArrayList possibleRooms, ArrayList notPossibleTimeSlots)
        {
            if (!notPossibleTimeSlots.Contains(tsp))
            {
                int       indexRow          = tsp.getIndexRow();
                int       indexCol          = tsp.getIndexCol();
                ArrayList possibleRoomsCopy = HardConstraintChecks.getPossibleRoomsRelTimeSlot(possibleRooms, indexRow, indexCol);


                //
                if (possibleRoomsCopy.Count == 0)
                {
                    tsp.BackColor = System.Drawing.Color.DarkSalmon;
                    tsp.AllowDrop = false;
                    notPossibleTimeSlots.Add(tsp);

                    ArrayList subLabels = tsp.getAllSubLabels();
                    foreach (Label [] courseRoomLabel in subLabels)
                    {
                        Label courseLabel = courseRoomLabel[0];
                        Label roomLabel   = courseRoomLabel[1];

                        courseLabel.BackColor = System.Drawing.Color.DarkSalmon;
                        roomLabel.BackColor   = System.Drawing.Color.DarkSalmon;
                    }
                }
            }
        }
Пример #3
0
        public override void undo()
        {
            _ep.Nodes.Remove(_course);
            AppForm.getAppForm().getCoursesTreeView().SelectedNode = _ep;
            AppForm.getAppForm().getCoursesTreeView().SelectedNode.EnsureVisible();

            if (HardConstraintChecks.checkIfCourseTypeIsFreeForDelete(_course))
            {
                AppForm.CURR_OCTT_DOC.CourseTypesList.Remove(_course.CourseType);
            }

            _ep.removeCourseFromUnallocatedLessonsModelAndView(_course, AppForm.getAppForm().getUnallocatedLessonsListView());

            AppForm.getAppForm().getStatusBarPanel2().Text = AppForm.CURR_OCTT_DOC.getNumOfUnallocatedLessonsStatusText();

            AppForm.getAppForm().getTreeTabControl().SelectedIndex = 0;
        }
Пример #4
0
        public override void undo()
        {
            AppForm.CURR_OCTT_DOC.TeachersRootNode.Nodes.Remove(_teacher);
            AppForm.getAppForm().getTeachersTreeView().SelectedNode = AppForm.CURR_OCTT_DOC.TeachersRootNode;
            AppForm.getAppForm().getTeachersTreeView().SelectedNode.EnsureVisible();

            if (HardConstraintChecks.checkIfTitleOfTeacherIsFreeForDelete(_teacher))
            {
                AppForm.CURR_OCTT_DOC.TeacherTitlesList.Remove(_teacher.getTitle());
            }

            if (HardConstraintChecks.checkIfEduRankOfTeacherIsFreeForDelete(_teacher))
            {
                AppForm.CURR_OCTT_DOC.TeacherEduRanksList.Remove(_teacher.getEduRank());
            }

            AppForm.getAppForm().getTreeTabControl().SelectedIndex = 1;
        }
Пример #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()
        {
            if (_newTitle != _oldTitle)
            {
                if (!AppForm.CURR_OCTT_DOC.TeacherTitlesList.Contains(_newTitle))
                {
                    AppForm.CURR_OCTT_DOC.TeacherTitlesList.Add(_newTitle);
                    AppForm.CURR_OCTT_DOC.TeacherTitlesList.Sort();
                }

                if (HardConstraintChecks.checkIfTitleOfTeacherIsFreeForDelete(_teacher))
                {
                    AppForm.CURR_OCTT_DOC.TeacherTitlesList.Remove(_oldTitle);
                }
            }

            if (_newEduRank != _oldEduRank)
            {
                if (!AppForm.CURR_OCTT_DOC.TeacherEduRanksList.Contains(_newEduRank))
                {
                    AppForm.CURR_OCTT_DOC.TeacherEduRanksList.Add(_newEduRank);
                    AppForm.CURR_OCTT_DOC.TeacherEduRanksList.Sort();
                }

                if (HardConstraintChecks.checkIfEduRankOfTeacherIsFreeForDelete(_teacher))
                {
                    AppForm.CURR_OCTT_DOC.TeacherEduRanksList.Remove(_oldEduRank);
                }
            }

            _teacher.setName(_newName);
            _teacher.setLastName(_newLastName);
            _teacher.setTitle(_newTitle);
            _teacher.setEduRank(_newEduRank);
            _teacher.ExtID = _newExtID;


            sortIt();

            AppForm.getAppForm().getTreeTabControl().SelectedIndex = 1;
        }
Пример #7
0
        public ArrayList calculateAllAllowedRooms(Course dragedCourse, int indexRow, int indexCol)
        {
            ArrayList allowedRooms = HardConstraintChecks.getPossibleRoomsRelCapacity(dragedCourse);

            return(HardConstraintChecks.getPossibleRoomsRelTimeSlot(allowedRooms, indexRow, indexCol));
        }
Пример #8
0
        public static ArrayList findAllFreeTimeSlots(Course dragedCourse)
        {
            ArrayList notPossibleTimeSlots = new ArrayList();
            Teacher   dragedTeacher        = dragedCourse.getTeacher();

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

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

            ArrayList possibleRooms = HardConstraintChecks.getPossibleRoomsRelCapacity(dragedCourse);



            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 edu_program_group, 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);
        }
Пример #9
0
        public override void doit()
        {
            _course.setNumberOfLessonsPerWeek(_newNumOfLessonsPerWeek);
            _course.setNumberOfEnrolledStudents(_newNumOfEnrolledStudents);
            _course.setIsGroup(_newIsGroup);
            _course.setGroupName(_newGroupName);
            _course.setShortName(_newShortName);
            _course.setTeacher(_newTeacher);
            _course.ExtID      = _newExtID;
            _course.CourseType = _newCourseType;

            if (_newCourseType != _oldCourseType)
            {
                updateTSPLabels();

                if (!AppForm.CURR_OCTT_DOC.CourseTypesList.Contains(_newCourseType))
                {
                    AppForm.CURR_OCTT_DOC.CourseTypesList.Add(_newCourseType);
                    AppForm.CURR_OCTT_DOC.CourseTypesList.Sort();
                }

                if (HardConstraintChecks.checkIfCourseTypeIsFreeForDelete(_course))
                {
                    AppForm.CURR_OCTT_DOC.CourseTypesList.Remove(_oldCourseType);
                }
            }


            if (_oldName != _newName || _oldCourseType != _newCourseType)
            {
                _course.setName(_newName);
                updateTSPLabels();
            }

            //update of existing lessons in ListView
            updateListViewText();

            int diff;

            if (_oldNumOfLessonsPerWeek > _newNumOfLessonsPerWeek)
            {
                diff = _oldNumOfLessonsPerWeek - _newNumOfLessonsPerWeek;
                for (int n = 0; n < diff; n++)
                {
                    _ep.removeOneLessonFromUnallocatedLessonsModelAndListView(_course, AppForm.getAppForm().getUnallocatedLessonsListView());
                    AppForm.CURR_OCTT_DOC.decrUnallocatedLessonsCounter(1);
                }
            }
            else if (_newNumOfLessonsPerWeek > _oldNumOfLessonsPerWeek)
            {
                //we have to add lessons
                diff = _newNumOfLessonsPerWeek - _oldNumOfLessonsPerWeek;
                for (int k = 0; k < diff; k++)
                {
                    string [] courseTeacher = new string[2];
                    courseTeacher[0] = _course.getFullName();
                    courseTeacher[1] = _course.getTeacher().getLastName() + " " + _course.getTeacher().getName();

                    ListViewItem lvi = new ListViewItem(courseTeacher);
                    lvi.Tag = _course;
                    lvi.EnsureVisible();
                    AppForm.getAppForm().getUnallocatedLessonsListView().Items.Add(lvi);

                    ListViewItem lvi2 = (ListViewItem)lvi.Clone();
                    _ep.getUnallocatedLessonsList().Add(lvi2);
                    AppForm.CURR_OCTT_DOC.incrUnallocatedLessonsCounter(1);
                }
            }

            _course.setTreeText();
            sortIt();
        }