예제 #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);
            }
        }
예제 #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);
            }
        }
예제 #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);
 }
예제 #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;
        }
예제 #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);
        }
예제 #6
0
 public SQLCondition(DBTable table, String sField, DBValue value, SQLConditionType type)
 {
     Add(table, sField, value, type);
 }
예제 #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);
        }
예제 #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);
 }
예제 #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);
            }
        }
예제 #10
0
 public SQLCondition(string column, SQLOperator op, int value, SQLConditionType conditionType = SQLConditionType.None) : this(column, op, conditionType)
 {
     Condition += value;
 }
예제 #11
0
 public SQLCondition(string column, SQLOperator op, string value, SQLConditionType conditionType = SQLConditionType.None) : this(column, op, conditionType)
 {
     Condition += "'" + value + "'";
 }
예제 #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);
        }
예제 #13
0
 public SQLCondition(DBTable table, String sField, DBValue value, SQLConditionType type)
 {
     Add(table, sField, value, type);
 }