/// <summary> /// Constructer that sets name, lecturer list & courseList /// </summary> /// <param name="name">The name of the Department</param> /// <param name="lectureList">LinkedList Of Lecturer in for this Department</param> /// <param name="courseList">LinkedList Of Course in for this Department</param> public Department(String name, LinkedList lectureList, LinkedList courseList) { setId("000"); setName(name); setLecturerList(lectureList); setCourseList(courseList); }
/// <summary> /// Constructer that sets name /// Sets Id to defualt 000 so as to know to use INSERT SQl command /// Creates a new linkedlists and assigns it to lecturerList & courseList to prevent /// trying to add to a non-existent list /// </summary> /// <param name="name">The name of the Department</param> public Department(String name) { setId("000"); setName(name); lecturerList = new LinkedList(); courseList = new LinkedList(); }
/// <summary> /// Add a Department to the Instutite /// </summary> /// <param name="dept">The Department to add</param> public void addDepartment(Department dept) { if (deptList == null) { deptList = new LinkedList(); } deptList.addAtTail(dept); }
/// <summary> /// add a Building to the Instutite /// </summary> /// <param name="building">The Building to add</param> public void addBuilding(Building building) { if (buildingList == null) { buildingList = new LinkedList(); } buildingList.addAtTail(building); }
/// <summary> /// Constructer that takes courseCode, name & bumber of students /// Sets Id to defualt 000 so as to know to use INSERT SQl command /// </summary> /// <param name="courseCode">code of the course</param> /// <param name="name">name of the course</param> /// <param name="numOfStudents">number of students in the course</param> /// <param name="moduleList">linked list of module on the course</param> public Course(string courseCode, string name, int numOfStudents, LinkedList moduleList) { setID("000"); setCourseCode(courseCode); setName(name); setNumOfStudents(numOfStudents); setModuleList(moduleList); }
/// <summary> /// Get a list of all the lecturers in the institute /// </summary> /// <returns>linkedList of all lecturers in the institute</returns> public LinkedList getallLecturers() { LinkedList allLec = new LinkedList(); LinkedList deptList = institute.getDeptList(); Node nodeDept = deptList.head; while (nodeDept.next != null) { Department tempDept = (Department)nodeDept.data; allLec = allLec + tempDept.getLecturerList(); } return allLec; }
/// <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> /// Save list of Lecturer to the database /// </summary> /// <param name="lecturers">The LinkedList of Lecturer</param> public void saveLecturers(LinkedList lecturers) { Node temp = lecturers.head; Lecturer tempLec ; while (temp.next != null) { tempLec = (Lecturer)temp.data; //if the lecturer is new i.e id=000 use Insert command if (tempLec.getId().Equals("000")) { insertLecturer(tempLec); } else // update the lecturer entry { updateLecturer(tempLec); } temp = temp.next; } }
/// <summary> /// Save's the list of Module to the database /// </summary> /// <param name="modules">the LinkedList of Module</param> public void saveModules(LinkedList modules) { Node temp = modules.head; Module tempModule; while (temp.next != null) { tempModule = (Module)temp.data; //if the modue isnt already in the database create a new entry if (tempModule.getID().Equals("000")) { insertModule(tempModule); } else { updateModule(tempModule); } temp = temp.next; } }
/// <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> /// Save a list of Department to the database /// </summary> /// <param name="depts">The LinkedList of Department</param> public void saveDepartments(LinkedList depts) { Node temp = depts.head; Department tempDept; while (temp.next != null) { tempDept = (Department)temp.data; //if the dept is'nt in the database insert a new one else if (tempDept.getID().Equals("000")) { insertDept(tempDept); } else { updateDept(tempDept); } } }
/// <summary> /// The parameter received by the method specifies the lecturer that can teach this Module. /// </summary> /// <param name="lecturerList">A lecturer from a list of Lecturers in LinkedList</param> public void setLecturerList(LinkedList lecturerList) { this.lecturerList = lecturerList; }
/// <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> /// Set the Building LinkedList /// </summary> /// <param name="buildingList">The LinkedList Of Building</param> public void setBuildingList(LinkedList buildingList) { this.buildingList = buildingList; }
/// <summary> /// Defuault Constructer /// Sets Id to defualt 000 so as to know to use INSERT SQl command /// Creates a new linkedlist and assigns it to moduleList to prevent addModule() /// trying to add to a non-existent list /// </summary> public Course() { setID("000"); moduleList = new LinkedList(); }
/// <summary> /// Constructer that takes name and roomList /// Sets Id to defualt 000 so as to know to use INSERT SQl command /// </summary> /// <param name="name">string containing the name of the building</param> /// <param name="roomList">linked list of room in the building</param> public Building(string name, LinkedList roomList) { setId("000"); setName(name); setRoomList(roomList); }
/// <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> /// Defuault Constructer /// Sets Id to defualt 000 so as to know to use INSERT SQl command /// Creates a new linkedlist and assigns it to roomlist to prevent addRoom() /// trying to add to a non-existent list /// </summary> public Building() { setId("000"); roomList = new LinkedList(); }
/// <summary> /// set the list of rooms for this building /// </summary> /// <param name="roomList">new linked list of room for the building</param> public void setRoomList(LinkedList roomList) { this.roomList = roomList; }
/// <summary> /// This method constructs a new Module object without setting any properties. /// </summary> public Module() { setId("000"); lecturerList = new LinkedList(); }
/// <summary> /// Saves a list of Room to the database /// </summary> /// <param name="rooms">The LinkedList of Room</param> public void saveRoom(LinkedList rooms) { Node temp = rooms.head; Room tempRoom; while (temp.next != null) { tempRoom = (Room)temp.data; //if the room isnt in the database insert it else update it if (tempRoom.getID().Equals("000")) { insertRoom(tempRoom); } else { updateRoom(tempRoom); } temp = temp.next; } }
/// <summary> ///Get a list of all teh room in the institute /// </summary> /// <returns>LinkedList of all Room objects</returns> public LinkedList getAllRooms() { LinkedList allRooms = new LinkedList(); LinkedList buildList = institute.getBuildingList(); Node buildNode = buildList.head; //for all the departmnets in the list add each room list together while (buildNode.next != null) { Building tempBuild = (Building)buildNode.data; allRooms = allRooms + tempBuild.getRoomList(); } return allRooms; }
/// <summary> /// Set the modules for this course /// </summary> /// <param name="moduleList">the number if students in the course</param> public void setModuleList(LinkedList moduleList) { this.moduleList = moduleList; }
/// <summary> /// List all the Modules in the Institute /// </summary> /// <returns>LinkedList of all Module objects</returns> public LinkedList getAllModules() { LinkedList allModules = new LinkedList(); LinkedList deptList = institute.getDeptList(); LinkedList courseList; Node nodeDept = deptList.head; while (nodeDept.next != null) { Department tempDept = (Department)nodeDept.data; courseList = tempDept.getCourseList(); Node nodeCourse = courseList.head; while (nodeCourse.next != null) { Course tempCourse = (Course)nodeCourse.data; allModules = allModules + tempCourse.getModuleList(); } } return allModules; }
/// <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> /// This method constructs a Module object with a set of properties as well as a List of Lecturers. /// </summary> /// <param name="name">String value will be assigned as the name of the Module</param> /// <param name="pratical">Boolean value specifies whether Module have a practical or not</param> /// <param name="hoursPerWeek">Integer value will be assigned as the number of hours the Module will be taught.</param> /// <param name="roomType">String value contains information about the Room type required for the Module</param> /// <param name="doubleSlots">Boolean value specifies wheter double lectures are allowed for the Module</param> /// <param name="maxConsecHours">Integer value will define the maximum consecutive hours during the day.</param> /// <param name="slotsOff">String value contains information about timeslots that the Module can not be taught</param> /// <param name="lecturerList">LinkedList with a List of Lecturers</param> public Module(String name, bool pratical, int hoursPerWeek, string roomType, bool doubleSlots, int maxConsecHours, string slotsOff, LinkedList lecturerList) { setId("000"); setName(name); setPractical(practical); setHoursPerWeek(hoursPerWeek); setRoomtype(roomType); setDoubleSlots(doubleSlots); setMaxConsecHours(maxConsecHours); setSlotsOff(slotsOff); setLecturerList(lecturerList); }
/// <summary> /// Set the Department LinkedList /// </summary> /// <param name="deptList">The LinkedList of Department</param> public void setDeptList(LinkedList deptList) { this.deptList = deptList; }
/// <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"); } }
/// <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> /// 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; }