public DataTable getEligibleCourse(string student_id) { Student student = new Student(student_id); student.getStudentInformation(); DataTable courses_offered_this_semester_table = Registration.getCoursesFromSemester(student.current_semester_id, student.program_id); return courses_offered_this_semester_table; }
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 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 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; }
private void btnReportRegistrationStudent_Click(object sender, EventArgs e) { // check for blank if (txtStudentID.Text != "" && txtStudentID.Text.All(char.IsDigit)) { // check for valid student id Student student = new Student(txtStudentID.Text); if (student.getStudentInformation()) { GenerateReportRegistrationInterface generate_report_registration_interface = new GenerateReportRegistrationInterface(txtStudentID.Text); generate_report_registration_interface.ShowDialog(); } else { MessageBox.Show("Fail to generate report! No student with that ID found!"); } } }
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<Student> getStudentsFromCourseCurrentSemester(string course_id) { List<Student> student_list = new List<Student>(); string query = "select * from registration where course_id=" + course_id +" and year_semester='" + GLOBALS.current_semester +"'"; DataTable registration_table = GLOBALS.db_query(query); foreach (DataRow row in registration_table.Rows) { Student student = new Student(row["student_id"].ToString()); student.getStudentInformation(); student_list.Add(student); } return student_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 bool reportStudentRegistration(string student_id, string year_semester) { // check if student_id is valid Student student = new Student(student_id); if (student.getStudentInformation()) { List<Course> course_list = Registration.getCoursesFromStudent(student_id, year_semester); // print out the list of course here List<string> lines = new List<string>(); lines.Add(String.Format("Report for student ID: {0}", student_id)); lines.Add(String.Format("Student's name: {0} {1}", student.first_name, student.last_name)); lines.Add("Semester: " + year_semester); lines.Add("===============================" + Environment.NewLine); foreach (var course in course_list) { lines.Add(course.course_designation); lines.Add(course.title); lines.Add("------------------------------" + Environment.NewLine); } //string file_name = AppDomain.CurrentDomain.BaseDirectory + String.Format("Report: Student ID {0}.txt", student_id); string file_path = @".\..\..\Reports\Report_Student.txt"; System.IO.File.WriteAllLines(file_path, lines); System.Diagnostics.Process.Start("notepad.exe", @".\..\..\Reports\Report_Student.txt"); return true; } return false; }