public List<Category> GetChildCategorysByID(string categoryid, string clientid) { var dal = new ProductsDAL(); DataTable dt = dal.GetChildCategorysByID(categoryid, clientid); List<Category> list = new List<Category>(); foreach (DataRow dr in dt.Rows) { Category model = new Category(); model.FillData(dr); list.Add(model); } return list; }
/// <summary> /// 获取产品分类详情(包括属性和值) /// </summary> public Category GetCategoryDetailByID(string categoryid) { var dal = new ProductsDAL(); DataSet ds = dal.GetCategoryDetailByID(categoryid); Category model = new Category(); if (ds.Tables.Contains("Category") && ds.Tables["Category"].Rows.Count > 0) { model.FillData(ds.Tables["Category"].Rows[0]); List<ProductAttr> salelist = new List<ProductAttr>(); List<ProductAttr> attrlist = new List<ProductAttr>(); foreach (DataRow attr in ds.Tables["Attrs"].Rows) { ProductAttr modelattr = new ProductAttr(); modelattr.FillData(attr); if (modelattr.Type==1) { attrlist.Add(modelattr); } else if (modelattr.Type == 2) { salelist.Add(modelattr); } modelattr.AttrValues = new List<AttrValue>(); foreach (DataRow value in ds.Tables["Values"].Select("AttrID='" + modelattr.AttrID + "'")) { AttrValue valuemodel = new AttrValue(); valuemodel.FillData(value); modelattr.AttrValues.Add(valuemodel); } } model.SaleAttrs = salelist; model.AttrLists = attrlist; } return model; }
/// <summary> /// 获取产品分类 /// </summary> public Category GetCategoryByID(string categoryid) { var dal = new ProductsDAL(); DataTable dt = dal.GetCategoryByID(categoryid); Category model = new Category(); if (dt.Rows.Count > 0) { model.FillData(dt.Rows[0]); } return model; }
public Category GetCategoryDetailByID(string categoryid) { var dal = new ProductsDAL(); DataSet ds = dal.GetCategoryDetailByID(categoryid); Category model = new Category(); if (ds.Tables.Contains("Category") && ds.Tables["Category"].Rows.Count > 0) { model.SaleAttrs = new List<ProductAttr>(); model.AttrLists = new List<ProductAttr>(); model.FillData(ds.Tables["Category"].Rows[0]); foreach (DataRow attr in ds.Tables["Attrs"].Rows) { ProductAttr modelattr = new ProductAttr(); modelattr.FillData(attr); if (modelattr.Type == 1) { model.AttrLists.Add(GetProductAttrByID(modelattr.AttrID, model.ClientID)); } else { model.SaleAttrs.Add(GetProductAttrByID(modelattr.AttrID, model.ClientID)); } } } return model; }
public Category GetCategoryByID(string categoryid,string clientid) { var list = GetCategorys(clientid); if (list.Where(m => m.CategoryID == categoryid).Count() > 0) { return list.Where(m => m.CategoryID == categoryid).FirstOrDefault(); } DataTable dt = ProductsDAL.BaseProvider.GetCategoryByID(categoryid); Category model = new Category(); if (dt.Rows.Count > 0) { model.FillData(dt.Rows[0]); list.Add(model); } return model; }
public List<Category> GetCategorys(string clientid) { if (CacheCategorys.ContainsKey(clientid)) { return CacheCategorys[clientid]; } DataTable dt = ProductsDAL.BaseProvider.GetCategorys(clientid); List<Category> list = new List<Category>(); foreach (DataRow dr in dt.Rows) { Category model = new Category(); model.FillData(dr); list.Add(model); } foreach (var model in list) { model.ChildCategorys = list.Where(m => m.PID == model.CategoryID).ToList(); } CacheCategorys.Add(clientid, list); return list; }