示例#1
0
    /// <summary>
    /// Handles events that occur when an edit operation is requested, but before the Update Subquestions ListView item is put in edit mode.
    /// </summary>
    /// <param name="sender">Contains a reference to the control/object that raised the event.</param>
    /// <param name="e">Provides data for the ItemEditing event, which occurs when an edit operation is requested but before the ListView item is put in edit mode.</param>
    protected void UpdateSubQuestionsListView_ItemEditing(object sender, ListViewEditEventArgs e)
    {
        //hide message user control
        MessageUserControl.Visible = false;

        //hide datapager
        DataPager pager = UpdateSubQuestionsListView.FindControl("ActiveDataPager") as DataPager;

        pager.Visible = false;
    }
示例#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 FetchSubQuestionsButton_Click(object sender, EventArgs e)
    {
        //if user selects the "Select a question..." option in the dropdown list, do the following actions:
        if (QuestionsWithSubQuestionsDropDownList.SelectedValue == "0")
        {
            //show error message
            MessageUserControl.Visible = true;
            MessageUserControl.ShowInfoError("No Question Selected", "Please select a question.");

            //highlight the dropdown list, and refresh the Update Subquestions listview
            QuestionsWithSubQuestionsDropDownList.Focus();
            UpdateSubQuestionsListView.DataBind();
        }
        //if user selects a question from the dropdown list, show informational message
        else
        {
            MessageUserControl.ShowInfo("Subquestions Displayed", "Subquestions under the selected question are now displayed.");
            UpdateSubQuestionsListView.DataBind();
        }
    }
示例#3
0
    /// <summary>
    /// Handles events that occur when a button in the Subquestions 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 UpdateSubQuestionsListView_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 subquestion text in the selected row can now be edited.");

            //disable drop-down list and fetch button to prevent editing of subquestions of other questions
            QuestionsWithSubQuestionsDropDownList.Enabled = false;
            FetchSubQuestionsButton.Enabled = false;
        }
        //If the Change button is clicked, do the following actions:
        else if (e.CommandName.Equals("Change"))
        {
            //capture the questionId associated to the selected subquestion
            int questionId = int.Parse(e.CommandArgument.ToString());

            //capture the display index
            int i = e.Item.DisplayIndex;

            //find the selected subquestion text box
            TextBox subQuestionTextBox = UpdateSubQuestionsListView.Items[i].FindControl("subQuestionTextTextBox") as TextBox;

            //capture the question text in the selected subquestion text box
            string subQuestionText = subQuestionTextBox.Text;

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

                //highlight the subquestion row that caused the error
                subQuestionTextBox.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(subQuestionText);

                    //update the subquestion text of the selected row
                    QuestionController sysmgr = new QuestionController();
                    sysmgr.SubQuestion_Update(questionId, subQuestionText);
                    UpdateSubQuestionsListView.DataBind();
                    UpdateSubQuestionsListView.EditIndex = -1;
                }, "Success", "Subquestion has been updated.");
            }

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

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

            //enable drop-down list and fetch button to allow editing of other subquestions of other questions
            QuestionsWithSubQuestionsDropDownList.Enabled = true;
            FetchSubQuestionsButton.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 Cancelled", "No changes to the selected subquestion were saved.");

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

            //enable drop-down list and fetch button to allow editing of other subquestions of other questions
            QuestionsWithSubQuestionsDropDownList.Enabled = true;
            FetchSubQuestionsButton.Enabled = true;
        }
    }