protected void ButtonDeleteAllQuestions_Click(object sender, EventArgs e) { try { CheckForDangerousInput(); var tableQuestions = Questions.GetDataByIssueKey(_IssueKey); foreach (var rowQuestion in tableQuestions) { Questions.DeleteByQuestionKey(rowQuestion.QuestionKey); } RenumberQuestions(); CreateQuestionsReport(); // Reset Tables Not Visible if (Questions.CountByIssueKey(_IssueKey) == 0) { Table_Question_Edit.Visible = false; Table_Question_Add.Visible = false; Table_Question.Visible = false; Table_Delete_Question.Visible = false; Table_Questions_Report.Visible = false; } Msg.Text = Ok("The questions with no answers have been deleted."); } catch (Exception ex) { Msg.Text = Fail(ex.Message); LogAdminError(ex); } }
protected void ButtonDeleteIssue_Click(object sender, EventArgs e) { try { // checks CheckForDangerousInput(); var issueKey = TextBox_Delete_IssueKey.Text.Trim(); if (!Issues.IsValidIssue(issueKey)) { throw new ApplicationException("The IssueKey is not valid."); } var icount = Questions.CountByIssueKey(issueKey); if (icount > 0) { throw new ApplicationException( $"There are {icount} questions. These need to be reassigned before" + " this issue can be deleted."); } var qcount = Answers.CountByQuestionKey(TextBox_Delete_QuestionKey.Text.Trim()); if (qcount > 0) { throw new ApplicationException( $"There are {qcount} answers. These need to be reassigned or deleted" + " before this question can be deleted."); } Issues.DeleteByIssueKey(issueKey); TextBox_Delete_IssueKey.Text = Empty; RenumberIssues(); //CreateIssuesReport(); // Reset Tables Not Visible Table_Question_Edit.Visible = false; Table_Question_Add.Visible = false; Table_Question.Visible = false; Table_Delete_Question.Visible = false; Table_Questions_Report.Visible = false; Table_Issue_Edit.Visible = false; Table_Issue_Add.Visible = false; Msg.Text = Ok("The issue has been deleted."); } catch (Exception ex) { Msg.Text = Fail(ex.Message); LogAdminError(ex); } }
private void CheckOrder() { if (QuestionOrder.Text.Trim() == Empty) //create an order as last in list { var count = Questions.CountByIssueKey(_IssueKey); var rowNumber = (count + 1) * 10; QuestionOrder.Text = rowNumber.ToString(CultureInfo.InvariantCulture); } if (!QuestionOrder.Text.Trim().IsValidInteger()) { throw new ApplicationException("The Order needs to be a whole number."); } }
protected void ButtonDeleteQuestion_Click(object sender, EventArgs e) { try { // checks CheckForDangerousInput(); var questionKey = TextBox_Delete_QuestionKey.Text.Trim(); if (!Questions.QuestionKeyExists(questionKey)) { throw new ApplicationException("The QuestionKey is not valid."); } var count = Answers.CountByQuestionKey(questionKey); if (count > 0) { throw new ApplicationException( $"There are {count} answers. These need to be reassigned or" + " deleted before this question can be deleted."); } // Msg needs to come before question is deleted Msg.Text = Ok($"The question ({Questions.GetQuestion(questionKey)})" + " has been deleted."); Questions.DeleteByQuestionKey(questionKey); RenumberQuestions(); CreateQuestionsReport(); // Reset Tables Not Visible if (Questions.CountByIssueKey(_IssueKey) == 0) { Table_Question_Edit.Visible = false; Table_Question_Add.Visible = false; Table_Question.Visible = false; Table_Delete_Question.Visible = false; Table_Questions_Report.Visible = false; } TextBox_Delete_QuestionKey.Text = Empty; } catch (Exception ex) { Msg.Text = Fail(ex.Message); LogAdminError(ex); } }
protected void ButtonDeleteAnswers_Click(object sender, EventArgs e) { try { // checks CheckForDangerousInput(); var questionKey = TextBox_Delete_QuestionKey.Text.Trim(); if (!Questions.QuestionKeyExists(questionKey)) { throw new ApplicationException("The QuestionKey is not valid."); } Answers.DeleteByQuestionKey(questionKey); RenumberQuestions(); CreateQuestionsReport(); // Reset Tables Not Visible if (Questions.CountByIssueKey(_IssueKey) == 0) { Table_Question_Edit.Visible = false; Table_Question_Add.Visible = false; Table_Question.Visible = false; Table_Delete_Question.Visible = false; Table_Questions_Report.Visible = false; } Msg.Text = Ok( $"All the ANSWERS to question ({Questions.GetQuestion(questionKey)}) have been deleted."); } catch (Exception ex) { Msg.Text = Fail(ex.Message); LogAdminError(ex); } }