예제 #1
0
        /// <summary>
        /// Creates a new object that is a copy of the current instance.
        /// </summary>
        /// <returns>
        /// A new object that is a copy of this instance.
        /// </returns>
        public override object Clone()
        {
            NumberCondition condition = base.Clone() as NumberCondition;

            condition.compareType  = this.compareType;
            condition.integerValue = this.integerValue;
            return(condition);
        }
예제 #2
0
        /// <summary>
        /// Creates a validator based on numbers.
        /// </summary>
        /// <param name="typeOperator">
        /// The type of <see cref="P:Dt.Cells.Data.DataValidator.ComparisonOperator" /> compare operator.
        /// </param>
        /// <param name="v1">The first object.</param>
        /// <param name="v2">The second object.</param>
        /// <param name="isIntegerValue">
        /// <c>true</c> if the validator is set to a number; otherwise, <c>false</c>.
        /// </param>
        /// <returns>Returns a new validator.</returns>
        public static DataValidator CreateNumberValidator(Dt.Cells.Data.ComparisonOperator typeOperator, object v1, object v2, bool isIntegerValue)
        {
            string        formula  = IsFormula(v1) ? (v1 as string).TrimStart(new char[] { '=' }) : null;
            object        expected = IsFormula(v1) ? null : v1;
            string        str2     = IsFormula(v2) ? (v2 as string).TrimStart(new char[] { '=' }) : null;
            object        obj3     = IsFormula(v2) ? null : v2;
            ConditionBase base2    = null;

            switch (typeOperator)
            {
            case Dt.Cells.Data.ComparisonOperator.Between:
            {
                NumberCondition condition = new NumberCondition(GeneralCompareType.GreaterThanOrEqualsTo, expected, formula)
                {
                    IntegerValue = isIntegerValue
                };
                NumberCondition condition2 = new NumberCondition(GeneralCompareType.LessThanOrEqualsTo, obj3, str2)
                {
                    IntegerValue = isIntegerValue
                };
                base2 = new RelationCondition(RelationCompareType.And, condition, condition2);
                break;
            }

            case Dt.Cells.Data.ComparisonOperator.NotBetween:
            {
                NumberCondition condition3 = new NumberCondition(GeneralCompareType.LessThan, expected, formula)
                {
                    IntegerValue = isIntegerValue
                };
                NumberCondition condition4 = new NumberCondition(GeneralCompareType.GreaterThan, obj3, str2)
                {
                    IntegerValue = isIntegerValue
                };
                base2 = new RelationCondition(RelationCompareType.Or, condition3, condition4);
                break;
            }

            case Dt.Cells.Data.ComparisonOperator.EqualTo:
            {
                NumberCondition condition5 = new NumberCondition(GeneralCompareType.EqualsTo, expected, formula)
                {
                    IntegerValue = isIntegerValue
                };
                base2 = condition5;
                break;
            }

            case Dt.Cells.Data.ComparisonOperator.NotEqualTo:
            {
                NumberCondition condition6 = new NumberCondition(GeneralCompareType.NotEqualsTo, expected, formula)
                {
                    IntegerValue = isIntegerValue
                };
                base2 = condition6;
                break;
            }

            case Dt.Cells.Data.ComparisonOperator.GreaterThan:
            {
                NumberCondition condition7 = new NumberCondition(GeneralCompareType.GreaterThan, expected, formula)
                {
                    IntegerValue = isIntegerValue
                };
                base2 = condition7;
                break;
            }

            case Dt.Cells.Data.ComparisonOperator.LessThan:
            {
                NumberCondition condition9 = new NumberCondition(GeneralCompareType.LessThan, expected, formula)
                {
                    IntegerValue = isIntegerValue
                };
                base2 = condition9;
                break;
            }

            case Dt.Cells.Data.ComparisonOperator.GreaterThanOrEqualTo:
            {
                NumberCondition condition8 = new NumberCondition(GeneralCompareType.GreaterThanOrEqualsTo, expected, formula)
                {
                    IntegerValue = isIntegerValue
                };
                base2 = condition8;
                break;
            }

            case Dt.Cells.Data.ComparisonOperator.LessThanOrEqualTo:
            {
                NumberCondition condition10 = new NumberCondition(GeneralCompareType.LessThanOrEqualsTo, expected, formula)
                {
                    IntegerValue = isIntegerValue
                };
                base2 = condition10;
                break;
            }
            }
            return(new DataValidator(base2)
            {
                type = isIntegerValue ? CriteriaType.WholeNumber : CriteriaType.DecimalValues, ComparisonOperator = typeOperator
            });
        }