protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { if (Session["setq"] != null) { Label lblID = GridView1.Rows[e.RowIndex].FindControl("lblID") as Label; TextBox txtLastName = GridView1.Rows[e.RowIndex].FindControl("txtLastName") as TextBox; Label lblI1 = GridView1.Rows[e.RowIndex].FindControl("lblI1") as Label; Label lblI2 = GridView1.Rows[e.RowIndex].FindControl("lblI2") as Label; Label lblI3 = GridView1.Rows[e.RowIndex].FindControl("lblI3") as Label; CourseHandler courseHandler = new CourseHandler(); Student user = new Student(); user.studentName = ""; user.idNumber = ""; user.email = (string)Session["user"]; user.password = (string)Session["pass"]; CourseDBAccess courseDB = new CourseDBAccess(); courseDB.GetStudentDetails(user); QuizAns quiz = new QuizAns(); quiz.courseID = Convert.ToInt32(Request.QueryString["id"]); quiz.studentID = user.studentID; quiz.questionID = Convert.ToInt32(lblID.Text.Trim()); quiz.Ans = txtLastName.Text; //Let us now update the database courseHandler.UpdateQuizAns(quiz); //end the editing and bind with updated records. GridView1.EditIndex = -1; BindData(); } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Login First');", true); } }
protected void btnPost_Click(object sender, EventArgs e) { Discussion course = new Discussion(); Student user = new Student(); Teacher user1 = new Teacher(); user.studentName = ""; user.idNumber = ""; user.email = (string)Session["user"]; user.password = (string)Session["pass"]; user1.email = (string)Session["user"]; user1.password = (string)Session["pass"]; CourseHandler courseHandler = new CourseHandler(); CourseDBAccess courseDB = new CourseDBAccess(); courseDB.GetStudentDetails(user); courseDB.GetTeacherDetails(user1); if (user.studentName != "") { course.post = txtPost.Text; course.name = user.studentName; course.email = user.email; course.courseID = Convert.ToInt32(Request.QueryString["id"]); } else { course.post = txtPost.Text; course.name = user1.teacherName; course.email = user1.email; course.courseID = Convert.ToInt32(Request.QueryString["id"]); } if (courseHandler.AddNewDiscussion(course) == true) { int idd = Convert.ToInt32(Request.QueryString["id"]); Response.Redirect("DetailCourse.aspx?id=" + idd); } }
protected void Page_Load(object sender, EventArgs e) { if (Session["user"] == null) { ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Login First');window.location ='Home.aspx';", true); } else { Discussion course = new Discussion(); Student user = new Student(); user.studentName = ""; user.idNumber = ""; user.email = (string)Session["user"]; user.password = (string)Session["pass"]; CourseHandler courseHandler = new CourseHandler(); CourseDBAccess courseDB = new CourseDBAccess(); courseDB.GetStudentDetails(user); int cId = Convert.ToInt32(Request.QueryString["id"]); int SId = user.studentID; if (courseHandler.GetStudentCourse(cId, SId) == true || (string)Session["pass"] == "123") { Response.Redirect("DetailCourse.aspx?id=" + cId); } else { Response.Redirect("AddNewStudentCourse.aspx?cid=" + cId + "&sid=" + SId); } } }
private void BindData() { CourseHandler courseHandler = new CourseHandler(); Student user = new Student(); user.studentName = ""; user.idNumber = ""; user.email = (string)Session["user"]; user.password = (string)Session["pass"]; CourseDBAccess courseDB = new CourseDBAccess(); courseDB.GetStudentDetails(user); int cid = Convert.ToInt32(Request.QueryString["id"]); int sid = user.studentID; int id = 1; id = id + 1; GridView1.DataSource = courseHandler.GetQuestionList(cid, sid); GridView1.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { if (Session["user"] == null) { Response.Redirect("Home.aspx"); } if ((string)Session["pass"] == "123") { ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Under Construction');window.location ='Home.aspx';", true); } Student user = new Student(); user.studentName = ""; user.idNumber = ""; user.email = (string)Session["user"]; user.password = (string)Session["pass"]; CourseHandler courseHandler = new CourseHandler(); CourseDBAccess courseDB = new CourseDBAccess(); courseDB.GetStudentDetails(user); txtId.Text = user.idNumber; txtName.Text = user.studentName; txtEmail.Text = user.email; txtPassword.Text = user.password; int x = Convert.ToInt32(user.studentID); ; txtStudentID.Text = x.ToString(); }