/// <summary> /// I should write a method which will save room name, then pick up these room name from roomList and make a selection if the room name is equal to another room name which is picked up from the TTTList, then update information for this room. /// /// </summary> /// <param name="newRoom"></param> /// public void collectTTTInfo(Room newRoom) { int TTTPosition = 0, roomListPosition = 0; //every time, the system will read "room.xml" which only includes a room name. SavingAndReading data = new SavingAndReading(); data.ReadRoomFile("room.xml"); foreach (Room e1 in SystemList.RoomsList) { //termTimetableList size is fixed, if doesnot initialize the TTTPosition, //then the TTTPosition will greater than the size of termTimetable TTTPosition = 0; foreach (WebpageTermTimetable e2 in SystemList.TermTimetableList) { if (e1.RoomName == e2.RoomName) { SystemList.RoomsList[roomListPosition].TtDimensionArray[e2.Day][e2.StartHour - 9].HasSubject = true; SystemList.RoomsList[roomListPosition].TtDimensionArray[e2.Day][e2.StartHour - 9].TermTTListPosition = TTTPosition; } TTTPosition++; } roomListPosition++; } data.WriteRoomFile(); }
private void mainTTListview_ItemActivate(object sender, EventArgs e) { var moduleFullName = mainTTListview.SelectedItems[0].SubItems[0].Text; SavingAndReading data = new SavingAndReading(); data.ReadTermTimetableFile(); details_dataGridView1.Rows.Clear(); foreach (WebpageTermTimetable e1 in SystemList.TermTimetableList) { if (e1.ModuleFullName == moduleFullName && e1.ModuleShortName.Last() != '1') { ListViewItem item = new ListViewItem(); var shortName = e1.ModuleShortName; var roomName = e1.RoomName; var startHour = e1.StartHour; var endHour = e1.EndHour; var sessionProperty = e1.SessinonProperty; details_dataGridView1.Rows.Add(shortName, roomName, startHour, endHour, sessionProperty); } } }
private void studentListView_ItemActivate(object sender, EventArgs e) { SavingAndReading data = new SavingAndReading(); data.ReadSgFile(); data.ReadTemplateFile(); removeControls(); var id = studentListView.SelectedItems[0].SubItems[0].Text; foreach (TTTemplateList e1 in SystemList.TemplateList) { if (e1.StudentList.Exists(r => r.Id.ToString() == id)) { foreach (WebpageTermTimetable e2 in e1.TttemPlateList) { drawingStudentTT(e2); } } } for (int i = 0; i < SystemList.SessionGroupList.Count(); i++) { var sg = SystemList.SessionGroupList[i]; foreach (Student e1 in sg.StudentGroup) { if (e1.Id.ToString() == id) { drawingStudentTT(sg.NonLectureSession); } } } }
private void displayListView(int tabPage) { SavingAndReading data = new SavingAndReading(); //data.ReadSystemList(); //displayStudentListView(); //displayLecturerListView(); switch (tabPage) { case 0: data.ReadStudentFile(); displayStudentListView(); break; case 1: data.ReadLecturerFile(); displayLecturerListView(); break; case 2: data.ReadRoomFile(data.RoomFilename); displayRoomListView(); break; } }
private void quit_button_Click(object sender, EventArgs e) { DialogResult dialogResult = MessageBox.Show("Do you want to exit?", "Warning", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { SavingAndReading save = new SavingAndReading(); save.WriteSystemList(); this.Close(); } }
private void AddSubjects_FormClosing(object sender, FormClosingEventArgs e) { DialogResult dialogResult = MessageBox.Show("Do you want to exit?", "Warning", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { SavingAndReading save = new SavingAndReading(); save.WriteSystemList(); } else { e.Cancel = true; } }
public void roomMain() { int choice; SavingAndReading data = new SavingAndReading(); Room newRoom = new Room(); while (true) { Console.WriteLine("\n1. Add A Room \n2. Print A Room \n3. Print All Room \n4. Collect Room Info"); choice = int.Parse(Console.ReadLine()); switch (choice) { case 1: newRoom = newRoom.enterRoomInfo(newRoom); //newRoom.TtCells1 = new TimetableCells(); //newRoom.ttDimensionList[0, 0].HasSubject = true; //newRoom.ttDimensionList[0, 0].TermTTListPosition = 1; SystemList.RoomsList.Add(newRoom); break; case 2: //newRoom.printARoom(); break; case 4: //newRoom.collectCellsInfoTest(); //newRoom.collectInNormalWay(); break; case 5: newRoom.defaultValue(newRoom); break; case 6: newRoom.collectTTTInfo(newRoom); break; } data.WriteRoomFile(); } }
public void prodceLecturer() { string docName = "TimetableTemplate.xlsx"; int position = 0, hour = 1, count = 0; SavingAndReading data = new SavingAndReading(); data.ReadSgFile(); data.ReadTemplateFile(); data.ReadTermTimetableFile(); foreach (Lecturer e1 in SystemList.LecturerList) { var workbook = new XLWorkbook(docName); var ws = workbook.Worksheet(1); foreach (WebpageTermTimetable e2 in SystemList.TermTimetableList) { if (e1.Id == e2.LecturerID) { var subHearder = e1.FirstName + e1.LastName; var moduleFullName = e2.ModuleFullName; var moduleShortName = e2.ModuleShortName.Substring(2); var roomName = e2.RoomName; var lecturerName = findLecturerName(e2.LecturerID); hour = e2.EndHour - e2.StartHour; insertTextToSubHeader(subHearder, ws); var startPosition = string.Format("{0}{1}", (char)(e2.StartHour - 9 + 66), (e2.Day + 4)); var endPosition = string.Format("{0}{1}", (char)(e2.StartHour - 9 + 66 + hour - 1), (e2.Day + 4)); //if a module over one hour then merge the cells if (hour > 1) { mergeCells(startPosition, endPosition, ws); insertDetailsToCells(roomName, moduleShortName, lecturerName, ws, startPosition, endPosition); } else { insertDetailsToCells(roomName, moduleShortName, lecturerName, ws, startPosition, endPosition); } } } createFolder(); string path = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "Timetable System"); workbook.SaveAs(path + "\\LecturerTimetable\\" + e1.FirstName + e1.LastName + ".xlsx"); } }
private void changeSessionProperty(string ModuleShortName, string sessionProperty) { SavingAndReading data = new SavingAndReading(); data.ReadTermTimetableFile(); foreach (WebpageTermTimetable e1 in SystemList.TermTimetableList) { if (e1.ModuleShortName == ModuleShortName) { e1.SessinonProperty = sessionProperty; } } data.WriteTermTimetable(); }
//private void drawingTimetable() //{ // List<string> hourList = new List<string> { "9:00\n-\n9:50", "10:00\n-\n10:50", "11:15\n-\n12:05", "12:15\n-\n13:05", "13:15", "14:15\n-\n15:05", "15:15\n-\n16:05", "16:15\n-\n17:05", "17:15\n-\n18:00" }; // List<string> dayList = new List<string> { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday" }; // timetableLayoutPanel.Controls.Clear(); // for (int i = 0; i < hourList.Count(); i++) // { // Label newLabel = new Label(); // newLabel.Dock = DockStyle.Fill; // newLabel.Text = hourList[i]; // newLabel.TextAlign = ContentAlignment.MiddleCenter; // timetableLayoutPanel.Controls.Add(newLabel); // timetableLayoutPanel.SetCellPosition(newLabel, new TableLayoutPanelCellPosition(i + 1, 0)); // } // for (int i = 0; i < dayList.Count(); i++) // { // Label newLabel = new Label(); // newLabel.Dock = DockStyle.Fill; // newLabel.Text = dayList[i]; // newLabel.TextAlign = ContentAlignment.MiddleCenter; // newLabel.Font = new Font("SimSum", 9, FontStyle.Bold); // timetableLayoutPanel.Controls.Add(newLabel); // timetableLayoutPanel.SetCellPosition(newLabel, new TableLayoutPanelCellPosition(0, i + 1)); // } //} private string findLecturerName(int lecturerID) { string lecturerName = ""; SavingAndReading data = new SavingAndReading(); data.ReadLecturerFile(); foreach (Lecturer e1 in SystemList.LecturerList) { if (e1.Id == lecturerID) { lecturerName = (e1.FirstName + e1.MiddleName + " " + e1.LastName); } } return(lecturerName); }
public void WebpageAnalyzationMain(string filename) { SavingAndReading data = new SavingAndReading(); string url = System.IO.File.ReadAllText(filename); WebpageAnalyzation web = new WebpageAnalyzation(); HtmlDocument doc = web.DepartmentNodeCollection(url); web.timePX(doc); web.Subject(doc); web.CountSubjectInEachDay(doc); web.CompeletTT(doc); web.print(); data.WriteSystemList(); }
public WebpageTermTimetable returnAnotherSameSession(WebpageTermTimetable abandonSession) { SavingAndReading data = new SavingAndReading(); data.ReadTermTimetableFile(); foreach (WebpageTermTimetable e1 in SystemList.TermTimetableList) { //if(abandonSession != e1) { if (e1.ModuleShortName != abandonSession.ModuleShortName && e1.ModuleFullName == abandonSession.ModuleFullName && e1.SessinonProperty == abandonSession.SessinonProperty) { return(e1); } } } return(null); }
public bool uniqueIDChecking(int id) { SavingAndReading data = new SavingAndReading(); data.ReadStudentFile(); for (int i = 0; i < SystemList.StudentList.Count(); i++) { if (SystemList.StudentList[i].Id == id) { //Console.WriteLine("The ID you entered: " + newStudent.Id + " is existent!"); //enterID(newStudent); return(false); } } return(true); }
private void displayModuleName() { SavingAndReading data = new SavingAndReading(); data.ReadTermTimetableFile(); foreach (WebpageTermTimetable e1 in SystemList.TermTimetableList) { if (e1.ModuleShortName.Last() == '1') { ListViewItem item = new ListViewItem(); //var moduleFullName = e1.ModuleFullName; item.Text = e1.ModuleFullName; mainTTListview.Items.Add(item); } } }
//internal Degree Degree //{ // get // { // return degree; // } // set // { // degree = value; // } //} public void moduleChoices() { int choice; Module newModule = new Module(); Console.WriteLine("\n**********************Module class**********************"); Console.WriteLine("\nWhich function you want to choose?"); Console.WriteLine("\n1. Add a new module \n2. Delete a module \n3. Modify a module \n4. Print Module Info"); Console.Write("I want to choose: "); choice = int.Parse(Console.ReadLine()); SavingAndReading data = new SavingAndReading(); switch (choice) { case 1: newModule = newModule.enterModuleInfo(newModule); SystemList.ModuleList.Add(newModule); data.WriteModuleFile(); break; case 2: newModule.removeModule(newModule); break; case 3: newModule.modifyModuleDetails(); break; case 4: //PrintInfo newPrintInfo = new PrintInfo(); //newPrintInfo.printModulesInfo(); break; default: Console.WriteLine("The choice you entered is not correct. Please try again."); newModule.moduleChoices(); break; } }
private void lecturerListView_ItemActivate(object sender, EventArgs e) { SavingAndReading data = new SavingAndReading(); data.ReadRoomFile(data.RoomFilename); data.ReadTermTimetableFile(); data.ReadLecturerFile(); removeControls(); //collect the modules a lecuter is teaching var id = lecturerListView.SelectedItems[0].SubItems[0].Text; //List<Module> tempModuleList = new List<Module>(); foreach (WebpageTermTimetable e1 in SystemList.TermTimetableList) { if (e1.LecturerID.ToString() == id) { var moduleShortName = e1.ModuleShortName.Substring(3); var roomName = e1.RoomName; var row = e1.Day + 1; var column = e1.StartHour - 8; var columnspan = e1.EndHour - e1.StartHour; Label newLabel = new Label(); newLabel.Dock = DockStyle.Fill; newLabel.Text = roomName + "\n" + moduleShortName + "\n"; newLabel.TextAlign = ContentAlignment.MiddleCenter; timetableLayoutPanel.Controls.Add(newLabel); timetableLayoutPanel.SetCellPosition(newLabel, new TableLayoutPanelCellPosition(column, row)); if (columnspan > 1) { timetableLayoutPanel.SetColumnSpan(newLabel, columnspan); } } } }
}//end of CompeletTT method public void print() { WebpageTimeTable test = new WebpageTimeTable(); foreach (WebpageTimeTable t in timetableContainer) { WebpageTermTimetable newWebpageTermTimetable = new WebpageTermTimetable(); newWebpageTermTimetable.Day = t.Day; newWebpageTermTimetable.RoomName = t.RoomName; newWebpageTermTimetable.RoomSize = t.RoomSize; newWebpageTermTimetable.StartHour = t.StartHour; newWebpageTermTimetable.StartMin = t.StartMin; newWebpageTermTimetable.EndHour = t.EndHour; newWebpageTermTimetable.EndMin = t.EndMin; newWebpageTermTimetable.ModuleFullName = t.SubjectFullName; newWebpageTermTimetable.ModuleShortName = t.SubjectShortName; newWebpageTermTimetable.SessinonProperty = "Lecture"; SavingAndReading data = new SavingAndReading(); data.ReadModuleFile("module.xml"); var i = SystemList.ModuleList.FindIndex(r => r.ModuleFullName == t.SubjectFullName) + 1; foreach (Module e1 in SystemList.ModuleList) { if (e1.ModuleFullName == t.SubjectFullName || e1.ModuleShortName == t.SubjectShortName) { newWebpageTermTimetable.LecturerID = e1.LecturerID; //Console.WriteLine(e1.ModuleFullName, " *** ", t.SubjectFullName); } } SystemList.TermTimetableList.Add(newWebpageTermTimetable); } }
//private void read_button_Click(object sender, EventArgs e) //{ //} private void save_button_Click(object sender, EventArgs e) { SavingAndReading data = new SavingAndReading(); data.WriteSystemList(); }
//private void addStaffDetailsGroupBox_Enter(object sender, EventArgs e) //{ // if (studentRadioButton.Checked) // { // staff = 1; // studentDetailsGroupBox.Visible = true; // } // else if (LecturerRadioButton.Checked) // { // staff = 2; // studentDetailsGroupBox.Visible = false; // } //} private void AddStaffFormAddButton_Click(object sender, EventArgs e) { //MessageWarning(); //foreach (string element in staffDetailsList) //{ // if (element == "" || element == "middleName) // MessageBox.Show("Please complete the form!"); //} if (id == null) { MessageWarning("ID"); } else if (firstName == null) { MessageWarning("first name"); } else if (middleName == null) { MessageWarning("middle name"); } else if (lastName == null) { MessageWarning("last name"); } //else if (department_1 == "None" && department_2 == "None") // MessageWarning("department"); else if (studentRadioButton.Checked) { Student newStudent = new Student(); newStudent.Id = int.Parse(id); newStudent.FirstName = firstName; newStudent.MiddleName = middleName; newStudent.LastName = lastName; //newStudent.Department_1 = department_1; //newStudent.Department_2 = department_2; newStudent.Degree = degree; newStudent.Grade = grade; newStudent.Term = term; //newStudent.Major = major; if (!newStudent.uniqueIDChecking(int.Parse(id))) { MessageBox.Show("The student ID: " + id + " is exist."); } else { SystemList.StudentList.Add(newStudent); SavingAndReading data = new SavingAndReading(); data.WriteStudentFile(); } } else if (LecturerRadioButton.Checked) { Lecturer newLecturer = new Lecturer(); newLecturer.Id = int.Parse(id); newLecturer.FirstName = firstName; newLecturer.MiddleName = middleName; newLecturer.LastName = lastName; if (!newLecturer.uniqueIDChecking(int.Parse(id))) { MessageBox.Show("The lecturer ID: " + id + " is exist."); } else { SystemList.LecturerList.Add(newLecturer); SavingAndReading data = new SavingAndReading(); data.WriteLecturerFile(); } } }
private void roomListView_ItemActivate(object sender, EventArgs e) { SavingAndReading data = new SavingAndReading(); data.ReadRoomFile(data.RoomFilename); data.ReadTermTimetableFile(); data.ReadLecturerFile(); Room newRoom = new Room(); newRoom.RoomName = roomListView.SelectedItems[0].SubItems[0].Text; //timetableLayoutPanel.Controls.Clear(); removeControls(); //drawingTimetable(); foreach (Room e1 in SystemList.RoomsList) { if (e1.RoomName == newRoom.RoomName) { for (int i = 0; i < 5; i++) { for (int j = 0; j < 9; j++) { if (e1.TtDimensionArray[i][j].HasSubject == true) { var position = e1.TtDimensionArray[i][j].TermTTListPosition; var ttDetails = SystemList.TermTimetableList[position]; var moduleFullName = ttDetails.ModuleFullName; var moduleShortName = ttDetails.ModuleShortName.Substring(3, ttDetails.ModuleShortName.Count() - 3); var roomName = ttDetails.RoomName; var lecturerName = findLecturerName(ttDetails.LecturerID); var row = ttDetails.Day + 1; var column = ttDetails.StartHour - 8; var columnspan = ttDetails.EndHour - ttDetails.StartHour; Label newLabel = new Label(); newLabel.Dock = DockStyle.Fill; newLabel.Text = newRoom.RoomName + "\n" + moduleShortName + "\n" + lecturerName; newLabel.TextAlign = ContentAlignment.MiddleCenter; timetableLayoutPanel.Controls.Add(newLabel); timetableLayoutPanel.SetCellPosition(newLabel, new TableLayoutPanelCellPosition(column, row)); if (columnspan > 1) { timetableLayoutPanel.SetColumnSpan(newLabel, columnspan); } } } } } } //Label newLabel = new Label(); //newLabel.Dock = DockStyle.Fill; //newLabel.Text = newRoom.RoomName; //timetableLayoutPanel.Controls.Add(newLabel); //timetableLayoutPanel.SetCellPosition(newLabel, new TableLayoutPanelCellPosition(1, 1)); //timetableLayoutPanel.SetColumnSpan(newLabel, 2); //timetableLayoutPanel.Controls.Add(new Label() {Text = "asdf", Dock = DockStyle.Fill }, 1,1); //timetableLayoutPanel.GetCellPosition; //timetableLayoutPanel.GetCellPosition() }
public void createTemplate() { SystemList.SessionGroupList.Clear(); SystemList.TemplateList.Clear(); int year = 1, term = 1, overlapTimeCollision = 0; int practical = 0, tutorial = 0, workshop = 0; int totalPracticalSesions = 0; int[] dayModules = new int[5]; //string major = "BSc Computing"; List <Student> tempStudentList = new List <Student>(); List <Module> tempModuleList = new List <Module>(); List <WebpageTermTimetable> tempModuleDetailsList = new List <WebpageTermTimetable>(); List <WebpageTermTimetable> moduleFullNameList = new List <WebpageTermTimetable>(); List <WebpageTermTimetable> moduleShortNameList = new List <WebpageTermTimetable>(); List <WebpageTermTimetable> overlapTimeModuleList = new List <WebpageTermTimetable>(); List <WebpageTermTimetable> overlapTimeModuleList2 = new List <WebpageTermTimetable>(); List <WebpageTermTimetable> tempNonOverlapTimeSessionList = new List <WebpageTermTimetable>(); List <WebpageTermTimetable> tempNonOverlapTimeSessionList2 = new List <WebpageTermTimetable>(); //List<WebpageTermTimetable> generalTTTemplateList = new List<WebpageTermTimetable>(); //TTTemplateList generalTTTemplateList = new TTTemplateList(); //List<WebpageTermTimetable> TTTemplateList = new List<WebpageTermTimetable>(); WebpageTermTimetable[][] tempModuleDetailsArray = new WebpageTermTimetable[5][]; WebpageTermTimetable[][] tempModuleDetailsArray2 = new WebpageTermTimetable[5][]; List <string> totalPracticalOfEachModuleList = new List <string>(); List <string> tempStudentTimetableList = new List <string>(); List <string> practicalList_1 = new List <string>(); List <string> practicalList_2 = new List <string>(); List <SessionProperty> spList = new List <SessionProperty>(); List <SessionGroups> sgList = new List <SessionGroups>(); List <TTTemplateList> newtttlist = new List <TTTemplateList>(); List <Student> splitStudentList = new List <Student>(); SavingAndReading data = new SavingAndReading(); //data.ReadSystemList(); data.ReadLecturerFile(); data.ReadModuleFile(data.ModuleFilename); data.ReadStudentFile(); //collect the student of a specific year and term tempStudentList = returnStudentList(); //foreach (Student e1 in SystemList.StudentList) //{ // if (e1.Grade == year && e1.Term == term) // { // tempStudentList.Add(e1); // } //} //collect the module of a specific year and term foreach (Module e1 in SystemList.ModuleList) { if (e1.Year == year && e1.Term == term) { tempModuleList.Add(e1); } } //collect the module details from termtimetable foreach (Module e1 in tempModuleList) { foreach (WebpageTermTimetable e2 in SystemList.TermTimetableList) { if (e1.ModuleFullName == e2.ModuleFullName) { tempModuleDetailsList.Add(e2); } } } for (int i = 0; i < 5; i++) { int countModules = 0; foreach (WebpageTermTimetable e1 in tempModuleDetailsList) { if (e1.Day == i) { countModules++; } } dayModules[i] = countModules; } //seperate modules to different days for (int i = 0; i < 5; i++) { tempModuleDetailsArray[i] = new WebpageTermTimetable[dayModules[i]]; tempModuleDetailsArray2[i] = new WebpageTermTimetable[dayModules[i]]; int j = 0; foreach (WebpageTermTimetable e1 in tempModuleDetailsList) { if (e1.Day == i) { WebpageTermTimetable newObj = e1; tempModuleDetailsArray[i][j] = newObj; j++; } } } //sort modules from 9am to 18pm for (int i = 0; i < 5; i++) { //for(int j = 0; j < tempModuleDetailsArray[i].Count(); j++) { tempModuleDetailsArray2[i] = tempModuleDetailsArray[i].OrderBy(r => r.EndHour).ToArray(); } } //check if there is a overlap time for sessions or not for (int i = 0; i < 5; i++) { for (int j = 0; j < tempModuleDetailsArray2[i].Count() - 1; j++)//module needs to make a comparision with rest of modules, so Count() - 1 { var original = tempModuleDetailsArray2[i][j]; var comparision = tempModuleDetailsArray2[i][j + 1]; bool result = false; result = checkSessionsCollision(original, comparision); if (result) { overlapTimeModuleList.Add(original); var anotherSameSession = returnAnotherSameSession(comparision); overlapTimeModuleList.Add(anotherSameSession); overlapTimeCollision++; } } } //add abandoned sessions to overlapTimeModuleList for (int i = 0; i < (overlapTimeCollision * 2); i++) { var anotherSameSession = returnAnotherSameSession(overlapTimeModuleList[i]); overlapTimeModuleList.Add(anotherSameSession); } //count total non-lecture session //foreach(Module e1 in tempModuleList) //{ // foreach(WebpageTermTimetable e2 in tempModuleDetailsList) // { // if(e1.ModuleFullName == e2.ModuleFullName && e2.ModuleShortName.Last() != '1') // { // SessionProperty newSp = new SessionProperty(); // if (e2.SessinonProperty == "Practical") // practical++; // else if (e2.SessinonProperty == "Tutorial") // tutorial++; // else if (e2.SessinonProperty == "Workshop") // workshop++; // spCount.Add(newSp); // } // } //} //copy overlapTimeList foreach (WebpageTermTimetable e1 in overlapTimeModuleList) { overlapTimeModuleList2.Add(e1); } //create general timetable templates for (int i = 0; i <= overlapTimeCollision; i++) { //List<WebpageTermTimetable> generalTTTList = new List<WebpageTermTimetable>(); TTTemplateList generalTTTemplateList = new TTTemplateList(); foreach (WebpageTermTimetable e1 in tempModuleDetailsList) { if (e1.ModuleShortName.Last() == '1') { generalTTTemplateList.TttemPlateList.Add(e1); } } if (overlapTimeModuleList.Count() != 0) { for (int j = 0; j < 2; j++) { generalTTTemplateList.TttemPlateList.Add(overlapTimeModuleList[j]); } overlapTimeModuleList.RemoveAt(0); overlapTimeModuleList.RemoveAt(0); } newtttlist.Add(generalTTTemplateList); //MessageBox.Show("test"); } //...................................................................... //collect non-lecture session and remove overlap time sessions //firstly, collect non-lecture sessions //RemoveOverlapTimeSessions(tempModuleDetailsList); foreach (WebpageTermTimetable e1 in tempModuleDetailsList) { if (e1.ModuleShortName.Last() != '1') { tempNonOverlapTimeSessionList.Add(e1); } } //remove the overlapTime Sessions foreach (WebpageTermTimetable e1 in tempNonOverlapTimeSessionList) { tempNonOverlapTimeSessionList2.Add(e1); } if (overlapTimeCollision != 0) { foreach (WebpageTermTimetable e1 in tempNonOverlapTimeSessionList2) { foreach (WebpageTermTimetable e2 in overlapTimeModuleList2) { if (e1.ModuleShortName == e2.ModuleShortName) { tempNonOverlapTimeSessionList.Remove(e1); } } } } //count how many practical, tutorial, and workshop of a module foreach (Module e1 in tempModuleList) { SessionProperty newSp = new SessionProperty(); newSp.ModuleFullName = e1.ModuleFullName; foreach (WebpageTermTimetable e2 in tempNonOverlapTimeSessionList) { if (e2.ModuleFullName == e1.ModuleFullName) { if (e2.SessinonProperty == "Practical") { newSp.Practical++; } else if (e2.SessinonProperty == "Tutorial") { newSp.Tutorial++; } else if (e2.SessinonProperty == "Workshop") { newSp.Workshop++; } } } spList.Add(newSp); } //..................................................................... //split studentList to different groups foreach (SessionProperty e1 in spList) { //SessionGroups newSg = new SessionGroups(); var sessionCount = sgList.Count(); int practicalCount = 0, tutorialCount = 0, workshopCount = 0; if (e1.Practical != 0) { foreach (WebpageTermTimetable e2 in tempNonOverlapTimeSessionList) { if (e2.SessinonProperty == "Practical" && e2.ModuleFullName == e1.ModuleFullName) { SessionGroups newSg = new SessionGroups(); newSg.NonLectureSession = e2; sgList.Add(newSg); } } //int i = sessionCount; for (int i = 0; i < e1.Practical; i++) { if (e1.Practical != 1) { sgList[practicalCount + sessionCount].StudentGroup = returnSplitStudentList(e1.Practical, i, tempStudentList); } else { sgList[practicalCount + sessionCount].StudentGroup = tempStudentList; } practicalCount++; } } if (e1.Tutorial != 0) { foreach (WebpageTermTimetable e2 in tempNonOverlapTimeSessionList) { if (e2.SessinonProperty == "Tutorial" & e2.ModuleFullName == e1.ModuleFullName) { SessionGroups newSg = new SessionGroups(); newSg.NonLectureSession = e2; sgList.Add(newSg); } } //int i = e1.Practical; for (int i = 0; i < e1.Tutorial; i++) { if (e1.Tutorial != 1) { sgList[tutorialCount + practicalCount + sessionCount].StudentGroup = returnSplitStudentList(e1.Tutorial, i, tempStudentList); } else { sgList[tutorialCount + practicalCount + sessionCount].StudentGroup = tempStudentList; } tutorialCount++; } } if (e1.Workshop != 0) { foreach (WebpageTermTimetable e2 in tempNonOverlapTimeSessionList) { if (e2.SessinonProperty == "Workshop" & e2.ModuleFullName == e1.ModuleFullName) { SessionGroups newSg = new SessionGroups(); newSg.NonLectureSession = e2; sgList.Add(newSg); } } //int i = e1.Practical + e1.Tutorial; for (int i = 0; i < e1.Workshop; i++) { if (e1.Workshop != 1) { sgList[workshopCount + tutorialCount + practicalCount + sessionCount].StudentGroup = returnSplitStudentList(e1.Workshop, i, tempStudentList); } else { sgList[workshopCount + tutorialCount + practicalCount + sessionCount].StudentGroup = tempStudentList; } workshopCount++; } } //MessageBox.Show("test"); } //split studentList to newtttlist if (overlapTimeCollision != 0) { int count = 0; foreach (TTTemplateList e1 in newtttlist) { e1.StudentList = returnSplitStudentList(overlapTimeCollision + 1, count, tempStudentList); count++; } } //data.WriteSgFile(); //data.WriteTemplate(); //data.WriteSystemList(); //copy newtttlist and newSg foreach (TTTemplateList e1 in newtttlist) { SystemList.TemplateList.Add(e1); } foreach (SessionGroups e1 in sgList) { SystemList.SessionGroupList.Add(e1); } //MessageBox.Show("test"); data.WriteSgFile(); data.WriteTemplate(); }
public void produceStudentTimetable(string yearX, string yearY, int degree, int grade, int term) { string docName = "TimetableTemplate.xlsx"; int position = 0, hour = 1, count = 0; SavingAndReading data = new SavingAndReading(); data.ReadSgFile(); data.ReadTemplateFile(); data.ReadTermTimetableFile(); //collect tempstudent List <Student> tempStudentList = new List <Student>(); foreach (Student e1 in SystemList.StudentList) { string x = e1.Id.ToString()[0].ToString(); string y = e1.Id.ToString()[1].ToString(); if (x == yearX && y == yearY && e1.Degree == degree && e1.Grade == grade && e1.Term == term) { tempStudentList.Add(e1); } } foreach (Student e1 in tempStudentList) { var workbook = new XLWorkbook(docName); var ws = workbook.Worksheet(1); foreach (TTTemplateList e2 in SystemList.TemplateList) { if (e2.StudentList.Exists(r => r.Id == e1.Id)) { foreach (WebpageTermTimetable e3 in e2.TttemPlateList) { var subHearder = e1.FirstName + e1.LastName; var moduleFullName = e3.ModuleFullName; var moduleShortName = e3.ModuleShortName.Substring(2); var roomName = e3.RoomName; var lecturerName = findLecturerName(e3.LecturerID); hour = e3.EndHour - e3.StartHour; insertTextToSubHeader(subHearder, ws); var startPosition = string.Format("{0}{1}", (char)(e3.StartHour - 9 + 66), (e3.Day + 4)); var endPosition = string.Format("{0}{1}", (char)(e3.StartHour - 9 + 66 + hour - 1), (e3.Day + 4)); //if a module over one hour then merge the cells if (hour > 1) { mergeCells(startPosition, endPosition, ws); insertDetailsToCells(roomName, moduleShortName, lecturerName, ws, startPosition, endPosition); } else { insertDetailsToCells(roomName, moduleShortName, lecturerName, ws, startPosition, endPosition); } } } } createFolder(); string path = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "Timetable System"); workbook.SaveAs(path + "\\StudentTimetable\\" + e1.FirstName + e1.LastName + ".xlsx"); } foreach (Student e1 in tempStudentList) { string path = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "Timetable System"); docName = path + "\\StudentTimetable\\" + e1.FirstName + e1.LastName + ".xlsx"; var workbook = new XLWorkbook(docName); var ws = workbook.Worksheet(1); foreach (SessionGroups e2 in SystemList.SessionGroupList) { foreach (Student e3 in e2.StudentGroup) { if (e3.Id == e1.Id) { var moduleFullName = e2.NonLectureSession.ModuleFullName; var moduleShortName = e2.NonLectureSession.ModuleShortName.Substring(2); var roomName = e2.NonLectureSession.RoomName; var lecturerName = findLecturerName(e2.NonLectureSession.LecturerID); hour = e2.NonLectureSession.EndHour - e2.NonLectureSession.StartHour; var startPosition = string.Format("{0}{1}", (char)(e2.NonLectureSession.StartHour - 9 + 66), (e2.NonLectureSession.Day + 4)); var endPosition = string.Format("{0}{1}", (char)(e2.NonLectureSession.StartHour - 9 + 66 + hour - 1), (e2.NonLectureSession.Day + 4)); //if a module over one hour then merge the cells if (hour > 1) { mergeCells(startPosition, endPosition, ws); insertDetailsToCells(roomName, moduleShortName, lecturerName, ws, startPosition, endPosition); } else { insertDetailsToCells(roomName, moduleShortName, lecturerName, ws, startPosition, endPosition); } } } } workbook.Save(); } }
public void produceRoomTimetable() { int position = 0, hour = 1, count = 0; //string moduleFullName, moduleShortName, roomName, lecturerName = "", startPosition, endPosition; WebpageTermTimetable ttDetails = new WebpageTermTimetable(); SavingAndReading data = new SavingAndReading(); //data.ReadSystemList(); string docName = "TimetableTemplate.xlsx"; //var workbook = new XLWorkbook(docName); //var ws = workbook.Worksheet(1); List <Room> tempRoomList = new List <Room>(); data.ReadRoomFile("room.xml"); tempRoomList = SystemList.RoomsList; data.ReadSystemList(); //start to select each object from roomsList and print details foreach (Room e1 in SystemList.RoomsList) { var workbook = new XLWorkbook(docName); var ws = workbook.Worksheet(1); //if (e1.RoomName == tempRoomList[count].RoomName) { subHeader = e1.RoomName; for (int i = 0; i < 5; i++) { for (int j = 0; j < 9; j++) { if (e1.TtDimensionArray[i][j].HasSubject == true) { position = e1.TtDimensionArray[i][j].TermTTListPosition; ttDetails = SystemList.TermTimetableList[position]; var moduleFullName = ttDetails.ModuleFullName; var moduleShortName = ttDetails.ModuleShortName; var roomName = ttDetails.RoomName; var lecturerName = findLecturerName(ttDetails.LecturerID); hour = ttDetails.EndHour - ttDetails.StartHour; //start inserting details for each timetable //ProduceTT ptt = new ProduceTT(); //change the subHeader insertTextToSubHeader(roomName, ws); var startPosition = string.Format("{0}{1}", (char)(j + 66), (i + 4)); var endPosition = string.Format("{0}{1}", (char)(j + 66 + hour - 1), (i + 4)); //if a module over one hour then merge the cells if (hour > 1) { mergeCells(startPosition, endPosition, ws); insertDetailsToCells(moduleFullName, moduleShortName, lecturerName, ws, startPosition, endPosition); } else { insertDetailsToCells(moduleFullName, moduleShortName, lecturerName, ws, startPosition, endPosition); } } } createFolder(); string path = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "Timetable System"); workbook.SaveAs(path + "\\Timetable\\" + e1.RoomName + ".xlsx"); } colorSelectionList.Clear(); count++; } } }