Esempio n. 1
0
        protected void btnFilter_Click(object sender, EventArgs e)
        {
            //-----Selection filter
            if (String.CompareOrdinal(ddSelect.SelectedIndex.ToString(CultureInfo.InvariantCulture), "0") != 0)
            {
                if (String.CompareOrdinal(ddSelect.SelectedIndex.ToString(CultureInfo.InvariantCulture), "2") == 0)
                {
                    if (_selectionFilter != null)
                    {
                        _selectionFilter.IncludeValues = !_selectionFilter.IncludeValues;
                    }
                    else
                    {
                        _selectionFilter = null; //New InSetFieldFilter()
                        //_SelectionFilter.IncludeValues = True
                    }
                }
                _paging.Fields["ID"].Filter = _selectionFilter;
            }
            else
            {
                _paging.Fields["ID"].Filter = null;
            }

            //----Name filter
            _paging.Fields["FormatName"].Filter = !string.IsNullOrEmpty(txtName.Text) ? new CompareFieldFilter { Expression = txtName.Text, ParamName = "@Name" } : null;

            //----Enabled filter
            if (ddluseInFilter.SelectedIndex != 0)
            {
                var efilter = new EqualFieldFilter { ParamName = "@Enable" };
                if (ddluseInFilter.SelectedIndex == 1)
                {
                    efilter.Value = "1";
                }
                if (ddluseInFilter.SelectedIndex == 2)
                {
                    efilter.Value = "0";
                }
                _paging.Fields["Enable"].Filter = efilter;
            }
            else
            {
                _paging.Fields["Enable"].Filter = null;
            }

            //----sort filter
            _paging.Fields["SortOrder"].Filter = !string.IsNullOrEmpty(txtSortOrder.Text) ? new CompareFieldFilter { Expression = txtSortOrder.Text, ParamName = "@sort" } : null;
            _paging.Fields["FormatType"].Filter = ddlFormatType.SelectedValue != "0"
                                                      ? new EqualFieldFilter
                                                          {
                                                              ParamName = "@FormatType",
                                                              Value = ddlFormatType.SelectedValue
                                                          }
                                                      : null;
            pageNumberer.CurrentPageIndex = 1;
            _paging.CurrentPageIndex = 1;
        }
        protected void btnOkParent_Click(object sender, EventArgs e)
        {
            hfParent.Value = tree.SelectedValue;
            lParent.Text = tree.SelectedNode.Text;
            mpeTree.Hide();

            var pfilter = new EqualFieldFilter { Value = hfParent.Value, ParamName = "@CategoryID" };
            //var pfilter = new InChildCategoriesFieldFilter { CategoryId = hfParent.Value, ParamName = "@CategoryID" };
            _paging.Fields["ParentCategory"].Filter = pfilter;
        }
Esempio n. 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            _paging = new SqlPaging
                {
                    TableName =
                        "[Catalog].[Product] LEFT JOIN [Catalog].[Offer] ON [Product].[ProductID] = [Offer].[ProductID] inner join Catalog.ProductCategories on ProductCategories.ProductId = [Product].[ProductID] Left JOIN [Catalog].[ProductPropertyValue] ON [Product].[ProductID] = [ProductPropertyValue].[ProductID] 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"
                };
            _paging.AddFieldsRange(
                new List<Field>
                    {
                        new Field {Name = "[Product].[ProductID]", IsDistinct = true},
                        //new Field {Name = "PhotoName AS Photo"},
                        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 = "(select [Settings].[ProductColorsToString]([Product].[ProductID])) as Colors"},
                        //new Field {Name = "[Photo].[Description] AS PhotoDesc"},
                        new Field {Name = "[ProductCategories].[CategoryID]", NotInQuery=true},
                        new Field {Name = "BriefDescription"},
                        new Field {Name = "Product.ArtNo"},
                        new Field {Name = "Name"},
                        new Field {Name = "(CASE WHEN Price=0 THEN 0 ELSE 1 END) as TempSort", Sorting=SortDirection.Descending},
                        new Field {Name = "Recomended"},
                        new Field {Name = "Bestseller"},
                        new Field {Name = "New"},
                        new Field {Name = "OnSale"},
                        new Field {Name = "Discount"},
                        new Field {Name = "Offer.Main", NotInQuery=true},
                        new Field {Name = "Offer.OfferID"},
                        new Field {Name = "Offer.Amount"},
                        new Field {Name = "(CASE WHEN Offer.Amount=0 OR Offer.Amount < IsNull(MinAmount,0) THEN 0 ELSE 1 END) as TempAmountSort", Sorting=SortDirection.Descending},
                        new Field {Name = "MinAmount"},
                        new Field {Name = "MaxAmount"},
                        new Field {Name = "Enabled"},
                        new Field {Name = "AllowPreOrder"},
                        new Field {Name = "Ratio"},
                        new Field {Name = "RatioID"},
                        new Field {Name = "DateModified"},
                        new Field {Name = "ShoppingCartItemId"},
                        new Field {Name = "UrlPath"},
                        new Field {Name = "[ProductCategories].[SortOrder]"},
                        new Field {Name = "[ShoppingCart].[CustomerID]", NotInQuery=true},
                        new Field {Name = "BrandID", NotInQuery=true},
                        new Field {Name = "Offer.ProductID as Size_ProductID", NotInQuery=true},
                        new Field {Name = "Offer.ProductID as Color_ProductID", NotInQuery=true},
                        new Field {Name = "Offer.ProductID as Price_ProductID", NotInQuery=true},
                        new Field {Name = "Offer.ColorID"},
                        new Field {Name = "CategoryEnabled", NotInQuery=true},
                    });

            if (SettingsCatalog.ComplexFilter)
            {
                _paging.AddFieldsRange(new List<Field>
                    {
                        new Field {Name = "(select max (price) - min (price) from catalog.offer where offer.productid=product.productid) as MultiPrices"},
                        new Field {Name = "(select min (price) from catalog.offer where offer.productid=product.productid) as Price"},
                    });
            }
            else
            {
                _paging.AddFieldsRange(new List<Field>
                    {
                        new Field {Name = "0 as MultiPrices"},
                        new Field {Name = "Price"},
                    });
            }

            _paging.AddParam(new SqlParam { ParameterName = "@CustomerId", Value = CustomerSession.CustomerId.ToString() });
            _paging.AddParam(new SqlParam { ParameterName = "@Type", Value = PhotoType.Product.ToString() });

            if (string.IsNullOrEmpty(Request["categoryid"]) || !Int32.TryParse(Request["categoryid"], out _categoryId))
            {
                _categoryId = 0;

                var sbMainPage = StaticBlockService.GetPagePartByKeyWithCache("MainPageSocial");
                if (sbMainPage != null && sbMainPage.Enabled)
                    MainPageText = sbMainPage.Content;
            }

            if (!string.IsNullOrEmpty(MainPageText))
            {
                SetMeta(null, string.Empty);
                return;
            }

            category = CategoryService.GetCategory(_categoryId);
            if (category == null || category.Enabled == false || category.ParentsEnabled == false)
            {
                Error404();
                return;
            }

            ProductsCount = category.GetProductCount();

            categoryView.CategoryID = _categoryId;
            categoryView.Visible = true;
            pnlSort.Visible = ProductsCount > 0;
            productView.Visible = ProductsCount > 0;

            lblCategoryName.Text = _categoryId != 0 ? category.Name : Resource.Client_MasterPage_Catalog;
            //lblCategoryDescription.Text = category.Description;

            //imgCategoryImage.ImageUrl = string.IsNullOrEmpty(category.Picture) ? "" : string.Format("{0}", ImageFolders.GetImageCategoryPath(false, category.Picture));

            breadCrumbs.Items =
                CategoryService.GetParentCategories(_categoryId).Select(parent => new BreadCrumbs
                    {
                        Name = parent.Name,
                        Url = "social/catalogsocial.aspx?categoryid=" + parent.CategoryId
                    }).Reverse().ToList();
            breadCrumbs.Items.Insert(0, new BreadCrumbs
                {
                    Name = Resource.Client_MasterPage_MainPage,
                    Url = UrlService.GetAbsoluteLink("social/catalogsocial.aspx")
                });

            SetMeta(category.Meta, category.Name);

            if (category.DisplayChildProducts)
            {
                var cfilter = new InChildCategoriesFieldFilter
                    {
                        CategoryId = _categoryId.ToString(),
                        ParamName = "@CategoryID"
                    };
                _paging.Fields["[ProductCategories].[CategoryID]"].Filter = cfilter;
            }
            else
            {
                var cfilter = new EqualFieldFilter { Value = _categoryId.ToString(), ParamName = "@catalog" };
                _paging.Fields["[ProductCategories].[CategoryID]"].Filter = cfilter;
            }

            _paging.Fields["Enabled"].Filter = new EqualFieldFilter { Value = "1", ParamName = "@enabled" }; ;
            _paging.Fields["CategoryEnabled"].Filter = new EqualFieldFilter { Value = "1", ParamName = "@CategoryEnabled" };

            var logicalFilter = new LogicalFilter { ParamName = "@Main", HideInCustomData = true };
            logicalFilter.AddFilter(new EqualFieldFilter { Value = "1", ParamName = "@Main1", HideInCustomData = true });
            logicalFilter.AddLogicalOperation("OR");
            logicalFilter.AddFilter(new NullFieldFilter { Null = true, ParamName = "@Main2", HideInCustomData = true });
            _paging.Fields["Offer.Main"].Filter = logicalFilter;

            BuildSorting();
        }
