Esempio n. 1
0
        public static IList <IFilter> GetFiltersState(ControlCollection filtersControls, SearchParameters searchParameters)
        {
            IList <IFilter> lastfilters = new List <IFilter>();

            IFilter f = FindFilter(filtersControls, typeof(Family), "ID");

            if (searchParameters.Categories[0] != 0)
            {
                f.Values = searchParameters.Categories[0];
                lastfilters.Add(f);
            }
            else if (f != null)
            {
                f.Clear();
            }

            f = FindFilter(filtersControls, typeof(CatalogPage), "ID");
            if (searchParameters.Categories[1] != 0)
            {
                f.Values = searchParameters.Categories[1];
                lastfilters.Add(f);
            }
            else if (f != null)
            {
                f.Clear();
            }

            f = FindFilter(filtersControls, typeof(ProductType), "ID");
            if (searchParameters.Categories[2] != 0)
            {
                f.Values = searchParameters.Categories[2];
                lastfilters.Add(f);
            }
            else if (f != null)
            {
                f.Clear();
            }

            f = FindFilter(filtersControls, typeof(Application), "ID");
            if (searchParameters.Categories[3] != 0)
            {
                f.Values = searchParameters.Categories[3];
                lastfilters.Add(f);
            }
            else if (f != null)
            {
                f.Clear();
            }

            f = FindFilter(filtersControls, typeof(Line), "ID");
            if (searchParameters.Categories[4] != 0)
            {
                f.Values = searchParameters.Categories[4];
                lastfilters.Add(f);
            }
            else if (f != null)
            {
                f.Clear();
            }

            f = FindFilter(filtersControls, typeof(Area), "ID");
            if (searchParameters.Categories[5] != 0)
            {
                f.Values = searchParameters.Categories[5];
                lastfilters.Add(f);
            }
            else if (f != null)
            {
                f.Clear();
            }

            f = FindFilter(filtersControls, typeof(Country), "ID");
            if (searchParameters.Country != 0)
            {
                f.Values = searchParameters.Country;
                lastfilters.Add(f);
            }
            else if (f != null)
            {
                f.Clear();
            }

            f = FindFilter(filtersControls, typeof(CtrRange), "ID");
            if (searchParameters.CtrRange != 0)
            {
                f.Values = searchParameters.CtrRange;
                lastfilters.Add(f);
            }
            else if (f != null)
            {
                f.Clear();
            }

            f = FindFilter(filtersControls, typeof(Currency), "ID");
            if (searchParameters.Currency != 0)
            {
                f.Values = searchParameters.Currency;
                lastfilters.Add(f);
            }
            else if (f != null)
            {
                f.Clear();
            }

            f = FindFilter(filtersControls, typeof(Product), "Description");
            if (!string.IsNullOrEmpty(searchParameters.Description))
            {
                f.Values = searchParameters.Description;
                lastfilters.Add(f);
            }
            else if (f != null)
            {
                f.Clear();
            }

            f = FindFilter(filtersControls, typeof(Distributor), "ID");
            if (searchParameters.Distributor != 0)
            {
                f.Values = searchParameters.Distributor;
                lastfilters.Add(f);
            }
            else if (f != null)
            {
                f.Clear();
            }

            f = FindFilter(filtersControls, typeof(DistributorStatus), "ID");
            if (searchParameters.DistributorStatus != null)
            {
                f.Values = searchParameters.DistributorStatus;
                lastfilters.Add(f);
            }
            else if (f != null)
            {
                f.Clear();
            }

            f = FindFilter(filtersControls, typeof(Incoterm), "ID");
            if (searchParameters.Incoterm != null)
            {
                f.Values = searchParameters.Incoterm;
                lastfilters.Add(f);
            }
            else if (f != null)
            {
                f.Clear();
            }

            f = FindFilter(filtersControls, typeof(IndexPrice), "ID");
            if (searchParameters.IndexPrice != 0)
            {
                f.Values = searchParameters.IndexPrice;
                lastfilters.Add(f);
            }
            else if (f != null)
            {
                f.Clear();
            }

            f = FindFilter(filtersControls, typeof(Lookup), "Payment");
            if (searchParameters.PaymentTerm != null)
            {
                f.Values = searchParameters.PaymentTerm.ID;
                lastfilters.Add(f);
            }
            else if (f != null)
            {
                f.Clear();
            }

            f = FindFilter(filtersControls, typeof(PriceBaseStatus), "ID");
            if (searchParameters.PriceBaseStatus != null)
            {
                f.Values = searchParameters.PriceBaseStatus;
                lastfilters.Add(f);
            }
            else if (f != null)
            {
                f.Clear();
            }

            f = FindFilter(filtersControls, typeof(PriceGroup), "ID");
            if (searchParameters.PriceGroup != 0)
            {
                f.Values = searchParameters.PriceGroup;
                lastfilters.Add(f);
            }
            else if (f != null)
            {
                f.Clear();
            }

            f = FindFilter(filtersControls, typeof(PriceImport), "ID");
            if (searchParameters.PriceImport != Guid.Empty)
            {
                f.Values = searchParameters.PriceImport;
                lastfilters.Add(f);
            }
            else if (f != null)
            {
                f.Clear();
            }

            f = FindFilter(filtersControls, typeof(PriceList), "ID");
            if (searchParameters.PriceList != 0)
            {
                f.Values = searchParameters.PriceList;
                lastfilters.Add(f);
            }
            else if (f != null)
            {
                f.Clear();
            }

            f = FindFilter(filtersControls, typeof(Frequency), "ID");
            if (searchParameters.Frequency != null)
            {
                f.Values = searchParameters.Frequency;
                lastfilters.Add(f);
            }
            else if (f != null)
            {
                f.Clear();
            }

            f = FindFilter(filtersControls, typeof(ProductStatus), "ID");
            if (searchParameters.ProductStatus != null)
            {
                f.Values = searchParameters.ProductStatus;
                lastfilters.Add(f);
            }
            else if (f != null)
            {
                f.Clear();
            }

            f = FindFilter(filtersControls, typeof(Provider), "ID");
            if (searchParameters.Provider != 0)
            {
                f.Values = searchParameters.Provider;
                lastfilters.Add(f);
            }
            else if (f != null)
            {
                f.Clear();
            }

            f = FindFilter(filtersControls, typeof(PublishList), "ID");
            if (searchParameters.PublishList != 0)
            {
                f.Values = searchParameters.PublishList.ToString();
                lastfilters.Add(f);
            }
            else if (f != null)
            {
                f.Clear();
            }

            f = FindFilter(filtersControls, typeof(PublishListStatus), "ID");
            if (searchParameters.PublishListStatus != null)
            {
                f.Values = searchParameters.PublishListStatus;
                lastfilters.Add(f);
            }
            else if (f != null)
            {
                f.Clear();
            }

            f = FindFilter(filtersControls, typeof(Pair), "TimeStampCheck");
            if (f != null && (searchParameters.SearchDateTo != null || searchParameters.SearchDate != null))
            {
                Pair p = new Pair();
                if (searchParameters.SearchDate != null)
                {
                    p.First = searchParameters.SearchDate.Value.ToShortDateString();
                }
                if (searchParameters.SearchDateTo != null)
                {
                    p.Second = searchParameters.SearchDateTo.Value.ToShortDateString();
                }

                f.Values = p;
                lastfilters.Add(f);
            }
            else if (f != null)
            {
                f.Clear();
            }

            f = FindFilter(filtersControls, typeof(Selection), "ID");
            if (searchParameters.Selection > 0)
            {
                f.Values = searchParameters.Selection;
                lastfilters.Add(f);
            }
            else if (f != null)
            {
                f.Clear();
            }

            f = FindFilter(filtersControls, typeof(WorkListItemStatus), "ID");
            if (searchParameters.WorkListItemStatus != null)
            {
                f.Values = searchParameters.WorkListItemStatus;
                lastfilters.Add(f);
            }
            else if (f != null)
            {
                f.Clear();
            }

            f = FindFilter(filtersControls, typeof(CategoryBase), "ID");
            if (searchParameters.CategoryBase != 0)
            {
                f.Values = searchParameters.CategoryBase;
                lastfilters.Add(f);
            }
            else if (f != null)
            {
                f.Clear();
            }

            f = FindFilter(filtersControls, typeof(Type), "FullName");
            if (!string.IsNullOrEmpty(searchParameters.CategoryType))
            {
                f.Values = Type.GetType(searchParameters.CategoryType);
                lastfilters.Add(f);
            }
            else if (f != null)
            {
                f.Clear();
            }

            f = FindFilter(filtersControls, typeof(Lookup), "ID");
            if (searchParameters.Type > 0)
            {
                f.Values = searchParameters.Type;
                lastfilters.Add(f);
            }
            else if (f != null)
            {
                f.Clear();
            }

            f = FindFilter(filtersControls, typeof(LookupType), "ID");
            if (searchParameters.LookupType != null)
            {
                f.Values = searchParameters.LookupType;
                lastfilters.Add(f);
            }
            else if (f != null)
            {
                f.Clear();
            }

            f = FindFilter(filtersControls, typeof(PriceCalculationPriority), "ID");
            if (searchParameters.PriceCalculationPriority != null)
            {
                f.Values = searchParameters.PriceCalculationPriority;
                lastfilters.Add(f);
            }
            else if (f != null)
            {
                f.Clear();
            }

            f = FindFilter(filtersControls, typeof(ProviderStatus), "ID");
            if (searchParameters.ProviderStatus != null)
            {
                f.Values = searchParameters.ProviderStatus;
                lastfilters.Add(f);
            }
            else if (f != null)
            {
                f.Clear();
            }

            f = FindFilter(filtersControls, typeof(QuoteStatus), "ID");
            if (searchParameters.QuoteStatus != null)
            {
                f.Values = searchParameters.QuoteStatus;
                lastfilters.Add(f);
            }
            else if (f != null)
            {
                f.Clear();
            }

            f = FindFilter(filtersControls, typeof(Guid), "UserId");
            if (searchParameters.MembershipHelperUser != null)
            {
                f.Values = searchParameters.MembershipHelperUser;
                lastfilters.Add(f);
            }
            else if (f != null)
            {
                f.Clear();
            }

            f = FindFilter(filtersControls, typeof(ImportStatus), "ID");
            if (searchParameters.ImportStatus != null)
            {
                f.Values = searchParameters.ImportStatus;
                lastfilters.Add(f);
            }
            else if (f != null)
            {
                f.Clear();
            }

            f = FindFilter(filtersControls, typeof(CatalogPage), "Parent");
            if (searchParameters.CatalogPage != 0)
            {
                f.Values = searchParameters.CatalogPage;
                lastfilters.Add(f);
            }
            else if (f != null)
            {
                f.Clear();
            }

            f = FindFilter(filtersControls, typeof(CategoryPageStatus), "ID");
            if (searchParameters.CategoryPageStatus != null)
            {
                f.Values = searchParameters.CategoryPageStatus;
                lastfilters.Add(f);
            }
            else if (f != null)
            {
                f.Clear();
            }

            return(lastfilters);
        }