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 = _questionId; updatedQuestion.SurveyId = getSurveyId(); updatedQuestion.QuestionText = QuestionFreeTextBox.Text.Length > 3900 ? Server.HtmlDecode(QuestionFreeTextBox.Text.Substring(0, 3900)) : Server.HtmlDecode(QuestionFreeTextBox.Text); updatedQuestion.ColumnsNumber = int.Parse(ColumnDropdownlist.SelectedValue); updatedQuestion.MinSelectionRequired = int.Parse(MinSelectionDropDownList.SelectedValue); updatedQuestion.MaxSelectionAllowed = int.Parse(MaxAllowedDropDownList.SelectedValue); updatedQuestion.LayoutModeId = byte.Parse(DisplayModeDropDownList.SelectedValue); updatedQuestion.SelectionModeId = byte.Parse(SelectionModeDropDownList.SelectedValue); updatedQuestion.RandomizeAnswers = RatingCheckbox.Checked ? false : RandomizeCheckBox.Checked; updatedQuestion.RatingEnabled = RatingCheckbox.Checked; updatedQuestion.QuestionPipeAlias = PipeAliasTextBox.Text; updatedQuestion.QuestionIdText = txtQuestionID.Text; updatedQuestion.ShowHelpText = chbShowHelpText.Checked; updatedQuestion.Alias = txtAlias.Text; updatedQuestion.HelpText = txtHelpText.Text; updatedQuestion.SetQuestionGroupIDNull(); if (ddlGroup.SelectedIndex != 0) { updatedQuestion.QuestionGroupID = int.Parse(ddlGroup.SelectedValue); } if (ddlSubGroup.SelectedIndex != 0) { updatedQuestion.QuestionGroupID = int.Parse(ddlSubGroup.SelectedValue); } if (!RatingCheckbox.Checked) { updatedQuestion.SetQuestionGroupIDNull(); } question.Questions.AddQuestionsRow(updatedQuestion); new Question().UpdateQuestion(question, LanguagesDropdownlist.SelectedValue); MessageLabel.Visible = true; ((PageBase)Page).ShowNormalMessage(MessageLabel, ((PageBase)Page).GetPageResource("OptionsUpdatedMessage")); BindQuestionOptions(); } }
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(); } }