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); }
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); }
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); }
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); }
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); }
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); }