/// <summary> /// Add a new lecturer to the system /// </summary> /// <param name="name">Name of the Lecturer</param> /// <param name="initials">Initials of the Lecturer</param> /// <param name="email">Email address of the Lecturer</param> /// <param name="maxHours">Maximum hours lecturer can work</param> /// <param name="maxConsecHours">Maximum Consecutive hours Lecturer can work</param> /// <param name="minSlotsPerDay">Minimum Lessons a day a teaches wants to teach</param> /// <param name="slotsOff">Times Lecturer Wants Off</param> /// <param name="deptId">The Id of the Dept the Lecturer is in</param> public void addLecturer(string name, string initials, string email, int maxHours, int maxConsecHours, int minSlotsPerDay, string slotsOff , string deptId) { Lecturer lecturer = new Lecturer(name, initials, email, maxHours, maxConsecHours, minSlotsPerDay, slotsOff); Node deptNode = institute.getDeptList().head; Department dept = institute.getDeptById(deptId); dept.addLecturer(lecturer); }
/// <summary> /// Update a Lecturer in the database /// </summary> /// <param name="lecturers">The updated Lecturer</param> public void updateLecturer(Lecturer lecturer) { string sql; sql = "UPDATE Lecturer SET "; sql += "Lec_Name='" + lecturer.name + "', "; sql += "Initials='" + lecturer.initials + "', "; sql += "Email='" + lecturer.email + "', "; sql += "MaxHours=" + lecturer.maxHours + ", "; sql += "MaxConsecHours=" + lecturer.maxConsecHours + ", "; sql += "MinSlotsPerDay=" + lecturer.minSlotsPerDay + ", "; sql += "SlotsOff='" + lecturer.slotsOff + "' "; sql += "WHERE ID LIKE " + lecturer.ID + ""; excuteNonQuery(sql); }
/// <summary> /// load lecturer from database /// </summary> /// private void loadLectuerList() { Lecturer newLec; string sqlStatment = "SELECT * FROM Lecturer"; try{ OpenConection(); cmd = new OleDbCommand(sqlStatment, conn); reader = cmd.ExecuteReader(); while (reader.Read()) { if (reader["Deleted"].ToString().Equals("False")) { newLec = new Lecturer(reader["ID"].ToString(), reader["Lec_Name"].ToString(), reader["Initials"].ToString(), reader["Email"].ToString(), Convert.ToInt32(reader["MaxHours"]), Convert.ToInt32(reader["MaxConsecHours"]), Convert.ToInt32(reader["MinSlotsPerDay"]), reader["SlotsOff"].ToString(),reader["DepartmentID"].ToString()); lecturerList.addAtTail(newLec); } } CloseConnection(); } catch { // MessageBox.Show("Failed to get data from source"); } }
/// <summary> /// Add a new Lecturer to the database /// </summary> /// <param name="lecturer">The new Lecturer</param> public void insertLecturer(Lecturer lecturer) { string sql; sql = "INSERT INTO Lecturer ( Lec_Name, Initials, Email, MaxHours, MaxConsecHours, MinSlotsPerDay, SlotsOff, DepartmentId, Deleted) VALUES("; sql += "'" + lecturer.name + "', "; sql += "'" + lecturer.initials + "', "; sql += "'" + lecturer.email + "', "; sql += lecturer.maxHours + ", "; sql += lecturer.maxConsecHours + ", "; sql += lecturer.minSlotsPerDay + ", "; sql += "'" + lecturer.slotsOff + "',"; sql += "'"+ lecturer.deptId +"',false)"; excuteNonQuery(sql); }
public void addLecturer(Lecturer theLec) { dataBaseHelper.insertLecturer(theLec); dataBaseHelper.update(); }
/// <summary> /// Update the values in the Lecturer /// </summary> /// <param name="name">String value for the name of lecturer</param> /// <param name="initials">String value for the initials of lecturer</param> /// <param name="email">String value for email details</param> /// <param name="maxHours">Integer value for Maximum number of hours during the week</param> /// <param name="maxConsecHours">Integer value for maximum consecutive hours a lecturer can teach</param> /// <param name="minSlotsPerDay">Integer value for the minimum amount of hours that a Lecturer can teach.</param> /// <param name="slotsOff">String value for the time slots that a lecturer is not available.</param> public void updateLecturer(Lecturer theLec) {
//Get and Set methods /// <summary> /// The parameter received by the method is used for setting the Lecturer for this Lesson /// </summary> /// <param name="lecturer"></param> public void setLecturer(Lecturer lecturer) { this.lecturer = lecturer; }
public Edit_Lecturer(Domain.Lecturer theLec) { this.thelec = theLec; InitializeComponent(); addNewLecture = false; }
/// <summary> /// returns a Lecturer Object corresponding to the ID given /// </summary> /// <param name="lecturerId">The Lecturer ID</param> /// <returns>A Lecturer with the given ID</returns> public Lecturer loadLecturer(string lecturerId) { Lecturer newLec = new Lecturer(); string sqlStatment = "SELECT * FROM Lecturer WHERE ID LIKE " + lecturerId; try { OpenConection(); cmd = new OleDbCommand(sqlStatment, conn); reader = cmd.ExecuteReader(); while (reader.Read()) { if (reader["Deleted"].ToString().Equals("False")) { 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()); } } CloseConnection(); } catch { // MessageBox.Show("Failed to get data from source"); } return newLec; }
/// <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> /// The constructor of Lesson object with a set of properties. /// </summary> /// <param name="lecturer">The name of the Lecturer</param> /// <param name="module">The name of the Module</param> /// <param name="room">The name/number of the Room</param> public Lesson(Lecturer lecturer, Module module, Room room) { this.lecturer = lecturer; this.module = module; this.room = room; }
/// <summary> /// The constructor of Lesson object with a set of properties. /// </summary> /// <param name="lecturer">The name of the Lecturer</param> /// <param name="module">The name of the Module</param> /// <param name="room">The name/number of the Room</param> public Lesson(Lecturer lecturer, Module module) { this.lecturer = lecturer; this.module = module; }
public PartialViewResult RegisterLecturer(Lecturer model) { if (!ModelState.IsValid) return PartialView("LecturerRegistration"); _repository.SaveLecturer(model); return PartialView("RegistrationFinished", new RegistrationFinishedModel() { Name = model.Name, Surname = model.Surname, Email = model.Email }); }
/// <summary> /// Check if a Lecturer is in the lecturerist /// </summary> /// <param name="lecturer">The Lecturer to search for</param> /// <returns>True or False</returns> public bool isInDept(Lecturer lecturer) { return lecturerList.searchList(lecturer); }
/// <summary> /// Add a new Lecturer to the database /// </summary> /// <param name="lecturer">The new Lecturer</param> private void insertLecturer(Lecturer lecturer) { string sql; sql = "INSERT INTO Lecturer (Lec_Name, Initials, Email, MaxHours, MaxConsecHours, MinSlotsPerDay, SlotsOff, Deleted) VALUES("; sql += "'" + lecturer.getName() + "', "; sql += "'" + lecturer.getInitials() + "', "; sql += "'" + lecturer.getEmail() + "', "; sql += lecturer.getMaxHours() + ", "; sql += lecturer.getMaxConsecHours() + ", "; sql += lecturer.getMinSlotsPerDay() + ", "; sql += "'" + lecturer.getSlotsOff() + "', false)"; excuteNonQuery(sql); }
/// <summary> /// Add a Lecturer to this department /// </summary> /// <param name="lecturer">The Lecturer to be added</param> public void addLecturer(Lecturer lecturer) { lecturerList.addAtTail(lecturer); }
/// <summary> /// Update a Lecturer in the database /// </summary> /// <param name="lecturers">The updated Lecturer</param> private void updateLecturer(Lecturer lecturer) { string sql; sql = "UPDATE Lecturer"; sql += "Lec_Name='" + lecturer.getName() + "', "; sql += "Initials='" + lecturer.getInitials() + "', "; sql += "Email='" + lecturer.getEmail() + "', "; sql += "MaxHours=" + lecturer.getMaxHours() + ", "; sql += "MaxConsecHours=" + lecturer.getMaxConsecHours() + ", "; sql += "MinSlotsPerDay=" + lecturer.getMinSlotsPerDay() + ", "; sql += "SlotsOff='" + lecturer.getSlotsOff() + "' "; sql += "WHERE ID LIKE '" + lecturer.getId() + "'"; excuteNonQuery(sql); }
public void saveChanges() { name = LecNameTextBox.Text; initials = LecInitialsTextBox.Text; email = LecEmailTextBox.Text; department = LectDepartmentComboBox.SelectedValue.ToString(); isAllFieldsFilled = true ; foreach (Control c in this.LecturerGroupBox.Controls) { if (c is TextBox) { TextBox textBox = c as TextBox; if (textBox.Text == string.Empty) { isAllFieldsFilled = false; } } } if (isAllFieldsFilled == false) { MessageBox.Show("All Fields must be filled", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (isAllFieldsFilled == true) { // When the Field is not empty,Check if the fields Contains a valid data e.g, int32 if (addNewLecture == true) { Domain.Lecturer lecturer = new Domain.Lecturer(name, initials, email, maxHours, maxConsecHours, minSlotsPerday, slotsOff, department); controller.addLecturer(lecturer); } else { // The following code will update the lecturer thelec.name = name; thelec.initials = initials; thelec.email = email; thelec.maxHours = maxHours; thelec.maxConsecHours = maxConsecHours; thelec.minSlotsPerDay = minSlotsPerday; thelec.deptId = LectDepartmentComboBox.SelectedValue.ToString(); controller.updateLecturer(thelec); } } }
/// <summary> /// The constructor of Lesson object with a set of properties. /// </summary> /// <param name="lecturer">The name of the Lecturer</param> /// <param name="module">The name of the Module</param> /// <param name="room">The name/number of the Room</param> public Lesson(Lecturer lecturer, Module module, Room room) { setLecturer(lecturer); setModule(module); setRoom(room); }