protected void btenter_Click(object sender, EventArgs e) { if (Session["User"] == null) { Response.Redirect("RegistLogin.aspx"); } if (this.txtanswer.Text != "") { if (Request.QueryString["Id"] != null) { Id = Request.QueryString["Id"]; } else { if (Session["Id"] != null) { Id = Session["Id"].ToString(); } } CY.CSTS.Core.Business.Answer answer = new CY.CSTS.Core.Business.Answer(); CY.CSTS.Core.Business.User user = (CY.CSTS.Core.Business.User)Session["User"]; answer.QuestionsID = new Guid(Id); answer.Content = txtanswer.Text; answer.CreateDate = DateTime.Now; answer.ExpertID = user.Id; txtanswer.Text = ""; answer.Save(); bindanswer(Id); } }
protected void DelQuesAnswer(Guid id) { CY.CSTS.Core.Business.Answer answer = new CY.CSTS.Core.Business.Answer(); IList<CY.CSTS.Core.Business.Answer> answerclass = CY.CSTS.Core.Business.Answer.GetAllAnswer(); for (int i = answerclass.Count - 1; i >= 0; i--) { answer = answerclass.ElementAt(i); if (id.Equals(answer.QuestionsID)) { answer.DeleteOnSave(); answer.Save(); } } }
protected void btnDel_Click(object sender, EventArgs e) { CheckBox cb; CY.CSTS.Core.Business.Answer answer = new CY.CSTS.Core.Business.Answer(); for (int i = 0; i < gvLinkClass.Rows.Count; i++) { cb = (CheckBox)gvLinkClass.Rows[i].FindControl("cbSelect"); if (cb.Checked) { try { Guid id = new Guid(gvLinkClass.DataKeys[i].Value.ToString()); answer = CY.CSTS.Core.Business.Answer.Load(id); answer.DeleteOnSave(); answer.Save(); } catch (Exception ex) { throw ex; } } } bindanswer(); }