Пример #1
0
        private void LoadRootCategories(TreeNodeCollection treeNodeCollection)
        {
            var rootCategory = CategoryService.GetCategory(0);
            var newNode = new ButtonTreeNodeCatalog
                {
                    Text = string.Format("{3}{0} ({1}/{2}){4}", rootCategory.Name, rootCategory.ProductsCount, rootCategory.TotalProductsCount,
                                         rootCategory.ProductsCount == 0 ? "<span class=\"lightlink\">" : string.Empty,
                                         rootCategory.ProductsCount == 0 ? "</span>" : string.Empty),
                    Value = rootCategory.CategoryId.ToString(),
                    NavigateUrl = "Catalog.aspx?CategoryID=" + rootCategory.CategoryId,
                    TreeView = tree,
                    Expanded = true,
                    PopulateOnDemand = false
                };

            treeNodeCollection.Add(newNode);

            foreach (var c in CategoryService.GetChildCategoriesByCategoryId(0, false))
            {
                newNode = new ButtonTreeNodeCatalog
                    {
                        Text = string.Format("{3}{0} ({1}/{2}){4}", c.Name, c.ProductsCount, c.TotalProductsCount,
                                             c.ProductsCount == 0 ? "<span class=\"lightlink\">" : string.Empty,
                                             c.ProductsCount == 0 ? "</span>" : string.Empty),
                        MessageToDel = Server.HtmlEncode(string.Format(Resource.Admin_MasterPageAdminCatalog_Confirmation, c.Name)),
                        Value = c.CategoryId.ToString(),
                        NavigateUrl = "Catalog.aspx?CategoryID=" + c.CategoryId,
                        TreeView = tree
                    };
                if (c.HasChild)
                {
                    newNode.Expanded = false;
                    newNode.PopulateOnDemand = true;
                }
                else
                {
                    newNode.Expanded = true;
                    newNode.PopulateOnDemand = false;
                }

                treeNodeCollection.Add(newNode);
            }
        }
Пример #2
0
 private void LoadChildCategories(TreeNode node)
 {
     foreach (var c in CategoryService.GetChildCategoriesByCategoryId(SQLDataHelper.GetInt(node.Value), false))
     {
         var newNode = new ButtonTreeNodeCatalog
             {
                 Text = string.Format("{0} ({1}/{2})", c.Name, c.ProductsCount, c.TotalProductsCount),
                 MessageToDel =
                     Server.HtmlEncode(string.Format(
                         Resource.Admin_MasterPageAdminCatalog_Confirmation, c.Name)),
                 Value = c.CategoryId.ToString(),
                 NavigateUrl = "Catalog.aspx?CategoryID=" + c.CategoryId,
                 TreeView = tree
             };
         if (c.HasChild)
         {
             newNode.Expanded = false;
             newNode.PopulateOnDemand = true;
         }
         else
         {
             newNode.Expanded = true;
             newNode.PopulateOnDemand = false;
         }
         node.ChildNodes.Add(newNode);
     }
 }