public void SetupStudentCourseRegistered() { dgStudentCourseRegistered.ShowFooter = true; string StudentID = Session["StudentID"].ToString(); StudentCourseSection lec = new StudentCourseSection(); DataSet ds = lec.GetDisplayBasedStudent(StudentID); dgStudentCourseRegistered.DataSource = ds.Tables["StudentCourseSection"]; dgStudentCourseRegistered.DataBind(); }
protected void dgStudentRegisterCourse_ItemCommand(object sender, System.Web.UI.WebControls.DataGridCommandEventArgs e) { if (e.CommandName == "Register") { Label TempCourseSectionID = (Label)e.Item.Cells[0].FindControl("lblID"); string studentID = Session["ID"].ToString(); StudentCourseSection lec = new StudentCourseSection(); if (lec.CheckDuplicate(studentID, TempCourseSectionID.Text) == false) { ClientScript.RegisterStartupScript(this.GetType(), "Error", "<script type='text/javascript'>swal('Error!', 'You have already registered for this course.', 'error')</script>'"); } else if (lec.Add(studentID, TempCourseSectionID.Text) == false) { ClientScript.RegisterStartupScript(this.GetType(), "Error", "<script type='text/javascript'>swal('Error!', 'Unsuccessful registration!', 'error')</script>'"); } else { ClientScript.RegisterStartupScript(this.GetType(), "Success", "<script type='text/javascript'>swal({title: 'Register successfully!', type : 'success', confirmButtonText : 'OK'}, function (isConfirm) { if (isConfirm) { window.location.href = 'courseRegistration.aspx'; }});</script>'"); } } }