/// <summary> /// find room for a building /// </summary> /// <param name="build">the building the rooms are in</param> /// <returns>linked list of rooms in a building</returns> public LinkedList getRoomList(Building build) { LinkedList list = new LinkedList(); Node roomNode = roomList.head; while (roomNode != null) { Room tempRoom = (Room)roomNode.data; if (tempRoom.buildingId == build.ID) { list.addAtTail(tempRoom); } } return list; }
/// <summary> /// Load the LinkedList of Room for a Building /// </summary> /// <param name="building">The Building the Rooms are in</param> /// <returns>Linked List of rooms</returns> public LinkedList loadRoomList(Building building) { LinkedList roomList = new LinkedList(); Room tempRoom; string sqlStatment = "SELECT * FROM Room WHERE BuildingID LIKE " + building.getID(); try { OpenConection(); cmd = new OleDbCommand(sqlStatment, conn); reader = cmd.ExecuteReader(); while (reader.Read()) { if (reader["Deleted"].ToString().Equals("False")) { tempRoom = new Room(); tempRoom.setID(reader["ID"].ToString()); tempRoom.setRoomNumber(reader["Number"].ToString()); tempRoom.setCapacity(Convert.ToInt32(reader["Capacity"])); tempRoom.setRoomType(reader["RoomType"].ToString()); tempRoom.setSlotsOff(reader["SlotsOff"].ToString()); roomList.addAtTail(tempRoom); } } CloseConnection(); } catch { // MessageBox.Show("Failed to get data from source"); } return roomList; }
/// <summary> /// Loads a LinkedList of Module from a Course /// </summary> /// <param name="course">The Course the Modules are in</param> /// <returns>A LinkedList of Modules</returns> public LinkedList LoadModuleList(Course course) { LinkedList moduleList = new LinkedList(); Module tempModule; string sqlStatment = "SELECT * FROM Course WHERE CourseCode LIKE "+ course.getCourseCode(); try { OpenConection(); cmd = new OleDbCommand(sqlStatment, conn); reader = cmd.ExecuteReader(); while (reader.Read()) { if (reader["Deleted"].ToString().Equals("False")) { tempModule = new Module(); tempModule.setId(reader["ID"].ToString()); tempModule.setName(reader["Module_Name"].ToString()); tempModule.setPractical(Convert.ToBoolean(reader["Pratcial"])); tempModule.setHoursPerWeek(Convert.ToInt32(reader["HoursPerWeek"])); tempModule.setRoomtype(reader["RoomType"].ToString()); tempModule.setMaxConsecHours(Convert.ToInt32(reader["MaxConsecHours"])); tempModule.setDoubleSlots(Convert.ToBoolean(reader["DoubleSlots"])); moduleList.addAtTail(tempModule); } } CloseConnection(); } catch { } return moduleList; }
/// <summary> /// Returns the Lectures that teach a Module /// </summary> /// <param name="module">The Module that the Lecturers teach</param> /// <returns>LinkedList of lecturer</returns> public LinkedList loadLectuerList(Module module) { LinkedList lectureList = new LinkedList(); Lecturer newLec; string sqlStatment = "SELECT ID, Lec_Name, Initials, Email, MaxHours, MaxConsecHours, MinSlotsPerDays, SlotsOff, Deleted"; sqlStatment += "FROM Lecturer, Lecturer/Module WHERE Lecturer/Module.Module_ID LIKE " + module.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> /// Returns a list of Departments /// </summary> /// <param name="institute">The Institute the Departments are in</param> /// <returns>A LinkedList of Departments</returns> public LinkedList loadDepartmentList(Institute institute) { LinkedList deptList = new LinkedList(); Department tempDept ; string sqlStatment = "SELECT * FROM Department"; try { OpenConection(); cmd = new OleDbCommand(sqlStatment, conn); reader = cmd.ExecuteReader(); while (reader.Read()) { if (reader["Deleted"].ToString().Equals("False")) { tempDept = new Department(); tempDept.setId(reader["ID"].ToString()); tempDept.setName(reader["Dept_Name"].ToString()); tempDept.setLecturerList(loadLectuerList(tempDept)); tempDept.setCourseList(loadCourseList(tempDept)); deptList.addAtTail("tempDept"); } } CloseConnection(); } catch { } return deptList; }
/// <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 ; }
/// <summary> /// Returns a list of buildings /// </summary> /// <param name="institute">The Institute the Buildings are in</param> /// <returns>A LinkedList of Buildings</returns> public LinkedList loadBuildingList(Institute institute) { LinkedList buildingList = new LinkedList(); Building tempBuild; string sqlStatment = "SELECT * FROM Building"; try { OpenConection(); cmd = new OleDbCommand(sqlStatment, conn); reader = cmd.ExecuteReader(); while (reader.Read()) { if (reader["Deleted"].ToString().Equals("False")) { tempBuild = new Building(); tempBuild.setId(reader["ID"].ToString()); tempBuild.setName("Building_Name"); tempBuild.setRoomList(loadRoomList(tempBuild)); buildingList.addAtTail(tempBuild); } } CloseConnection(); } catch { } return buildingList; }
/// <summary> /// load room list from the database /// </summary> private void loadRoomList() { LinkedList roomList = new LinkedList(); Room tempRoom; string sqlStatment = "SELECT * FROM Room "; try { OpenConection(); cmd = new OleDbCommand(sqlStatment, conn); reader = cmd.ExecuteReader(); while (reader.Read()) { if (reader["Deleted"].ToString().Equals("False")) { tempRoom = new Room( reader["ID"].ToString(), reader["Number"].ToString(), Convert.ToInt32(reader["Capacity"]), reader["RoomType"].ToString(), reader["SlotsOff"].ToString(), reader["BuildingID"].ToString()); roomList.addAtTail(tempRoom); } } CloseConnection(); } catch { // MessageBox.Show("Failed to get data from source"); } }