예제 #1
0
        public static string GetWhere(ITableViewFilterM iFilter, List <IParams> listParams)
        {
            if (iFilter == null)
            {
                return("1 = 1");
            }
            else
            {
                if (iFilter is CosTableViewFilterM && FilterHasError(iFilter))
                {
                    return("1 = 1");
                }
                else if (iFilter is CosTableViewFiltersM)
                {
                    CosTableViewFiltersM container = iFilter as CosTableViewFiltersM;
                    if (container.Container.Count == 0 || FilterHasError(iFilter))
                    {
                        return("1=1");
                    }
                }
            }

            switch (iFilter.Type)
            {
            case TableViewFilterType.Filter:
            {
                var filter = iFilter as CosTableViewFilterM;
                if (filter == null)
                {
                    break;
                }
                if (filter.HasError)
                {
                    //if (filter.UseOwnValue)
                    //{
                    //    return null;
                    //}
                    //else
                    {
                        throw new Exception();
                    }
                }
                //var param = GetWhereParams(filter, listParams.Count + 1);
                //listParams.Add(param);
                //return GetWhereFilter(filter, param);
                return("");
            }
                //case PgTVM.PgTableViewFilterType.Container:
                //    {
                //        var filters = iFilter as PgTVM.PgTableViewFiltersM;
                //        if (filters == null)
                //            break;
                //        return GetWhereContainer(filters, listParams);
                //    }
            }
            throw new Exception("Ошибка при выборе фильтра");
        }
예제 #2
0
 public static bool FilterHasError(ITableViewFilterM iFilter)
 {
     if (iFilter is CosTableViewFilterM)
     {
         CosTableViewFilterM filter = iFilter as CosTableViewFilterM;
         return(filter.HasError);
     }
     else if (iFilter is CosTableViewFiltersM)
     {
         CosTableViewFiltersM container = iFilter as CosTableViewFiltersM;
         bool result = false;
         foreach (ITableViewFilterM innerIFilter in container.Container)
         {
             result |= FilterHasError(innerIFilter);
         }
         return(result);
     }
     else
     {
         return(false);
     }
 }