protected void btnConfirmSubmit_Click(object sender, EventArgs e) { //to do validations ChatBotAnswerDAO cbaDAO = new ChatBotAnswerDAO(); ChatBotAnswer cbAnswer = new ChatBotAnswer(); cbAnswer.answer = txtAnswers.Text; cbAnswer.intent = ddlIntent.SelectedValue; if (txtEntity.Text != "") { cbAnswer.entityName = txtEntity.Text; } else { cbAnswer.entityName = null; } int answerID = cbaDAO.insertAnswer(cbAnswer); //set audit User currentUser = (User)Session["currentUser"]; setAudit(currentUser, "learny answers", "create", answerID.ToString(), "answer: " + txtAnswers.Text); Response.Redirect("askLearnyAddAns.aspx"); }
protected void deleteBtn_Click(object sender, EventArgs e) { ChatBotAnswerDAO cbaDAO = new ChatBotAnswerDAO(); int answerID = Convert.ToInt32(Request.QueryString["id"]); cbaDAO.deleteAnswerByID(answerID); //set audit User currentUser = (User)Session["currentUser"]; setAudit(currentUser, "learny answers", "delete", answerID.ToString(), "deleted answer: " + txtAnswers.Text); Response.Redirect("askLearnyAddAns.aspx"); }
protected void Page_Load(object sender, EventArgs e) { if (Session["currentUser"] == null) { Response.Redirect("/Login.aspx"); } else { if (!IsPostBack) { User currentUser = (User)Session["currentUser"]; Boolean superuser = false; foreach (String s in currentUser.getRoles()) { if (s.Equals("superuser")) { superuser = true; } } if (!currentUser.getDepartment().Equals("hr")) { if (!superuser) { Response.Redirect("errorPage.aspx"); } } else { ChatBotAnswerDAO cbaDAO = new ChatBotAnswerDAO(); ChatBotAnswer currrentAnswer = cbaDAO.getChatBotAnswerByID(Convert.ToInt32(Request.QueryString["id"])); if (currrentAnswer.answer != null) { txtAnswers.Text = currrentAnswer.answer; txtEntity.Text = currrentAnswer.entityName; ddlIntent.DataBind(); ddlIntent.SelectedIndex = ddlIntent.Items.IndexOf(ddlIntent.Items.FindByText(currrentAnswer.intent)); } else { Response.Redirect("errorPage.aspx"); } } } } }
protected void cfmSubmit_Click(object sender, EventArgs e) { //to do validation ChatBotAnswerDAO cbaDAO = new ChatBotAnswerDAO(); int answerID = Convert.ToInt32(Request.QueryString["id"]); if (txtEntity.Text.Equals("")) { cbaDAO.updateChatBotAnswer(txtAnswers.Text, null, ddlIntent.SelectedValue, answerID); } else { cbaDAO.updateChatBotAnswer(txtAnswers.Text, txtEntity.Text, ddlIntent.SelectedValue, answerID); } //set audit User currentUser = (User)Session["currentUser"]; setAudit(currentUser, "learny answers", "update", answerID.ToString(), "updated answer: " + txtAnswers.Text); Response.Redirect("askLearnyAddAns.aspx"); }