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 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); }
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); } } } }
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(); }
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() }