/// <summary> /// Confirmation button click event handler. Removes or adds the course /// from/to the student's courses. Redirects user to previous page afterwards. /// </summary> /// <param name="sender">sender</param> /// <param name="e">event args</param> protected void ConfirmButton_Click(object sender, EventArgs e) { using (TablesDataContext db = new TablesDataContext()) { if (action.Equals("add")) { StudentCourse sc = new StudentCourse(); sc.CourseID = courseID; sc.StudentID = (int)Session["StudentID"]; db.StudentCourses.InsertOnSubmit(sc); SubmitChanges(db); } else if (action.Equals("remove")) { var course = from sc in db.StudentCourses where (sc.CourseID.Equals(courseID) && sc.StudentID == (int)Session["StudentID"]) select sc; db.StudentCourses.DeleteOnSubmit(course.FirstOrDefault()); SubmitChanges(db); } else { Response.Redirect("default.aspx"); } Session["Action"] = null; Session["CourseID"] = null; Response.Redirect("courses.aspx"); } }
private void detach_StudentCourses(StudentCourse entity) { this.SendPropertyChanging(); entity.Student = null; }
private void attach_StudentCourses(StudentCourse entity) { this.SendPropertyChanging(); entity.Student = this; }
partial void DeleteStudentCourse(StudentCourse instance);
partial void UpdateStudentCourse(StudentCourse instance);
partial void InsertStudentCourse(StudentCourse instance);