Exemplo n.º 1
0
        public override DataSet Clone()
        {
            BranchingRuleData data = (BranchingRuleData)base.Clone();

            data.InitVars();
            return(data);
        }
 /// <summary>
 /// Add a new branching rule to the survey
 /// </summary>
 /// <param name="newBranchingRule"></param>
 public void AddBranchingRule(BranchingRuleData newBranchingRule)
 {
     SurveyFactory.Create().AddBranchingRule(newBranchingRule);
 }
        /// <summary>
        /// returns the branching rules for the given page with all
        /// their details
        /// </summary>
        /// <param name="surveyId"></param>
        /// <param name="pageNumber"></param>
        /// <returns></returns>
        public BranchingRuleData GetSurveyPageBranchingRulesDetails(int surveyId, int pageNumber)
        {
            BranchingRuleData branchingRule = new BranchingRuleData();

            //SqlParameter[] spParameters = new SqlParameter[2];
            //spParameters[0] = new SqlParameter("@SurveyId", surveyId);
            //spParameters[1] = new SqlParameter("@pageNumber", pageNumber);

            ArrayList sqlParams = new ArrayList();
            {
                sqlParams.Add(new SqlParameter("@SurveyId", surveyId).SqlValue);
                sqlParams.Add(new SqlParameter("@pageNumber", pageNumber).SqlValue);
            }

            DbConnection.db.LoadDataSet("vts_spSurveyBranchingRuleGetDetailsForPage", branchingRule, new string[] { "BranchingRules" }, sqlParams.ToArray());

            return branchingRule;

        }
 /// <summary>
 /// returns the branching rules for the given survey
 /// </summary>
 /// <param name="surveyId"></param>
 /// <returns></returns>
 public BranchingRuleData GetSurveyBranchingRules(int surveyId)
 {
     BranchingRuleData branchingRule = new BranchingRuleData();
    DbConnection.db.LoadDataSet("vts_spSurveyBranchingRuleGetAll", branchingRule, new string[] { "BranchingRules" }, new SqlParameter("@SurveyID", surveyId).SqlValue);
     return branchingRule;
 }
        /// <summary>
        /// Add a new branching rule to the survey
        /// </summary>
        public void AddBranchingRule(BranchingRuleData newBranchingRule)
        {

            SqlConnection dbConnection = new SqlConnection(DbConnection.NewDbConnectionString);
            SqlCommand addNewRule = new SqlCommand("vts_spSurveyBranchingRuleAddNew", dbConnection);
            addNewRule.CommandType = CommandType.StoredProcedure;
            addNewRule.Parameters.Add(new SqlParameter("@PageNumber", SqlDbType.Int, 4, "PageNumber"));
            addNewRule.Parameters.Add(new SqlParameter("@ExpressionOperator", SqlDbType.Int, 4, "ExpressionOperator"));
            addNewRule.Parameters.Add(new SqlParameter("@QuestionID", SqlDbType.Int, 4, "QuestionID"));
            addNewRule.Parameters.Add(new SqlParameter("@AnswerID", SqlDbType.Int, 4, "AnswerID"));
            addNewRule.Parameters.Add(new SqlParameter("@TargetPageNumber", SqlDbType.Int, 4, "TargetPageNumber"));
            addNewRule.Parameters.Add(new SqlParameter("@TextFilter", SqlDbType.NVarChar, 4000, "TextFilter"));
            addNewRule.Parameters.Add(new SqlParameter("@ConditionalOperator", SqlDbType.Int, 4, "ConditionalOperator"));
            addNewRule.Parameters.Add(new SqlParameter("@Score", SqlDbType.Int, 4, "Score"));
            addNewRule.Parameters.Add(new SqlParameter("@ScoreMax", SqlDbType.Int, 4, "ScoreMax"));
            addNewRule.Parameters.Add(new SqlParameter("@BranchingRuleID", SqlDbType.Int, 4, "BranchingRuleID"));
            addNewRule.Parameters["@BranchingRuleID"].Direction = ParameterDirection.Output;

            //SqlHelper.UpdateDataset(addNewRule, new SqlCommand(), new SqlCommand(), newBranchingRule, "BranchingRules", true);
           DbConnection.db.UpdateDataSet(newBranchingRule, "BranchingRules", addNewRule, new SqlCommand(), new SqlCommand(), UpdateBehavior.Transactional);
        }
 public BranchingRulesRowChangeEvent(BranchingRuleData.BranchingRulesRow row, DataRowAction action)
 {
     this.eventRow = row;
     this.eventAction = action;
 }
 public void RemoveBranchingRulesRow(BranchingRuleData.BranchingRulesRow row)
 {
     base.Rows.Remove(row);
 }
 public void AddBranchingRulesRow(BranchingRuleData.BranchingRulesRow row)
 {
     base.Rows.Add(row);
 }
        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;
        }