Ejemplo n.º 1
0
    private void UpdateBrandDDL()
    {
        if (WAFShopHelper.SiteHasShop(WAFContext.Request.SiteId)) {
            int brandId = Utils.GetIntegerOnly(ddlBrandFilter.SelectedValue);
           // if (WAFShopHelper.GetCurrentShopId() > 0) {
                Shop shop = WAFContext.Session.GetContent<Shop>(WAFShopHelper.GetCurrentShopId());
                List<Manufacturer> manufacturers = new List<Manufacturer>();

                AqlQuery q = WAFContext.Session.CreateQuery();
                AqlAliasShop aliasShop = new AqlAliasShop();
                AqlAliasProductCategory aliasProdCat = new AqlAliasProductCategory();
                AqlAliasProductBase aliasProduct = new AqlAliasProductBase();
                AqlAliasManufacturer aliasManufacturer = new AqlAliasManufacturer();

                AqlAliasRelShopProductCategory relShopCategories = new AqlAliasRelShopProductCategory(aliasShop, aliasProdCat);
                AqlAliasRelProductCategoryProducts relAliasProdCatProducts = new AqlAliasRelProductCategoryProducts(relShopCategories, aliasProduct, aliasProdCat);
                AqlAliasRelManufacturerProducts aliasRelManufacturerProducts = new AqlAliasRelManufacturerProducts(aliasManufacturer, relAliasProdCatProducts, aliasProduct);

                q.From(aliasRelManufacturerProducts);
                AqlResultContent<Manufacturer> manufacturer = q.Select<Manufacturer>(aliasManufacturer);
                AqlResultShortString name = q.Select(aliasManufacturer.Name);
                q.Where(aliasShop.NodeId == WAFShopHelper.GetCurrentShopId());
                q.Distinct();
                q.OrderBy(aliasManufacturer.Name);

                AqlResultSet rs = q.Execute();
                while (rs.Read()) {
                    manufacturers.Add(manufacturer.Value);
                }
                ddlBrandFilter.DataSource = manufacturers;
                ddlBrandFilter.DataBind();
           // }
            if (brandId > 0) {
                ddlBrandFilter.SelectedValue = brandId.ToString();
            }
        }
    }
