示例#1
0
 /// <summary>
 /// 添加属性值
 /// </summary>
 /// <param name="valueName">值</param>
 /// <param name="attrID">属性ID</param>
 /// <returns></returns>
 public string AddAttrValue(string valueName, string attrID, string operateid, string clientid)
 {
     var valueID = Guid.NewGuid().ToString();
     var dal = new ProductsDAL();
     if (dal.AddAttrValue(valueID, valueName, attrID, operateid, clientid))
     {
         return valueID.ToString();
     }
     return string.Empty;
 }
示例#2
0
        public List<Brand> GetBrandList(string keyWords, int pageSize, int pageIndex, ref int totalCount, ref int pageCount, string clientID)
        {
            var dal = new ProductsDAL();
            DataSet ds = dal.GetBrandList(keyWords, pageSize, pageIndex, ref totalCount, ref pageCount, clientID);

            List<Brand> list = new List<Brand>();
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                Brand model = new Brand();
                model.FillData(dr);
                model.City = CommonBusiness.Citys.Where(c => c.CityCode == model.CityCode).FirstOrDefault();
                list.Add(model);
            }
            return list;
        }
示例#3
0
        public string AddAttrValue(string valueName, string attrID, string operateid, string clientid)
        {
            var valueID = Guid.NewGuid().ToString().ToLower();
            var dal = new ProductsDAL();
            if (dal.AddAttrValue(valueID, valueName, attrID, operateid, clientid))
            {
                var model = GetProductAttrByID(attrID, clientid);
                model.AttrValues.Add(new AttrValue()
                {
                    ValueID = valueID,
                    ValueName = valueName,
                    Status = 1,
                    AttrID = attrID,
                    ClientID = clientid,
                    CreateTime = DateTime.Now
                });

                return valueID;
            }
            return string.Empty;
        }
 public static string InsertProduct(List<Products> list)
 { 
     string mes ="";
     list.ForEach(x =>
     {
         string result = "";
         string pid
             = new ProductsDAL().InsertProductExcel(x.ProductCode, x.ProductName, x.GeneralName, (x.IsCombineProduct == 1), x.BrandID,
             x.BigUnitID,x.UnitID,x.BigSmallMultiple.Value,x.CategoryID,x.Status.Value,x.AttrList,x.ValueList,x.AttrValueList,
             x.CommonPrice.Value,x.Price,x.Weight.Value,(x.IsNew==1),(x.IsRecommend==1),x.IsAllow,x.IsAutoSend,x.EffectiveDays.Value,
             x.DiscountValue.Value, x.WarnCount, x.ProductImage, x.ShapeCode, x.Description, x.CreateUserID, x.ClientID, ref result);
         if (string.IsNullOrEmpty(result))
         {
             LogBusiness.AddActionLog(CloudSalesEnum.EnumSystemType.Client,
                 CloudSalesEnum.EnumLogObjectType.Product, EnumLogType.Create, "", x.CreateUserID, "", x.ClientID);
         }
         else
         {
             mes += result+",";
         }
     });
     return string.IsNullOrEmpty(mes)  ? "" : mes;
 }
示例#5
0
 public bool UpdateAttrValueStatus(string valueid, EnumStatus status, string operateIP, string operateID)
 {
     var dal = new ProductsDAL();
     return dal.UpdateAttrValueStatus(valueid, (int)status);
 }
示例#6
0
        public List<ProductAttr> GetAttrs(string clientid)
        {
            if (ClientAttrs.ContainsKey(clientid))
            {
                return ClientAttrs[clientid];
            }

            List<ProductAttr> list = new List<ProductAttr>();
            DataSet ds = new ProductsDAL().GetAttrs(clientid);
            foreach (DataRow dr in ds.Tables["Attrs"].Rows)
            {
                ProductAttr model = new ProductAttr();
                model.FillData(dr);
                model.AttrValues = new List<AttrValue>();
                foreach (DataRow item in ds.Tables["Values"].Rows)
                {
                    AttrValue attrValue = new AttrValue();
                    attrValue.FillData(item);
                    model.AttrValues.Add(attrValue);
                }
            }
            ClientAttrs.Add(clientid, list);

            return list;
        }
