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