/// <summary>
    ///Loads the page and checks for querystrings and display a  message if needed.
    /// </summary>
    /// <param name="sender">Contains a reference to the control/object that raised the event.</param>
    /// <param name="e">Contains the event data of the event that triggered the method.</param>
    protected void Page_Load(object sender, EventArgs e)
    {
        //checks for error query string


        string error = Request.QueryString["error"];

        if (error == "nodataquestions")
        {
            MessageUserControl.ShowInfoError("No data", "Sorry for the inconvenience, currently there are no questions in the database. Please contact an administrator at 555-555-5555 to resolve the issue.");
        }
        if (error == "nounitsinsite")
        {
            MessageUserControl.ShowInfoError("No data", "Sorry for the inconvenience, currently there are no active units at your site. Please contact an administrator at 555-555-5555 to resolve the issue.");
        }
    }
Exemple #2
0
    /// <summary>
    /// Populates and updates the subquestions list view based on the selected question
    /// </summary>
    /// <param name="sender">Contains a reference to the control/object that raised the event.</param>
    /// <param name="e">Represents the base class for classes that contain event data, and provides a value to use for events that do not include event data.</param>
    protected void FetchAnswersButton_Click(object sender, EventArgs e)
    {
        //if user selects the "Select a question..." option in the dropdown list, do the following actions:
        if (QuestionsWithAnswersDropDownList.SelectedValue == "0")
        {
            //show error message
            MessageUserControl.Visible = true;
            MessageUserControl.ShowInfoError("No Question Selected", "Please select a question.");

            //highlight the dropdown list and refresh the answers listview
            QuestionsWithAnswersDropDownList.Focus();
            UpdateAnswersListView.DataBind();
        }
        else
        {
            //show informational message
            MessageUserControl.ShowInfo("Answers Displayed", "Answers associated under the selected question are now displayed.");
            UpdateAnswersListView.DataBind();
        }
    }
    /// <summary>
    ///Checks if the correct passcode was entered. If passcode is correct user will be re-directed to the survey page, if not an error message will be thrown.
    /// </summary>
    /// <param name="sender">Contains a reference to the control/object that raised the event.</param>
    /// <param name="e">Contains the event data of the event that triggered the method.</param>
    protected void SubmitButton_Click(object sender, EventArgs e)
    {
        //Calls utility controllter
        Utility utility = new Utility();
        //Creates a empty list to store Active Site's Passcodes
        List <string>  PasscodeList = new List <string>();
        SiteController sysmgr       = new SiteController();

        PasscodeList = sysmgr.Site_PasscodeList();
        //Passcode entered from textbox
        string passcode = SurveyPasscode.Text;

        //Check if passcode entered on page matches any in list
        MessageUserControl.TryRun(() =>
        {
            utility.checkValidString(SurveyPasscode.Text);
            for (int SitePasscode = 0; SitePasscode < PasscodeList.Count; SitePasscode++)
            {
                //Passcode matches
                if (passcode.ToUpper() == PasscodeList[SitePasscode].ToUpper())
                {
                    //Redirects the user to survey page correct passcode is passed to survey page
                    Response.Redirect("Survey.aspx?passcode=" + passcode);
                }
                else if (passcode == "")
                {
                    // No Passcode is entered show message
                    MessageUserControl.ShowInfoError("No Passcode Entered", "Please enter the passcode to access the survey.");
                }
                else
                {
                    // Passcode is incorrect show message
                    MessageUserControl.ShowInfoError("Incorrect Passcode", "Passcode entered was incorrect. Please try again.");
                    SurveyPasscode.Text = "";
                }
            }
        });
    }
