public override void doit() { _ep.removeCourseFromUnallocatedLessonsModelAndView(_course, AppForm.getAppForm().getUnallocatedLessonsListView()); _ep.Nodes.Remove(_course); foreach (Course newCourse in _groupsList) { _ep.Nodes.Add(newCourse); for (int k = 0; k < newCourse.getNumberOfLessonsPerWeek(); k++) { AppForm.CURR_OCTT_DOC.incrUnallocatedLessonsCounter(1); ListViewItem lvi = new ListViewItem(); lvi.Tag = newCourse; _ep.getUnallocatedLessonsList().Add(lvi); string [] courseTeacher = new string[2]; courseTeacher[0] = newCourse.getFullName(); courseTeacher[1] = newCourse.getTeacher().getLastName() + " " + newCourse.getTeacher().getName(); ListViewItem lviGUI = new ListViewItem(courseTeacher); lviGUI.Tag = newCourse; lvi.EnsureVisible(); AppForm.getAppForm().getUnallocatedLessonsListView().Items.Add(lviGUI); } } AppForm.getAppForm().getCoursesTreeView().SelectedNode = _ep; AppForm.getAppForm().getStatusBarPanel2().Text = AppForm.CURR_OCTT_DOC.getNumOfUnallocatedLessonsStatusText(); AppForm.getAppForm().getTreeTabControl().SelectedIndex = 0; }
public override void doit() { AppForm.CURR_OCTT_DOC.incrUnallocatedLessonsCounter(1); Course course = (Course)_lviDroped.Tag; Teacher myTeacher = course.getTeacher(); EduProgram ep = (EduProgram)course.Parent; string [] courseTeacher = new string[2]; courseTeacher[0] = course.getFullName(); courseTeacher[1] = myTeacher.getLastName() + " " + myTeacher.getName(); ListViewItem lviNew = new ListViewItem(courseTeacher); lviNew.Tag = course; _ullv.Items.Add(lviNew); _ullv.EnsureVisible(_ullv.Items.IndexOf(lviNew)); ep.getUnallocatedLessonsList().Add(lviNew); if (course.getCoursesToHoldTogetherList().Count > 0) { foreach (Course courseHT in course.getCoursesToHoldTogetherList()) { EduProgram epHT = (EduProgram)courseHT.Parent; Teacher myTeacherHT = courseHT.getTeacher(); ListViewItem lviNewHT = new ListViewItem(); lviNewHT.Tag = courseHT; epHT.getUnallocatedLessonsList().Add(lviNewHT); } } AppForm.getAppForm().getStatusBarPanel2().Text = AppForm.CURR_OCTT_DOC.getNumOfUnallocatedLessonsStatusText(); }
public override void doit() { AppForm.CURR_OCTT_DOC.incrUnallocatedLessonsCounter(1); Course course = (Course)_lviDroped.Tag; EduProgram eduProg = (EduProgram)course.Parent; string [] ulsEPSem = new string[3]; ulsEPSem[0] = course.getFullName(); string epText = ""; if (eduProg.getCode() != null) { epText = eduProg.getCode() + ", "; } epText += eduProg.getName(); ulsEPSem[1] = epText; ulsEPSem[2] = eduProg.getSemester(); ListViewItem newLvi = new ListViewItem(ulsEPSem); newLvi.Tag = course; _ullv.Items.Add(newLvi); _ullv.EnsureVisible(_ullv.Items.IndexOf(newLvi)); eduProg.getUnallocatedLessonsList().Add(_lviDroped); if (course.getCoursesToHoldTogetherList().Count > 0) { foreach (Course courseHT in course.getCoursesToHoldTogetherList()) { EduProgram epHT = (EduProgram)courseHT.Parent; ListViewItem lviNew = new ListViewItem(); lviNew.Tag = courseHT; epHT.getUnallocatedLessonsList().Add(lviNew); //add in ListView string [] ulsEPSemHT = new string[3]; ulsEPSemHT[0] = courseHT.getFullName(); string epTextHT = ""; if (epHT.getCode() != null) { epTextHT = epHT.getCode() + ", "; } epTextHT += epHT.getName(); ulsEPSemHT[1] = epTextHT; ulsEPSemHT[2] = epHT.getSemester(); ListViewItem newLviHT = new ListViewItem(ulsEPSemHT); newLviHT.Tag = courseHT; _ullv.Items.Add(newLviHT); } } AppForm.getAppForm().getStatusBarPanel2().Text = AppForm.CURR_OCTT_DOC.getNumOfUnallocatedLessonsStatusText(); }
public int getNumberOfUnallocatedLessons() { int myCounter = 0; EduProgram ep = (EduProgram)this.Parent; foreach (ListViewItem lvi in ep.getUnallocatedLessonsList()) { Course course = (Course)lvi.Tag; if (course == this) { myCounter++; } } return(myCounter); }
public override void undo() { AppForm.CURR_OCTT_DOC.decrUnallocatedLessonsCounter(_numOfUnallocatedLessonsUndoRedoCounter); foreach (Object [] onePair in _epAndLviForUndoRedoList) { EduProgram ep = (EduProgram)onePair[0]; ListViewItem lvi = (ListViewItem)onePair[1]; ArrayList lessonsInOneTimeSlot = (ArrayList)onePair[2]; Object [] courseAndRoomPair = (Object [])onePair[3]; ep.getUnallocatedLessonsList().Remove(lvi); lessonsInOneTimeSlot.Add(courseAndRoomPair); } AppForm.getAppForm().getCoursesTreeView().SelectedNode = _ep; if (AppForm.getAppForm().getTreeTabControl().SelectedIndex != 0) { AppForm.getAppForm().getTreeTabControl().SelectedIndex = 0; } else { AppForm.getAppForm().updateTimeSlotPanel(1, _ep, false); AppForm.getAppForm().getUnallocatedLessonsListView().BeginUpdate(); AppForm.getAppForm().getUnallocatedLessonsListView().Items.Clear(); foreach (ListViewItem lvi in _ep.getUnallocatedLessonsList()) { Course courseTag = (Course)lvi.Tag; string [] courseAndTeacher = new string[2]; courseAndTeacher[0] = courseTag.getFullName(); string teacherStr = courseTag.getTeacher().getLastName() + " " + courseTag.getTeacher().getName(); courseAndTeacher[1] = teacherStr; 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(); }
public override void undo() { _unallocatedLessonsListView.Items.Add(_dragedLvi); Course dragedCourse = (Course)_dragedLvi.Tag; EduProgram ep = (EduProgram)dragedCourse.Parent; ep.getUnallocatedLessonsList().Add(_dragedLvi); AppForm.CURR_OCTT_DOC.incrUnallocatedLessonsCounter(1); if (dragedCourse.getCoursesToHoldTogetherList().Count > 0) { foreach (Course courseHT in dragedCourse.getCoursesToHoldTogetherList()) { EduProgram epHT = (EduProgram)courseHT.Parent; ListViewItem lviHT = new ListViewItem(); lviHT.Tag = courseHT; epHT.getUnallocatedLessonsList().Add(lviHT); } } AppForm.getAppForm().getStatusBarPanel2().Text = AppForm.CURR_OCTT_DOC.getNumOfUnallocatedLessonsStatusText(); }
public override void undo() { _ep.Nodes.Add(_course); AppForm.getAppForm().getCoursesTreeView().SelectedNode = _course; _ep.Expand(); AppForm.getAppForm().getCoursesTreeView().SelectedNode.EnsureVisible(); foreach (Course course in _course.getCoursesToHoldTogetherList()) { course.getCoursesToHoldTogetherList().Add(_course); } for (int k = 0; k < _course.getNumberOfLessonsPerWeek(); k++) { if (_course.getCoursesToHoldTogetherList().Count == 0) { AppForm.CURR_OCTT_DOC.incrUnallocatedLessonsCounter(1); } ListViewItem lvi = new ListViewItem(); lvi.Tag = _course; _ep.getUnallocatedLessonsList().Add(lvi); string [] courseTeacher = new string[2]; courseTeacher[0] = _course.getFullName(); courseTeacher[1] = _course.getTeacher().getLastName() + " " + _course.getTeacher().getName(); ListViewItem lviGUI = new ListViewItem(courseTeacher); lviGUI.Tag = _course; lvi.EnsureVisible(); AppForm.getAppForm().getUnallocatedLessonsListView().Items.Add(lviGUI); } AppForm.getAppForm().getStatusBarPanel2().Text = AppForm.CURR_OCTT_DOC.getNumOfUnallocatedLessonsStatusText(); AppForm.getAppForm().getTreeTabControl().SelectedIndex = 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(); }
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(); }
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(); }