private void AddRuleButton_Click(object sender, System.EventArgs e)
        {
            BranchingRuleData branchingRuleData = new BranchingRuleData();

            BranchingRuleData.BranchingRulesRow branchingRule = branchingRuleData.BranchingRules.NewBranchingRulesRow();

            if ((LogicDropDownList.SelectedValue == "3" ||
                 LogicDropDownList.SelectedValue == "4" ||
                 LogicDropDownList.SelectedValue == "5") &&
                Information.IsNumeric(ScoreTextbox.Text))
            {
                branchingRule.Score = int.Parse(ScoreTextbox.Text);
            }
            else if (LogicDropDownList.SelectedValue == "6" &&
                     Information.IsNumeric(ScoreTextbox.Text) &&
                     Information.IsNumeric(ScoreMaxTextbox.Text))
            {
                branchingRule.Score    = int.Parse(ScoreTextbox.Text);
                branchingRule.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)
                {
                    branchingRule.SetAnswerIdNull();
                }
                else if (answerId < 0)
                {
                    branchingRule.AnswerId = -answerId;
                }
                else
                {
                    branchingRule.AnswerId = answerId;
                }

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

            branchingRule.QuestionId          = int.Parse(QuestionFilterDropdownlist.SelectedValue);
            branchingRule.TargetPageNumber    = int.Parse(PageTargetDropdownlist.SelectedValue);
            branchingRule.ConditionalOperator = int.Parse(LogicDropDownList.SelectedValue);
            branchingRule.PageNumber          = _pageNumber;
            branchingRuleData.BranchingRules.AddBranchingRulesRow(branchingRule);
            new Survey().AddBranchingRule(branchingRuleData);
            MessageLabel.Visible = true;
            ((PageBase)Page).ShowNormalMessage(MessageLabel, ((PageBase)Page).GetPageResource("BranchingRuleAddedMessage"));
            BindFields();
            ScoreTextbox.Text    = string.Empty;
            ScoreMaxTextbox.Text = string.Empty;
        }
 /// <summary>
 /// Add a new branching rule to the survey
 /// </summary>
 /// <param name="newBranchingRule"></param>
 public void AddBranchingRule(BranchingRuleData newBranchingRule)
 {
     SurveyFactory.Create().AddBranchingRule(newBranchingRule);
 }