Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            _IssueKey    = QueryIssue;
            _QuestionKey = QueryQuestion;

            if (!IsPostBack)
            {
                H1.InnerText = Page.Title = "Issues and Questions";

                if (IsNullOrWhiteSpace(StateCode))
                {
                    UpdateControls.Visible = false;
                    NoJurisdiction.CreateStateLinks("/admin/Issues.aspx?state={StateCode}");
                    NoJurisdiction.ShowHeadOptional(false);
                    NoJurisdiction.Visible = true;
                    return;
                }

                try
                {
                    // Page Title
                    PageTitle.Text = Empty;

                    if (StateCode == "LL")
                    {
                        PageTitle.Text += "<br>All Candidates";
                    }
                    else if (StateCode == "US")
                    {
                        PageTitle.Text += "<br>National Candidates";
                    }
                    else
                    {
                        PageTitle.Text +=
                            $"<br>{StateCache.GetStateName(StateCode)} Candidates";
                    }

                    if (!IsNullOrEmpty(_IssueKey))
                    {
                        PageTitle.Text +=
                            $"<br><span style=color:red>{Issue_Desc(_IssueKey)}</span>";
                    }

                    //On initial entry there is only a StateCode Anchor
                    //Anchors on Issues and Questions Reports have 4 possible query string prameters:
                    //Issue Link => db.QueryString("Issue")
                    //Issue Ok/Omit Link => db.QueryString("Issue") & db.QueryString("Omit")
                    //Question Link => db.QueryString("Issue") & db.QueryString("Question")
                    //Question Ok/Omit Link => db.QueryString("Issue") & db.QueryString("Question") & db.QueryString("Omit")

                    if (IsNullOrEmpty(QueryIssue))
                    {
                        MakeAllControlsNotVisible();
                    }
                    else
                    {
                        // Entry from Link on Issues or Question Reports
                        if (IsNullOrEmpty(QueryQuestion) &&
                            IsNullOrEmpty(GetQueryString("Omit")))
                        {
                            // Issue Link to edit issue and/or issue questions
                            MakeAllControlsNotVisible();
                            Table_Issue_Edit.Visible       = true;
                            Table_Question.Visible         = true;
                            Table_Questions_Report.Visible = true;

                            TextBox_Issue_Description.Text = Issue_Desc(QueryIssue);
                            TextBox_Issue_Order.Text       =
                                Issues.GetIssueOrder(QueryIssue, 0)
                                .ToString(CultureInfo.InvariantCulture);

                            CreateQuestionsReport();
                        }
                        else if (IsNullOrEmpty(QueryQuestion) &&
                                 !IsNullOrEmpty(GetQueryString("Omit")))
                        {
                            // Issue Ok/Omit Link to change status to ok or omit

                            MakeAllControlsNotVisible();

                            Issues.UpdateIsIssueOmit(GetQueryString("Omit").IsEqIgnoreCase("true"),
                                                     QueryIssue);
                        }
                        else if (!IsNullOrEmpty(QueryQuestion) &&
                                 IsNullOrEmpty(GetQueryString("Omit")))
                        {
                            // Question Link to edit question

                            MakeAllControlsNotVisible();
                            Table_Question_Edit.Visible    = true;
                            Table_Question.Visible         = true;
                            Table_Questions_Report.Visible = true;

                            TextBox_Question_Description.Text = Questions.GetQuestion(_QuestionKey);
                            TextBox_Question_Order.Text       =
                                Questions.GetQuestionOrder(_QuestionKey, 0)
                                .ToString(CultureInfo.InvariantCulture);

                            RenumberQuestions();

                            CreateQuestionsReport();
                        }
                        else if (!IsNullOrEmpty(QueryQuestion) &&
                                 !IsNullOrEmpty(GetQueryString("Omit")))
                        {
                            // Question Ok/Omit Link to change status to ok or omit

                            MakeAllControlsNotVisible();
                            Table_Question.Visible         = true;
                            Table_Questions_Report.Visible = true;

                            Questions.UpdateIsQuestionOmit(GetQueryString("Omit").IsEqIgnoreCase("true"),
                                                           QueryQuestion);

                            RenumberQuestions();

                            CreateQuestionsReport();
                        }
                    }

                    RenumberIssues();

                    // Only Master controls
                    if (IsSuperUser)
                    {
                        Table_Delete_Issue.Visible = true;

                        if (!IsNullOrEmpty(QueryIssue) &&
                            IsNullOrEmpty(GetQueryString("Omit")))
                        {
                            Table_Delete_Question.Visible = true;
                        }
                    }
                }
                catch (Exception ex)
                {
                    Msg.Text = Fail(ex.Message);
                    LogAdminError(ex);
                }
            }
            CreateIssuesReport();
        }