Esempio n. 1
0
        public void Add(DBTable table, String sField, DBValue value, SQLConditionType type)
        {
            if (table.m_fields.ContainsKey(sField))
            {
                String sValue = String.Empty;
                switch (table.m_fields[sField].Type)
                {
                case DBField.cTypeInt:
                    sValue = value;
                    break;

                case DBField.cTypeString:
                    if (type == SQLConditionType.Like || type == SQLConditionType.NotLike)
                    {
                        sValue = "'%" + ((String)value).Replace("'", "''") + "%'";
                    }
                    else
                    {
                        sValue = "'" + ((String)value).Replace("'", "''") + "'";
                    }
                    break;
                }
                AddCustom(table.m_tableName + "." + sField, sValue, type);
            }
        }
Esempio n. 2
0
        public void AddCustom(string what, string value, SQLConditionType type)
        {
            String sType = String.Empty;

            switch (type)
            {
            case SQLConditionType.Equal:
                sType = " = ";
                break;

            case SQLConditionType.NotEqual:
                sType = " != ";
                break;

            case SQLConditionType.LessThan:
                sType = " < ";
                break;

            case SQLConditionType.LessEqualThan:
                sType = " <= ";
                break;

            case SQLConditionType.GreaterThan:
                sType = " > ";
                break;

            case SQLConditionType.GreaterEqualThan:
                sType = " >= ";
                break;

            case SQLConditionType.Like:
                sType = " like ";
                break;

            case SQLConditionType.NotLike:
                sType = " not like ";
                break;

            case SQLConditionType.In:
                sType = " in ";
                break;

            case SQLConditionType.NotIn:
                sType = " not in ";
                break;
            }

            if (SQLConditionType.In == type || SQLConditionType.NotIn == type) // reverse
            {
                AddCustom(value + sType + "(" + what + ")");
            }
            else
            {
                AddCustom(what + sType + value);
            }
        }
Esempio n. 3
0
 public void AddCustom(string what, string value, SQLConditionType type, bool EncloseIfString)
 {
     if (EncloseIfString)
     {
         if (value.Length > 2 && value[0] != '\'' && !value.IsNumerical())
         {
             value = "'" + value + "'";
         }
     }
     AddCustom(what, value, type);
 }
Esempio n. 4
0
        private SQLCondition(string column, SQLOperator op, SQLConditionType conditionType = SQLConditionType.None)
        {
            string sqlOperator = "";

            switch (op)
            {
            case SQLOperator.Equal:
                sqlOperator = "="; break;

            case SQLOperator.NEqual:
                sqlOperator = "<>"; break;

            case SQLOperator.Greater:
                sqlOperator = ">"; break;

            case SQLOperator.Lesser:
                sqlOperator = "<"; break;

            case SQLOperator.GEqual:
                sqlOperator = ">="; break;

            case SQLOperator.LEqual:
                sqlOperator = "<="; break;

            case SQLOperator.Between:
                sqlOperator = "BETWEEN"; break;

            case SQLOperator.Like:
                sqlOperator = "LIKE"; break;

            case SQLOperator.In:
                sqlOperator = "IN"; break;

            default:
                break;
            }
            switch (conditionType)
            {
            case SQLConditionType.None:
                ConditionType = ""; break;

            case SQLConditionType.And:
                ConditionType = "AND"; break;

            case SQLConditionType.Or:
                ConditionType = "OR"; break;

            default:
                ConditionType = ""; break;
            }
            Condition = column + sqlOperator;
        }
Esempio n. 5
0
        public void AddSubQuery(string field, DBTable table, SQLCondition innerConditions, DBValue value, SQLConditionType type)
        {
            string sValue;
            if (type == SQLConditionType.Like || type == SQLConditionType.NotLike)
                sValue = "'%" + ((String)value).Replace("'", "''") + "%'";
            else
                sValue = ((String)value).Replace("'", "''");

            AddCustom("( select " + field + " from " + table.m_tableName + innerConditions + innerConditions.orderString + innerConditions.limitString +  " ) ", sValue, type);
        }
Esempio n. 6
0
 public SQLCondition(DBTable table, String sField, DBValue value, SQLConditionType type)
 {
     Add(table, sField, value, type);
 }
Esempio n. 7
0
        public void AddCustom(string what, string value, SQLConditionType type)
        {
            String sType = String.Empty;
            switch (type)
            {
                case SQLConditionType.Equal:
                    sType = " = ";
                    break;

                case SQLConditionType.NotEqual:
                    sType = " != ";
                    break;
                
                case SQLConditionType.LessThan:
                    sType = " < ";
                    break;
            
                case SQLConditionType.LessEqualThan:
                    sType = " <= ";
                    break;
                
                case SQLConditionType.GreaterThan:
                    sType = " > ";
                    break;
            
                case SQLConditionType.GreaterEqualThan:
                    sType = " >= ";
                    break;
            
                case SQLConditionType.Like:
                    sType = " like ";
                    break;

                case SQLConditionType.NotLike:
                    sType = " not like ";
                    break;

                case SQLConditionType.In:
                    sType = " in ";
                    break;

                case SQLConditionType.NotIn:
                    sType = " not in ";
                    break;
            }

            if (SQLConditionType.In == type || SQLConditionType.NotIn == type) // reverse
                AddCustom(value + sType + "(" + what + ")");
            else 
                AddCustom(what + sType + value);
        }
Esempio n. 8
0
 public void AddCustom(string what, string value, SQLConditionType type, bool EncloseIfString)
 {
     if (EncloseIfString)
     {
         if (value.Length > 2 && value[0] != '\'' && !value.IsNumerical())
             value = "'" + value + "'";
     }
     AddCustom(what, value, type);
 }
Esempio n. 9
0
        public void Add(DBTable table, String sField, DBValue value, SQLConditionType type)
        {
            if (table.m_fields.ContainsKey(sField))
            {
                String sValue = String.Empty;
                switch (table.m_fields[sField].Type)
                {
                    case DBField.cTypeInt:
                        sValue = value;
                        break;

                    case DBField.cTypeString:
                        if (type == SQLConditionType.Like || type == SQLConditionType.NotLike)
                            sValue = "'%" + ((String)value).Replace("'", "''") + "%'";
                        else
                            sValue = "'" + ((String)value).Replace("'", "''") + "'";
                        break;
                }
                AddCustom(table.m_tableName + "." + sField, sValue, type);
            }
        }
Esempio n. 10
0
 public SQLCondition(string column, SQLOperator op, int value, SQLConditionType conditionType = SQLConditionType.None) : this(column, op, conditionType)
 {
     Condition += value;
 }
Esempio n. 11
0
 public SQLCondition(string column, SQLOperator op, string value, SQLConditionType conditionType = SQLConditionType.None) : this(column, op, conditionType)
 {
     Condition += "'" + value + "'";
 }
Esempio n. 12
0
        public void AddSubQuery(string field, DBTable table, SQLCondition innerConditions, DBValue value, SQLConditionType type)
        {
            string sValue;

            if (type == SQLConditionType.Like || type == SQLConditionType.NotLike)
            {
                sValue = "'%" + ((String)value).Replace("'", "''") + "%'";
            }
            else
            {
                sValue = ((String)value).Replace("'", "''");
            }

            AddCustom("( select " + field + " from " + table.m_tableName + innerConditions + innerConditions.orderString + innerConditions.limitString + " ) ", sValue, type);
        }
Esempio n. 13
0
 public SQLCondition(DBTable table, String sField, DBValue value, SQLConditionType type)
 {
     Add(table, sField, value, type);
 }