/// <summary> /// Load all the Lecturers for a given Department /// </summary> /// <param name="dept">The Department the Lecturers are in</param> /// <returns>LinkedList of Lecturer</returns> public LinkedList loadLectuerList(Department dept) { LinkedList lectureList = new LinkedList(); Lecturer newLec; string sqlStatment = "SELECT Lec_Name, Initials, Email, MaxHours, MaxConsecHours, MinSlotsPerDays, SlotsOff, Deleted"; sqlStatment += "FROM Lecturer WHERE Lecturer.Dept_ID LIKE" + dept.getID(); try { OpenConection(); cmd = new OleDbCommand(sqlStatment, conn); reader = cmd.ExecuteReader(); while (reader.Read()) { if (reader["Deleted"].ToString().Equals("False")) { newLec = new Lecturer(); newLec.setId(reader["ID"].ToString()); newLec.setName(reader["Lec_Name"].ToString()); newLec.setInitials(reader["Initials"].ToString()); newLec.setEmail(reader["Email"].ToString()); newLec.setMaxHours(Convert.ToInt32(reader["MaxHours"])); newLec.setMaxConsecHours(Convert.ToInt32(reader["MaxConsecHours"])); newLec.setMinSlotsPerDay(Convert.ToInt32(reader["MinSlotsPerDays"])); newLec.setSlotsOff(reader["SlotsOff"].ToString()); lectureList.addAtTail(newLec); } } CloseConnection(); } catch { // MessageBox.Show("Failed to get data from source"); } return lectureList; }
/// <summary> /// Load LinkedList of Course for a Department /// </summary> /// <param name="dept">The Department the Courses are in</param> /// <returns>A LinkedList of Course</returns> public LinkedList loadCourseList(Department dept) { LinkedList courses = new LinkedList(); Course tempCourse ; string sqlStatment = "SELECT ID, Code, CourseName, NumOfStudents FROM Course WHERE DeptId Like " + dept.getID(); try { OpenConection(); cmd = new OleDbCommand(sqlStatment, conn); reader = cmd.ExecuteReader(); while (reader.Read()) { if (reader["Deleted"].ToString().Equals("False")) { tempCourse = new Course(); tempCourse.setID(reader["ID"].ToString()); tempCourse.setCourseCode(reader["Code"].ToString()); tempCourse.setName(reader["CourseName"].ToString()); tempCourse.setNumOfStudents(Convert.ToInt32(reader["NumOfStudents"])); tempCourse.setModuleList(LoadModuleList(tempCourse)); courses.addAtTail(tempCourse); } } CloseConnection(); } catch { // MessageBox.Show("Failed to get data from source"); } return courses ; }