Beispiel #1
0
        public void AddFilter(BusinessFilter _filter, AndOr andor)
        {
            string strfilter;


            if (_filter == null || _filter.Filter == null || _filter.Filter.Equals(string.Empty))
            {
                return;
            }

            strfilter = _filter.Filter.Trim();

            if (strfilter.IndexOf(AndOr.AND.ToString(), 0, strfilter.Length) == 0)
            {
                strfilter = strfilter.Substring(4, strfilter.Length - 4);
            }
            else
            {
                strfilter = strfilter.Substring(3, strfilter.Length - 3);
            }

            if (this.filter == null || this.filter.Equals(string.Empty))
            {
                this.filter = string.Format(" {0}   ( {1} ) ", andor.ToString(), strfilter);
            }
            else
            {
                this.filter = string.Format("{0} {1} {2} )", this.filter, andor.ToString(), strfilter);
            }
        }
Beispiel #2
0
 public void AddCustomerFilter(string where, AndOr andor)
 {
     if (where.Equals(string.Empty))
     {
         return;
     }
     if (filter.Equals(string.Empty))
     {
         this.filter = string.Format("{0} ({1} ", andor.ToString(), where);
     }
     else
     {
         this.filter = string.Format("{0} {1}  {2} ", this.filter, andor.ToString(), where);
     }
 }
Beispiel #3
0
		public CSFilter(CSFilter filter1, AndOr andOr, CSFilter filter2)
		{
            if (filter1.IsBlank && filter2.IsBlank)
            {
                _expression = "";
                _parameters = new CSParameterCollection();
            }
            else if (filter1.IsBlank)
            {
                _expression = "(" + filter2.Expression + ")";
                _parameters = new CSParameterCollection(filter2.Parameters);
                return;
            }
            else if (filter2.IsBlank)
            {
                _expression = "(" + filter1.Expression + ")";
                _parameters = new CSParameterCollection(filter1.Parameters);
            }
            else
            {
                _expression = "(" + filter1._expression + ") " + andOr.ToString() + " (" + filter2.Expression + ")";

                _parameters = new CSParameterCollection(filter1.Parameters);
                _parameters.Add(filter2.Parameters);
            }
		}
Beispiel #4
0
        public DataTable GetDataTableQ(Category c, Attrib attrib1, string attrib1T, Attrib attrib2, string attrib2T, AndOr sign)
        {
            string           sql = "SELECT * FROM " + c.ToString() + " WHERE " + attrib1.ToString() + attrib1T + " " + sign.ToString() + " " + attrib2.ToString() + attrib2T + ";";
            SQLiteCommand    cmd = new SQLiteCommand(sql, dbConnection);
            SQLiteDataReader sdr = cmd.ExecuteReader();
            DataTable        dt  = new DataTable();

            dt.Load(sdr);
            return(dt);
        }
