示例#1
0
        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;
        }
示例#2
0
        /// <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;
        }
示例#3
0
        /// <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;
        }
示例#4
0
        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;
        }
示例#5
0
        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;
        }
示例#6
0
        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;
        }