示例#1
0
        public List <PerformerSearchCriteria> GetFilters()
        {
            var stat   = new PerformerStat();
            var result = new List <PerformerSearchCriteria>();

            if (fioCheckBox.Checked)
            {
                result.Add(new PerformerSearchCriteria
                {
                    propertyName = stat.Property(t => t.FullName),
                    compradant   = fioTextBox.Text,
                    ignoreCase   = !fioCSCheckBox.Checked
                });
            }
            if (emailCheckBox.Checked)
            {
                result.Add(new PerformerSearchCriteria
                {
                    propertyName = stat.Property(t => t.Email),
                    compradant   = emailTextBox.Text,
                    ignoreCase   = !emailCSCheckBox.Checked
                });
            }
            if (accountCheckBox.Checked)
            {
                result.Add(new PerformerSearchCriteria
                {
                    propertyName   = stat.Property(t => t.Account),
                    compradant     = accountNumericUpDown.Value.ToString(),
                    ignoreCase     = true,
                    checkWholeWord = true
                });
            }
            return(result);
        }
        private void UpdateServiceTypeInSelectedFunction()
        {
            var stat             = new PerformerStat();
            var serviceTypeFiled = PerformerStatField.fields.FirstOrDefault(f => f.PropertyName == stat.Property(p => p.ServiceType));

            SelectedFunction.Filters.RemoveAll(f => f.a == serviceTypeFiled);
            if (signalsToolStripMenuItem.Checked || pammsToolStripMenuItem.Checked)
            {
                SelectedFunction.Filters.Add(
                    new Cortege3 <PerformerStatField, ExpressionOperator, double>(serviceTypeFiled, ExpressionOperator.Equal,
                                                                                  ((signalsToolStripMenuItem.Checked ? 1 : 0) +
                                                                                   (pammsToolStripMenuItem.Checked ? 2 : 0))));
            }
            topFilterControl.SetExpression(SelectedFunction);
        }
        private void UpdateExpression()
        {
            // если что-то изменили в таблице, то формула обновляется;
            // если таблица в предыдущей итерации не смогла представить ее, то старая формула стирается,
            // и новая начинает формироваться по таблице
            var expression = "";

            foreach (var fiterObject in filterObjects)
            {
                if (!fiterObject.Selected)
                {
                    continue;
                }
                expression = fiterObject.UpdateExpression(expression);
            }
            // избегаем ошибки парсинга в PerformerStatField.ParseSimpleFormula, задавая поле для сортировки
            if (SortField == null)
            {
                var blank = new PerformerStat();
                SortField = PerformerStatField.fields.FirstOrDefault(f => f.PropertyName == blank.Property(p => p.Profit));
                if (SortField == null)
                {
                    return;
                }
            }
            expression       = (!string.IsNullOrEmpty(expression) ? "(" + expression + ")*" : "") + SortField.ExpressionParamName;
            SelectedFunction = new PerformerCriteriaFunction
            {
                Function           = expression,
                PreferredSortOrder = SortOrder,
                MarginValue        = 0
            };
            expressionLabel.Text = SelectedFunction.Function;
            if (PerformerCriteriaFunctionChanged != null)
            {
                PerformerCriteriaFunctionChanged(this, new EventArgs());
            }
        }