Esempio n. 4
0
        protected void btnFilter_Click(object sender, EventArgs e)
        {
            //-----Selection filter
            if (String.CompareOrdinal(ddSelect.SelectedIndex.ToString(CultureInfo.InvariantCulture), "0") != 0)
            {

                if (String.CompareOrdinal(ddSelect.SelectedIndex.ToString(CultureInfo.InvariantCulture), "2") == 0)
                {
                    if (_selectionFilter != null)
                    {
                        _selectionFilter.IncludeValues = !_selectionFilter.IncludeValues;
                    }
                    else
                    {
                        _selectionFilter = null;
                    }
                }
                _paging.Fields["ID"].Filter = _selectionFilter;
            }
            else
            {
                _paging.Fields["ID"].Filter = null;
            }

            //----Name filter
            if (!string.IsNullOrEmpty(txtName.Text))
            {
                var nfilter = new CompareFieldFilter { Expression = txtName.Text, ParamName = "@Name" };
                _paging.Fields["Name"].Filter = nfilter;
            }
            else
            {
                _paging.Fields["Name"].Filter = null;
            }
            //----RegNumber filter
            if (!string.IsNullOrEmpty(txtRegNumber.Text))
            {
                var nfilter = new CompareFieldFilter
                    {
                        Expression = txtRegNumber.Text,
                        ParamName = "@RegNumber"
                    };
                _paging.Fields["RegNumber"].Filter = nfilter;
            }
            else
            {
                _paging.Fields["RegNumber"].Filter = null;
            }

            //----Country filter
            if (ddlCountryFilter.SelectedIndex != 0)
            {
                var nfilter = new CompareFieldFilter
                    {
                        Expression = ddlCountryFilter.SelectedItem.Text,
                        ParamName = "@Country"
                    };
                _paging.Fields["CountryName"].Filter = nfilter;
            }
            else
            {
                _paging.Fields["CountryName"].Filter = null;
            }

            //----Enabled filter
            if (ddlEnabled.SelectedIndex != 0)
            {

                var efilter = new EqualFieldFilter { ParamName = "@Enabled" };
                if (ddlEnabled.SelectedIndex == 1)
                {
                    efilter.Value = "1";
                }
                if (ddlEnabled.SelectedIndex == 2)
                {
                    efilter.Value = "0";
                }
                _paging.Fields["Enabled"].Filter = efilter;
            }
            else
            {
                _paging.Fields["Enabled"].Filter = null;
            }

            pageNumberer.CurrentPageIndex = 1;
        }
Esempio n. 5
0
        protected void btnFilter_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txtSearchName.Text))
            {
                var sfilter = new CompareFieldFilter { Expression = txtSearchName.Text, ParamName = "@Name" };
                _paging.Fields["BrandName"].Filter = sfilter;
            }
            else
            {
                _paging.Fields["BrandName"].Filter = null;
            }

            if (!string.IsNullOrEmpty(txtSearchProducts_Count.Text))
            {
                var sfilter = new EqualFieldFilter { Value = txtSearchProducts_Count.Text, ParamName = "@ProductsCount" };
                _paging.Fields["ProductsCount"].Filter = sfilter;
            }
            else
            {
                _paging.Fields["ProductsCount"].Filter = null;
            }

            ViewState["Show"] = true;
            pageNumberer.CurrentPageIndex = 1;
        }
