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); } }