示例#7
0
 public bool UpdateAttrValue(string valueID, string attrid, string valueName, string operateIP, string operateID, string clientid)
 {
     var dal = new ProductsDAL();
     var bl = dal.UpdateAttrValue(valueID, valueName);
     if (bl)
     {
         var model = GetProductAttrByID(attrid, clientid);
         var value = model.AttrValues.Where(m => m.ValueID == valueID).FirstOrDefault();
         value.ValueName = valueName;
     }
     return bl;
 }
示例#8
0
 public bool UpdateProductDetails(string detailid, string productid, string productCode, string shapeCode, decimal bigPrice, string attrlist, string valuelist, string attrvaluelist, decimal price, decimal weight, string description, string productImg, string operateid, string clientid)
 {
     lock (SingleLock)
     {
         if (!string.IsNullOrEmpty(productImg) && productImg.IndexOf(TempPath) >= 0)
         {
             if (productImg.IndexOf("?") > 0)
             {
                 productImg = productImg.Substring(0, productImg.IndexOf("?"));
             }
             FileInfo file = new FileInfo(HttpContext.Current.Server.MapPath(productImg));
             productImg = FILEPATH + file.Name;
             if (file.Exists)
             {
                 file.MoveTo(HttpContext.Current.Server.MapPath(productImg));
             }
         }
         var dal = new ProductsDAL();
         return dal.UpdateProductDetails(detailid, productid, productCode, shapeCode, bigPrice, attrlist, valuelist, attrvaluelist, price, weight, description, productImg);
     }
 }
示例#9
0
 public bool UpdateUnitStatus(string unitID, EnumStatus status, string operateIP, string operateID)
 {
     var dal = new ProductsDAL();
     return dal.UpdateUnitStatus(unitID, (int)status);
 }
示例#10
0
 public bool UpdateCategoryAttrStatus(string categoryid, string attrid, EnumStatus status, int type, string operateIP, string operateID)
 {
     var dal = new ProductsDAL();
     return dal.UpdateCategoryAttrStatus(categoryid, attrid, (int)status, type);
 }
示例#11
0
 public bool UpdateProductAttr(string attrID, string attrName, string description, string operateIP, string operateID,string clientid)
 {
     var dal = new ProductsDAL();
     var bl = dal.UpdateProductAttr(attrID, attrName, description);
     if (bl)
     {
         var model = GetProductAttrByID(attrID, clientid);
         model.AttrName = attrName;
         model.Description = description;
     }
     return bl;
 }
示例#12
0
        public List<ProductUnit> GetClientUnits(string clientid)
        {
            var dal = new ProductsDAL();
            DataTable dt = dal.GetClientUnits(clientid);

            List<ProductUnit> list = new List<ProductUnit>();
            foreach (DataRow dr in dt.Rows)
            {
                ProductUnit model = new ProductUnit();
                model.FillData(dr);
                list.Add(model);
            }
            return list;
        }
示例#13
0
        public List<Products> GetFilterProducts(string categoryid, List<FilterAttr> Attrs, int doctype, string beginprice, string endprice, string keyWords, string orderby, bool isasc, int pageSize, int pageIndex, ref int totalCount, ref int pageCount, string clientID)
        {
            var dal = new ProductsDAL();
            StringBuilder attrbuild = new StringBuilder();
            StringBuilder salebuild = new StringBuilder();
            foreach (var attr in Attrs)
            {
                if (attr.Type == EnumAttrType.Parameter)
                {
                    attrbuild.Append(" and p.ValueList like '%" + attr.ValueID + "%'");
                }
                else if (attr.Type == EnumAttrType.Specification)
                {
                    salebuild.Append(" and AttrValue like '%" + attr.ValueID + "%'");
                }
            }

            DataSet ds = dal.GetFilterProducts(categoryid, attrbuild.ToString(), salebuild.ToString(), doctype, beginprice, endprice, keyWords, orderby, isasc ? 1 : 0, pageSize, pageIndex, ref totalCount, ref pageCount, clientID);

            List<Products> list = new List<Products>();
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                Products model = new Products();
                model.FillData(dr);
                list.Add(model);
            }
            return list;
        }
示例#14
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;
        }
示例#15
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;
        }
示例#16
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;
        }
示例#17
0
        public List<Brand> GetBrandList(string clientID)
        {
            var dal = new ProductsDAL();
            DataTable dt = dal.GetBrandList(clientID);

            List<Brand> list = new List<Brand>();
            foreach (DataRow dr in dt.Rows)
            {
                Brand model = new Brand();
                model.FillData(dr);
                list.Add(model);
            }
            return list;
        }
