/// <summary>
 /// Add a new skip logic rule
 /// </summary>
 public void AddSkipLogicRule(SkipLogicRuleData newSkipLogicRule)
 {
     QuestionFactory.Create().AddSkipLogicRule(newSkipLogicRule);
 }
예제 #2
0
        private void AddRuleButton_Click(object sender, System.EventArgs e)
        {
            SkipLogicRuleData skipLogicRuleData = new SkipLogicRuleData();

            SkipLogicRuleData.SkipLogicRulesRow skipLogicRule = skipLogicRuleData.SkipLogicRules.NewSkipLogicRulesRow();

            if ((LogicDropDownList.SelectedValue == "3" ||
                 LogicDropDownList.SelectedValue == "4" ||
                 LogicDropDownList.SelectedValue == "5") &&
                Information.IsNumeric(ScoreTextbox.Text))
            {
                skipLogicRule.Score = int.Parse(ScoreTextbox.Text);
            }
            else if (LogicDropDownList.SelectedValue == "6" &&
                     Information.IsNumeric(ScoreTextbox.Text) &&
                     Information.IsNumeric(ScoreMaxTextbox.Text))
            {
                skipLogicRule.Score    = int.Parse(ScoreTextbox.Text);
                skipLogicRule.ScoreMax = int.Parse(ScoreMaxTextbox.Text);
            }
            else if (LogicDropDownList.SelectedValue == "3" ||
                     LogicDropDownList.SelectedValue == "4" ||
                     LogicDropDownList.SelectedValue == "5" ||
                     LogicDropDownList.SelectedValue == "6")
            {
                ((PageBase)Page).ShowErrorMessage(MessageLabel, ((PageBase)Page).GetPageResource("ScoreNotNumericMessage"));
                MessageLabel.Visible = true;
                return;
            }
            else
            {
                int answerId = int.Parse(AnswerFilterDropdownlist.SelectedValue);
                if (answerId == 0)
                {
                    skipLogicRule.SetAnswerIdNull();
                }
                else if (answerId < 0)
                {
                    skipLogicRule.AnswerId = -answerId;
                }
                else
                {
                    skipLogicRule.AnswerId = answerId;
                }

                if (TextFilterTextbox.Visible)
                {
                    skipLogicRule.ExpressionOperator =
                        int.Parse(ExpressionLogicDropdownlist.SelectedValue);
                    skipLogicRule.TextFilter = TextFilterTextbox.Text;
                }
            }

            skipLogicRule.SkipQuestionId      = _questionId;
            skipLogicRule.QuestionId          = int.Parse(QuestionFilterDropdownlist.SelectedValue);
            skipLogicRule.ConditionalOperator = int.Parse(LogicDropDownList.SelectedValue);
            skipLogicRuleData.SkipLogicRules.AddSkipLogicRulesRow(skipLogicRule);
            new Question().AddSkipLogicRule(skipLogicRuleData);
            MessageLabel.Visible = true;
            ((PageBase)Page).ShowNormalMessage(MessageLabel, ((PageBase)Page).GetPageResource("SkipLogicRuleAddedMessage"));
            BindFields();
            ScoreTextbox.Text    = string.Empty;
            ScoreMaxTextbox.Text = string.Empty;
        }