Example #1
0
        public override DataSet Clone()
        {
            FilterData data = (FilterData)base.Clone();

            data.InitVars();
            return(data);
        }
 /// <summary>
 /// Adds a new filter
 /// </summary>
 /// <param name="newFilter"></param>
 public void AddFilter(FilterData newFilter)
 {
     SqlConnection connection = new SqlConnection(DbConnection.NewDbConnectionString);
     SqlCommand insertCommand = new SqlCommand("vts_spFilterAddNew", connection);
     insertCommand.CommandType = CommandType.StoredProcedure;
     insertCommand.Parameters.Add(new SqlParameter("@SurveyId", SqlDbType.Int, 4, "SurveyId"));
     insertCommand.Parameters.Add(new SqlParameter("@Description", SqlDbType.VarChar, 200, "Description"));
     insertCommand.Parameters.Add(new SqlParameter("@LogicalOperatorTypeID", SqlDbType.Int, 4, "LogicalOperatorTypeID"));
     insertCommand.Parameters.Add(new SqlParameter("@FilterId", SqlDbType.Int, 4, "FilterId"));
     insertCommand.Parameters.Add(new SqlParameter("@ParentFilterId", SqlDbType.Int, 4, "ParentFilterId"));
     insertCommand.Parameters["@FilterId"].Direction = ParameterDirection.Output;
     DbConnection.db.UpdateDataSet(newFilter, "Filters", insertCommand, new SqlCommand(), new SqlCommand(), UpdateBehavior.Transactional);
 }
 /// <summary>
 /// Update the filter options
 /// </summary>
 /// <param name="updatedFilter"></param>
 public void UpdateFilter(FilterData updatedFilter)
 {
     FilterFactory.Create().UpdateFilter(updatedFilter);
 }
 /// <summary>
 /// Adds a new filter
 /// </summary>
 /// <param name="newFilter"></param>
 public void AddFilter(FilterData newFilter)
 {
     FilterFactory.Create().AddFilter(newFilter);
 }
 public FiltersRowChangeEvent(FilterData.FiltersRow row, DataRowAction action)
 {
     this.eventRow = row;
     this.eventAction = action;
 }
 public void RemoveFiltersRow(FilterData.FiltersRow row)
 {
     base.Rows.Remove(row);
 }
 public void AddFiltersRow(FilterData.FiltersRow row)
 {
     base.Rows.Add(row);
 }
        public FilterData GetFilters(int surveyId)
        {
            FilterData dataSet = new FilterData();

            ArrayList commandParameters = new ArrayList();
            {
                commandParameters.Add(new SqlParameter("@SurveyID", surveyId).SqlValue);
            }

            DbConnection.db.LoadDataSet("vts_spFilterGetForSurvey", dataSet, new string[] { "Filters" }, commandParameters.ToArray());
            return dataSet;
        }
        public FilterData GetFilterById(int filterId)
        {
            FilterData dataSet = new FilterData();

            ArrayList commandParameters = new ArrayList();
            {
                commandParameters.Add(new SqlParameter("@FilterId", filterId).SqlValue);
            }

            DbConnection.db.LoadDataSet("vts_spFilterGetDetails", dataSet, new string[] { "Filters" }, commandParameters.ToArray());
            return dataSet;
        }
        public FilterData GetEmptyFilter()
        {
            var dataSet = new FilterData();
            dataSet.Filters.AddFiltersRow(0, "", 0, 0);

            return dataSet;
        }
 /// <summary>
 /// Update the filter options
 /// </summary>
 /// <param name="updatedFilter"></param>
 public void UpdateFilter(FilterData updatedFilter)
 {
     SqlConnection connection = new SqlConnection(DbConnection.NewDbConnectionString);
     SqlCommand insertCommand = new SqlCommand("vts_spFilterUpdate", connection);
     insertCommand.CommandType = CommandType.StoredProcedure;
     insertCommand.Parameters.Add(new SqlParameter("@FilterId", SqlDbType.Int, 4, "FilterId"));
     insertCommand.Parameters.Add(new SqlParameter("@Description", SqlDbType.VarChar, 200, "Description"));
     insertCommand.Parameters.Add(new SqlParameter("@LogicalOperatorTypeID", SqlDbType.SmallInt, 4, "LogicalOperatorTypeID"));
     insertCommand.Parameters.Add(new SqlParameter("@ParentFilterId", SqlDbType.Int, 4, "ParentFilterId"));
     DbConnection.db.UpdateDataSet(updatedFilter, "Filters", insertCommand, new SqlCommand(), insertCommand, UpdateBehavior.Transactional);
 }
 private void CreatefilterButton_Click(object sender, System.EventArgs e)
 {
     if (FilterNameTextBox.Text.Length == 0)
     {
         MessageLabel.Visible = true;
         ((PageBase)Page).ShowErrorMessage(MessageLabel, ((PageBase)Page).GetPageResource("InvalidFilterDescriptionMessage"));
     }
     else
     {
         FilterData filterData = new FilterData();
         FilterData.FiltersRow filterRow = filterData.Filters.NewFiltersRow();
         filterRow.LogicalOperatorTypeID = short.Parse(LogicalOperatorDropDownList.SelectedValue);
         filterRow.Description = FilterNameTextBox.Text;
         filterRow.SurveyId = SurveyId;
         filterRow.ParentFilterId = int.Parse(ParentFilterNameDropDownList.SelectedValue);
         filterData.Filters.AddFiltersRow(filterRow);
         new Filter().AddFilter(filterData);
         UINavigator.NavigateToFilterEditor(SurveyId, ((PageBase)Page).MenuIndex);
     }
 }
        void AddFilter(QuestionData.QuestionsRow q, AnswerData.AnswersRow a, FilterData.FiltersRow p)
        {
            FilterData filterData = new FilterData();
            FilterData.FiltersRow filterRow = filterData.Filters.NewFiltersRow();
            filterRow.LogicalOperatorTypeID = short.Parse(LogicalOperatorDropDownList.SelectedValue);
            filterRow.Description = FilterName(q, a, p);
            filterRow.SurveyId = SurveyId;
            filterRow.ParentFilterId = p.FilterId;
            filterData.Filters.AddFiltersRow(filterRow);
            new Filter().AddFilter(filterData);

            FilterRuleData filterRuleData = new FilterRuleData();
            FilterRuleData.FilterRulesRow filterRuleRow = filterRuleData.FilterRules.NewFilterRulesRow();
            filterRuleRow.QuestionId = q.QuestionId;
            filterRuleRow.AnswerId = a.AnswerId;
            filterRuleRow.FilterId = filterRow.FilterId;
            filterRuleData.FilterRules.AddFilterRulesRow(filterRuleRow);
            new Filter().AddRule(filterRuleData);
        }
        private string GetFilterPart(FilterData.FiltersRow f, string splitChar)
        {
            var split = f.Description.Split(new[] { splitChar[0] });

            return split.Any()
                ? split[0]
                : f.Description;
        }
        public string FilterName(QuestionData.QuestionsRow q, AnswerData.AnswersRow a, FilterData.FiltersRow f)
        {
            const string splitChar = "|";

            return f.FilterId == 0
                ? FilterName(q, a, splitChar)
                : FilterName(q, a, f, splitChar);
        }
 public string FilterName(QuestionData.QuestionsRow q, AnswerData.AnswersRow a, FilterData.FiltersRow f, string splitChar)
 {
     return GetSubstr(GetFilterPart(f, splitChar)) + splitChar + FilterName(q, a, splitChar);
 }