示例#18
0
        public Brand GetBrandByBrandID(string brandID)
        {
            var dal = new ProductsDAL();
            DataTable dt = dal.GetBrandByBrandID(brandID);

            Brand model = new Brand();
            if (dt.Rows.Count > 0)
            {
                model.FillData(dt.Rows[0]);
                model.City = CommonBusiness.Citys.Where(c => c.CityCode == model.CityCode).FirstOrDefault();
            }
            return model;
        }
示例#19
0
 public bool UpdateBrand(string brandID, string name, string anotherName, string countryCode, string cityCode, string icopath, int status, string remark, string brandStyle, string operateIP, string operateID)
 {
     if (!string.IsNullOrEmpty(icopath) && icopath.IndexOf(TempPath) >= 0)
     {
         if (icopath.IndexOf("?") > 0)
         {
             icopath = icopath.Substring(0, icopath.IndexOf("?"));
         }
         FileInfo file = new FileInfo(HttpContext.Current.Server.MapPath(icopath));
         icopath = FILEPATH + file.Name;
         if (file.Exists)
         {
             file.MoveTo(HttpContext.Current.Server.MapPath(icopath));
         }
     }
     var dal = new ProductsDAL();
     return dal.UpdateBrand(brandID, name, anotherName, countryCode, cityCode, status, icopath, remark, brandStyle, operateIP, operateID);
 }
示例#20
0
        public ProductAttr GetProductAttrByID(string attrid, string clientid)
        {
            var list = GetAttrs(clientid);
            if (list.Where(m => m.AttrID == attrid).Count() > 0)
            {
                return list.Where(m => m.AttrID == attrid).FirstOrDefault();
            }
            var dal = new ProductsDAL();
            DataSet ds = dal.GetProductAttrByID(attrid);

            ProductAttr model = new ProductAttr();
            if (ds.Tables.Contains("Attrs") && ds.Tables["Attrs"].Rows.Count > 0)
            {
                model.FillData(ds.Tables["Attrs"].Rows[0]);
                model.AttrValues = new List<AttrValue>();
                foreach (DataRow item in ds.Tables["Values"].Rows)
                {
                    AttrValue attrValue = new AttrValue();
                    attrValue.FillData(item);
                    model.AttrValues.Add(attrValue);
                }
            }

            ClientAttrs[clientid].Add(model);

            return model;
        }
示例#21
0
 public bool UpdateCategory(string categoryid, string categoryName, int status, List<string> attrlist, List<string> saleattr, string description, string operateid)
 {
     var dal = new ProductsDAL();
     return dal.UpdateCategory(categoryid, categoryName, status, string.Join(",", attrlist), string.Join(",", saleattr), description, operateid);
 }
示例#22
0
        public Products GetProductByID(string productid)
        {
            var dal = new ProductsDAL();
            DataSet ds = dal.GetProductByID(productid);

            Products model = new Products();
            if (ds.Tables.Contains("Product") && ds.Tables["Product"].Rows.Count > 0)
            {
                model.FillData(ds.Tables["Product"].Rows[0]);
                model.Category = GetCategoryDetailByID(model.CategoryID);
                var bigunit = new ProductUnit();
                bigunit.FillData(ds.Tables["Unit"].Select("UnitID='" + model.BigUnitID + "'").FirstOrDefault());
                model.BigUnit = bigunit;

                var smallunit = new ProductUnit();
                smallunit.FillData(ds.Tables["Unit"].Select("UnitID='" + model.SmallUnitID + "'").FirstOrDefault());
                model.SmallUnit = smallunit;

                model.ProductDetails = new List<ProductDetail>();
                foreach (DataRow item in ds.Tables["Details"].Rows)
                {
                    //子产品
                    ProductDetail detail = new ProductDetail();
                    detail.FillData(item);

                    Dictionary<string, string> attrs = new Dictionary<string, string>();
                    foreach (string attr in detail.SaleAttrValue.Split(','))
                    {
                        if (!string.IsNullOrEmpty(attr))
                        {
                            attrs.Add(attr.Split(':')[0], attr.Split(':')[1]);
                        }
                    }
                    detail.SaleAttrValueString = "";
                    foreach (var attr in model.Category.SaleAttrs)
                    {
                        if (attrs.ContainsKey(attr.AttrID))
                        {
                            detail.SaleAttrValueString += attr.AttrName + ":" + attr.AttrValues.Where(a => a.ValueID.ToLower() == attrs[attr.AttrID].ToLower()).FirstOrDefault().ValueName + ",";
                        }
                    }

                    if (detail.SaleAttrValueString.Length > 0)
                    {
                        detail.SaleAttrValueString = detail.SaleAttrValueString.Substring(0, detail.SaleAttrValueString.Length - 1);
                    }

                    model.ProductDetails.Add(detail);
                }
            }

            return model;
        }