Esempio n. 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SetMeta(string.Format("{0} - {1}", SettingsMain.ShopName, Resource.Admin_MenuManager_TopMenu));

            Int32.TryParse(Request["menuid"], out _menuId);
            _needReloadTree = SQLDataHelper.GetBoolean(ViewState["updateTree"]);

            hlEditCategory.Visible = _menuId > 0;
            lblSeparator.Visible = _menuId > 0;
            hlDeleteCategory.Visible = _menuId > 0;

            if (!string.IsNullOrWhiteSpace(Request["type"]))
                Enum.TryParse(Request["type"], true, out _menuType);

            var menuitem = new AdvMenuItem();
            switch (_menuType)
            {
                case MenuService.EMenuType.Top:
                    menuitem = MenuService.GetMenuItemById(_menuId, _menuType);

                    lblHead.Text = menuitem == null
                                       ? Resource.Admin_MenuManager_TopMenu
                                       : string.Format("{0} - {1}", Resource.Admin_MenuManager_TopMenu, menuitem.MenuItemName);
                    lblSubHead.Text = Resource.Admin_MenuManager_SubHeaderTop;

                    Page.Title = menuitem == null
                                     ? Resource.Admin_MenuManager_TopMenu
                                     : string.Format("{0} - {1}", Resource.Admin_MenuManager_TopMenu, menuitem.MenuItemName);

                    break;
                case MenuService.EMenuType.Bottom:
                    menuitem = MenuService.GetMenuItemById(_menuId, _menuType);

                    lblHead.Text = menuitem == null
                                       ? Resource.Admin_MenuManager_BottomMenu
                                       : string.Format("{0} - {1}", Resource.Admin_MenuManager_BottomMenu, menuitem.MenuItemName);
                    lblSubHead.Text = Resource.Admin_MenuManager_SubHeaderBottom;

                    Page.Title = menuitem == null
                                     ? Resource.Admin_MenuManager_BottomMenu
                                     : string.Format("{0} - {1}", Resource.Admin_MenuManager_BottomMenu, menuitem.MenuItemName);
                    break;
            }

            btnAdd.OnClientClick = "open_window('m_Menu.aspx?MenuID=" + _menuId + "&mode=create&type=" + _menuType + "', 750, 640);return false;";
            hlEditCategory.NavigateUrl = "javascript:open_window(\'m_Menu.aspx?MenuID=" + _menuId + "&mode=edit&type=" + _menuType + "\', 750, 640)";
            ConfirmButtonExtenderCategory.ConfirmText =
                string.Format(Resource.Admin_MasterPageAdminCatalog_MenuConfirmation, menuitem != null ? menuitem.MenuItemName : string.Empty);

            if (!IsPostBack)
            {
                switch (_menuType)
                {
                    case MenuService.EMenuType.Top:
                        _paging = new SqlPaging
                            {
                                TableName = "[CMS].[MainMenu]",
                                ItemsPerPage = 10
                            };
                        break;
                    case MenuService.EMenuType.Bottom:
                        _paging = new SqlPaging
                            {
                                TableName = "[CMS].[BottomMenu]",
                                ItemsPerPage = 10
                            };
                        break;
                }

                _paging.AddFieldsRange(new List<Field>
                    {
                        new Field
                            {
                                Name = "MenuItemID as ID",
                                IsDistinct = true
                            },
                        new Field {Name = "MenuItemParentID" },
                        new Field {Name = "MenuItemName"},
                        new Field {Name = "Enabled"},
                        new Field {Name = "Blank"},
                        new Field {Name = "SortOrder",Sorting = SortDirection.Ascending}
                    });

                if (_menuId != 0)
                {
                    var filter = new EqualFieldFilter { ParamName = "@MenuItemParentID", Value = _menuId.ToString() };
                    _paging.Fields["MenuItemParentID"].Filter = filter;
                }
                else
                {
                    var filter = new NullFieldFilter { ParamName = "@MenuItemParentID", Null = true };
                    _paging.Fields["MenuItemParentID"].Filter = filter;
                }

                grid.ChangeHeaderImageUrl("arrowSortOrder", "images/arrowup.gif");

                _paging.ItemsPerPage = 10;

                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(' ');

                    _selectionFilter = new InSetFieldFilter();
                    if (arrids.Contains("-1"))
                    {
                        _selectionFilter.IncludeValues = false;
                        _inverseSelection = true;
                    }
                    else
                    {
                        _selectionFilter.IncludeValues = true;
                    }
                    _selectionFilter.Values = arrids.Where(id => id != "-1").ToArray();
                }
            }
        }
Esempio n. 7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SetMeta(string.Format("{0} - {1}", SettingsMain.ShopName, Resource.Admin_Taxes_Header));

            var cats = new List<Category> { CategoryService.GetCategory(0) };
            Category[] rootCategories = cats.ToArray();
            CatalogDataTreeViewForTaxes.RootCategories = rootCategories;

            var taxIdStr = Request["taxid"];
            if (string.IsNullOrEmpty(taxIdStr))
            {
                Response.Redirect("Taxes.aspx", true);
                return;
            }
            int taxId;
            if (!Int32.TryParse(taxIdStr, out taxId))
            {
                Response.Redirect("Taxes.aspx", true);
                return;
            }

            CurrentTax = TaxServices.GetTax(taxId);

            Title = CurrentTax.Name;

            if (!IsPostBack)
            {
                _paging = new SqlPaging { TableName = "[Catalog].[TaxRegionRate] JOIN [Customers].[Region] ON [TaxRegionRate].[RegionID] = [Region].[RegionID]", ItemsPerPage = 10 };

                var f = new Field { Name = "TaxID" };
                var ff = new EqualFieldFilter { ParamName = "@TaxID", Value = CurrentTax.TaxId.ToString(CultureInfo.InvariantCulture) };
                f.Filter = ff;

                _paging.AddField(f);

                f = new Field { Name = "RegionName", Sorting = SortDirection.Ascending };
                _paging.AddField(f);
                grid.ChangeHeaderImageUrl("arrowName", f.Sorting == SortDirection.Ascending ? "images/arrowup.gif" : "images/arrowdown.gif");

                f = new Field { Name = "RegionRate" };
                _paging.AddField(f);

                f = new Field { Name = "[Catalog].[TaxRegionRate].RegionID as RegionID" };
                _paging.AddField(f);

                _paging.CurrentPageIndex = 1;

                ViewState["Paging"] = _paging;

                ddlDependsOnAddress.Items.Add(new ListItem(Resources.Resource.Admin_Taxes_DefaultAddress, ((int)TypeRateDepends.Default).ToString(CultureInfo.InvariantCulture)));
                ddlDependsOnAddress.Items.Add(new ListItem(Resources.Resource.Admin_Taxes_ShippingAddress, ((int)TypeRateDepends.ByShippingAddress).ToString(CultureInfo.InvariantCulture)));
                ddlDependsOnAddress.Items.Add(new ListItem(Resources.Resource.Admin_Taxes_BillingAddress, ((int)TypeRateDepends.ByBillingAddress).ToString(CultureInfo.InvariantCulture)));
                ddlDependsOnAddress.SelectedValue = ((int)CurrentTax.DependsOnAddress).ToString(CultureInfo.InvariantCulture);

                ddlRateType.Items.Add(new ListItem(Resources.Resource.Admin_Taxes_Fixed, ((int)RateType.LumpSum).ToString(CultureInfo.InvariantCulture)));
                ddlRateType.Items.Add(new ListItem(Resources.Resource.Admin_Taxes_Proportional, ((int)RateType.Proportional).ToString(CultureInfo.InvariantCulture)));
                ddlRateType.SelectedValue = ((int)CurrentTax.Type).ToString(CultureInfo.InvariantCulture);

                ddlCountry.DataSource = CountryService.GetAllCountries();
                DataBind();

                ddlCountry.SelectedValue = CurrentTax.CountryID.ToString(CultureInfo.InvariantCulture);
                ddlCountry_SelectedIndexChanged(ddlCountry, e);
                chkEnabled.Checked = CurrentTax.Enabled;
            }
            else
            {
                _paging = (SqlPaging)ViewState["Paging"];
            }
        }