Ejemplo n.º 2
0
    public void UpdateProductSelection(ProductFilter filter)
    {
        if (WAFShopHelper.SiteHasShop(GetSiteId())) {
           // if (WAFShopHelper.GetCurrentShopId() > 0) {
                AqlQuery query = WAFContext.Session.CreateQuery();
                AqlAliasShop aliasShop = new AqlAliasShop();
                AqlAliasProductCategory aliasProdCat = new AqlAliasProductCategory();
                AqlAliasProductBase aliasProduct = new AqlAliasProductBase();
                AqlAliasManufacturer aliasManufacturer = new AqlAliasManufacturer();

                AqlAliasRelShopProductCategory relShopCategories = new AqlAliasRelShopProductCategory(aliasShop, aliasProdCat);
                AqlAliasRelProductCategoryProducts relAliasProdCatProducts = new AqlAliasRelProductCategoryProducts(relShopCategories, aliasProduct, aliasProdCat);
                AqlAliasRelManufacturerProducts aliasRelManufacturerProducts = new AqlAliasRelManufacturerProducts(aliasManufacturer, relAliasProdCatProducts, aliasProduct);
                switch (filter) {
                    case ProductFilter.NoFilter:
                        query.From(aliasProduct);
                        break;
                    case ProductFilter.ProductCategory:
                        int prodCatId = Utils.GetIntegerOnly(ddlProductCategoryFilter.SelectedValue);
                        if (prodCatId > 0) {
                            query.Where(aliasProdCat.NodeId == prodCatId);
                        }
                        query.From(relAliasProdCatProducts);
                        break;
                    case ProductFilter.Stock:
                        int rangeType = Utils.GetIntegerOnly(ddlStockCriteria.SelectedValue);
                        switch ((RangeCriteria)rangeType) {
                            case RangeCriteria.Above:
                                int aboveNumber = Utils.GetIntegerOnly(txtStockFilterLevel1.Text);
                                query.Where(aliasProduct.NumberInStock >= aboveNumber);
                                break;
                            case RangeCriteria.Below:
                                int belowNum = Utils.GetIntegerOnly(txtStockFilterLevel1.Text);
                                query.Where(aliasProduct.NumberInStock <= belowNum);
                                break;
                            case RangeCriteria.Between:
                                int level1Num = Utils.GetIntegerOnly(txtStockFilterLevel1.Text);
                                int level2Num = Utils.GetIntegerOnly(txtStockFilterLevel2.Text);
                                query.Where(aliasProduct.NumberInStock > level1Num & aliasProduct.NumberInStock < level2Num);
                                break;
                            case RangeCriteria.EqualTo:
                                int stockNumber = Utils.GetIntegerOnly(txtStockFilterLevel1.Text);
                                query.Where(aliasProduct.NumberInStock == stockNumber);
                                break;
                            default:
                                break;
                        }
                        query.From(relAliasProdCatProducts);
                        break;
                    case ProductFilter.Price:
                        int criteriaType = Utils.GetIntegerOnly(ddlPriceCriteria.SelectedValue);
                        switch ((RangeCriteria)criteriaType) {
                            case RangeCriteria.Above:
                                int aboveNumber = Utils.GetIntegerOnly(txtPriceFilterLevel1.Text);
                                query.Where(aliasProduct.PriceExVat >= aboveNumber);
                                break;
                            case RangeCriteria.Below:
                                int belowNum = Utils.GetIntegerOnly(txtPriceFilterLevel1.Text);
                                query.Where(aliasProduct.PriceExVat <= belowNum);
                                break;
                            case RangeCriteria.Between:
                                int level1Num = Utils.GetIntegerOnly(txtPriceFilterLevel1.Text);
                                int level2Num = Utils.GetIntegerOnly(txtPriceFilterLevel2.Text);
                                query.Where(aliasProduct.PriceExVat > level1Num & aliasProduct.PriceExVat < level2Num);
                                break;
                            case RangeCriteria.EqualTo:
                                int priceNumber = Utils.GetIntegerOnly(txtPriceFilterLevel1.Text);
                                query.Where(aliasProduct.PriceExVat == priceNumber);
                                break;
                            default:
                                break;
                        }
                        query.From(relAliasProdCatProducts);
                        break;
                    case ProductFilter.Brand:
                        int brandId = Utils.GetIntegerOnly(ddlBrandFilter.SelectedValue);
                        if (brandId > 0) {
                            query.Where(aliasManufacturer.NodeId == brandId);
                        }
                        query.From(aliasRelManufacturerProducts);
                        break;
                    case ProductFilter.Search:

                        query.Where(Aql.Like(aliasProduct.Name, "*" + txtSearch.Text + "*"));
                        query.From(relAliasProdCatProducts);
                        break;
                    default:
                        query.From(relAliasProdCatProducts);
                        break;
                }
                if (!chkShowVariantNodes.Checked) {
                    query.Where(aliasProduct.Subvariant == false);
                }
                //query.Distinct();
                query.Select<ProductBase>();
                query.Select(aliasProduct.NumberInStock);
                query.Select(aliasProduct.NodeId);
                query.Select(aliasProduct.PriceExVat);
                query.Select(aliasProduct.Name);
                query.Select(aliasProduct.CreateDate);
                query.Select(aliasProduct.ChangeDate);
                if (WAFShopHelper.SiteHasShop(WAFContext.Request.SiteId)) {
                    if (filter == ProductFilter.NoFilter) {
                       query.Where(aliasProduct.SiteId == WAFContext.Session.SiteId);
                    } else {
                        query.Where(AqlShop.NodeId == WAFShopHelper.GetCurrentShopId());
                    }
             //
                } else {
                    query.Where(AqlSite.NodeId == WAFContext.Request.SiteId);
                }
                query.IncludeUnpublished = true;
                contentListProducts.Query = query;
                contentListProducts.DataBind();

            } else {
                contentListProducts.Enabled = false;
            }
    }