示例#1
0
        private void UpdateSectionsButton_Click(object sender, System.EventArgs e)
        {
            if (int.Parse(RepeatModeDropdownlist.SelectedValue) == (int)RepeatableSectionMode.None)
            {
                // Deletes section options
                new Question().DeleteQuestionSectionOptions(_questionId);
                DeleteSectionLinkTextBox.Text = string.Empty;
                AddSectionLinkTextBox.Text    = string.Empty;
                UpdateSectionLinkTextBox.Text = string.Empty;
                EditSectionLinkTextBox.Text   = string.Empty;
                AnswersListBox.Items.Clear();
                GridAnswersListBox.Items.Clear();
            }
            else
            {
                // creates a BE and update the options
                QuestionSectionOptionData sectionOptions = new QuestionSectionOptionData();
                QuestionSectionOptionData.QuestionSectionOptionsRow updatedSectionOption =
                    sectionOptions.QuestionSectionOptions.NewQuestionSectionOptionsRow();

                // Set the updated fields
                updatedSectionOption.QuestionId = _questionId;
                updatedSectionOption.RepeatableSectionModeId = int.Parse(RepeatModeDropdownlist.SelectedValue);
                updatedSectionOption.DeleteSectionLinkText   = DeleteSectionLinkTextBox.Text;
                updatedSectionOption.AddSectionLinkText      = AddSectionLinkTextBox.Text;
                updatedSectionOption.UpdateSectionLinkText   = UpdateSectionLinkTextBox.Text;
                updatedSectionOption.EditSectionLinkText     = EditSectionLinkTextBox.Text;
                updatedSectionOption.MaxSections             = int.Parse(MaxSectionAllowedDropdownlist.SelectedValue);
                sectionOptions.QuestionSectionOptions.AddQuestionSectionOptionsRow(updatedSectionOption);
                new Question().UpdateQuestionSectionOptions(sectionOptions, LanguagesDropdownlist.SelectedValue);
            }

            MessageLabel.Visible = true;
            ((PageBase)Page).ShowNormalMessage(MessageLabel, ((PageBase)Page).GetPageResource("SectionOptionsUpdatedMessage"));

            BindQuestionSectionOptions();
        }
 /// <summary>
 /// updates a section options, creates it if it doesnt exists
 /// </summary>
 public void UpdateQuestionSectionOptions(QuestionSectionOptionData sectionOptions, string languageCode)
 {
     QuestionFactory.Create().UpdateQuestionSectionOptions(sectionOptions, languageCode);
 }
        private void UpdateQuestionButton_Click(object sender, System.EventArgs e)
        {
            if (QuestionFreeTextBox.Text.Length == 0)
            {
                MessageLabel.Visible = true;
                ((PageBase)Page).ShowErrorMessage(MessageLabel, ((PageBase)Page).GetPageResource("MissingQuestionMessage"));
            }
            else
            {
                // Removes any single paragraph description
                if (QuestionFreeTextBox.Text.StartsWith("<p>") &&
                    QuestionFreeTextBox.Text.EndsWith("</p>") &&
                    QuestionFreeTextBox.Text.IndexOf("<p>", 3) < 0)
                {
                    QuestionFreeTextBox.Text = QuestionFreeTextBox.Text.Substring(3, QuestionFreeTextBox.Text.Length - 7);
                }

                // creates a BE and update the question
                QuestionData question = new QuestionData();
                QuestionData.QuestionsRow updatedQuestion =
                    question.Questions.NewQuestionsRow();

                // Set the updated fields
                updatedQuestion.QuestionId   = _parentQuestionId;
                updatedQuestion.SurveyId     = getSurveyId();
                updatedQuestion.QuestionText = QuestionFreeTextBox.Text.Length > 3900 ?
                                               Server.HtmlDecode(QuestionFreeTextBox.Text.Substring(0, 3900)) : Server.HtmlDecode(QuestionFreeTextBox.Text);
                updatedQuestion.MinSelectionRequired = int.Parse(MinSelectionDropDownList.SelectedValue);
                updatedQuestion.MaxSelectionAllowed  = int.Parse(MaxAllowedDropDownList.SelectedValue);
                updatedQuestion.RatingEnabled        = RatingCheckbox.Checked;
                updatedQuestion.RandomizeAnswers     = false;
                updatedQuestion.QuestionIdText       = txtQuestionID.Text;
                updatedQuestion.ShowHelpText         = chbShowHelpText.Checked;
                updatedQuestion.Alias          = txtAlias.Text;
                updatedQuestion.HelpText       = txtHelpText.Text;
                updatedQuestion.QuestionIdText = txtQuestionID.Text;
                updatedQuestion.SetQuestionGroupIDNull();
                if (ddlGroup.SelectedIndex != 0)
                {
                    updatedQuestion.QuestionGroupID = int.Parse(ddlGroup.SelectedValue);
                }
                if (ddlSubGroup.SelectedIndex != 0)
                {
                    updatedQuestion.QuestionGroupID = int.Parse(ddlSubGroup.SelectedValue);
                }
                if (MultipleChoiceCheckbox.Checked)
                {
                    updatedQuestion.SelectionModeId = (int)QuestionSelectionMode.MultiMatrix;
                }
                else
                {
                    updatedQuestion.SelectionModeId = (int)QuestionSelectionMode.Matrix;
                }

                question.Questions.AddQuestionsRow(updatedQuestion);

                new Question().UpdateQuestion(question, LanguagesDropdownlist.SelectedValue);

                // Matrix can be repeated
                if (RepeatSectionCheckbox.Checked)
                {
                    // creates a BE and update the options
                    QuestionSectionOptionData sectionOptions = new QuestionSectionOptionData();
                    QuestionSectionOptionData.QuestionSectionOptionsRow updatedSectionOption =
                        sectionOptions.QuestionSectionOptions.NewQuestionSectionOptionsRow();

                    // Set the updated fields
                    updatedSectionOption.QuestionId = _parentQuestionId;
                    updatedSectionOption.RepeatableSectionModeId = (int)RepeatableSectionMode.FullAnswers;
                    updatedSectionOption.DeleteSectionLinkText   = DeleteSectionLinkTextBox.Text;
                    updatedSectionOption.AddSectionLinkText      = AddSectionLinkTextBox.Text;
                    sectionOptions.QuestionSectionOptions.AddQuestionSectionOptionsRow(updatedSectionOption);
                    new Question().UpdateQuestionSectionOptions(sectionOptions, LanguagesDropdownlist.SelectedValue);
                }
                else
                {
                    new Question().DeleteQuestionSectionOptions(_parentQuestionId);
                    DeleteSectionLinkTextBox.Text = string.Empty;
                    AddSectionLinkTextBox.Text    = string.Empty;
                }

                MessageLabel.Visible = true;
                ((PageBase)Page).ShowNormalMessage(MessageLabel, ((PageBase)Page).GetPageResource("OptionsUpdatedMessage"));


                BindQuestionOptions();
                BindAnswerOptions();
            }
        }