Esempio n. 8
0
        protected void btnFilter_Click(object sender, EventArgs e)
        {
            // ---- PropertyID filter
            if (!String.IsNullOrEmpty(Request["propertyid"]))
            {
                int propertyID = 0;
                Property prop = null;
                if (int.TryParse(Request["propertyid"], out propertyID))
                {
                    prop = PropertyService.GetPropertyById(propertyID);
                }
                if (prop != null)
                {
                    var ef = new EqualFieldFilter
                        {
                            ParamName = "@PropertyID",
                            Value = propertyID.ToString(CultureInfo.InvariantCulture)
                        };
                    _paging.Fields["PropertyID"].Filter = ef;
                }
                else
                {
                    Response.Redirect("Properties.aspx");
                }
            }

            //-----Selection filter
            if (String.CompareOrdinal(ddSelect.SelectedIndex.ToString(CultureInfo.InvariantCulture), "0") != 0)
            {
                if (String.CompareOrdinal(ddSelect.SelectedIndex.ToString(CultureInfo.InvariantCulture), "2") == 0 && _selectionFilter != null)
                {
                    _selectionFilter.IncludeValues = !_selectionFilter.IncludeValues;
                }
                _paging.Fields["ID"].Filter = _selectionFilter;
            }
            else
            {
                _paging.Fields["ID"].Filter = null;
            }

            //----Name filter
            _paging.Fields["Value"].Filter = string.IsNullOrEmpty(txtValue.Text)
                                                 ? null
                                                 : new CompareFieldFilter
                                                     {
                                                         Expression = txtValue.Text,
                                                         ParamName = "@Name"
                                                     };

            //----SortOrder filter
            _paging.Fields["SortOrder"].Filter = string.IsNullOrEmpty(txtSortOrder.Text)
                                                     ? null
                                                     : new EqualFieldFilter
                                                         {
                                                             ParamName = "@SortOrder",
                                                             Value = txtSortOrder.Text
                                                         };

            _paging.Fields["ProductsCount"].Filter = string.IsNullOrEmpty(txtProductsCount.Text)
                                                         ? null
                                                         : new EqualFieldFilter
                                                             {
                                                                 ParamName = "@ProductsCount",
                                                                 Value = txtProductsCount.Text
                                                             };

            pageNumberer.CurrentPageIndex = 1;
        }
Esempio n. 9
0
        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;
                }
            }
        }
Esempio n. 10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SetMeta(string.Format("{0} - {1}", SettingsMain.ShopName, Resource.Admin_StaticPage_lblSubMain));

            int.TryParse(Request["parentid"], out _parentPageId);
            if (!IsPostBack)
            {
                _paging = new SqlPaging
                    {
                        TableName = "[CMS].[StaticPage]",
                        ItemsPerPage = 10
                    };

                _paging.AddFieldsRange(new List<Field>
                    {
                        new Field {Name = "StaticPageID as ID",IsDistinct = true},
                        new Field {Name = "PageName"},
                        new Field {Name = "Enabled"},
                        new Field {Name = "ParentID"},
                        new Field {Name = "SortOrder",Sorting = SortDirection.Ascending},
                        new Field {Name = "ModifyDate"}
                    });

                if (_parentPageId != 0)
                {
                    var ef = new EqualFieldFilter()
                        {
                            ParamName = "@ParentID",
                            Value = _parentPageId.ToString(CultureInfo.InvariantCulture)
                        };

                    _paging.Fields["ParentID"].Filter = ef;
                }
                else
                {
                    var nf = new NullFieldFilter()
                        {
                            ParamName = "@ParentID",
                            Null = true
                        };

                    _paging.Fields["ParentID"].Filter = nf;
                }

                grid.ChangeHeaderImageUrl("arrowSortOrder", "images/arrowup.gif");

                _paging.ItemsPerPage = 10;

                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();
                    var arrids = strIds.Split(' ');

                    _selectionFilter = new InSetFieldFilter();
                    if (arrids.Contains("-1"))
                    {
                        _selectionFilter.IncludeValues = false;
                        _inverseSelection = true;
                    }
                    else
                    {
                        _selectionFilter.IncludeValues = true;
                    }
                    _selectionFilter.Values = arrids.Where(id => id != "-1").ToArray();
                }
            }
        }
        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"));
                }
            }
        }
