public override void undo() { AppForm.CURR_OCTT_DOC.CoursesRootNode.Nodes.Add(_epg); foreach (EduProgram ep in _epg.Nodes) { foreach (Course course in ep.Nodes) { foreach (Course deepCourse in course.getCoursesToHoldTogetherList()) { EduProgram deepEP = (EduProgram)deepCourse.Parent; EduProgramGroup deepEPG = (EduProgramGroup)deepEP.Parent; if (deepEPG != _epg) { deepCourse.getCoursesToHoldTogetherList().Add(course); } } } } AppForm.getAppForm().getCoursesTreeView().SelectedNode = _epg; AppForm.CURR_OCTT_DOC.incrUnallocatedLessonsCounter(_numOfUnallocatedLessonsStep); AppForm.getAppForm().getStatusBarPanel2().Text = AppForm.CURR_OCTT_DOC.getNumOfUnallocatedLessonsStatusText(); AppForm.getAppForm().getTreeTabControl().SelectedIndex = 0; }
public override void doit() { if (_cmdType == Constants.ATSF_TIME_SLOT_TYPE_TEACHER) { Teacher teacher = (Teacher)_workingObject; teacher.setAllowedTimeSlots(_newAllowedTimeSlots); AppForm.getAppForm().getTeachersTreeView().SelectedNode = teacher; AppForm.getAppForm().getTreeTabControl().SelectedIndex = 1; } else if (_cmdType == Constants.ATSF_TIME_SLOT_TYPE_EDU_PROGRAM) { EduProgram ep = (EduProgram)_workingObject; ep.setAllowedTimeSlots(_newAllowedTimeSlots); AppForm.getAppForm().getCoursesTreeView().SelectedNode = ep; AppForm.getAppForm().getTreeTabControl().SelectedIndex = 0; } else if (_cmdType == Constants.ATSF_TIME_SLOT_TYPE_EDU_PROGRAM_GROUP) { EduProgramGroup epg = (EduProgramGroup)_workingObject; epg.setAllowedTimeSlots(_newAllowedTimeSlots); AppForm.getAppForm().getCoursesTreeView().SelectedNode = epg; AppForm.getAppForm().getTreeTabControl().SelectedIndex = 0; } else if (_cmdType == Constants.ATSF_TIME_SLOT_TYPE_ROOM) { Room room = (Room)_workingObject; room.setAllowedTimeSlots(_newAllowedTimeSlots); AppForm.getAppForm().getRoomsTreeView().SelectedNode = room; AppForm.getAppForm().getTreeTabControl().SelectedIndex = 2; } }
private static void markNotPossibleTimeSlotsRelEduProgramGroup(EduProgramGroup epg, TimeSlotPanel tsp, ArrayList notPossibleTimeSlots) { if (epg.getAllowedTimeSlots()[tsp.getIndexRow(), tsp.getIndexCol()] == false) { tsp.BackColor = System.Drawing.Color.DarkSalmon; tsp.AllowDrop = false; notPossibleTimeSlots.Add(tsp); } }
private void sortIt() { EduProgramGroup myEPG = (EduProgramGroup)_ep.Parent; myEPG.Nodes.Remove(_ep); myEPG.Nodes.Add(_ep); AppForm.getAppForm().getCoursesTreeView().SelectedNode.EnsureVisible(); AppForm.getAppForm().getCoursesTreeView().SelectedNode = _ep; }
public ChangeEduProgramGroupDataCmd(EduProgramGroup epg, string newName, string newExtID) { _epg = epg; _oldName = _epg.getName(); _newName = newName; _oldExtID = _epg.ExtID; _newExtID = newExtID; }
private void Form_Closing(Object sender, CancelEventArgs e) { if (this.DialogResult == DialogResult.OK) { if (_epg == null) { if (!EduProgramGroup.checkNewName(_epgNameTextBox.Text)) { e.Cancel = true; string message2 = RES_MANAGER.GetString("Form_Closing.msb.epgnotcreated.message"); string caption2 = RES_MANAGER.GetString("Form_Closing.msb.epgnotcreated.caption"); MessageBoxButtons buttons2 = MessageBoxButtons.OK; MessageBox.Show(this, message2, caption2, buttons2, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); } else { e.Cancel = false; } } else { if (_epgNameTextBox.Text.ToUpper() != _epg.getName().ToUpper()) { if (!EduProgramGroup.checkNewName(_epgNameTextBox.Text)) { e.Cancel = true; string message2 = RES_MANAGER.GetString("Form_Closing.msb.epgdatanotchanged.message"); string caption2 = RES_MANAGER.GetString("Form_Closing.msb.epgdatanotchanged.caption"); MessageBoxButtons buttons2 = MessageBoxButtons.OK; MessageBox.Show(this, message2, caption2, buttons2, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); } else { e.Cancel = false; } } } } }
public ChangeAllowedTimeSlotsCmd(Object workingObject, int cmdType, AllowedTimeSlotsForm atsf) { _atsf = atsf; _cmdType = cmdType; _workingObject = workingObject; if (_cmdType == Constants.ATSF_TIME_SLOT_TYPE_TEACHER) { Teacher teacher = (Teacher)_workingObject; _oldAllowedTimeSlots = teacher.getAllowedTimeSlots(); } else if (_cmdType == Constants.ATSF_TIME_SLOT_TYPE_EDU_PROGRAM) { EduProgram ep = (EduProgram)_workingObject; _oldAllowedTimeSlots = ep.getAllowedTimeSlots(); } else if (_cmdType == Constants.ATSF_TIME_SLOT_TYPE_EDU_PROGRAM_GROUP) { EduProgramGroup epg = (EduProgramGroup)_workingObject; _oldAllowedTimeSlots = epg.getAllowedTimeSlots(); } else if (_cmdType == Constants.ATSF_TIME_SLOT_TYPE_ROOM) { Room room = (Room)_workingObject; _oldAllowedTimeSlots = room.getAllowedTimeSlots(); } _newAllowedTimeSlots = (bool [, ])_oldAllowedTimeSlots.Clone(); foreach (Label edotlW in _atsf.getMainPanel().Controls) { if (edotlW.GetType().FullName == "OpenCTT.EnableDisableOneTermLabel") { EnableDisableOneTermLabel edotl = (EnableDisableOneTermLabel)edotlW; if (edotl.getIsTermEnabled()) { _newAllowedTimeSlots[edotl.getIndexRow(), edotl.getIndexCol()] = true; } else { _newAllowedTimeSlots[edotl.getIndexRow(), edotl.getIndexCol()] = false; } } } }
private void checkChangeEduProgramGroup(CancelEventArgs e) { EduProgramGroup epg = (EduProgramGroup)_workingObject; bool allowed = true; foreach (Label edotlW in _mainPanel.Controls) { if (edotlW.GetType().FullName == "OpenCTT.EnableDisableOneTermLabel") { EnableDisableOneTermLabel edotl = (EnableDisableOneTermLabel)edotlW; if (!edotl.getIsTermEnabled()) { foreach (EduProgram ep in epg.Nodes) { ArrayList [,] mytt = ep.getTimetable(); if (!(mytt[edotl.getIndexRow(), edotl.getIndexCol()] == null || mytt[edotl.getIndexRow(), edotl.getIndexCol()].Count == 0)) { allowed = false; goto raus; } } } } } raus: if (!allowed) { e.Cancel = true; string message1 = RES_MANAGER.GetString("checkChangeEduProgramGroup.msb.notsuccessfull.message"); string caption1 = RES_MANAGER.GetString("checkChangeEduProgramGroup.msb.notsuccessfull.caption"); MessageBoxButtons buttons1 = MessageBoxButtons.OK; MessageBox.Show(this, message1, caption1, buttons1, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); } else { e.Cancel = false; } }
private void Form_Load(object sender, System.EventArgs e) { _topLabel.Text = RES_MANAGER.GetString("Form_Load._topLabel.Text1") + " '" + _course.getFullName() + "' " + RES_MANAGER.GetString("Form_Load._topLabel.Text2"); if (_course.getCoursesToHoldTogetherList() != null) { _thtWorkingList = (ArrayList)_course.getCoursesToHoldTogetherList().Clone(); } foreach (Course tempCourse in _thtWorkingList) { string [] epgAndEpAndCourse = new string[3]; EduProgram ep = (EduProgram)tempCourse.Parent; EduProgramGroup epg = (EduProgramGroup)ep.Parent; String textEduProgram = ep.getName() + ", " + ep.getCode() + ", " + ep.getSemester() + ". " + RES_MANAGER.GetString("Form_Load.listView.textEduProgram.sem"); epgAndEpAndCourse[0] = epg.getName(); epgAndEpAndCourse[1] = textEduProgram; epgAndEpAndCourse[2] = tempCourse.getFullName(); ListViewItem newLvi = new ListViewItem(epgAndEpAndCourse); newLvi.Tag = tempCourse; _thtCoursesListView.Items.Add(newLvi); } this.fillPickListView(); if (_isFormDisabled) { this._thtPickListView.DoubleClick -= new System.EventHandler(this._thtPickListView_DoubleClick); this._thtCoursesListView.DoubleClick -= new System.EventHandler(this._thtCoursesListView_DoubleClick); this.Text += " - READ ONLY"; _okButton.Enabled = false; } }
private ArrayList getUnallowedTSForEpg(EduProgramGroup epg) { ArrayList epgUnallowedTS = new ArrayList(); int wtuts = 0; for (int k = 0; k < AppForm.CURR_OCTT_DOC.getNumberOfDays(); k++) { for (int j = 0; j < AppForm.CURR_OCTT_DOC.IncludedTerms.Count; j++) { wtuts++; if (epg.getAllowedTimeSlots()[j, k] == false) { for (int qq = 0; qq < NUM_OF_ROOMS; qq++) { epgUnallowedTS.Add(qq * NUM_OF_SLOTS_PER_ROOM + wtuts); } } } } return(epgUnallowedTS); }
public AddEduProgramCmd(EduProgramGroup epg, string name, string semester, string code, string extID) { _epg = epg; _eduProgram = new EduProgram(name, semester, code, extID); }
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 void importDataForTTStart(DataSet ds) { AppForm.CURR_OCTT_DOC = new OCTTDocument(); DataTable dtDocumentProperties = ds.Tables["DocumentProperties"]; DataRow drDP = dtDocumentProperties.Rows[0]; AppForm.CURR_OCTT_DOC.EduInstitutionName = (string)drDP["DocEduInstitutionName"]; AppForm.CURR_OCTT_DOC.SchoolYear = (string)drDP["DocSchoolYear"]; AppForm.CURR_OCTT_DOC.DocumentType = System.Convert.ToInt32(drDP["DocType"]); AppForm.CURR_OCTT_DOC.DocumentVersion = (string)drDP["DocVersion"]; //included days DataTable dtIncludedDays = ds.Tables["IncludedDays"]; ArrayList dl = new ArrayList(); foreach (DataRow dr in dtIncludedDays.Rows) { int d = System.Convert.ToInt16(dr["DayIndexInWeek"]) - 1; dl.Add(d); } for (int n = 0; n < 7; n++) { if (dl.Contains(n)) { AppForm.CURR_OCTT_DOC.setIsDayIncluded(n, true); } else { AppForm.CURR_OCTT_DOC.setIsDayIncluded(n, false); } } //included terms DataTable dtIncludedTerms = ds.Tables["IncludedTerms"]; int[] oneT; AppForm.CURR_OCTT_DOC.IncludedTerms.Clear(); foreach (DataRow dr in dtIncludedTerms.Rows) { oneT = new int[4]; oneT[0] = System.Convert.ToInt32(dr["StartH"]); oneT[1] = System.Convert.ToInt32(dr["StartM"]); oneT[2] = System.Convert.ToInt32(dr["EndH"]); oneT[3] = System.Convert.ToInt32(dr["EndM"]); AppForm.CURR_OCTT_DOC.IncludedTerms.Add(oneT); } //teachers DataTable dtTeachers = ds.Tables["Teachers"]; Hashtable htTeachers = new Hashtable(); foreach (DataRow dr in dtTeachers.Rows) { int tID = System.Convert.ToInt16(dr["ID"]); Teacher teacher = new Teacher((string)dr["Name"], (string)dr["Lastname"], (string)dr["Title"], (string)dr["EduRank"], (string)dr["ExtId"]); AppForm.CURR_OCTT_DOC.TeachersRootNode.Nodes.Add(teacher); htTeachers.Add(tID, teacher); if (!AppForm.CURR_OCTT_DOC.TeacherTitlesList.Contains(teacher.getTitle())) { AppForm.CURR_OCTT_DOC.TeacherTitlesList.Add(teacher.getTitle()); } if (!AppForm.CURR_OCTT_DOC.TeacherEduRanksList.Contains(teacher.getEduRank())) { AppForm.CURR_OCTT_DOC.TeacherEduRanksList.Add(teacher.getEduRank()); } } AppForm.CURR_OCTT_DOC.TeacherTitlesList.Sort(); AppForm.CURR_OCTT_DOC.TeacherEduRanksList.Sort(); AppForm.CURR_OCTT_DOC.TeachersRootNode.ExpandAll(); //rooms DataTable dtRooms = ds.Tables["Rooms"]; foreach (DataRow dr in dtRooms.Rows) { Room room = new Room((string)dr["Name"], System.Convert.ToInt32(dr["Capacity"]), (string)dr["ExtId"]); AppForm.CURR_OCTT_DOC.RoomsRootNode.Nodes.Add(room); } AppForm.CURR_OCTT_DOC.RoomsRootNode.Expand(); //EPGs, EPs, courses DataTable dtEduProgramGroups = ds.Tables["EduProgramGroups"]; DataTable dtEduPrograms = ds.Tables["EduPrograms"]; DataTable dtCourses = ds.Tables["Courses"]; foreach (DataRow drepg in dtEduProgramGroups.Rows) { string name = (string)drepg["Name"]; string extid; if (drepg["ExtId"] != null) { extid = (string)drepg["ExtId"]; } else { extid = ""; } EduProgramGroup newEPG = new EduProgramGroup(name, extid); AppForm.CURR_OCTT_DOC.CoursesRootNode.Nodes.Add(newEPG); DataRow[] drep = drepg.GetChildRows(ds.Relations["EPG_EP"]); foreach (DataRow r in drep) { string semester; string code; string extidop; if (r["Semester"] != null) { semester = (string)r["Semester"]; } else { semester = ""; } if (r["Code"] != null) { code = (string)r["Code"]; } else { code = ""; } if (r["ExtId"] != null) { extidop = (string)r["ExtId"]; } else { extidop = ""; } EduProgram newEP = new EduProgram((string)r["Name"], semester, code, extidop); newEPG.Nodes.Add(newEP); DataRow[] drc = r.GetChildRows(ds.Relations["EP_Courses"]); foreach (DataRow rc in drc) { int teacherID; string groupName; string extidc; int numoflessperweek; int numofenrstud; string courseType; Teacher myTeacher; teacherID = System.Convert.ToInt32(rc["TeacherID"]); myTeacher = (Teacher)htTeachers[teacherID]; numoflessperweek = System.Convert.ToInt32(rc["NumOfLessPerWeek"]); numofenrstud = System.Convert.ToInt32(rc["NumOfEnrolledStud"]); courseType = (string)rc["CourseType"]; if (rc["GroupName"] != null) { groupName = System.Convert.ToString(rc["GroupName"]); } else { groupName = ""; } bool isGroup; if (groupName == null || groupName == "") { isGroup = false; } else { isGroup = true; } if (rc["ExtId"] != null) { extidc = (string)rc["ExtId"]; } else { extidc = ""; } Course newCourse = new Course((string)rc["Name"], (string)rc["ShortName"], myTeacher, numoflessperweek, numofenrstud, isGroup, groupName, extidc, courseType); newEP.Nodes.Add(newCourse); if (!AppForm.CURR_OCTT_DOC.CourseTypesList.Contains(courseType)) { AppForm.CURR_OCTT_DOC.CourseTypesList.Add(courseType); } AppForm.CURR_OCTT_DOC.incrUnallocatedLessonsCounter(numoflessperweek); for (int k = 0; k < numoflessperweek; k++) { ListViewItem lvi = new ListViewItem(); lvi.Tag = newCourse; newEP.getUnallocatedLessonsList().Add(lvi); } } } AppForm.CURR_OCTT_DOC.CoursesRootNode.Expand(); foreach (EduProgramGroup epg in AppForm.CURR_OCTT_DOC.CoursesRootNode.Nodes) { epg.Expand(); } AppForm.CURR_OCTT_DOC.CourseTypesList.Sort(); AppForm.getAppForm().getStatusBarPanel2().Text = AppForm.CURR_OCTT_DOC.getNumOfUnallocatedLessonsStatusText(); } AppForm.getAppForm().doNewDocAction(); }
public DeleteEduProgramGroupCmd(EduProgramGroup epg, int numOfUnallocatedLessonsStep) { _epg = epg; _numOfUnallocatedLessonsStep = numOfUnallocatedLessonsStep; }
public AddEduProgramGroupCmd(string name, string extID) { _newEPG = new EduProgramGroup(name, extID); }
private AGlobal prepareDataForAutomatedTT() { _coursesMapping = new Hashtable(); int[] buildings = new int[1]; //to do buildings[0] = 0; // to do NUM_OF_ROOMS = AppForm.CURR_OCTT_DOC.RoomsRootNode.Nodes.Count; ROOM_CAPACITIES = new int[NUM_OF_ROOMS]; int[] roomBuildings = new int[NUM_OF_ROOMS]; ALL_POSSIBLE_TS = new ArrayList(); NUM_OF_SLOTS_PER_ROOM = AppForm.CURR_OCTT_DOC.getNumberOfDays() * AppForm.CURR_OCTT_DOC.IncludedTerms.Count; // _sortedRoomsRelCapacityList = this.sortRoomsRelCapacity(); int n = 0; foreach (Room room in _sortedRoomsRelCapacityList) { ROOM_CAPACITIES[n] = room.getRoomCapacity(); roomBuildings[n] = buildings[0]; //to do int wts = 0; for (int k = 0; k < AppForm.CURR_OCTT_DOC.getNumberOfDays(); k++) { for (int j = 0; j < AppForm.CURR_OCTT_DOC.IncludedTerms.Count; j++) { wts++; if (room.getAllowedTimeSlots()[j, k] == true) { ALL_POSSIBLE_TS.Add(n * NUM_OF_SLOTS_PER_ROOM + wts); } } } n++; } //prepare educational programs and courses Hashtable tempUsedTeachers = new Hashtable(); Hashtable tempUsedEduPrograms = new Hashtable(); ArrayList allACoursesList = new ArrayList(); foreach (EduProgramGroup epg in AppForm.CURR_OCTT_DOC.CoursesRootNode.Nodes) { foreach (EduProgram ep in epg.Nodes) { foreach (Course course in ep.Nodes) { if (!course.TempIsPreparedForAutomatedTT) { ArrayList courseTotalPossibleTS = this.getPossibleTSForCourse(course); Teacher teacher = (Teacher)course.getTeacher(); int teacherIndex = AppForm.CURR_OCTT_DOC.TeachersRootNode.Nodes.IndexOf(teacher); ATeacher at; if (!tempUsedTeachers.Contains(teacherIndex)) { at = new ATeacher(); tempUsedTeachers.Add(teacherIndex, at); //1 object[] args1 = new object[2]; args1[1] = Settings.SC_TEACHER_MAX_HOURS_DAILY_WEIGHT; if (teacher.SCMaxHoursDaily != -1) { args1[0] = teacher.SCMaxHoursDaily; } else { args1[0] = SCBaseSettings.TEACHER_MAX_HOURS_DAILY; } SCTeacherMaxHoursDaily sctmhd = new SCTeacherMaxHoursDaily(at, args1, null); at.MySoftConstraints.Add(sctmhd); //2 object[] args2 = new object[2]; args2[1] = Settings.SC_TEACHER_MAX_HOURS_CONTINUOUSLY_WEIGHT; if (teacher.SCMaxHoursContinously != -1) { args2[0] = teacher.SCMaxHoursContinously; } else { args2[0] = SCBaseSettings.TEACHER_MAX_HOURS_CONTINUOUSLY; } SCTeacherMaxHoursContinuously sctmhc = new SCTeacherMaxHoursContinuously(at, args2, null); at.MySoftConstraints.Add(sctmhc); //3 object[] args3 = new object[2]; args3[1] = Settings.SC_TEACHER_MAX_DAYS_PER_WEEK_WEIGHT; if (teacher.SCMaxDaysPerWeek != -1) { args3[0] = teacher.SCMaxDaysPerWeek; } else { args3[0] = SCBaseSettings.TEACHER_MAX_DAYS_PER_WEEK; } SCTeacherMaxDaysPerWeek sctmdpw = new SCTeacherMaxDaysPerWeek(at, args3, null); at.MySoftConstraints.Add(sctmdpw); } else { at = (ATeacher)tempUsedTeachers[teacherIndex]; } // AEduProgram aep; int epgIndex = AppForm.CURR_OCTT_DOC.CoursesRootNode.Nodes.IndexOf(epg); int epIndex = epg.Nodes.IndexOf(ep); string myKey = epgIndex + "," + epIndex; if (!tempUsedEduPrograms.Contains(myKey)) { aep = new AEduProgram(); tempUsedEduPrograms.Add(myKey, aep); } else { aep = (AEduProgram)tempUsedEduPrograms[myKey]; } // bool[] boolPossTS = this.convertTSListToBoolArray(courseTotalPossibleTS); ACourse ac = new ACourse(aep, at, course.getGroupName(), boolPossTS, course.getReportName()); allACoursesList.Add(ac); aep.MyCourses.Add(ac); if (course.getGroupName() != null && course.getGroupName() != "") { if (!aep.MyIncludedGroups.Contains(course.getGroupName())) { aep.MyIncludedGroups.Add(course.getGroupName()); } } //sc for course if (course.getNumberOfLessonsPerWeek() > 1) { int numOfLessPerWeek = course.getNumberOfLessonsPerWeek(); string clKey; if (numOfLessPerWeek <= 9) { clKey = numOfLessPerWeek.ToString(); } else { clKey = "default"; } int[] lessonBlocksParam; if (course.SCLessonBlocksParameters != null) { lessonBlocksParam = course.SCLessonBlocksParameters; } else { lessonBlocksParam = (int[])SCBaseSettings.COURSE_LESSON_BLOCKS[clKey]; } object[] args = new object[2]; args[0] = lessonBlocksParam; args[1] = Settings.SC_COURSE_LESSON_BLOCKS_WEIGHT; SCCourseLessonBlocks scclb = new SCCourseLessonBlocks(ac, args, null); ac.MySoftConstraints.Add(scclb); } // //courses mapping int courseIndex = ep.Nodes.IndexOf(course); _coursesMapping.Add(epgIndex + "," + epIndex + "," + courseIndex, ac); // ALessonNode alnode; int numOfNodesToSolve = 0; if (_fromCurrentStateRadioButton.Checked) { numOfNodesToSolve = course.getNumberOfUnallocatedLessons(); ArrayList myFixedTSList = course.getTimeSlotsOfMyAllocatedLessons(); foreach (int fts in myFixedTSList) { //fixed nodes alnode = new ALessonNode(ac, fts, NUM_OF_SLOTS_PER_ROOM * NUM_OF_ROOMS); alnode.PositionInGlobalBestSolution = fts; ac.MyFixedLessonNodes.Add(alnode); at.MyFixedLessonNodes.Add(alnode); } } else if (_fromStartRadioButton.Checked) { numOfNodesToSolve = course.getNumberOfLessonsPerWeek(); } for (int nnode = 0; nnode < numOfNodesToSolve; nnode++) { //nodes to solve alnode = new ALessonNode(ac, NUM_OF_SLOTS_PER_ROOM * NUM_OF_ROOMS); ac.MyAllLessonNodesForAllocation.Add(alnode); at.MyTempAllocatedLessonNodes.Add(alnode); } if (course.getCoursesToHoldTogetherList().Count > 0) { foreach (Course htCourse in course.getCoursesToHoldTogetherList()) { prepareDataForHTCourse(htCourse, at, ac, tempUsedEduPrograms, allACoursesList); } } course.TempIsPreparedForAutomatedTT = true; } } //end of course loop } } //end epg loop //reset values for course.TempIsPreparedForAutomatedTT to false foreach (EduProgramGroup epg in AppForm.CURR_OCTT_DOC.CoursesRootNode.Nodes) { foreach (EduProgram ep in epg.Nodes) { foreach (Course course in ep.Nodes) { course.TempIsPreparedForAutomatedTT = false; } } } ArrayList allATeachersList = new ArrayList(); foreach (ATeacher ateacher in tempUsedTeachers.Values) { allATeachersList.Add(ateacher); } ArrayList allAEduProgramsList = new ArrayList(); foreach (AEduProgram aEduProg in tempUsedEduPrograms.Values) { allAEduProgramsList.Add(aEduProg); } //sc for ep foreach (string thisKey in tempUsedEduPrograms.Keys) { AEduProgram aep = (AEduProgram)tempUsedEduPrograms[thisKey]; char[] separator = new char[1]; separator[0] = ','; string[] parts = thisKey.Split(separator, 2); int epgIndex = Int32.Parse(parts[0]); int epIndex = Int32.Parse(parts[1]); EduProgramGroup epg = (EduProgramGroup)AppForm.CURR_OCTT_DOC.CoursesRootNode.Nodes[epgIndex]; EduProgram ep = (EduProgram)epg.Nodes[epIndex]; // if (aep.MyIncludedGroups.Count > 0) { foreach (string groupName in aep.MyIncludedGroups) { //1 object[] args1 = new object[3]; args1[2] = Settings.SC_STUDENT_MAX_HOURS_DAILY_WEIGHT; args1[1] = groupName; if (ep.SCStudentMaxHoursDaily != -1) { args1[0] = ep.SCStudentMaxHoursDaily; } else { args1[0] = SCBaseSettings.EP_STUDENT_MAX_HOURS_DAILY; } SCStudentMaxHoursDaily scsmhd = new SCStudentMaxHoursDaily(aep, args1, null); aep.MySoftConstraints.Add(scsmhd); //2 object[] args2 = new object[3]; args2[2] = Settings.SC_STUDENT_NO_GAPS_WEIGHT; args2[1] = groupName; if (ep.SCStudentNoGapsGapIndicator != -1) { args2[0] = ep.SCStudentNoGapsGapIndicator; } else { args2[0] = SCBaseSettings.EP_STUDENT_NO_GAPS_GAP_INDICATOR; } SCStudentNoGaps scsng = new SCStudentNoGaps(aep, args2, null); aep.MySoftConstraints.Add(scsng); //3 object[] args3 = new object[3]; args3[2] = Settings.SC_STUDENT_MAX_HOURS_CONTINUOUSLY_WEIGHT; args3[1] = groupName; if (ep.SCStudentMaxHoursContinuously != -1) { args3[0] = ep.SCStudentMaxHoursContinuously; } else { args3[0] = SCBaseSettings.EP_STUDENT_MAX_HOURS_CONTINUOUSLY; } SCStudentMaxHoursContinuously scsmhc = new SCStudentMaxHoursContinuously(aep, args3, null); aep.MySoftConstraints.Add(scsmhc); //4 object[] args4 = new object[3]; args4[2] = Settings.SC_TEACHER_MAX_DAYS_PER_WEEK_WEIGHT; args4[1] = groupName; if (ep.SCStudentMaxDaysPerWeek != -1) { args4[0] = ep.SCStudentMaxDaysPerWeek; } else { args4[0] = SCBaseSettings.EP_STUDENT_MAX_DAYS_PER_WEEK; } SCStudentMaxDaysPerWeek scsmdpw = new SCStudentMaxDaysPerWeek(aep, args4, null); aep.MySoftConstraints.Add(scsmdpw); //5 object[] args5 = new object[3]; args5[2] = Settings.SC_STUDENT_PREFERRED_START_TIME_PERIOD_WEIGHT; args5[1] = groupName; if (ep.SCStudentPreferredStartTimePeriod != -1) { args5[0] = ep.SCStudentPreferredStartTimePeriod; } else { args5[0] = SCBaseSettings.EP_STUDENT_PREFERRED_START_TIME_PERIOD; } SCStudentPreferredStartTimePeriod scspstp = new SCStudentPreferredStartTimePeriod(aep, args5, null); aep.MySoftConstraints.Add(scspstp); } } else { //1 object[] args1 = new object[3]; args1[2] = Settings.SC_STUDENT_MAX_HOURS_DAILY_WEIGHT; args1[1] = null; if (ep.SCStudentMaxHoursDaily != -1) { args1[0] = ep.SCStudentMaxHoursDaily; } else { args1[0] = SCBaseSettings.EP_STUDENT_MAX_HOURS_DAILY; } SCStudentMaxHoursDaily scsmhd = new SCStudentMaxHoursDaily(aep, args1, null); aep.MySoftConstraints.Add(scsmhd); //2 object[] args2 = new object[3]; args2[2] = Settings.SC_STUDENT_NO_GAPS_WEIGHT; args2[1] = null; if (ep.SCStudentNoGapsGapIndicator != -1) { args2[0] = ep.SCStudentNoGapsGapIndicator; } else { args2[0] = SCBaseSettings.EP_STUDENT_NO_GAPS_GAP_INDICATOR; } SCStudentNoGaps scsng = new SCStudentNoGaps(aep, args2, null); aep.MySoftConstraints.Add(scsng); //3 object[] args3 = new object[3]; args3[2] = Settings.SC_STUDENT_MAX_HOURS_CONTINUOUSLY_WEIGHT; args3[1] = null; if (ep.SCStudentMaxHoursContinuously != -1) { args3[0] = ep.SCStudentMaxHoursContinuously; } else { args3[0] = SCBaseSettings.EP_STUDENT_MAX_HOURS_CONTINUOUSLY; } SCStudentMaxHoursContinuously scsmhc = new SCStudentMaxHoursContinuously(aep, args3, null); aep.MySoftConstraints.Add(scsmhc); //4 object[] args4 = new object[3]; args4[2] = Settings.SC_TEACHER_MAX_DAYS_PER_WEEK_WEIGHT; args4[1] = null; if (ep.SCStudentMaxDaysPerWeek != -1) { args4[0] = ep.SCStudentMaxDaysPerWeek; } else { args4[0] = SCBaseSettings.EP_STUDENT_MAX_DAYS_PER_WEEK; } SCStudentMaxDaysPerWeek scsmdpw = new SCStudentMaxDaysPerWeek(aep, args4, null); aep.MySoftConstraints.Add(scsmdpw); //5 object[] args5 = new object[3]; args5[2] = Settings.SC_STUDENT_PREFERRED_START_TIME_PERIOD_WEIGHT; args5[1] = null; if (ep.SCStudentPreferredStartTimePeriod != -1) { args5[0] = ep.SCStudentPreferredStartTimePeriod; } else { args5[0] = SCBaseSettings.EP_STUDENT_PREFERRED_START_TIME_PERIOD; } SCStudentPreferredStartTimePeriod scspstp = new SCStudentPreferredStartTimePeriod(aep, args5, null); aep.MySoftConstraints.Add(scspstp); } } Control.CheckForIllegalCrossThreadCalls = false; //Console.WriteLine(allATeachersList.Count); //Console.WriteLine(allAEduProgramsList.Count); AGlobal ag = new AGlobal(AppForm.CURR_OCTT_DOC.getNumberOfDays(), AppForm.CURR_OCTT_DOC.IncludedTerms.Count, NUM_OF_ROOMS, ROOM_CAPACITIES, roomBuildings, buildings, allACoursesList, allATeachersList, allAEduProgramsList); return(ag); }
public EPGPropertiesForm(EduProgramGroup epg) : this() { _epg = epg; _epgNameTextBox.Text = epg.getName(); _extIDTextBox.Text = epg.ExtID; }
public override void undo() { AppForm.CURR_OCTT_DOC.setIsDayIncluded(_guiIndex, true); ModelOperations.addDayInModel(_dayIndexInModel); ArrayList epgURList = _undoRedoLists[0]; ArrayList epURList = _undoRedoLists[1]; ArrayList teachersURList = _undoRedoLists[2]; ArrayList roomsURList = _undoRedoLists[3]; foreach (object [] oneItem in epgURList) { EduProgramGroup epg = (EduProgramGroup)oneItem[0]; bool [,] epgAllowedTimeSlotsUR = (bool[, ])oneItem[1]; for (int j = 0; j < AppForm.CURR_OCTT_DOC.IncludedTerms.Count; j++) { epg.getAllowedTimeSlots()[j, _dayIndexInModel] = epgAllowedTimeSlotsUR[j, 0]; } } foreach (object [] oneItem in epURList) { EduProgram ep = (EduProgram)oneItem[0]; bool [,] epAllowedTimeSlotsUR = (bool[, ])oneItem[1]; for (int j = 0; j < AppForm.CURR_OCTT_DOC.IncludedTerms.Count; j++) { ep.getAllowedTimeSlots()[j, _dayIndexInModel] = epAllowedTimeSlotsUR[j, 0]; } } foreach (object [] oneItem in teachersURList) { Teacher teacher = (Teacher)oneItem[0]; bool [,] teacherAllowedTimeSlotsUR = (bool[, ])oneItem[1]; for (int j = 0; j < AppForm.CURR_OCTT_DOC.IncludedTerms.Count; j++) { teacher.getAllowedTimeSlots()[j, _dayIndexInModel] = teacherAllowedTimeSlotsUR[j, 0]; } } foreach (object [] oneItem in roomsURList) { Room room = (Room)oneItem[0]; bool [,] roomAllowedTimeSlotsUR = (bool[, ])oneItem[1]; for (int j = 0; j < AppForm.CURR_OCTT_DOC.IncludedTerms.Count; j++) { room.getAllowedTimeSlots()[j, _dayIndexInModel] = roomAllowedTimeSlotsUR[j, 0]; } } AppForm.getAppForm().getTreeTabControl().SelectedIndexChanged -= new System.EventHandler(AppForm.getAppForm().treeTabControl_SelectedIndexChanged); AppForm.getAppForm().getTreeTabControl().SelectedIndex = _tabIndex; AppForm.getAppForm().getTreeTabControl().SelectedIndexChanged += new System.EventHandler(AppForm.getAppForm().treeTabControl_SelectedIndexChanged); AppForm.getAppForm().refreshGUIAfterDaysTermsChange(false); if (_tabIndex == 0) { 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) { 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) { 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); } }
private ArrayList getUnallowedTSForCourseHT(Course course) { EduProgram ep = (EduProgram)course.Parent; EduProgramGroup epg = (EduProgramGroup)ep.Parent; ArrayList epgUnallowedTS = this.getUnallowedTSForEpg(epg); ArrayList epUnallowedTS = this.getUnallowedTSForEp(ep); ArrayList courseTeacherUnallowedTS = this.getUnallowedTSForTeacher(course.getTeacher()); ArrayList courseUnallowedTS = new ArrayList(); ArrayList crrList = course.getAllowedRoomsList(); ArrayList crrIntList = new ArrayList(); if (crrList != null && crrList.Count > 0) { foreach (Room room in crrList) { int roomIndex = _sortedRoomsRelCapacityList.IndexOf(room); crrIntList.Add(roomIndex); } } if (crrIntList.Count > 0) { for (int rsroom = 0; rsroom < NUM_OF_ROOMS; rsroom++) { if (!crrIntList.Contains(rsroom)) { for (int rs = 0; rs < NUM_OF_SLOTS_PER_ROOM; rs++) { int newitem = rsroom * NUM_OF_SLOTS_PER_ROOM + rs + 1; courseUnallowedTS.Add(newitem); } } } } ArrayList totalUnallowedTSList = new ArrayList(); foreach (int ts in epgUnallowedTS) { if (!totalUnallowedTSList.Contains(ts)) { totalUnallowedTSList.Add(ts); } } foreach (int ts in epUnallowedTS) { if (!totalUnallowedTSList.Contains(ts)) { totalUnallowedTSList.Add(ts); } } foreach (int ts in courseTeacherUnallowedTS) { if (!totalUnallowedTSList.Contains(ts)) { totalUnallowedTSList.Add(ts); } } foreach (int ts in courseUnallowedTS) { if (!totalUnallowedTSList.Contains(ts)) { totalUnallowedTSList.Add(ts); } } return(totalUnallowedTSList); }
private ArrayList getPossibleTSForCourse(Course course) { EduProgram ep = (EduProgram)course.Parent; EduProgramGroup epg = (EduProgramGroup)ep.Parent; ArrayList epgUnallowedTS = this.getUnallowedTSForEpg(epg); ArrayList epUnallowedTS = this.getUnallowedTSForEp(ep); ArrayList courseTeacherUnallowedTS = this.getUnallowedTSForTeacher(course.getTeacher()); //Console.WriteLine("Course: " + course.getName() + " TeacherTotalUnallowedTS: " + courseTeacherUnallowedTS.Count); ArrayList courseUnallowedTS = new ArrayList(); ArrayList crrList = course.getAllowedRoomsList(); ArrayList crrIntList = new ArrayList(); if (crrList != null && crrList.Count > 0) { foreach (Room room in crrList) { int roomIndex = _sortedRoomsRelCapacityList.IndexOf(room); crrIntList.Add(roomIndex); } } if (crrIntList.Count > 0) { for (int rsroom = 0; rsroom < NUM_OF_ROOMS; rsroom++) { if (!crrIntList.Contains(rsroom)) { for (int rs = 0; rs < NUM_OF_SLOTS_PER_ROOM; rs++) { int newitem = rsroom * NUM_OF_SLOTS_PER_ROOM + rs + 1; courseUnallowedTS.Add(newitem); } } } } // int numOfSeatsNeeded = course.getNumberOfEnrolledStudents(); ArrayList allUnallowedTSHT = new ArrayList(); if (course.getCoursesToHoldTogetherList() != null && course.getCoursesToHoldTogetherList().Count > 0) { //Console.WriteLine(course.getCoursesToHoldTogetherList().Count); foreach (Course htCourse in course.getCoursesToHoldTogetherList()) { numOfSeatsNeeded += htCourse.getNumberOfEnrolledStudents(); ArrayList oneHtTS = this.getUnallowedTSForCourseHT(htCourse); foreach (int ts in oneHtTS) { if (!allUnallowedTSHT.Contains(ts)) { allUnallowedTSHT.Add(ts); } } } } ArrayList totalPossibleTSList = new ArrayList(); foreach (int ts in ALL_POSSIBLE_TS) { int roomIndex = (int)(ts - 1) / NUM_OF_SLOTS_PER_ROOM; //Console.WriteLine(ts+" "+roomIndex); if (numOfSeatsNeeded <= ROOM_CAPACITIES[roomIndex]) { if (!epgUnallowedTS.Contains(ts) && !epUnallowedTS.Contains(ts) && !courseTeacherUnallowedTS.Contains(ts) && !courseUnallowedTS.Contains(ts) && !allUnallowedTSHT.Contains(ts)) { totalPossibleTSList.Add(ts); } } } //Console.WriteLine(totalPossibleTSList.Count); return(totalPossibleTSList); }
public DeleteEduProgramCmd(EduProgram ep) { _ep = ep; _epg = (EduProgramGroup)_ep.Parent; }
private void prepareDataForHTCourse(Course htCourse, ATeacher at, ACourse startACourse, Hashtable tempUsedEduPrograms, ArrayList allACoursesList) { if (!htCourse.TempIsPreparedForAutomatedTT) { ArrayList courseTotalPossibleTS = this.getPossibleTSForCourse(htCourse); EduProgram ep = (EduProgram)htCourse.Parent; EduProgramGroup epg = (EduProgramGroup)ep.Parent; // AEduProgram aep; int epgIndex = AppForm.CURR_OCTT_DOC.CoursesRootNode.Nodes.IndexOf(epg); int epIndex = epg.Nodes.IndexOf(ep); string myKey = epgIndex + "," + epIndex; if (!tempUsedEduPrograms.Contains(myKey)) { aep = new AEduProgram(); tempUsedEduPrograms.Add(myKey, aep); } else { aep = (AEduProgram)tempUsedEduPrograms[myKey]; } // bool[] boolPossTS = this.convertTSListToBoolArray(courseTotalPossibleTS); ACourse ac = new ACourse(aep, at, htCourse.getGroupName(), /*courseTotalPossibleTS,*/ boolPossTS, htCourse.getReportName()); ac.IsHTCourse = true; allACoursesList.Add(ac); aep.MyCourses.Add(ac); startACourse.ACoursesHT.Add(ac);//add HT course //courses mapping int courseIndex = ep.Nodes.IndexOf(htCourse); _coursesMapping.Add(epgIndex + "," + epIndex + "," + courseIndex, ac); // ALessonNode alnode; int numOfNodesToSolve = 0; if (_fromCurrentStateRadioButton.Checked) { numOfNodesToSolve = htCourse.getNumberOfUnallocatedLessons(); ArrayList myFixedTSList = htCourse.getTimeSlotsOfMyAllocatedLessons(); foreach (int fts in myFixedTSList) { //fixed nodes alnode = new ALessonNode(ac, fts, NUM_OF_SLOTS_PER_ROOM * NUM_OF_ROOMS); alnode.PositionInGlobalBestSolution = fts; ac.MyFixedLessonNodes.Add(alnode); at.MyFixedLessonNodes.Add(alnode); } } else if (_fromStartRadioButton.Checked) { numOfNodesToSolve = htCourse.getNumberOfLessonsPerWeek(); } for (int nnode = 0; nnode < numOfNodesToSolve; nnode++) { //nodes to solve alnode = new ALessonNode(ac, NUM_OF_SLOTS_PER_ROOM * NUM_OF_ROOMS); ac.MyAllLessonNodesForAllocation.Add(alnode); at.MyTempAllocatedLessonNodes.Add(alnode); } htCourse.TempIsPreparedForAutomatedTT = true; } }