protected void btnAnswer_Click(object sender, EventArgs e) { if (txtAnswer.Text != "") { objQuestions = new clsQuestionAnswers(); objQuestions.QuestionId = Convert.ToInt32(Session["QuestionId"]); objQuestions.Answer = txtAnswer.Text.Trim(); objQuestions.UserId = Convert.ToInt32(Session["UserLoginId"]); int i = objQuestions.InsertAnswers(); if (i > 0) { Page.RegisterClientScriptBlock("admin", "<script>alert('Answer Posted')</script>"); txtAnswer.Text = ""; } else { Page.RegisterClientScriptBlock("Admin", "<script>alert('Already One Answer Posted By you')</script>"); txtAnswer.Text = ""; } Field2.Visible = false; Field1.Visible = true; } else { Page.RegisterClientScriptBlock("admin", "<script>alert('Type Your Answer')</script>"); } }
public void PostANewQuestion() { if (txtQuestion.Text != "") { objQuestion = new clsQuestionAnswers(); objQuestion.Question = txtQuestion.Text.Trim(); objQuestion.UserId = Convert.ToInt32(Session["UserLoginId"]); int i = objQuestion.PostANewQuestion(); if (i > 0) { Page.RegisterClientScriptBlock("admin", "<script>alert('Your Question Posted, Wait for Result')</script>"); txtQuestion.Text = ""; txtQuestion.Focus(); } else { Page.RegisterClientScriptBlock("Admin", "<script>alert('Bad Server Request')</script>"); } } else { Page.RegisterClientScriptBlock("Student", "<script>alert('Enter Question')</script>"); txtQuestion.Focus(); } }
protected void GrvQuestions_RowCommand(object sender, GridViewCommandEventArgs e) { Field1.Visible = false; Field2.Visible = true; Session["QuestionId"] = e.CommandArgument.ToString(); objQuestions = new clsQuestionAnswers(); objQuestions.QuestionId = Convert.ToInt32(Session["QuestionId"]); DataSet ds = objQuestions.GetQuestionById(); lblQuestion.Text = ds.Tables[0].Rows[0][0].ToString(); }
public void GetQuestions() { objQuestions = new clsQuestionAnswers(); DataSet dsQuestions = objQuestions.GetQuestions(); if (dsQuestions.Tables[0].Rows.Count > 0) { GrvQuestions.DataSource = dsQuestions.Tables[0]; GrvQuestions.DataBind(); } }
public void GetQuestionsByUserId() { objQuestions = new clsQuestionAnswers(); objQuestions.UserId = Convert.ToInt32(Session["UserLoginId"]); DataSet dsQuestions = objQuestions.GetQuestionsByUserId(); if (dsQuestions.Tables[0].Rows.Count > 0) { GRVPostedQuestions.DataSource = dsQuestions.Tables[0]; GRVPostedQuestions.DataBind(); } }
protected void GRVPostedQuestions_RowCommand(object sender, GridViewCommandEventArgs e) { Field2.Visible = true; objQuestions = new clsQuestionAnswers(); objQuestions.QuestionId = Convert.ToInt32(e.CommandArgument.ToString()); DataSet dsAnswers = objQuestions.GetPostedAnswersByQuestionId(); if (dsAnswers.Tables[0].Rows.Count > 0) { GRVAnswers.DataSource = dsAnswers.Tables[0]; GRVAnswers.DataBind(); } DataSet dsQuestion = objQuestions.GetQuestionById(); lblQuestion.Text = dsQuestion.Tables[0].Rows[0][0].ToString(); }