Esempio n. 12
0
        protected void btnFilter_Click(object sender, EventArgs e)
        {
            //-----Selection filter
            if (ddSelect.SelectedIndex != 0)
            {
                if (ddSelect.SelectedIndex == 2)
                {
                    if (_selectionFilter != null)
                    {
                        _selectionFilter.IncludeValues = !_selectionFilter.IncludeValues;
                    }
                    else
                    {
                        _selectionFilter = null;
                    }
                }
                _paging.Fields["ID"].Filter = _selectionFilter;
            }
            else
            {
                _paging.Fields["ID"].Filter = _selectionFilter;
            }

            //----FirstName filter
            if (!string.IsNullOrEmpty(txtFirstName.Text))
            {
                var nfilter = new CompareFieldFilter { Expression = txtFirstName.Text, ParamName = "@FirstName" };
                _paging.Fields["FirstName"].Filter = nfilter;
            }
            else
            {
                _paging.Fields["FirstName"].Filter = null;
            }

            //----Login filter
            //if (!string.IsNullOrEmpty(txtLogin.Text))
            //{
            //    var nfilter = new CompareFieldFilter { Expression = txtLogin.Text, ParamName = "@Login" };
            //    _paging.Fields["Login"].Filter = nfilter;
            //}
            //else
            //{
            //    _paging.Fields["Login"].Filter = null;
            //}

            //---LastName
            if (!string.IsNullOrEmpty(txtLastName.Text))
            {
                var nfilter = new CompareFieldFilter { Expression = txtLastName.Text, ParamName = "@LastName" };
                _paging.Fields["LastName"].Filter = nfilter;
            }
            else
            {
                _paging.Fields["LastName"].Filter = null;
            }

            //---Email Filter
            if (!string.IsNullOrEmpty(txtEmail.Text))
            {
                var nfilter = new CompareFieldFilter { Expression = txtEmail.Text, ParamName = "@Email" };
                _paging.Fields["Email"].Filter = nfilter;
            }
            else
            {
                _paging.Fields["Email"].Filter = null;
            }

            //----Subscribed4News
            if (subscribed4News.SelectedIndex != 0)
            {
                var beforeFilter = new EqualFieldFilter { ParamName = "@Subscribed4News" };
                if (subscribed4News.SelectedIndex == 1)
                {
                    beforeFilter.Value = "1";
                }
                if (subscribed4News.SelectedIndex == 2)
                {
                    beforeFilter.Value = "0";
                }
                _paging.Fields["Subscribed4News"].Filter = beforeFilter;
            }
            else
            {
                _paging.Fields["Subscribed4News"].Filter = null;
            }

            var dfilter = new DateTimeRangeFieldFilter { ParamName = "@RegistrationDateTime" };
            if (!string.IsNullOrEmpty(txtDateFrom.Text))
            {
                DateTime? d = null;
                try
                {
                    d = DateTime.Parse(txtDateFrom.Text);
                }
                catch (Exception)
                {
                }
                if (d.HasValue)
                {
                    var dt = new DateTime(d.Value.Year, d.Value.Month, d.Value.Day, 0, 0, 0, 0);
                    dfilter.From = dt;
                }
            }

            if (!string.IsNullOrEmpty(txtDateTo.Text))
            {
                DateTime? d = null;
                try
                {
                    d = DateTime.Parse(txtDateTo.Text);
                }
                catch (Exception)
                {
                }
                if (d.HasValue)
                {
                    var dt = new DateTime(d.Value.Year, d.Value.Month, d.Value.Day, 23, 59, 59, 99);
                    dfilter.To = dt;
                }
            }

            if (dfilter.From.HasValue || dfilter.To.HasValue)
            {
                _paging.Fields["RegistrationDateTime"].Filter = dfilter;
            }
            else
            {
                _paging.Fields["RegistrationDateTime"].Filter = null;
            }

            pageNumberer.CurrentPageIndex = 1;
        }
Esempio n. 13
0
        protected void btnFilter_Click(object sender, EventArgs e)
        {
            //-----Selection filter
            if (ddSelect.SelectedIndex != 0)
            {
                if (ddSelect.SelectedIndex == 2)
                {
                    if (_selectionFilter != null)
                    {
                        _selectionFilter.IncludeValues = !_selectionFilter.IncludeValues;
                    }
                    else
                    {
                        _selectionFilter = null;
                    }
                }
                _paging.Fields["ID"].Filter = _selectionFilter;
            }
            else
            {
                _paging.Fields["ID"].Filter = _selectionFilter;
            }

            //----Name filter
            if (!string.IsNullOrEmpty(txtUrlFilter.Text))
            {
                var nfilter = new CompareFieldFilter { Expression = txtUrlFilter.Text, ParamName = "@URL" };
                _paging.Fields["URL"].Filter = nfilter;
            }
            else
            {
                _paging.Fields["URL"].Filter = null;
            }

            //----CurrencyValue filter
            if (!string.IsNullOrEmpty(txtSortOrder.Text))
            {
                var nfilter = new CompareFieldFilter { Expression = txtSortOrder.Text, ParamName = "@SortOrder" };
                _paging.Fields["SortOrder"].Filter = nfilter;
            }
            else
            {
                _paging.Fields["SortOrder"].Filter = null;
            }

            if (ddlEnabled.SelectedIndex != 0)
            {
                var eFilter = new EqualFieldFilter { ParamName = "@Enabled" };
                if (ddlEnabled.SelectedIndex == 1)
                {
                    eFilter.Value = "1";
                }
                if (ddlEnabled.SelectedIndex == 2)
                {
                    eFilter.Value = "0";
                }
                _paging.Fields["Enabled"].Filter = eFilter;
            }
            else
            {
                _paging.Fields["Enabled"].Filter = null;
            }

            pageNumberer.CurrentPageIndex = 1;
            _paging.CurrentPageIndex = 1;
        }
Esempio n. 14
0
        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();
        }
