Ejemplo n.º 1
0
 private string SelectCategory(int catId, string moduleName, string message)
 {
     if (ExportFeedService.CheckCategoryHierical(moduleName, catId) || ExportFeedService.CheckCategory(moduleName, catId))
     {
         return("<span style='color: blue;font-weight:bold;'>" + message + "</span>");
     }
     return(message);
 }
Ejemplo n.º 2
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;
            }

            YaHelp.Visible  = (ModuleName == "YandexMarket");
            CsvHelp.Visible = (ModuleName == "CsvExport");

            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.CheckCategoryHierical(ModuleName, _catId);
                pnlCategorySet.Enabled = !flag;
                chbFull.Checked        = ExportFeedService.CheckCategory(ModuleName, _catId);
                pnlData.Enabled        = !chbFull.Checked && !flag;
            }
            PageSubheader.Visible  = true;
            ModuleNameLiteral.Text = ModuleName;

            if (!IsPostBack)
            {
                var rootCategory = CategoryService.GetCategory(0);
                var node2        = new TreeNode {
                    Text = SelectCategory(0, ModuleName, rootCategory != null ? rootCategory.Name : 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] 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 = ModuleName != "CsvExport" ? "and Offer.Price > 0 and ((Select Max(Amount) from Catalog.Offer where Offer.ProductID = Product.ProductID) > 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;
                }
            }
        }