コード例 #1
0
        private AutoFilterRowCondition TransformFromAutoFilterCondition(DevExpress.XtraGrid.Columns.AutoFilterCondition filterType)
        {
            switch (filterType)
            {
            case DevExpress.XtraGrid.Columns.AutoFilterCondition.Default: return(AutoFilterRowCondition.Default);

            case DevExpress.XtraGrid.Columns.AutoFilterCondition.Like: return(AutoFilterRowCondition.Like);

            case DevExpress.XtraGrid.Columns.AutoFilterCondition.Equals: return(AutoFilterRowCondition.Equals);

            case DevExpress.XtraGrid.Columns.AutoFilterCondition.Contains: return(AutoFilterRowCondition.Contains);

            case DevExpress.XtraGrid.Columns.AutoFilterCondition.BeginsWith: return(AutoFilterRowCondition.BeginsWith);

            case DevExpress.XtraGrid.Columns.AutoFilterCondition.EndsWith: return(AutoFilterRowCondition.EndsWith);

            case DevExpress.XtraGrid.Columns.AutoFilterCondition.DoesNotContain: return(AutoFilterRowCondition.DoesNotContain);

            case DevExpress.XtraGrid.Columns.AutoFilterCondition.DoesNotEqual: return(AutoFilterRowCondition.DoesNotEqual);

            case DevExpress.XtraGrid.Columns.AutoFilterCondition.Greater: return(AutoFilterRowCondition.Greater);

            case DevExpress.XtraGrid.Columns.AutoFilterCondition.GreaterOrEqual: return(AutoFilterRowCondition.GreaterOrEqual);

            case DevExpress.XtraGrid.Columns.AutoFilterCondition.Less: return(AutoFilterRowCondition.Less);

            case DevExpress.XtraGrid.Columns.AutoFilterCondition.LessOrEqual: return(AutoFilterRowCondition.LessOrEqual);

            case DevExpress.XtraGrid.Columns.AutoFilterCondition.NotLike: return(AutoFilterRowCondition.NotLike);

            default: throw new UserFriendlyException($"Auto Filter Condition {filterType} was not recognised.");
            }
        }
コード例 #2
0
 protected override DevExpress.Data.Filtering.CriteriaOperator CreateAutoFilterCriterion(DevExpress.XtraGrid.Columns.GridColumn column, DevExpress.XtraGrid.Columns.AutoFilterCondition condition, object _value, string strVal)
 {
     if (column.ColumnType == typeof(DateTime) && strVal.Length > 0)
     {
         BinaryOperatorType type    = BinaryOperatorType.Equal;
         string             operand = string.Empty;
         if (strVal.Length > 1)
         {
             operand = strVal.Substring(0, 2);
             if (operand.Equals(">="))
             {
                 type = BinaryOperatorType.GreaterOrEqual;
             }
             else if (operand.Equals("<="))
             {
                 type = BinaryOperatorType.LessOrEqual;
             }
         }
         if (type == BinaryOperatorType.Equal)
         {
             operand = strVal.Substring(0, 1);
             if (operand.Equals(">"))
             {
                 type = BinaryOperatorType.Greater;
             }
             else if (operand.Equals("<"))
             {
                 type = BinaryOperatorType.Less;
             }
         }
         if (type != BinaryOperatorType.Equal)
         {
             string val = strVal.Replace(operand, string.Empty);
             try
             {
                 DateTime dt = DateTime.ParseExact(val, "d", column.RealColumnEdit.EditFormat.Format);
                 return(new BinaryOperator(column.FieldName, dt, type));
             }
             catch
             {
                 return(null);
             }
         }
     }
     return(base.CreateAutoFilterCriterion(column, condition, _value, strVal));
 }