Esempio n. 15
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SetMeta(string.Format("{0} - {1}", AdvantShop.Configuration.SettingsMain.ShopName, Resource.Admin_MasterPageAdminCatalog_Catalog));
            if (string.IsNullOrEmpty(ModuleName))
            {
                Response.Redirect("ExportFeed.aspx?ModuleId=YandexMarket");
                return;
            }
            if (!string.IsNullOrEmpty(Request["CatId"]))
            {
                Int32.TryParse(Request["CatId"], out _catId);
            }
            Category cat = CategoryService.GetCategory(_catId);
            if (cat != null)
            {
                lblCategoryName.Text = cat.Name;
                sn.BuildNavigationAdmin(_catId);
            }
            if (!Page.IsPostBack)
            {
                var flag = ExportFeedService.CheakCategoryHierical(ModuleName, _catId);
                pnlCategorySet.Enabled = !flag;
                chbFull.Checked = ExportFeedService.CheakCategory(ModuleName, _catId);
                pnlData.Enabled = !chbFull.Checked && !flag;
            }
            PageSubheader.Visible = true;
            ModuleNameLiteral.Text = ModuleName;
            if (!IsPostBack)
            {
                var node2 = new TreeNode { Text = SelectCategory(0, ModuleName, Resource.Admin_m_Category_Root), Value = "0", Selected = true, NavigateUrl = ExportFeedNew + "?moduleid=" + ModuleName };

                tree2.Nodes.Add(node2);
                LoadChildCategories2(tree2.Nodes[0]);

                _paging = new SqlPaging
                    {
                        TableName = "[Catalog].[Product] left JOIN [Catalog].[Offer] ON [Product].[ProductID] = [Offer].[ProductID]  AND [Offer].Main=1 INNER JOIN Catalog.ProductCategories on ProductCategories.ProductId = [Product].[ProductID] and ProductCategories.Main=1",
                        ItemsPerPage = 100
                    };

                var f = new Field { Name = "Product.ProductId as ID", IsDistinct = true };
                _paging.AddField(f);

                f = new Field { Name = "Product.ArtNo" };
                _paging.AddField(f);

                f = new Field { Name = "Name" };
                _paging.AddField(f);

                f = new Field { Name = "(Select count(*) from Settings.ExportFeedSelectedProducts where ModuleName=@ModuleName and ExportFeedSelectedProducts.ProductID=Product.ProductId) as Cheaked" };
                _paging.AddField(f);

                var pf = new EqualFieldFilter { Value = _catId.ToString(), ParamName = "@Parent" };
                f = new Field { Name = "CategoryId", Filter = pf };
                _paging.AddField(f);

                f = new Field { Name = "SortOrder", Sorting = SortDirection.Ascending };
                _paging.AddField(f);

                _paging.AddParam(new SqlParam { ParameterName = "@ModuleName", Value = ModuleName });

                _paging.ExtensionWhere = "and Offer.Price > 0 and (Offer.Amount > 0 or Product.AllowPreorder=1) and CategoryEnabled=1 and Enabled=1";
                grid.ChangeHeaderImageUrl("arrowName", "images/arrowup.gif");

                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;
                }
            }
        }
Esempio n. 16
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (string.IsNullOrEmpty(Request["categoryid"]) || !Int32.TryParse(Request["categoryid"], out _categoryId))
        {
            Error404();
        }

        Category = CategoryService.GetCategory(_categoryId);
        if (Category == null || Category.Enabled == false || Category.ParentsEnabled == false)
        {
            Error404();
            return;
        }

        Indepth = Request["indepth"] == "1" || Category.DisplayChildProducts;

        _priceField = CustomerSession.CurrentCustomer.PriceType.ToString();

        _paging = new SqlPaging
            {
                TableName =
                    "[Catalog].[Product] " +
                    "LEFT JOIN [Catalog].[Offer] ON [Product].[ProductID] = [Offer].[ProductID] " +
                    "inner join Catalog.ProductCategories on ProductCategories.ProductId = [Product].[ProductID] " +
                    "Left JOIN [Catalog].[ProductPropertyValue] ON [Product].[ProductID] = [ProductPropertyValue].[ProductID] " +
                    "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]", IsDistinct = true},
                    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 = "[ProductCategories].[CategoryID]", NotInQuery=true},
                    new Field {Name = "BriefDescription"},
                    new Field {Name = "Product.ArtNo"},
                    new Field {Name = "Name"},
                    new Field {Name = string.Format("(CASE WHEN {0}=0 THEN 0 ELSE 1 END) as TempSort", _priceField), Sorting=SortDirection.Descending},
                    new Field {Name = "Recomended"},
                    new Field {Name = "Bestseller"},
                    new Field {Name = "New"},
                    new Field {Name = "OnSale"},
                    new Field {Name = "Discount"},
                    new Field {Name = "Offer.Main", NotInQuery=true},
                    new Field {Name = "Offer.OfferID"},
                    new Field {Name = "(Select Max(Offer.Amount) from catalog.Offer Where ProductId=[Product].[ProductID]) as Amount"},
                    new Field {Name = "(CASE WHEN (Select Max(Offer.Amount) from catalog.Offer Where ProductId=[Product].[ProductID])  <= 0 OR (Select Max(Offer.Amount) from catalog.Offer Where ProductId=[Product].[ProductID]) < IsNull(MinAmount,0) THEN 0 ELSE 1 END) as TempAmountSort", Sorting=SortDirection.Descending},
                    new Field {Name = "MinAmount"},
                    new Field {Name = "MaxAmount"},
                    new Field {Name = "Multiplicity"},
                    new Field {Name = "Enabled"},
                    new Field {Name = "AllowPreOrder"},
                    new Field {Name = "Ratio"},
                    new Field {Name = "RatioID"},
                    new Field {Name = "DateModified"},
                    new Field {Name = "ShoppingCartItemId"},
                    new Field {Name = "UrlPath"},
                    new Field {Name = !Indepth ? "[ProductCategories].[SortOrder]" : "0 as SortOrder"},
                    new Field {Name = "[ShoppingCart].[CustomerID]", NotInQuery=true},
                    new Field {Name = "BrandID", NotInQuery=true},
                    new Field {Name = "Offer.ProductID as Size_ProductID", NotInQuery=true},
                    new Field {Name = "Offer.ProductID as Color_ProductID", NotInQuery=true},
                    new Field {Name = "Offer.ProductID as Price_ProductID", NotInQuery=true},
                    new Field {Name = "Offer.ColorID"},
                    new Field {Name = "CategoryEnabled", NotInQuery=true},
                });

        if (SettingsCatalog.ComplexFilter)
        {
            _paging.AddFieldsRange(new List<Field>
                {
                    new Field {Name = "(select [Settings].[ProductColorsToString]([Product].[ProductID])) as Colors"},
                    new Field {Name = string.Format("(select max ({0}) - min ({0}) from catalog.offer where offer.productid=product.productid) as MultiPrices", _priceField)},
                    new Field {Name = string.Format("(select min ({0}) from catalog.offer where offer.productid=product.productid) as Price", _priceField)},
                });
        }
        else
        {
            _paging.AddFieldsRange(new List<Field>
                {
                    new Field {Name = "null as Colors"},
                    new Field {Name = "0 as MultiPrices"},
                    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)
                    },
                });
        }

        _paging.AddParam(new SqlParam { ParameterName = "@CustomerId", Value = CustomerSession.CustomerId.ToString() });
        _paging.AddParam(new SqlParam { ParameterName = "@Type", Value = PhotoType.Product.ToString() });

        ProductsCount = Indepth ? Category.TotalProductsCount : Category.GetProductCount();

        categoryView.CategoryID = _categoryId;
        categoryView.Visible = Category.DisplayStyle == "True" || ProductsCount == 0;
        pnlSort.Visible = ProductsCount > 0;
        productView.Visible = ProductsCount > 0;
        catalogView.CategoryID = _categoryId;

        filterProperty.CategoryId = _categoryId;

        filterBrand.CategoryId = _categoryId;
        filterBrand.InDepth = Indepth;

        filterSize.CategoryId = _categoryId;
        filterSize.InDepth = Indepth;

        filterColor.CategoryId = _categoryId;
        filterColor.InDepth = Indepth;

        filterPrice.CategoryId = _categoryId;
        filterPrice.InDepth = Indepth;

        filterPrice.PriceType = CustomerSession.CurrentCustomer.PriceType;

        lblCategoryName.Text = _categoryId != 0 ? Category.Name : Resource.Client_MasterPage_Catalog;

        breadCrumbs.Items =
            CategoryService.GetParentCategories(_categoryId).Select(parent => new BreadCrumbs
                                                                                  {
                                                                                      Name = parent.Name,
                                                                                      Url = UrlService.GetLink(ParamType.Category, parent.UrlPath, parent.CategoryId)
                                                                                  }).Reverse().ToList();
        breadCrumbs.Items.Insert(0, new BreadCrumbs
                                        {
                                            Name = Resource.Client_MasterPage_MainPage,
                                            Url = UrlService.GetAbsoluteLink("/")
                                        });

        var categoryMeta = SetMeta(Category.Meta, Category.Name, page: paging.CurrentPage);
        lblCategoryName.Text = categoryMeta.H1;

        if (Category.DisplayChildProducts || Indepth)
        {
            var cfilter = new InChildCategoriesFieldFilter
                              {
                                  CategoryId = _categoryId.ToString(),
                                  ParamName = "@CategoryID"
                              };
            _paging.Fields["[ProductCategories].[CategoryID]"].Filter = cfilter;
        }
        else
        {
            var cfilter = new EqualFieldFilter { Value = _categoryId.ToString(), ParamName = "@catalog" };
            _paging.Fields["[ProductCategories].[CategoryID]"].Filter = cfilter;
        }

        _paging.Fields["Enabled"].Filter = new EqualFieldFilter { Value = "1", ParamName = "@enabled" };
        _paging.Fields["CategoryEnabled"].Filter = new EqualFieldFilter { Value = "1", ParamName = "@CategoryEnabled" };

        var logicalFilter = new LogicalFilter{ ParamName = "@Main", HideInCustomData = true };
        logicalFilter.AddFilter(new EqualFieldFilter {Value = "1", ParamName = "@Main1", HideInCustomData = true});
        logicalFilter.AddLogicalOperation("OR");
        logicalFilter.AddFilter(new NullFieldFilter { Null = true, ParamName = "@Main2", HideInCustomData = true });
        _paging.Fields["Offer.Main"].Filter = logicalFilter;

        BuildSorting();
        BuildFilter();
    }
