Exemplo n.º 1
0
        public bool DeleteCategory(int CategoryId)
        {
            ProductsDS.CategoriesViewDataTable cats = this.GetChildrenCategories(CategoryId);
            foreach (DataRow cat in cats)
            {
                DeleteCategory((Int32)cat["CategoryId"]);
            }


            ProductsDS.CategoriesRow category = GetCategory(CategoryId);

            string path = WebContext.Server.MapPath(WebContext.Root + lw.CTE.Folders.CategoriesImages);

            if (category["Image"] != System.DBNull.Value)
            {
                if (category.Image != "")
                {
                    if (this.GetCategories("Image='" + category.Image + "' and CategoryId<>" + CategoryId.ToString()).Count == 0)
                    {
                        if (System.IO.File.Exists(path + "/Large/" + category.Image))
                        {
                            System.IO.File.Delete(path + "/Large/" + category.Image);
                        }
                    }
                }
            }

            CategoriesAdp adp = new CategoriesAdp();

            adp.DeleteCategory(CategoryId);

            return(true);
        }
Exemplo n.º 2
0
 public ProductsDS.CategoriesViewDataTable GetChildrenCategories(string CategoryName, int ParentId)
 {
     ProductsDS.CategoriesViewDataTable cats = this.GetCategories(
         string.Format("ParentId in (select CategoryId from Categories where Title='{0}' and ParentId={1})",
                       lw.Utils.StringUtils.SQLEncode(CategoryName), ParentId)
         );
     return(cats);
 }
Exemplo n.º 3
0
 public ProductsDS.CategoriesViewDataTable GetChildrenCategories(int CategoryId, int ItemId)
 {
     ProductsDS.CategoriesViewDataTable cats = GetCategories(
         string.Format("ParentId={0} And CategoryId not in (select CategoryId from ItemCategories where ItemId={1})",
                       CategoryId, ItemId)
         );
     return(cats);
 }
Exemplo n.º 4
0
        public ProductsDS.CategoriesViewRow GetCategoryRowView(int CategoryId)
        {
            ProductsDS.CategoriesViewDataTable cats = GetCategories(string.Format("CategoryId={0}", CategoryId));
            if (cats.Count > 0)
            {
                return((ProductsDS.CategoriesViewRow)cats.Rows[0]);
            }

            return(null);
        }
Exemplo n.º 5
0
        public ProductsDS.CategoriesViewDataTable GetChildrenCategories(int CategoryId, string cond)
        {
            if (cond != "")
            {
                cond = " And " + cond;
            }
            ProductsDS.CategoriesViewDataTable cats = GetCategories(string.Format("ParentId={0}{1}", CategoryId, cond));

            return(cats);
        }
Exemplo n.º 6
0
        public ProductsDS.CategoriesViewDataTable GetParentCategories(int CategoryId)
        {
            ArrayList ar = new ArrayList();

            while (CategoryId != -1)
            {
                ProductsDS.CategoriesViewRow cat = this.GetCategoryRowView(CategoryId);
                if (cat != null)
                {
                    ar.Add(cat);
                }
                CategoryId = cat.ParentId;
            }
            ProductsDS.CategoriesViewDataTable dt = new ProductsDS.CategoriesViewDataTable();
            for (int i = ar.Count - 1; i >= 0; i--)
            {
                dt.Rows.Add((ProductsDS.CategoriesRow)ar[i]);
            }
            return(dt);
        }