protected void Page_Load(object sender, EventArgs e) { SettingsDesign.eMainPageMode currentMode = !Demo.IsDemoEnabled || !CommonHelper.GetCookieString("structure").IsNotEmpty() ? SettingsDesign.MainPageMode : (SettingsDesign.eMainPageMode)Enum.Parse(typeof(SettingsDesign.eMainPageMode), CommonHelper.GetCookieString("structure")); if (Mode != currentMode) { this.Visible = false; return; } const byte itemsPerLine = 4; const byte itemsPerLineThin = 3; var countNew = ProductOnMain.GetProductCountByType(ProductOnMain.TypeFlag.New); var countDiscount = ProductOnMain.GetProductCountByType(ProductOnMain.TypeFlag.Discount); var countBestseller = ProductOnMain.GetProductCountByType(ProductOnMain.TypeFlag.Bestseller); switch (Mode) { case SettingsDesign.eMainPageMode.Default: mvMainPageProduct.SetActiveView(viewDefault); if (countBestseller == 0) { ItemsCount = 3; } if (countNew == 0) { ItemsCount = ItemsCount == 2 ? 3 : 6; } if (countDiscount == 0) { ItemsCount = ItemsCount == 2 ? 3 : 6; } if (countBestseller > 0) { liBestsellers.Attributes.Add("class", "block width-for-" + ItemsCount); lvBestSellers.DataSource = ProductOnMain.GetProductsByType(ProductOnMain.TypeFlag.Bestseller, ItemsCount * SettingsDesign.CountLineOnMainPage); lvBestSellers.DataBind(); } else { liBestsellers.Visible = false; } if (countNew > 0) { liNew.Attributes.Add("class", "block width-for-" + ItemsCount); lvNew.DataSource = ProductOnMain.GetProductsByType(ProductOnMain.TypeFlag.New, ItemsCount * SettingsDesign.CountLineOnMainPage); lvNew.DataBind(); } else { liNew.Visible = false; } if (countDiscount > 0) { liDiscount.Attributes.Add("class", "block block-last width-for-" + ItemsCount); lvDiscount.DataSource = ProductOnMain.GetProductsByType(ProductOnMain.TypeFlag.Discount, ItemsCount * SettingsDesign.CountLineOnMainPage); lvDiscount.DataBind(); } else { liDiscount.Visible = false; } break; case SettingsDesign.eMainPageMode.TwoColumns: mvMainPageProduct.SetActiveView(viewAlternative); if (countBestseller > 0) { lvBestSellersAltervative.DataSource = ProductOnMain.GetProductsByType(ProductOnMain.TypeFlag.Bestseller, itemsPerLine * SettingsDesign.CountLineOnMainPage); lvBestSellersAltervative.DataBind(); } else { pnlBest.Visible = false; } if (countNew > 0) { lvNewAlternative.DataSource = ProductOnMain.GetProductsByType(ProductOnMain.TypeFlag.New, itemsPerLine * SettingsDesign.CountLineOnMainPage); lvNewAlternative.DataBind(); } else { pnlNew.Visible = false; } if (countDiscount > 0) { lvDiscountAlternative.DataSource = ProductOnMain.GetProductsByType(ProductOnMain.TypeFlag.Discount, itemsPerLine * SettingsDesign.CountLineOnMainPage); lvDiscountAlternative.DataBind(); } else { pnlDiscount.Visible = false; } break; case SettingsDesign.eMainPageMode.ThreeColumns: mvMainPageProduct.SetActiveView(viewAlternative); if (countBestseller > 0) { lvBestSellersAltervative.DataSource = ProductOnMain.GetProductsByType(ProductOnMain.TypeFlag.Bestseller, itemsPerLineThin * SettingsDesign.CountLineOnMainPage); lvBestSellersAltervative.DataBind(); } else { pnlBest.Visible = false; } if (countNew > 0) { lvNewAlternative.DataSource = ProductOnMain.GetProductsByType(ProductOnMain.TypeFlag.New, itemsPerLineThin * SettingsDesign.CountLineOnMainPage); lvNewAlternative.DataBind(); } else { pnlNew.Visible = false; } if (countDiscount > 0) { lvDiscountAlternative.DataSource = ProductOnMain.GetProductsByType(ProductOnMain.TypeFlag.Discount, itemsPerLineThin * SettingsDesign.CountLineOnMainPage); lvDiscountAlternative.DataBind(); } else { pnlDiscount.Visible = false; } break; default: throw new NotImplementedException(); } }
private void AddNewContentInFooter() { SettingsDesign.eMainPageMode currentMode = !Demo.IsDemoEnabled || !CommonHelper.GetCookieString("structure").IsNotEmpty() ? SettingsDesign.MainPageMode : (SettingsDesign.eMainPageMode)Enum.Parse(typeof(SettingsDesign.eMainPageMode), CommonHelper.GetCookieString("structure")); if (SettingsDesign.Template == TemplateService.DefaultTemplateId && Mode != currentMode) { this.Visible = false; return; } LoadModules(); var countNew = ProductOnMain.GetProductCountByType(ProductOnMain.TypeFlag.New); var countDiscount = ProductOnMain.GetProductCountByType(ProductOnMain.TypeFlag.Discount); var countBestseller = ProductOnMain.GetProductCountByType(ProductOnMain.TypeFlag.Bestseller); var countRecomended = ProductOnMain.GetProductCountByType(ProductOnMain.TypeFlag.Recomended); switch (Mode) { case SettingsDesign.eMainPageMode.Default: mvMainPageProduct.SetActiveView(viewDefault); int ItemsCount = 3; if (countBestseller == 0) { ItemsCount = 3; } if (countNew == 0) { ItemsCount = ItemsCount == 2 ? 3 : 6; } if (countDiscount == 0) { ItemsCount = ItemsCount == 2 ? 3 : 6; } if (countRecomended == 0) { ItemsCount = ItemsCount == 2 ? 3 : 6; } if (countBestseller > 0) { liBestsellers.Attributes.Add("class", "block width-for-" + ItemsCount); //SettingsDesign.CountLineOnMainPage); //lvBestSellers.DataSource = ProductOnMain.GetProductsByType(ProductOnMain.TypeFlag.Bestseller, ItemCountInRow); lvBestSellers.DataSource = ProductOnMain.GetProductsByType(ProductOnMain.TypeFlag.Bestseller, 12); lvBestSellers.DataBind(); } else { liBestsellers.Visible = false; } if (countNew > 0) { liNew.Attributes.Add("class", "block width-for-" + ItemsCount); //SettingsDesign.CountLineOnMainPage); //lvNew.DataSource = ProductOnMain.GetProductsByType(ProductOnMain.TypeFlag.New, ItemCountInRow); lvNew.DataSource = ProductOnMain.GetProductsByType(ProductOnMain.TypeFlag.New, 12); lvNew.DataBind(); } else { liNew.Visible = false; } if (countDiscount > 0) { liDiscount.Attributes.Add("class", "block block-last width-for-" + ItemsCount); //SettingsDesign.CountLineOnMainPage); //lvDiscount.DataSource = ProductOnMain.GetProductsByType(ProductOnMain.TypeFlag.OnSale, ItemCountInRow); lvDiscount.DataSource = ProductOnMain.GetProductsByType(ProductOnMain.TypeFlag.OnSale, 12); lvDiscount.DataBind(); } else { liDiscount.Visible = false; } if (countRecomended > 0) { liRecomended.Attributes.Add("class", "block width-for-" + ItemsCount); //SettingsDesign.CountLineOnMainPage); //lvRecomended.DataSource = ProductOnMain.GetProductsByType(ProductOnMain.TypeFlag.Recomended, ItemCountInRow); lvRecomended.DataSource = ProductOnMain.GetProductsByType(ProductOnMain.TypeFlag.Recomended, 12); lvRecomended.DataBind(); } else { liRecomended.Visible = false; } break; case SettingsDesign.eMainPageMode.TwoColumns: mvMainPageProduct.SetActiveView(viewDefault); if (countBestseller > 0) { lvBestSellers.DataSource = ProductOnMain.GetProductsByType(ProductOnMain.TypeFlag.Bestseller, ItemCountInRow); lvBestSellers.DataBind(); } else { pnlBest.Visible = false; } if (countNew > 0) { lvNewAlternative.DataSource = ProductOnMain.GetProductsByType(ProductOnMain.TypeFlag.New, ItemCountInRow); lvNewAlternative.DataBind(); } else { pnlNew.Visible = false; } if (countDiscount > 0) { lvDiscountAlternative.DataSource = ProductOnMain.GetProductsByType(ProductOnMain.TypeFlag.Discount, ItemCountInRow); lvDiscountAlternative.DataBind(); } else { pnlDiscount.Visible = false; } if (countRecomended > 0) { lvRecomended.DataSource = ProductOnMain.GetProductsByType(ProductOnMain.TypeFlag.Recomended, ItemCountInRow); lvRecomended.DataBind(); } else { pnlRecomended.Visible = false; } break; case SettingsDesign.eMainPageMode.ThreeColumns: mvMainPageProduct.SetActiveView(viewDefault); if (countBestseller > 0) { lvBestSellers.DataSource = ProductOnMain.GetProductsByType(ProductOnMain.TypeFlag.Bestseller, ItemCountInRow); lvBestSellers.DataBind(); } else { pnlBest.Visible = false; } if (countNew > 0) { lvNewAlternative.DataSource = ProductOnMain.GetProductsByType(ProductOnMain.TypeFlag.New, ItemCountInRow); lvNewAlternative.DataBind(); } else { pnlNew.Visible = false; } if (countDiscount > 0) { lvDiscountAlternative.DataSource = ProductOnMain.GetProductsByType(ProductOnMain.TypeFlag.Discount, ItemCountInRow); lvDiscountAlternative.DataBind(); } else { pnlDiscount.Visible = false; } if (countRecomended > 0) { lvRecomended.DataSource = ProductOnMain.GetProductsByType(ProductOnMain.TypeFlag.Recomended, ItemCountInRow); lvRecomended.DataBind(); } else { pnlRecomended.Visible = false; } break; default: throw new NotImplementedException(); } }
protected void Page_Load(object sender, EventArgs e) { if (string.IsNullOrEmpty(Request["type"]) || !Enum.TryParse(Request["type"], true, out _typeFlag) || _typeFlag == ProductOnMain.TypeFlag.None) { Error404(); } ProductsCount = ProductOnMain.GetProductCountByType(_typeFlag); pnlSort.Visible = ProductsCount > 0; productView.Visible = ProductsCount > 0; filterBrand.CategoryId = 0; filterBrand.InDepth = true; filterBrand.WorkType = _typeFlag; filterPrice.CategoryId = 0; filterPrice.InDepth = true; //changed by Evgeni for multiple price defaultDS.TableName = "[Catalog].[Product] LEFT JOIN [Catalog].[Offer] ON [Product].[ProductID] = [Offer].[ProductID] AND [OfferListID] = 6 LEFT JOIN [Catalog].[Photo] ON [Product].[ProductID] = [Photo].[ObjId] And Type='Product' AND [Main] = 1 LEFT JOIN [Catalog].[ShoppingCart] ON [Catalog].[ShoppingCart].[EntityID] = [Catalog].[Product].[ProductID] AND [Catalog].[ShoppingCart].[ShoppingCartTypeId] = 3 AND [ShoppingCart].[CustomerID] = @CustomerId Left JOIN [Catalog].[Ratio] on Product.ProductId= Ratio.ProductID and Ratio.CustomerId=@CustomerId"; defaultDS.AddParamSql(new SqlParam { ParamName = "@CustomerId", ParamValue = CustomerSession.CustomerId.ToString() }); defaultDS.AddCondition("[Settings].[CountCategoriesByProduct](Product.ProductID) > 0"); defaultDS.Fields["HirecalEnabled"].Filter = new EqualFieldFilter { Value = "1", ParamName = "@HirecalEnabled" }; defaultDS.Fields["Enabled"].Filter = new EqualFieldFilter { Value = "1", ParamName = "@Enabled" }; if (_typeFlag == ProductOnMain.TypeFlag.Bestseller) { var filterB = new EqualFieldFilter { ParamName = "@Bestseller", Value = "1" }; defaultDS.Fields["Bestseller"].Filter = filterB; defaultDS.Fields.Add(new KeyValuePair <string, Field>("SortBestseller", new Field { Name = "SortBestseller as Sort" })); PageName = Resource.Client_ProductList_AllBestSellers; SetMeta(new AdvantShop.SEO.MetaInfo(SettingsMain.ShopName + " - " + Resource.Client_Bestsellers_Header), string.Empty); } if (_typeFlag == ProductOnMain.TypeFlag.New) { var filterN = new EqualFieldFilter { ParamName = "@New", Value = "1" }; defaultDS.Fields["New"].Filter = filterN; defaultDS.Fields.Add(new KeyValuePair <string, Field>("SortNew", new Field { Name = "SortNew as Sort" })); PageName = Resource.Client_ProductList_AllNew; SetMeta(new AdvantShop.SEO.MetaInfo(SettingsMain.ShopName + " - " + Resource.Client_New_Header), string.Empty); } if (_typeFlag == ProductOnMain.TypeFlag.Discount) { var filterN = new NotEqualFieldFilter() { ParamName = "@Discount", Value = "0" }; defaultDS.Fields["Discount"].Filter = filterN; defaultDS.Fields.Add(new KeyValuePair <string, Field>("SortDiscount", new Field { Name = "SortDiscount as Sort" })); PageName = Resource.Client_ProductList_AllDiscount; SetMeta(new AdvantShop.SEO.MetaInfo(SettingsMain.ShopName + " - " + Resource.Client_Discount_Header), string.Empty); } breadCrumbs.Items.AddRange(new BreadCrumbs[] { new BreadCrumbs() { Name = Resource.Client_MasterPage_MainPage, Url = UrlService.GetAbsoluteLink("/") }, new BreadCrumbs() { Name = PageName, Url = null } }); BuildSorting(); BuildFilter(); }
protected void Page_Load(object sender, EventArgs e) { _paging = new SqlPaging(); _paging.From("[Catalog].[Product]"); _paging.Inner_Join("[Catalog].[ProductExt] ON [Product].[ProductID] = [ProductExt].[ProductID]"); _paging.Left_Join("[Catalog].[Photo] ON [Photo].[PhotoId] = [ProductExt].[PhotoId]"); _paging.Left_Join("[Catalog].[Offer] ON [ProductExt].[OfferID] = [Offer].[OfferID]"); _paging.Left_Join("[Catalog].[ShoppingCart] ON [ShoppingCart].[OfferID] = [Offer].[OfferID] AND [ShoppingCart].[ShoppingCartType] = 3 AND [ShoppingCart].[CustomerID] = {0}", CustomerContext.CustomerId); _paging.Left_Join("[Catalog].[Ratio] on Product.ProductId= Ratio.ProductID and Ratio.CustomerId=[ShoppingCart].[CustomerID]"); _paging.Select( "[Product].[ProductID]", "CountPhoto", "Photo.PhotoId", "PhotoName AS Photo", "Photo.Description as PhotoDesc", "BriefDescription", "Product.ArtNo", "Name", "Recomended", "Bestseller", "New", "OnSale", "[Product].Discount", "Offer.OfferID", "MaxAvailable AS Amount", "MinAmount", "MaxAmount", "Enabled", "AllowPreOrder", "Ratio", "RatioID", "ShoppingCartItemId", "UrlPath", "Offer.ColorID", "null as AdditionalPhoto" ); if (SettingsCatalog.ComplexFilter) { _paging.Select( "Colors", "NotSamePrices as MultiPrices", "MinPrice as Price" ); } else { _paging.Select( "null as Colors", "0 as MultiPrices", "Price" ); } if (string.IsNullOrEmpty(Request["type"]) || !Enum.TryParse(Request["type"], true, out _typeFlag) || _typeFlag == ProductOnMain.TypeFlag.None) { Error404(); } switch (_typeFlag) { case ProductOnMain.TypeFlag.Bestseller: PageName = Resource.Client_ProductList_AllBestSellers; SetMeta(new MetaInfo(SettingsMain.ShopName + " - " + Resource.Client_Bestsellers_Header), string.Empty); break; case ProductOnMain.TypeFlag.New: PageName = Resource.Client_ProductList_AllNew; SetMeta(new MetaInfo(SettingsMain.ShopName + " - " + Resource.Client_New_Header), string.Empty); break; case ProductOnMain.TypeFlag.Discount: PageName = Resource.Client_ProductList_AllDiscount; SetMeta(new MetaInfo(SettingsMain.ShopName + " - " + Resource.Client_Discount_Header), string.Empty); break; case ProductOnMain.TypeFlag.OnSale: PageName = Resource.Client_ProductList_OnSale; SetMeta(new MetaInfo(SettingsMain.ShopName + " - " + Resource.Client_OnSale_Header), string.Empty); break; case ProductOnMain.TypeFlag.Recomended: PageName = Resource.Client_ProductList_Recomended; SetMeta(new MetaInfo(SettingsMain.ShopName + " - " + Resource.Client_Recomended_Header), string.Empty); break; } ProductsCount = ProductOnMain.GetProductCountByType(_typeFlag); pnlSort.Visible = ProductsCount > 0; productView.Visible = ProductsCount > 0; breadCrumbs.Items.AddRange(new BreadCrumbs[] { new BreadCrumbs() { Name = Resource.Client_MasterPage_MainPage, Url = UrlService.GetAbsoluteLink("/") }, new BreadCrumbs() { Name = PageName, Url = null } }); BuildSorting(); BuildFilter(); }