public static bool reportCourseDetail(string course_designation) { // check if student_id is valid Course course = new Course(course_designation); if (course.GetCourseInformation(GLOBALS.current_semester)) { List<Student> student_list = Registration.getStudentsFromCourseCurrentSemester(course.course_id); List<string> lines = new List<string>(); lines.Add(String.Format("Report for course ID: {0}", course.course_id)); lines.Add(course.ToString()); lines.Add("===============================" + Environment.NewLine); lines.Add("Students who are in this course: " + Environment.NewLine); lines.Add(String.Format("Student ID\t\t First name\t\t Last name" + Environment.NewLine)); foreach (var student in student_list) { lines.Add(String.Format("{0}\t\t\t {1}\t\t\t {2}", student.student_id, student.first_name, student.last_name)); lines.Add(Environment.NewLine); } //string file_name = AppDomain.CurrentDomain.BaseDirectory + String.Format("Report: Student ID {0}.txt", student_id); string file_path = @".\..\..\Reports\Report_Course_Detail.txt"; System.IO.File.WriteAllLines(file_path, lines); System.Diagnostics.Process.Start("notepad.exe", @".\..\..\Reports\Report_Course_Detail.txt"); return true; } return false; }
public static bool dropRegistration(Student student, Course course) { string query = "delete from REGISTRATION where "+ "course_id= "+course.course_id + " and student_id =" + student.student_id + " and year_semester='"+ GLOBALS.current_semester + "'"; return GLOBALS.db_command(query); }
public string searchCourse(string course_designation) { Course course = new Course(course_designation); string result = "No course found in this semester"; if (course.GetCourseInformation(GLOBALS.current_semester)) { result = course.ToString(); } return result; }
public static bool checkCourseTaken(Student student, Course course) { DataTable dt = GLOBALS.db_query( "select * from REGISTRATION " + "where course_id = "+course.course_id+ " and student_id = "+student.student_id+ " and (passed_course = 1 or passed_course is null)"); if (dt.Rows.Count == 0) { return false; } return true; }
public static List<Course> getCoursesFromStudent(string student_id, string year_semester) { List<Course> course_list = new List<Course>(); string query = "select * from registration where student_id=" + student_id + " and year_semester='" + year_semester + "'"; DataTable registration_table = GLOBALS.db_query(query); foreach (DataRow row in registration_table.Rows){ DataTable course_table = GLOBALS.db_query("select course_designation from course where course_id=" + row["course_id"].ToString()); Course course = new Course(course_table.Rows[0]["course_designation"].ToString()); if (course.GetCourseInformation(GLOBALS.current_semester)) { course_list.Add(course); } } return course_list; }
public static bool checkCoursePrereqNotTaken(Student student, Course course) { // if there is no pre-req course if (course.prereq_course == null || course.prereq_course == "") return false; DataTable dt = GLOBALS.db_query( "select * from REGISTRATION " + "where course_id = " + course.prereq_course + " and student_id = " + student.student_id + " and passed_course = 1"); if (dt.Rows.Count == 1) { return false; } return true; }
public string addCourse(string student_id, string course_designation) { Student student = new Student(student_id); student.getStudentInformation(); Course course = new Course(course_designation); if (!course.GetCourseInformation(GLOBALS.current_semester)) { return "This course is not offered this semester. Sorry!"; } if (Registration.checkCoursePrereqNotTaken(student, course)) { return "Pre requisite is not taken"; } if (Registration.checkCourseTaken(student, course)) { return "You already took this course!"; } // check limit credit hours int new_credit_hour = student.current_credit_hour + course.credit_hours; if (new_credit_hour > student.max_credit_hour_allowed) { return "Maximum credit hours reached!"; } // check course capacity if (course.enrolled_student >= course.capacity ) { return "This course is full!"; } // Update Registration Table if (Registration.addRegistration(student, course)) { student.updateCreditHour(new_credit_hour); course.updateEnrolledStudent(course.enrolled_student + 1); return "ok"; } return "This course conflicts with your Registration. Please contact the admin for more information"; }
public static List<Course> getCoursesFromFaculty(string faculty_id) { List<Course> course_list = new List<Course>(); DataTable course_table = GLOBALS.db_query("select * from course where instructor_id=" + faculty_id); foreach (DataRow row in course_table.Rows) { Course course = new Course(row["course_designation"].ToString()); course.GetCourseInformation(GLOBALS.current_semester); course_list.Add(course); } return course_list; }
public static bool addRegistration(Student student, Course course) { string query = "insert into REGISTRATION (course_id, student_id, year_semester)" + "values (" + course.course_id + ", " + student.student_id + ", '" + GLOBALS.current_semester + "')"; return GLOBALS.db_command(query); }
public static Course searchCourse(string course_designation, string year_semester) { Course course = new Course(course_designation); if (course.GetCourseInformation(year_semester)) { return course; } return course; }