Esempio n. 17
0
        protected void btnFilter_Click(object sender, EventArgs e)
        {
            //-----Selection filter
            if (ddSelect.SelectedIndex != 0)
            {
                if (ddSelect.SelectedIndex == 2)
                {
                    if (_selectionFilter != null)
                    {
                        _selectionFilter.IncludeValues = !_selectionFilter.IncludeValues;
                    }
                    else
                    {
                        _selectionFilter = null;
                    }
                }
                if (_selectionFilter != null)
                {
                    _paging.Fields["ID"].Filter = _selectionFilter;
                }
            }
            else
            {
                _paging.Fields["ID"].Filter = null;
            }

            //----Enabled filter
            if (ddlEnabled.SelectedIndex != 0)
            {
                var efilter = new EqualFieldFilter { ParamName = "@enabled" };
                if (ddlEnabled.SelectedIndex == 1)
                {
                    efilter.Value = "1";
                }
                if (ddlEnabled.SelectedIndex == 2)
                {
                    efilter.Value = "0";
                }
                _paging.Fields["Enabled"].Filter = efilter;
            }
            else
            {
                _paging.Fields["Enabled"].Filter = null;
            }

            //----Price filter

            var priceFilter = new RangeFieldFilter { ParamName = "@price" };

            int priceFrom;
            priceFilter.From = int.TryParse(txtPriceFrom.Text, out priceFrom) ? priceFrom : 0;

            int priceTo;
            priceFilter.To = int.TryParse(txtPriceTo.Text, out priceTo) ? priceTo : int.MaxValue;

            if (!string.IsNullOrEmpty(txtPriceFrom.Text) || !string.IsNullOrEmpty(txtPriceTo.Text))
            {
                _paging.Fields["Price"].Filter = priceFilter;
            }
            else
            {
                _paging.Fields["Price"].Filter = null;
            }

            //----Qty filter
            var qtyFilter = new RangeFieldFilter { ParamName = "@Amount" };
            int from;
            qtyFilter.From = int.TryParse(txtQtyFrom.Text, out from) ? from : int.MinValue;

            int to;
            qtyFilter.To = int.TryParse(txtQtyTo.Text, out to) ? to : int.MaxValue;

            if (!string.IsNullOrEmpty(txtQtyFrom.Text) || !string.IsNullOrEmpty(txtQtyTo.Text))
            {
                _paging.Fields["Amount"].Filter = qtyFilter;
            }
            else
            {
                _paging.Fields["Amount"].Filter = null;
            }

            //----SortOrder filter
            var soFilter = new RangeFieldFilter { ParamName = "@SortOrder" };

            try
            {
                soFilter.From = int.Parse(txtSortOrderFrom.Text);
            }
            catch (Exception)
            {
                soFilter.From = int.MinValue;
            }

            try
            {
                soFilter.To = int.Parse(txtSortOrderTo.Text);
            }
            catch (Exception)
            {
                soFilter.To = int.MaxValue;
            }

            if (ShowMethod == EShowMethod.Normal)
            {
                if (!string.IsNullOrEmpty(txtSortOrderFrom.Text) || !string.IsNullOrEmpty(txtSortOrderTo.Text))
                {
                    _paging.Fields["ProductCategories.SortOrder"].Filter = soFilter;
                }
                else
                {
                    _paging.Fields["ProductCategories.SortOrder"].Filter = null;
                }
            }

            //----Id filter
            if (!string.IsNullOrEmpty(txtArtNo.Text))
            {
                var sfilter = new CompareFieldFilter { Expression = txtArtNo.Text, ParamName = "@artno" };
                _paging.Fields["Product.ArtNo"].Filter = sfilter;

            }
            else
            {
                _paging.Fields["Product.ArtNo"].Filter = null;

            }

            //----Name filter
            if (!string.IsNullOrEmpty(txtName.Text))
            {
                var nfilter = new CompareFieldFilter { Expression = txtName.Text, ParamName = "@name" };
                _paging.Fields["Name"].Filter = nfilter;
            }
            else
            {
                _paging.Fields["Name"].Filter = null;
            }

            //---Photo filter
            if (ddPhoto.SelectedIndex != 0)
            {
                var phfilter = new NullFieldFilter();
                if (ddPhoto.SelectedIndex == 1)
                {
                    phfilter.Null = false;
                }
                if (ddPhoto.SelectedIndex == 2)
                {
                    phfilter.Null = true;
                }
                phfilter.ParamName = "@PhotoName";
                _paging.Fields["PhotoName"].Filter = phfilter;
            }
            else
            {
                _paging.Fields["PhotoName"].Filter = null;
            }

            pageNumberer.CurrentPageIndex = 1;
            _paging.CurrentPageIndex = 1;
            //lblFound.Text = _paging.TotalRowsCount.ToString();
            //pnlFilterCount.Visible = true;
            //pnlNormalCount.Visible = false;
        }