示例#23
0
        public bool UpdateProduct(string productid,string productCode, string productName, string generalName, bool iscombineproduct, string brandid, string bigunitid, string smallunitid, int bigSmallMultiple,
                         int status, string categoryid, string attrlist, string valuelist, string attrvaluelist, decimal commonprice, decimal price, decimal weight, bool isnew,
                         bool isRecommend, int isallow, int isautosend, int effectiveDays, decimal discountValue, string productImg, string shapeCode, string description, string operateid, string clientid)
        {
            if (!string.IsNullOrEmpty(productImg) && productImg.IndexOf(TempPath) >= 0)
            {
                if (productImg.IndexOf("?") > 0)
                {
                    productImg = productImg.Substring(0, productImg.IndexOf("?"));
                }
                FileInfo file = new FileInfo(HttpContext.Current.Server.MapPath(productImg));
                productImg = FILEPATH + file.Name;
                if (file.Exists)
                {
                    file.MoveTo(HttpContext.Current.Server.MapPath(productImg));
                }
            }

            var dal = new ProductsDAL();
            return dal.UpdateProduct(productid, productCode, productName, generalName, iscombineproduct, brandid, bigunitid, smallunitid, bigSmallMultiple, status, categoryid,attrlist,
                                    valuelist, attrvaluelist, commonprice, price, weight, isnew, isRecommend, isallow, isautosend, effectiveDays, discountValue, productImg, shapeCode, description, operateid, clientid);
        }
示例#24
0
        /// <summary>
        /// 获取属性列表(包括属性值列表)
        /// </summary>
        public List<ProductAttr> GetAttrList(string categoryid, string keyWords, int pageSize, int pageIndex, ref int totalCount, ref int pageCount, string agentid, string clientid)
        {
            var dal = new ProductsDAL();
            DataSet ds = dal.GetAttrList(categoryid, keyWords, pageSize, pageIndex, ref totalCount, ref pageCount, clientid);

            List<ProductAttr> list = new List<ProductAttr>();
            if (ds.Tables.Contains("Attrs"))
            {
                foreach (DataRow dr in ds.Tables["Attrs"].Rows)
                {
                    ProductAttr model = new ProductAttr();
                    model.FillData(dr);
                    model.CreateUser = OrganizationBusiness.GetUserByUserID(model.CreateUserID, agentid);

                    List<AttrValue> valueList = new List<AttrValue>();
                    foreach (DataRow drValue in ds.Tables["Values"].Select("AttrID='" + model.AttrID + "'"))
                    {
                        AttrValue valueModel = new AttrValue();
                        valueModel.FillData(drValue);
                        valueList.Add(valueModel);
                    }
                    model.AttrValues = valueList;

                    list.Add(model);
                }
            }
            return list;
        }
示例#25
0
 public bool UpdateProductAttrStatus(string attrid, EnumStatus status, string operateIP, string operateID)
 {
     var dal = new ProductsDAL();
     return dal.UpdateProductAttrStatus(attrid, (int)status);
 }