Beispiel #5
0
        public void AddFilterItem(string field, string Value, string operation, FilterType filterType, AndOr andor)
        {
            if (filterType == FilterType.StringType)
            {
                if (operation.ToLower().Trim().IndexOf("like") == -1)
                {
                    if (!filter.Equals(string.Empty))
                    {
                        filter = filter + string.Format(" {0} {1}.{2}  {3} '{4}'", andor.ToString(), businessobject, field, operation.ToString(), Value);
                    }
                    else
                    {
                        filter = " " + andor.ToString() + " ( " + string.Format(" {0}.{1} {2} '{3}' ", businessobject, field, operation.ToString(), Value);
                    }
                }
                else if (operation.ToLower().Trim() == "like")                /* Andy Modify 2008-12-30 性能优化 */
                {
                    if (!filter.Equals(string.Empty))
                    {
                        filter = filter + string.Format(" {0}  {1}.{2}  {3}  '%{4}%' ", andor.ToString(), businessobject, field, Operation.Like, Value);
                    }
                    else
                    {
                        filter = " " + andor.ToString() + " (" + string.Format(" {0}.{1}   {2}  '%{3}%'  ", businessobject, field, Operation.Like, Value);
                    }
                }


//					/* Andy Modify 2008-07-30 只有Mobile、TelePhone、ChineseName、EnglishName用前匹配模糊查询 */
//					if(operation.ToLower().Trim() == "like")
//					{
//						if(this.businessobject.ToLower() == "client")
//						{
//							if( field.ToLower().Trim().IndexOf("mobile") == -1 &&
//								field.ToLower().Trim().IndexOf("telephone") == -1 &&
//								field.ToLower().Trim().IndexOf("chinesename") == -1 &&
//								field.ToLower().Trim().IndexOf("englishname") == -1)
//							{
//								if (!filter.Equals(string.Empty))
//								{
//									filter = filter + string.Format(" {0}  {1}.{2}  {3}  '%{4}%' ",andor.ToString(),businessobject,field,Operation.Like,Value);
//								}
//								else
//								{
//									filter = " " + andor.ToString()  +  " (" +string.Format(" {0}.{1}   {2}  '%{3}%'  ",businessobject,field,Operation.Like,Value);
//								}
//							}
//							else
//							{
//								if (!filter.Equals(string.Empty))
//								{
//									filter = filter + string.Format(" {0}  {1}.{2}  {3}  '{4}%' ",andor.ToString(),businessobject,field,Operation.Like,Value);
//								}
//								else
//								{
//									filter = " " + andor.ToString()  +  " (" +string.Format(" {0}.{1}   {2}  '{3}%'  ",businessobject,field,Operation.Like,Value);
//								}
//							}
//						}
//						else
//						{
//							if (!filter.Equals(string.Empty))
//							{
//								filter = filter + string.Format(" {0}  {1}.{2}  {3}  '%{4}%' ",andor.ToString(),businessobject,field,Operation.Like,Value);
//							}
//							else
//							{
//								filter = " " + andor.ToString()  +  " (" +string.Format(" {0}.{1}   {2}  '%{3}%'  ",businessobject,field,Operation.Like,Value);
//							}
//						}
//					}


//					if(operation.ToLower().Trim() == "like")
//					{
//
//						if (!filter.Equals(string.Empty))
//						{
//							//							/* Andy Modify 2008-07-25 */
//							//							filter = filter + string.Format(" {0}  {1}.{2}  {3}  '{4}%' ",andor.ToString(),businessobject,field,operation.ToString(),Value);
//							filter = filter + string.Format(" {0}  {1}.{2}  {3}  '%{4}%' ",andor.ToString(),businessobject,field,Operation.Like,Value);
//						}
//						else
//						{
//							//							/* Andy Modify 2008-07-25 */
//							//							filter = " " + andor.ToString()  +  " (" +string.Format(" {0}.{1}   {2}  '{3}%'  ",businessobject,field,operation.ToString(),Value);
//							filter = " " + andor.ToString()  +  " (" +string.Format(" {0}.{1}   {2}  '%{3}%'  ",businessobject,field,Operation.Like,Value);
//						}
//					}
//					else if(operation.ToLower().Trim() == "leftlike")
//					{
//						if (!filter.Equals(string.Empty))
//						{
//							/* Andy Modify 2008-07-25 */
//							filter = filter + string.Format(" {0}  {1}.{2}  {3}  '%{4}' ",andor.ToString(),businessobject,field,Operation.LeftLike,Value);
//						}
//						else
//						{
//							/* Andy Modify 2008-07-25 */
//							filter = " " + andor.ToString()  +  " (" +string.Format(" {0}.{1}   {2}  '%{3}'  ",businessobject,field,Operation.LeftLike,Value);
//						}
//					}
//					else if(operation.ToLower().Trim() == "rightlike")
//					{
//						if (!filter.Equals(string.Empty))
//						{
//							/* Andy Modify 2008-07-25 */
//							filter = filter + string.Format(" {0}  {1}.{2}  {3}  '{4}%' ",andor.ToString(),businessobject,field,Operation.RightLike,Value);
//						}
//						else
//						{
//							/* Andy Modify 2008-07-25 */
//							filter = " " + andor.ToString()  +  " (" +string.Format(" {0}.{1}   {2}  '{3}%'  ",businessobject,field,Operation.RightLike,Value);
//						}
//					}
            }
            else if (filterType == FilterType.NumberType)
            {
                if (!filter.Equals(string.Empty))
                {
                    filter = filter + string.Format(" {0}  {1}.{2} {3} {4}  ", andor.ToString(), businessobject, field, operation.ToString(), Value);
                }
                else
                {
                    filter = " " + andor.ToString() + " (" + string.Format("{0}.{1} {2} {3} ", businessobject, field, operation.ToString(), Value);
                }
            }
        }