/// <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");
            }
        }
        /// <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);
Ejemplo n.º 8
0
 private void detach_StudentCourses(StudentCourse entity)
 {
     this.SendPropertyChanging();
     entity.Student = null;
 }
Ejemplo n.º 9
0
 private void attach_StudentCourses(StudentCourse entity)
 {
     this.SendPropertyChanging();
     entity.Student = this;
 }
Ejemplo n.º 10
0
 partial void DeleteStudentCourse(StudentCourse instance);
Ejemplo n.º 11
0
 partial void UpdateStudentCourse(StudentCourse instance);
Ejemplo n.º 12
0
 partial void InsertStudentCourse(StudentCourse instance);