示例#26
0
        /// <summary>
        /// 获取产品信息(加入购物车页面)
        /// </summary>
        /// <param name="productid"></param>
        /// <returns></returns>
        public Products GetProductByIDForDetails(string productid)
        {
            var dal = new ProductsDAL();
            DataSet ds = dal.GetProductByIDForDetails(productid);

            Products model = new Products();
            if (ds.Tables.Contains("Product") && ds.Tables["Product"].Rows.Count > 0)
            {
                model.FillData(ds.Tables["Product"].Rows[0]);

                //单位
                model.BigUnit = new ProductUnit();
                model.BigUnit.FillData(ds.Tables["Unit"].Select("UnitID='" + model.BigUnitID + "'").FirstOrDefault());

                model.SmallUnit = new ProductUnit();
                model.SmallUnit.FillData(ds.Tables["Unit"].Select("UnitID='" + model.SmallUnitID + "'").FirstOrDefault());

                model.AttrLists = new List<ProductAttr>();
                model.SaleAttrs = new List<ProductAttr>();

                foreach (DataRow attrtr in ds.Tables["Attrs"].Rows)
                {
                    ProductAttr attrModel = new ProductAttr();
                    attrModel.FillData(attrtr);
                    attrModel.AttrValues = new List<AttrValue>();

                    //参数
                    if (attrModel.Type == (int)EnumAttrType.Parameter)
                    {
                        foreach (DataRow valuetr in ds.Tables["Values"].Select("AttrID='" + attrModel.AttrID + "'"))
                        {
                            AttrValue valueModel = new AttrValue();
                            valueModel.FillData(valuetr);
                            if (model.AttrValueList.IndexOf(valueModel.ValueID) >= 0)
                            {
                                attrModel.AttrValues.Add(valueModel);
                                model.AttrLists.Add(attrModel);
                                break;
                            }
                        }

                    }
                    else
                    {
                        model.SaleAttrs.Add(attrModel);
                    }
                }

                model.ProductDetails = new List<ProductDetail>();
                foreach (DataRow item in ds.Tables["Details"].Rows)
                {

                    ProductDetail detail = new ProductDetail();
                    detail.FillData(item);

                    //填充存在的规格
                    foreach (var attrModel in model.SaleAttrs)
                    {
                        foreach (DataRow valuetr in ds.Tables["Values"].Select("AttrID='" + attrModel.AttrID + "'"))
                        {
                            AttrValue valueModel = new AttrValue();
                            valueModel.FillData(valuetr);
                            if (detail.AttrValue.IndexOf(valueModel.ValueID) >= 0)
                            {
                                if (attrModel.AttrValues.Where(v => v.ValueID == valueModel.ValueID).Count() == 0)
                                {
                                    attrModel.AttrValues.Add(valueModel);
                                }
                                break;
                            }
                        }
                    }
                    model.ProductDetails.Add(detail);
                }
            }

            return model;
        }
示例#27
0
 public bool UpdateUnit(string unitID, string unitName, string desciption, string operateID)
 {
     var dal = new ProductsDAL();
     DataTable dt = dal.GetUnitByUnitID(unitID);
     string message = "单位名称“" + dt.Rows[0]["unitName"].ToString() + "”变更为“" + unitName + "”;描述“" + dt.Rows[0]["Description"].ToString() + "”变更为“" + desciption + "”";
     LogBusiness.AddOperateLog(operateID, "ProductsBusiness.UpdateUnit", EnumLogType.Update, EnumLogModules.Stock, EnumLogEntity.ProductUnit, unitID, message,"");
     return dal.UpdateUnit(unitID, unitName, desciption);
 }
示例#28
0
        public List<Products> GetProductList(string categoryid, string beginprice, string endprice, string keyWords, string orderby, bool isasc, int pageSize, int pageIndex, ref int totalCount, ref int pageCount, string clientID)
        {
            var dal = new ProductsDAL();
            DataSet ds = dal.GetProductList(categoryid, beginprice, endprice, keyWords, orderby, isasc ? 1 : 0, pageSize, pageIndex, ref totalCount, ref pageCount, clientID);

            List<Products> list = new List<Products>();
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                Products model = new Products();
                model.FillData(dr);
                list.Add(model);
            }
            return list;
        }
示例#29
0
 public string AddCategory(string categoryCode, string categoryName, string pid, int status, List<string> attrlist, List<string> saleattr, string description, string operateid, string clientid)
 {
     var dal = new ProductsDAL();
     return dal.AddCategory(categoryCode, categoryName, pid, status, string.Join(",", attrlist), string.Join(",", saleattr), description, operateid, clientid);
 }
示例#30
0
        public List<ProductAttr> GetAttrList(string categoryid, string clientid)
        {
            var dal = new ProductsDAL();
            DataTable dt = dal.GetAttrList(categoryid, clientid);

            List<ProductAttr> list = new List<ProductAttr>();
            foreach (DataRow dr in dt.Rows)
            {
                ProductAttr model = new ProductAttr();
                model.FillData(dr);
                list.Add(model);
            }
            return list;
        }