Esempio n. 18
0
        protected void Page_Load(object sender, EventArgs e)
        {
            bool categoryIdIsNum = false;
            int categoryId = -1;
            if (!string.IsNullOrEmpty(Request["newscategoryid"]) &&
                Int32.TryParse(Request["newscategoryid"], out categoryId))
            {
                categoryIdIsNum = categoryId != -1;
            }

            _paging = new SqlPaging
                {
                    TableName = "Settings.News left join Catalog.Photo on Photo.objId=News.NewsID and Type=@Type",
                    ItemsPerPage = SettingsNews.NewsPerPage
                };

            _paging.AddField(new Field { Name = "NewsID" });

            _paging.AddField(new Field { Name = "AddingDate", Sorting = SortDirection.Descending });

            _paging.AddField(new Field { Name = "Title" });

            _paging.AddField(new Field { Name = "PhotoName as Picture" });

            _paging.AddField(new Field { Name = "TextToPublication" });

            _paging.AddField(new Field { Name = "TextToEmail" });

            _paging.AddField(new Field { Name = "TextAnnotation" });

            _paging.AddField(new Field { Name = "UrlPath" });

            _paging.AddParam(new SqlParam { ParameterName = "@Type", Value = PhotoType.News.ToString() });

            if (categoryIdIsNum)
            {
                var f = new Field { Name = "NewsCategoryID", NotInQuery = true };
                var filter = new EqualFieldFilter
                    {
                        ParamName = "@NewsCategoryID",
                        Value = categoryId.ToString(CultureInfo.InvariantCulture)
                    };
                f.Filter = filter;
                _paging.AddField(f);
            }

            MetaInfo nmeta = new MetaInfo
                {
                    Type = MetaType.News,
                    Title = SettingsNews.NewsMetaTitle,
                    MetaKeywords = SettingsNews.NewsMetaKeywords,
                    MetaDescription = SettingsNews.NewsMetaDescription,
                    H1 = SettingsNews.NewsMetaH1
                };

            var category = NewsService.GetNewsCategoryById(categoryId);
            header.Text = category != null
                              ? string.Format("{0} / {1}", Resource.Client_News_News, category.Name)
                              : Resource.Client_News_News;

            if (paging.CurrentPage > 1)
            {
                header.Text = header.Text + Resource.Client_Catalog_PageIs + paging.CurrentPage;
            }

            if (category != null)
            {
                ucBreadCrumbs.Items = new List<BreadCrumbs>
                    {
                        new BreadCrumbs
                            {
                                Name = Resource.Client_News_News,
                                Url = UrlService.GetAbsoluteLink("news")
                            },
                        new BreadCrumbs
                            {
                                Name = category.Name,
                                Url = UrlService.GetLink(ParamType.NewsCategory, category.UrlPath, category.NewsCategoryID)
                            }
                    };
            }
            else
            {
                ucBreadCrumbs.Visible = false;
            }

            if (paging.CurrentPage > 1)
            {
                nmeta.Title += Resource.Client_Catalog_PageIs + paging.CurrentPage;
                nmeta.MetaDescription += Resource.Client_Catalog_PageIs + paging.CurrentPage;
            }
            SetMeta(nmeta, string.Empty);
        }
Esempio n. 19
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SetMeta(string.Format("{0} - {1}", SettingsMain.ShopName, Resource.Admin_Properties_ListPropreties));

            if (!IsPostBack)
            {
                _paging = new SqlPaging
                    {
                        TableName = "[Catalog].[PropertyValue]",
                        ItemsPerPage = 50,
                        CurrentPageIndex = 1
                    };

                _paging.AddFieldsRange(new[]
                    {
                        new Field {Name = "PropertyValueID as ID"},
                        new Field {Name = "PropertyID"},
                        new Field {Name = "Value"},
                        new Field {Name = "SortOrder", Sorting = SortDirection.Ascending},
                        new Field {Name = "(Select Count(ProductID) from Catalog.ProductPropertyValue Where propertyValueid=[PropertyValue].propertyValueid) as ProductsCount"},
                    });

                if (!String.IsNullOrEmpty(Request["propertyid"]))
                {
                    int propertyId = 0;
                    Property prop = null;
                    if (int.TryParse(Request["propertyid"], out propertyId))
                    {
                        prop = PropertyService.GetPropertyById(propertyId);

                    }
                    if (prop != null)
                    {
                        lblHead.Text += string.Format(" - \"{0}\"", prop.Name);

                        var ef = new EqualFieldFilter
                            {
                                ParamName = "@PropertyID",
                                Value = propertyId.ToString(CultureInfo.InvariantCulture)
                            };
                        _paging.Fields["PropertyID"].Filter = ef;
                    }
                    else
                    {
                        Response.Redirect("Properties.aspx");
                    }
                }
                else
                    Response.Redirect("Properties.aspx");

                grid.ChangeHeaderImageUrl("arrowSortOrder", "images/arrowup.gif");
                pageNumberer.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();

                    var 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(CultureInfo.InvariantCulture);
                        }
                        else
                        {
                            _selectionFilter.IncludeValues = false;
                            _inverseSelection = true;
                        }
                    }
                    _selectionFilter.Values = ids;
                }
            }
        }