Exemple #4
0
    /// <summary>
    /// Handles events that occur when a button in the Questions list view is clicked.
    /// </summary>
    /// <param name="sender">Contains a reference to the control/object that raised the event.</param>
    /// <param name="e">Provides data for the ItemCommand event, which occurs when a button in a ListView is clicked.</param>
    protected void UpdateQuestionsListView_ItemCommand(object sender, ListViewCommandEventArgs e)
    {
        //hide message user control
        MessageUserControl.Visible = false;

        //If the Edit button is clicked, show informational message
        if (e.CommandName.Equals("Edit"))
        {
            MessageUserControl.Visible = true;
            MessageUserControl.ShowInfo("Edit Mode Active", "The question text in the selected row can now be edited.");
        }
        //If the Change button is clicked, do the following actions:
        else if (e.CommandName.Equals("Change"))
        {
            int i = e.Item.DisplayIndex;

            //Capture and store the question text on the selected index
            TextBox questionTextBox = UpdateQuestionsListView.Items[i].FindControl("questionTextTextBox") as TextBox;
            string  questionText    = questionTextBox.Text;

            //handle null values and white-space-only values
            if (string.IsNullOrEmpty(questionText) || string.IsNullOrWhiteSpace(questionText))
            {
                //show error message
                MessageUserControl.Visible = true;
                MessageUserControl.ShowInfoError("Processing Error", "Question is required.");

                //highlight the question textbox that handled the error
                questionTextBox.Focus();
            }
            //if user-entered value is not null or just a white space, do the the following actions:
            else
            {
                //find the question Id repeater that stores the question Ids associated with the edited question text
                Repeater questionIdRepeater = UpdateQuestionsListView.Items[i].FindControl("QuestionIdListRepeater") as Repeater;

                //loop through the question Id repeater
                foreach (RepeaterItem item in questionIdRepeater.Items)
                {
                    //capture the question Id
                    int questionId = int.Parse(((Label)item.FindControl("questionIdLabel")).Text);

                    MessageUserControl.TryRun(() =>
                    {   //check if user entered invalid values
                        Utility utility = new Utility();
                        utility.checkValidString(questionText);

                        //Update the selected question(s)
                        QuestionController sysmgr = new QuestionController();
                        sysmgr.Question_Update(questionText, questionId);

                        //turn off edit mode and refresh the listview
                        UpdateQuestionsListView.EditIndex = -1;
                        UpdateQuestionsListView.DataBind();
                    }, "Success", "Question has been updated.");
                }

                //show success/error message captured by message user control's try run method
                MessageUserControl.Visible = true;

                //reset update subquestions tab
                QuestionsWithSubQuestionsDropDownList.Items.Clear();
                QuestionsWithSubQuestionsDropDownList.Items.Add(new ListItem("Select a question...", "0"));
                QuestionsWithSubQuestionsDropDownList.DataBind();
                QuestionsWithSubQuestionsDropDownList.Enabled = true;
                FetchSubQuestionsButton.Enabled = true;

                //reset update answers tab
                QuestionsWithAnswersDropDownList.Items.Clear();
                QuestionsWithAnswersDropDownList.Items.Add(new ListItem("Select a question...", "0"));
                QuestionsWithAnswersDropDownList.DataBind();
                QuestionsWithAnswersDropDownList.Enabled = true;
                FetchAnswersButton.Enabled = true;

                //show datapager
                DataPager pager = UpdateQuestionsListView.FindControl("ActiveDataPager") as DataPager;
                pager.Visible = true;
            }
        }
        //If the Cancel button is clicked, show informational message
        else if (e.CommandName.Equals("Cancel"))
        {
            MessageUserControl.Visible = true;
            MessageUserControl.ShowInfo("Update Cancelled", "No changes to the selected question were saved.");

            //show datapager
            DataPager pager = UpdateQuestionsListView.FindControl("ActiveDataPager") as DataPager;
            pager.Visible = true;
        }
    }
Exemple #5
0
    /// <summary>
    /// Handles the actions executed by command buttons found in the Answers list view
    /// </summary>
    /// <param name="sender">Contains a reference to the control/object that raised the event.</param>
    /// <param name="e">Provides data for the ItemCommand event, which occurs when a button in a ListView is clicked.</param>
    protected void UpdateAnswersListView_ItemCommand(object sender, ListViewCommandEventArgs e)
    {
        //If the Edit button is clicked, do the following actions:
        if (e.CommandName.Equals("Edit"))
        {
            //show informational message
            MessageUserControl.Visible = true;
            MessageUserControl.ShowInfo("Edit Mode Active", "The answer text in the selected row can now be edited.");

            //disable drop-down list and fetch button to prevent editing of answers to other questions
            QuestionsWithAnswersDropDownList.Enabled = false;
            FetchAnswersButton.Enabled = false;
        }
        //If the Change button is clicked, do the following actions:
        else if (e.CommandName.Equals("Change"))
        {
            //capture the answer Id of the selected row
            int answerId = int.Parse(e.CommandArgument.ToString());
            //capture the row index of the selected row
            int i = e.Item.DisplayIndex;

            //find the answer textbox in the selected row
            TextBox answerTextBox = UpdateAnswersListView.Items[i].FindControl("descriptionTextBox") as TextBox;

            //capture the answer text from the textbox
            string answerText = answerTextBox.Text;

            //handle null values and white-space-only values
            if (string.IsNullOrEmpty(answerText) || string.IsNullOrWhiteSpace(answerText))
            {
                //show error message
                MessageUserControl.Visible = true;
                MessageUserControl.ShowInfoError("Processing Error", "Answer is required.");

                //highlight the answer textbox in the row that caused the error
                answerTextBox.Focus();
            }
            //if user-entered value is not null or just a white space, do the the following actions:
            else
            {
                MessageUserControl.TryRun(() =>
                {
                    //check if user entered invalid values
                    Utility utility = new Utility();
                    utility.checkValidString(answerText);

                    //update the answer text of the selected row
                    AnswerController sysmgr = new AnswerController();
                    sysmgr.Answer_Update(answerText, answerId);
                    UpdateAnswersListView.DataBind();
                    UpdateAnswersListView.EditIndex = -1;
                }, "Success", "Answer has been updated.");
            }

            //show success/error message
            MessageUserControl.Visible = true;

            //show datapager
            DataPager pager = UpdateAnswersListView.FindControl("ActiveDataPager") as DataPager;
            pager.Visible = true;

            //enable drop-down list and fetch button to allow editing of other answers to other questions
            QuestionsWithAnswersDropDownList.Enabled = true;
            FetchAnswersButton.Enabled = true;
        }
        //If the Cancel button is clicked, do the following actions:
        else if (e.CommandName.Equals("Cancel"))
        {
            //show informational message
            MessageUserControl.Visible = true;
            MessageUserControl.ShowInfo("Update canceled", "No changes to the selected answer were saved.");

            //show datapager
            DataPager pager = UpdateAnswersListView.FindControl("ActiveDataPager") as DataPager;
            pager.Visible = true;

            //enable drop-down list and fetch button to allow editing of other answers to other questions
            QuestionsWithAnswersDropDownList.Enabled = true;
            FetchAnswersButton.Enabled = true;
        }
    }