public static Boolean deleteStudent(int student_id) { GradingSystem_DataClassesDataContext db = new GradingSystem_DataClassesDataContext(); var deleteQuery = from stud in db.Students where stud.Student_id == student_id select stud; foreach (var stud in deleteQuery) { db.Students.DeleteOnSubmit(stud); } try { db.SubmitChanges(); return true; } catch (Exception e) { Console.WriteLine(e); return false; // Provide for exceptions. } }
public static Boolean updateStudent(int student_id, string fName, string lName, string address, bool gender, DateTime dob, int dept_no) { GradingSystem_DataClassesDataContext db = new GradingSystem_DataClassesDataContext(); var query = from stud in db.Students where stud.Student_id == student_id select stud; // Execute the query, and change the column values // you want to change. foreach (Student stud in query) { stud.First_name = fName; stud.Last_name = lName; stud.Address = address; stud.Gender = gender; stud.DOB = dob; stud.Dept_no = dept_no; } // Submit the changes to the database. try { db.SubmitChanges(); return true; } catch (Exception e) { Console.WriteLine(e); return false; } }
public static Boolean updateClass(int cCode, int semester_id, int max_enrollment, int enrollment, DateTime Class_time) { GradingSystem_DataClassesDataContext db = new GradingSystem_DataClassesDataContext(); var query = from c in db.Classes where c.Course_code == cCode && c.Semester_id == semester_id select c; // Execute the query, and change the column values // you want to change. foreach (Class c in query) { c.Max_enrollment = max_enrollment; c.Enrollment = enrollment; c.Class_time = Class_time; } // Submit the changes to the database. try { db.SubmitChanges(); return true; } catch (Exception e) { Console.WriteLine(e); return false; } }
public static Boolean addStudent(string fName, string lName, string address, bool gender, DateTime dob, int dept_no) { GradingSystem_DataClassesDataContext db = new GradingSystem_DataClassesDataContext(); Student student = new Student { First_name = fName, Last_name = lName, Address = address, Gender = gender, DOB = dob, Dept_no = dept_no, }; db.Students.InsertOnSubmit(student); // Submit the change to the database. try { db.SubmitChanges(); return true; } catch (Exception e) { Console.WriteLine(e); return false; } }
public static Boolean updateStudent_CourseMarks(int cCode, int semester_id, int student_id, double year_work, double project_marks, double final_exam, double total_marks) { GradingSystem_DataClassesDataContext db = new GradingSystem_DataClassesDataContext(); var query = from c in db.Enrollments where c.Course_code == cCode && c.Semester_id == semester_id && c.Student_id == student_id select c; // Execute the query, and change the column values // you want to change. foreach (Enrollment c in query) { c.Year_work = (Decimal) year_work; c.Project_marks = (Decimal) project_marks; c.Final_exam = (Decimal) final_exam; c.Total_marks = (Decimal) total_marks; } // Submit the changes to the database. try { db.SubmitChanges(); return true; } catch (Exception e) { Console.WriteLine(e); return false; } }
public static Boolean deleteClass(int cCode, int semester_id) { GradingSystem_DataClassesDataContext db = new GradingSystem_DataClassesDataContext(); var deleteQuery = from c in db.Classes where c.Course_code == cCode && c.Semester_id == semester_id select c; foreach (var c in deleteQuery) { db.Classes.DeleteOnSubmit(c); } try { db.SubmitChanges(); return true; } catch (Exception e) { Console.WriteLine(e); return false; // Provide for exceptions. } }
public static Boolean unregisterStudent(int cCode, int semester_id, int student_id) { GradingSystem_DataClassesDataContext db = new GradingSystem_DataClassesDataContext(); var deleteQuery = from enroll in db.Enrollments where enroll.Course_code == cCode && enroll.Semester_id == semester_id && enroll.Student_id == student_id select enroll; foreach (var enroll in deleteQuery) { db.Enrollments.DeleteOnSubmit(enroll); } try { db.SubmitChanges(); return true; } catch (Exception e) { Console.WriteLine(e); return false; // Provide for exceptions. } }
public static Boolean registerStudent(int cCode, int semester_id, int student_id, double year_work, double project_marks, double final_exam, double total_marks) { GradingSystem_DataClassesDataContext db = new GradingSystem_DataClassesDataContext(); Enrollment enroll = new Enrollment { Course_code = cCode, Semester_id = semester_id, Student_id = student_id, Year_work = (Decimal) year_work, Project_marks = (Decimal) project_marks, Final_exam = (Decimal) final_exam, Total_marks = (Decimal) total_marks }; db.Enrollments.InsertOnSubmit(enroll); // Submit the change to the database. try { db.SubmitChanges(); return true; } catch (Exception e) { Console.WriteLine(e); return false; } }
public static Boolean updateCourse(int cCode, string cName, int credit_hours, int prof_id) { GradingSystem_DataClassesDataContext db = new GradingSystem_DataClassesDataContext(); var query = from c in db.Courses where c.Course_code == cCode select c; // Execute the query, and change the column values // you want to change. foreach (Course c in query) { c.Credit_hours = credit_hours; c.Professor_id = prof_id; } // Submit the changes to the database. try { db.SubmitChanges(); return true; } catch (Exception e) { Console.WriteLine(e); return false; } }
public static Boolean addCourse(int cCode, string cName, int credit_hours, int prof_id) { GradingSystem_DataClassesDataContext db = new GradingSystem_DataClassesDataContext(); Course course = new Course { Course_code = cCode, Course_name = cName, Credit_hours = credit_hours, Professor_id = prof_id }; db.Courses.InsertOnSubmit(course); // Submit the change to the database. try { db.SubmitChanges(); return true; } catch (Exception e) { Console.WriteLine(e); return false; } }
public static Boolean addClass(int cCode, int semester_id, int max_enrollment, int enrollment, DateTime Class_time) { GradingSystem_DataClassesDataContext db = new GradingSystem_DataClassesDataContext(); Class classObj = new Class { Course_code = cCode, Semester_id = semester_id, Max_enrollment = max_enrollment, Enrollment = enrollment, Class_time = Class_time, }; db.Classes.InsertOnSubmit(classObj); // Submit the change to the database. try { db.SubmitChanges(); return true; } catch (Exception e) { Console.WriteLine(e); return false; } }