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) { GradingSys_DataClassesDataContext db = new GradingSys_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 deleteSemester_Year(int semester_id) { GradingSys_DataClassesDataContext db = new GradingSys_DataClassesDataContext(); var deleteQuery = from sem in db.Semester_Years where sem.Semester_id == semester_id select sem; foreach (var sem in deleteQuery) { db.Semester_Years.DeleteOnSubmit(sem); } 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) { GradingSys_DataClassesDataContext db = new GradingSys_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 List<Class> selectAll() { GradingSys_DataClassesDataContext db = new GradingSys_DataClassesDataContext(); var query = from class1 in db.Classes select class1; return query.ToList<Class>(); }
public static Boolean deleteClass(int cCode, int semester_id) { GradingSys_DataClassesDataContext db = new GradingSys_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 updateSemester_Year(int semester_id, int semester_code, string year) { GradingSys_DataClassesDataContext db = new GradingSys_DataClassesDataContext(); var query = from sem in db.Semester_Years where sem.Semester_id == semester_id select sem; // Execute the query, and change the column values // you want to change. foreach (Semester_Year sem in query) { sem.Semester_code = semester_code; sem.Year = year; } // Submit the changes 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, int prof_id) { GradingSys_DataClassesDataContext db = new GradingSys_DataClassesDataContext(); Class classObj = new Class { Course_code = cCode, Semester_id = semester_id, Max_enrollment = max_enrollment, Enrollment = enrollment, Class_time = Class_time, Professor_id = prof_id }; db.Classes.InsertOnSubmit(classObj); // 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) { GradingSys_DataClassesDataContext db = new GradingSys_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; } // 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) { GradingSys_DataClassesDataContext db = new GradingSys_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 registerStudent(int cCode, int semester_id, int student_id, double year_work, double project_marks, double final_exam, double total_marks) { GradingSys_DataClassesDataContext db = new GradingSys_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 List<Course> selectAll() { GradingSys_DataClassesDataContext db = new GradingSys_DataClassesDataContext(); var query = from course in db.Courses select course; return query.ToList<Course>(); }
public static Boolean updateStudent(int student_id, string fName, string lName, string address, bool gender, DateTime dob, int dept_no) { GradingSys_DataClassesDataContext db = new GradingSys_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 List<Student> selectAll() { GradingSys_DataClassesDataContext db = new GradingSys_DataClassesDataContext(); var query = from student in db.Students select student; return query.ToList<Student>(); }
public static Boolean deleteStudent(int student_id) { GradingSys_DataClassesDataContext db = new GradingSys_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 updateClass(int cCode, int semester_id, int max_enrollment, int enrollment, DateTime Class_time, int prof_id) { GradingSys_DataClassesDataContext db = new GradingSys_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; 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 List<Semester_Year> selectAll() { GradingSys_DataClassesDataContext db = new GradingSys_DataClassesDataContext(); var query = from Semester_Year in db.Semester_Years select Semester_Year; return query.ToList<Semester_Year>(); }
public static List<Class> getClassesOfProfessor(int semester_id, int prof_id) { GradingSys_DataClassesDataContext db = new GradingSys_DataClassesDataContext(); var query = from class1 in db.Classes where class1.Semester_id == semester_id && class1.Professor_id == prof_id select class1; return query.ToList<Class>(); }
public static List<Professor> selectAll() { GradingSys_DataClassesDataContext db = new GradingSys_DataClassesDataContext(); var query = from prof in db.Professors select prof; return query.ToList<Professor>(); }
public static List<Student> getStudentsOFClass(int cCode, int semester_id) { GradingSys_DataClassesDataContext db = new GradingSys_DataClassesDataContext(); var query = from enroll in db.Enrollments where enroll.Course_code == cCode && enroll.Semester_id == semester_id select enroll.Student; return query.ToList<Student>(); }
//prof_id is auto increment field public static Professor getProfessor(string username, string password) { GradingSys_DataClassesDataContext db = new GradingSys_DataClassesDataContext(); var query = from prof in db.Professors where prof.Username == username && prof.Password == password select prof; if (query.Count() == 0) return null; return query.First<Professor>(); }
public static List<Student_Grades> getStudentsGradesOFClass(int cCode, int semester_id) { GradingSys_DataClassesDataContext db = new GradingSys_DataClassesDataContext(); var result = from enroll in db.Enrollments join stud in db.Students on enroll.Student_id equals stud.Student_id where enroll.Course_code == cCode && enroll.Semester_id == semester_id select new Student_Grades(){ name = stud.First_name + stud.Last_name, year_work = (double) enroll.Year_work, project_marks = (double) enroll.Project_marks, final_exam = (double) enroll.Final_exam, total_marks = (double) enroll.Total_marks }; return result.ToList<Student_Grades>(); }
//Semester_id is auto increment field public static Boolean addSemester_Year(int semester_code, string year) { GradingSys_DataClassesDataContext db = new GradingSys_DataClassesDataContext(); Semester_Year Semester_Year = new Semester_Year { Semester_code = semester_code, Year = year, }; db.Semester_Years.InsertOnSubmit(Semester_Year); // Submit the change 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) { GradingSys_DataClassesDataContext db = new GradingSys_DataClassesDataContext(); Course course = new Course { Course_code = cCode, Course_name = cName, Credit_hours = credit_hours, }; 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 addStudent(string fName, string lName, string address, bool gender, DateTime dob, int dept_no) //{ // GradingSys_DataClassesDataContext db = new GradingSys_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(int student_id, string fName, string lName, string address, bool gender, DateTime dob, int dept_no) //{ // GradingSys_DataClassesDataContext db = new GradingSys_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 deleteStudent(int student_id) //{ // GradingSys_DataClassesDataContext db = new GradingSys_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 List<Department> selectAll() { GradingSys_DataClassesDataContext db = new GradingSys_DataClassesDataContext(); var query = from department in db.Departments select department; return query.ToList<Department>(); }