예제 #1
0
        private bool checkExpression(eExpression exp, object value, string value1, string value2)
        {
            IComparable v = value as IComparable;
            IComparable v1 = value1, v2 = value2;
            if (value is Int32)
            {
                v1 = Int32.Parse(value1);
                if (!string.IsNullOrEmpty(value2))
                    v2 = Int32.Parse(value2);
            }
            else if (value is Double)
            {
                v1 = Double.Parse(value1);
                if (!string.IsNullOrEmpty(value2))
                    v2 = Double.Parse(value2);
            }
            else if (value is DateTime)
            {
                v1 = DateTime.Parse(value1);
                if (!string.IsNullOrEmpty(value2))
                    v2 = DateTime.Parse(value2);
            }
            int n1 = v.CompareTo(v1);
            int n2 = v.CompareTo(v2);
            switch (exp)
            {
                case eExpression.Between:
                    if (n1 >= 0 && n2 <= 0) return true;
                    break;
                case eExpression.LessThan:
                    if (n1 < 0) return true;
                    break;
                case eExpression.LessThanOrEqual:
                    if (n1 <= 0) return true;
                    break;
                case eExpression.Equal:
                    if (n1 == 0) return true;
                    break;
                case eExpression.GreaterThanOrEqual:
                    if (n1 >= 0) return true;
                    break;
                case eExpression.GreaterThan:
                    if (n2 > 0) return true;
                    break;
            }

            return false;
        }
예제 #2
0
        private bool checkExpression(eExpression exp, object value, string value1, string value2)
        {
            IComparable v = value as IComparable;
            IComparable v1 = value1, v2 = value2;

            if (value is Int32)
            {
                v1 = Int32.Parse(value1);
                if (!string.IsNullOrEmpty(value2))
                {
                    v2 = Int32.Parse(value2);
                }
            }
            else if (value is Double)
            {
                v1 = Double.Parse(value1);
                if (!string.IsNullOrEmpty(value2))
                {
                    v2 = Double.Parse(value2);
                }
            }
            else if (value is DateTime)
            {
                v1 = DateTime.Parse(value1);
                if (!string.IsNullOrEmpty(value2))
                {
                    v2 = DateTime.Parse(value2);
                }
            }
            int n1 = v.CompareTo(v1);
            int n2 = v.CompareTo(v2);

            switch (exp)
            {
            case eExpression.Between:
                if (n1 >= 0 && n2 <= 0)
                {
                    return(true);
                }
                break;

            case eExpression.LessThan:
                if (n1 < 0)
                {
                    return(true);
                }
                break;

            case eExpression.LessThanOrEqual:
                if (n1 <= 0)
                {
                    return(true);
                }
                break;

            case eExpression.Equal:
                if (n1 == 0)
                {
                    return(true);
                }
                break;

            case eExpression.GreaterThanOrEqual:
                if (n1 >= 0)
                {
                    return(true);
                }
                break;

            case eExpression.GreaterThan:
                if (n2 > 0)
                {
                    return(true);
                }
                break;
            }

            return(false);
        }