protected void Page_Load(object sender, EventArgs e) { _priceField = CustomerSession.CurrentCustomer.PriceType.ToString(); _paging = new SqlPaging { TableName = "[Catalog].[Product] " + "LEFT JOIN [Catalog].[Offer] ON [Product].[ProductID] = [Offer].[ProductID] and [Offer].Main = 1 " + "LEFT JOIN [Catalog].[ShoppingCart] ON [Catalog].[ShoppingCart].[OfferID] = [Catalog].[Offer].[OfferID] AND [Catalog].[ShoppingCart].[ShoppingCartType] = 3 AND [ShoppingCart].[CustomerID] = @CustomerId " + "Left JOIN [Catalog].[Ratio] on Product.ProductId= Ratio.ProductID and Ratio.CustomerId=@CustomerId " + "LEFT JOIN [Customers].[LastPrice] ON [LastPrice].[ProductId] = [Product].[ProductId] AND [LastPrice].[CustomerId] = @CustomerId" }; _paging.AddFieldsRange( new List<Field>() { new Field {Name = "[Product].[ProductID] as ProductID", IsDistinct = true}, new Field {Name = "null AS AdditionalPhoto"}, new Field {Name = "(CASE WHEN Offer.ColorID is not null THEN (Select Count(PhotoName) From [Catalog].[Photo] WHERE ([Photo].ColorID = Offer.ColorID or [Photo].ColorID is null) and [Product].[ProductID] = [Photo].[ObjId] and Type=@Type) ELSE (Select Count(PhotoName) From [Catalog].[Photo] WHERE [Product].[ProductID] = [Photo].[ObjId] and Type=@Type) END) AS CountPhoto"}, new Field {Name = "(CASE WHEN Offer.ColorID is not null THEN (Select TOP(1) PhotoName From [Catalog].[Photo] WHERE ([Photo].ColorID = Offer.ColorID or [Photo].ColorID is null) and [Product].[ProductID] = [Photo].[ObjId] and Type=@Type Order By main desc, [Photo].[PhotoSortOrder]) ELSE (Select TOP(1) PhotoName From [Catalog].[Photo] WHERE [Product].[ProductID] = [Photo].[ObjId] and Type=@Type AND [Photo].[Main] = 1) END) AS Photo"}, new Field {Name = "(CASE WHEN Offer.ColorID is not null THEN (Select TOP(1) [Photo].[Description] From [Catalog].[Photo] WHERE ([Photo].ColorID = Offer.ColorID or [Photo].ColorID is null) and [Product].[ProductID] = [Photo].[ObjId] and Type=@Type Order By main desc, [Photo].[PhotoSortOrder]) ELSE (Select TOP(1) [Photo].[Description] From [Catalog].[Photo] WHERE [Product].[ProductID] = [Photo].[ObjId] and Type=@Type AND [Photo].[Main] = 1) END) AS PhotoDesc"}, new Field {Name = "BriefDescription"}, new Field {Name = "Product.ArtNo"}, new Field {Name = "Name"}, new Field { Name = SettingsCatalog.UseLastPrice ? string.Format("(CASE WHEN ProductPrice IS NULL THEN {0} ELSE ProductPrice END) as Price", _priceField) : string.Format("{0} as Price", _priceField) }, new Field {Name = string.Format("{0} - {0}*discount/100 as discountPrice", _priceField), NotInQuery = true}, new Field {Name = "0 as MultiPrices"}, new Field {Name = "Recomended"}, new Field {Name = "New"}, new Field {Name = "Bestseller"}, new Field {Name = "OnSale"}, new Field {Name = "Discount"}, new Field {Name = "UrlPath"}, new Field {Name = "[Offer].Amount"}, new Field {Name = "Offer.Main", NotInQuery = true}, new Field {Name = "Offer.OfferID"}, new Field {Name = "MinAmount"}, new Field {Name = "MaxAmount"}, new Field {Name = "Multiplicity"}, new Field {Name = "Enabled"}, new Field {Name = "ShoppingCartItemId"}, new Field {Name = "AllowPreOrder"}, new Field {Name = "Ratio"}, new Field {Name = "RatioID"}, new Field {Name = "DateModified"}, new Field {Name = "[ShoppingCart].[CustomerID]", NotInQuery = true}, new Field {Name = "BrandID", NotInQuery = true}, new Field {Name = "CategoryEnabled", NotInQuery = true}, new Field {Name = "Offer.ColorID as ColorID"}, new Field { Name = "(select [Settings].[ProductColorsToString]([Product].[ProductID])) as Colors" } }); _paging.AddParam(new SqlParam { ParameterName = "@CustomerId", Value = CustomerSession.CustomerId.ToString() }); _paging.AddParam(new SqlParam { ParameterName = "@Type", Value = PhotoType.Product.ToString() }); 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; _paging.Fields["CategoryEnabled"].Filter = new EqualFieldFilter { Value = "1", ParamName = "@CategoryEnabled" }; _paging.Fields["Enabled"].Filter = new EqualFieldFilter {Value = "1", ParamName = "@Enabled"}; if (_typeFlag == ProductOnMain.TypeFlag.Bestseller) { var filterB = new EqualFieldFilter {ParamName = "@Bestseller", Value = "1"}; _paging.Fields["Bestseller"].Filter = filterB; _paging.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"}; _paging.Fields["New"].Filter = filterN; _paging.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"}; _paging.Fields["Discount"].Filter = filterN; _paging.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) { if (!string.IsNullOrEmpty(Request["type"])) { if (!string.IsNullOrEmpty(Request["type"])) { Enum.TryParse(Request["type"], true, out _typeFlag); } } switch (_typeFlag) { case ProductOnMain.TypeFlag.Bestseller: lblHead.Text = Resource.Admin_UserControls_MainPageProduct_Bestseller; break; case ProductOnMain.TypeFlag.New: lblHead.Text = Resource.Admin_UserControls_MainPageProduct_New; break; case ProductOnMain.TypeFlag.Discount: lblHead.Text = Resource.Admin_UserControls_MainPageProduct_Discount; break; } SetMeta(string.Format("{0} - {1}", AdvantShop.Configuration.SettingsMain.ShopName, lblHead.Text)); if (!IsPostBack) { _paging = new SqlPaging { TableName = "[Catalog].[Product]", ItemsPerPage = 20 }; var f = new Field { Name = "Product.ProductId as ID" }; _paging.AddField(f); f = new Field { Name = "ArtNo" }; _paging.AddField(f); f = new Field { Name = "Name" }; _paging.AddField(f); if (_typeFlag == ProductOnMain.TypeFlag.Bestseller) { f = new Field { Name = "Bestseller" }; var filterB = new EqualFieldFilter { ParamName = "@Bestseller", Value = "1" }; f.Filter = filterB; _paging.AddField(f); _paging.AddField(new Field { Name = "SortBestseller as Sort", Sorting = SortDirection.Ascending }); } if (_typeFlag == ProductOnMain.TypeFlag.New) { f = new Field { Name = "New" }; var filterN = new EqualFieldFilter { ParamName = "@New", Value = "1" }; f.Filter = filterN; _paging.AddField(f); _paging.AddField(new Field { Name = "SortNew as Sort", Sorting = SortDirection.Ascending }); } if (_typeFlag == ProductOnMain.TypeFlag.Discount) { f = new Field { Name = "Discount" }; var filterN = new NotEqualFieldFilter() { ParamName = "@Discount", Value = "0" }; f.Filter = filterN; _paging.AddField(f); _paging.AddField(new Field { Name = "SortDiscount as Sort", Sorting = SortDirection.Ascending }); btnAddProduct.Visible = false; } grid.ChangeHeaderImageUrl("arrowSort", "images/arrowup.gif"); _paging.ItemsPerPage = 20; pageNumberer.CurrentPageIndex = 1; _paging.CurrentPageIndex = 1; ViewState["Paging"] = _paging; } else { _paging = (SqlPaging)(ViewState["Paging"]); _paging.ItemsPerPage = SQLDataHelper.GetInt(ddRowsPerPage.SelectedValue); if (_paging == null) { throw (new Exception("Paging lost")); } string strIds = Request.Form["SelectedIds"]; if (!string.IsNullOrEmpty(strIds)) { strIds = strIds.Trim(); string[] arrids = strIds.Split(' '); var ids = new string[arrids.Length ]; _selectionFilter = new InSetFieldFilter { IncludeValues = true }; for (int idx = 0; idx <= ids.Length - 1; idx++) { int t = int.Parse(arrids[idx]); if (t != -1) { ids[idx] = t.ToString(); } else { _selectionFilter.IncludeValues = false; _inverseSelection = true; } } _selectionFilter.Values = ids; } } }
protected void Page_Load(object sender, EventArgs e) { SetMeta(string.Format("{0} - {1}", SettingsMain.ShopName, Resource.Admin_m_CategorySortOrder_Title)); divSave.Visible = false; grid.ResetToDefaultValueOnRowEditCancel = false; if (!IsPostBack) { var root = new TreeNode { Text = Resource.Admin_m_CategorySortOrder_Root, Value = @"0", Selected = true }; tree.Nodes.Add(root); LoadChildCategories(tree.Nodes[0]); } if (!IsPostBack) { _paging = new SqlPaging { TableName = "Catalog.Category" }; var f = new Field { Name = "CategoryID", IsDistinct = true }; var ifilter = new NotEqualFieldFilter { Value = "0", ParamName = "@id" }; f.Filter = ifilter; _paging.AddField(f); f = new Field { Name = "Name" }; _paging.AddField(f); f = new Field { Name = "SortOrder", Sorting = SortDirection.Ascending }; _paging.AddField(f); f = new Field { Name = "ParentCategory" }; var pfilter = new EqualFieldFilter { Value = hfParent.Value, ParamName = "@CategoryID" }; f.Filter = pfilter; _paging.AddField(f); grid.ChangeHeaderImageUrl("arrowSortOrder", "images/arrowup.gif"); _paging.ItemsPerPage = SQLDataHelper.GetInt(ddRowsPerPage.SelectedValue); pageNumberer.CurrentPageIndex = 1; _paging.CurrentPageIndex = 1; ViewState["Paging"] = _paging; } else { _paging = (SqlPaging)(ViewState["Paging"]); _paging.ItemsPerPage = SQLDataHelper.GetInt(ddRowsPerPage.SelectedValue); if (_paging == null) { throw (new Exception("Paging lost")); } } }