Пример #1
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);
        }
Пример #2
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);
        }
Пример #3
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);
        }
Пример #4
0
        private void Bind()
        {
            Dictionary <string, string> dicAttr = new Dictionary <string, string>();

            if (!productItemId.Equals(Guid.Empty))
            {
                ProductAttr bll   = new ProductAttr();
                var         model = bll.GetModel(productItemId);
                if (model != null)
                {
                    var li = ddlProductItem.Items.FindByValue(model.ProductItemId.ToString());
                    if (li != null)
                    {
                        li.Selected = true;
                    }

                    XElement xel = XElement.Parse(model.AttrValue);
                    var      q   = from x in xel.Descendants("Attr")
                                   select new { name = x.Element("Name").Value, value = x.Element("Value").Value };
                    foreach (var item in q)
                    {
                        dicAttr.Add(item.name, item.value);
                    }
                }
            }

            if (dicAttr.Count == 0)
            {
                dicAttr.Add("", "");
            }

            rpData.DataSource = dicAttr;
            rpData.DataBind();
        }
Пример #5
0
        /// <summary>
        /// 获取属性列表(包括属性值列表)
        /// </summary>
        /// <param name="keyWords"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <param name="totalCount"></param>
        /// <param name="pageCount"></param>
        /// <returns></returns>
        public List <ProductAttr> GetAttrList(string categoryid, string keyWords, int pageSize, int pageIndex, ref int totalCount, ref int pageCount, 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);

                    List <AttrValue> valueList = new List <AttrValue>();
                    StringBuilder    build     = new StringBuilder();
                    foreach (DataRow drValue in ds.Tables["Values"].Select("AttrID='" + model.AttrID + "'"))
                    {
                        AttrValue valueModel = new AttrValue();
                        valueModel.FillData(drValue);
                        valueList.Add(valueModel);
                        build.Append(valueModel.ValueName + ",");
                    }
                    model.AttrValues = valueList;
                    if (string.IsNullOrEmpty(build.ToString()))
                    {
                        model.ValuesStr = "暂无属性值(单击添加)";
                    }
                    else
                    {
                        if (build.ToString().Length > 50)
                        {
                            if (build.ToString().Substring(49, 1).ToString() != ",")
                            {
                                model.ValuesStr = build.ToString() + "...";
                            }
                            else
                            {
                                model.ValuesStr = build.ToString().Substring(0, 49) + " ...";
                            }
                        }
                        else
                        {
                            model.ValuesStr = build.ToString().Substring(0, build.ToString().Length - 1);
                        }
                    }
                    list.Add(model);
                }
            }
            return(list);
        }
        public static IEnumerable <ProductAttr> GetAttsByPID(Guid pid)
        {
            List <ProductAttr> attrs = new List <ProductAttr>();

            foreach (var item in Product_Att_ValService.instance().GetEnumByProductID(pid).OrderBy(m => m.Short))
            {
                ProductAttr pa = new ProductAttr();
                pa.key   = Product_Att_KeyService.instance().Single(item.Att_Key_ID);
                pa.val   = item;
                pa.price = Product_PriceService.instance().GetEnumByKVP(pid, item.Att_Key_ID, item.ID);
                attrs.Add(pa);
            }
            return(attrs);
        }
Пример #7
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);
        }
Пример #8
0
        public virtual IHttpActionResult Disable(ProductAttrDisableRequest request)
        {
            var entity = new ProductAttr
            {
                Id = request.Id,
            };
            var result = _productAttrService.Disable(request.Id);

            if (result > 0)
            {
                return(Succeed("禁用成功"));
            }
            else
            {
                return(Fail("禁用失败"));
            }
        }
Пример #9
0
        public List <ProductAttr> GetAttrList(string keyWords, int pageSize, int pageIndex, ref int totalCount, ref int pageCount)
        {
            var     dal = new ProductsDAL();
            DataSet ds  = dal.GetAttrList(keyWords, pageSize, pageIndex, ref totalCount, ref pageCount);

            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);
                    list.Add(model);
                }
            }
            return(list);
        }
Пример #10
0
        public virtual IHttpActionResult Add(ProductAttrAddRequest request)
        {
            var entity = new ProductAttr
            {
            };
            var result = _productAttrService.Add(entity);

            if (result > 0)
            {
                return(Succeed(new ProductAttrAddResponse
                {
                    Id = entity.Id
                }, "新增成功"));
            }
            else
            {
                return(Fail("新增失败"));
            }
        }
Пример #11
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);
        }
Пример #12
0
        public List <ProductAttr> GetAttrs()
        {
            if (CacheAttrs.Count > 0)
            {
                return(CacheAttrs);
            }
            DataSet ds = ProductsDAL.BaseProvider.GetAttrs();

            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"].Select(" AttrID='" + model.AttrID + "' "))
                {
                    AttrValue attrValue = new AttrValue();
                    attrValue.FillData(item);
                    model.AttrValues.Add(attrValue);
                }
                CacheAttrs.Add(model);
            }
            return(CacheAttrs);
        }
Пример #13
0
        /// <summary>
        /// 根据属性ID获取属性
        /// </summary>
        /// <param name="attrID"></param>
        /// <returns></returns>
        public ProductAttr GetProductAttrByID(string attrID)
        {
            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]);
                List <AttrValue> list = new List <AttrValue>();
                foreach (DataRow item in ds.Tables["Values"].Rows)
                {
                    AttrValue attrValue = new AttrValue();
                    attrValue.FillData(item);
                    list.Add(attrValue);
                }
                model.AttrValues = list;
            }


            return(model);
        }
Пример #14
0
        public List <Category> GetCategorys()
        {
            if (CacheCategory.Count() > 0)
            {
                return(CacheCategory);
            }

            DataSet ds = ProductsDAL.BaseProvider.GetCategorys();

            foreach (DataRow dr in ds.Tables["Category"].Rows)
            {
                Category model = new Category();
                model.FillData(dr);
                model.ChildCategory = new List <Category>();
                model.AttrLists     = new List <ProductAttr>();
                model.SaleAttrs     = new List <ProductAttr>();
                foreach (DataRow item in ds.Tables["Attr"].Select(" CategoryID='" + model.CategoryID + "' "))
                {
                    ProductAttr attr = new ProductAttr();
                    attr.FillData(item);
                    if (attr.Type == 1)
                    {
                        model.AttrLists.Add(GetAttrByID(attr.AttrID));
                    }
                    else
                    {
                        model.SaleAttrs.Add(GetAttrByID(attr.AttrID));
                    }
                }
                CacheCategory.Add(model);
            }
            foreach (var model in CacheCategory)
            {
                model.ChildCategory = CacheCategory.Where(m => m.PID == model.CategoryID).ToList();
            }
            return(CacheCategory);
        }
Пример #15
0
        public Category GetCategoryByID(string categoryid)
        {
            var cacheList = GetCategorys();

            if (cacheList.Where(m => m.CategoryID.ToLower() == categoryid.ToLower()).Count() > 0)
            {
                return(cacheList.Where(m => m.CategoryID.ToLower() == categoryid.ToLower()).FirstOrDefault());
            }

            DataSet ds = ProductsDAL.BaseProvider.GetCategoryByID(categoryid);

            Category model = new Category();

            if (ds.Tables[0].Rows.Count > 0)
            {
                model.FillData(ds.Tables[0].Rows[0]);
                model.ChildCategory = new List <Category>();
                model.AttrLists     = new List <ProductAttr>();
                model.SaleAttrs     = new List <ProductAttr>();
                foreach (DataRow item in ds.Tables["Attr"].Rows)
                {
                    ProductAttr attr = new ProductAttr();
                    attr.FillData(item);
                    if (attr.Type == 1)
                    {
                        model.AttrLists.Add(GetAttrByID(attr.AttrID));
                    }
                    else
                    {
                        model.SaleAttrs.Add(GetAttrByID(attr.AttrID));
                    }
                }
                CacheCategory.Add(model);
            }

            return(model);
        }
Пример #16
0
        /// <summary>
        /// 保存属性
        /// </summary>
        /// <param name="attr"></param>
        /// <returns></returns>
        public JsonResult SaveAttr(string attr)
        {
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            ProductAttr          model      = serializer.Deserialize <ProductAttr>(attr);

            string attrID = string.Empty;

            if (string.IsNullOrEmpty(model.AttrID))
            {
                attrID = new ProductsBusiness().AddProductAttr(model.AttrName, model.Description, model.CategoryID, model.Type, CurrentUser.UserID, CurrentUser.ClientID);
            }
            else if (new ProductsBusiness().UpdateProductAttr(model.AttrID, model.AttrName, model.Description, OperateIP, CurrentUser.UserID, CurrentUser.ClientID))
            {
                attrID = model.AttrID.ToString();
            }


            JsonDictionary.Add("ID", attrID);
            return(new JsonResult
            {
                Data = JsonDictionary,
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
Пример #17
0
        public Products GetProductByIDForDetails(string productid, string clientid)
        {
            var     dal = new ProductsDAL();
            DataSet ds  = dal.GetProductByIDForDetails(productid, clientid);

            Products model = new Products();

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

                model.SmallUnit = GetUnitByID(model.UnitID);

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

                model.Providers = new ProvidersEntity();
                if (!string.IsNullOrEmpty(model.ProviderID))
                {
                    model.Providers.FillData(ds.Tables["Providers"].Rows[0]);
                    if (!string.IsNullOrEmpty(model.Providers.CityCode))
                    {
                        var city = CommonBusiness.GetCityByCode(model.Providers.CityCode);
                        model.Providers.Address = city.Description + model.Providers.Address;
                    }
                }

                if (!string.IsNullOrEmpty(model.CategoryID))
                {
                    var category = GetCategoryByID(model.CategoryID);
                    foreach (var attr in category.AttrLists)
                    {
                        ProductAttr attrModel = new ProductAttr();
                        attrModel.AttrName   = attr.AttrName;
                        attrModel.AttrValues = new List <AttrValue>();
                        foreach (var value in attr.AttrValues)
                        {
                            if (model.AttrValueList.IndexOf(value.ValueID) >= 0)
                            {
                                attrModel.AttrValues.Add(value);
                                model.AttrLists.Add(attrModel);
                                break;
                            }
                        }
                    }
                    model.SaleAttrs = category.SaleAttrs;
                }

                model.ProductDetails = new List <ProductDetail>();
                foreach (DataRow item in ds.Tables["Details"].Rows)
                {
                    ProductDetail detail = new ProductDetail();
                    detail.FillData(item);
                    detail.DetailStocks = new List <ProductStock>();
                    foreach (var stocktr in ds.Tables["Stocks"].Select("ProductDetailID='" + detail.ProductDetailID + "'"))
                    {
                        ProductStock stock = new ProductStock();
                        stock.FillData(stocktr);
                        detail.DetailStocks.Add(stock);
                    }
                    model.ProductDetails.Add(detail);
                }
            }

            return(model);
        }
Пример #18
0
 public bool AddProductAttr(ProductAttr attr)
 {
     return(dal.AddProductAttr(attr));
 }
Пример #19
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);
        }
Пример #20
0
 public bool AddProductAttr(ProductAttr attr)
 {
     throw new NotImplementedException();
 }
Пример #21
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ShopId = Request.QueryString["pid"].TryParseToInt32(0);

            if (Page.IsPostBack)
            {
                return;
            }

            var unity = new UnityContext();
            var svr   = unity.GetInstance <IAttributeService>();

            attributes = svr.GetList(new Model.Attribute.Query {
                Status = 1
            });


            if ("GET".Equals(Request.RequestType))
            {
            }
            else if ("POST".Equals(Request.RequestType))
            {
                var productService = unity.GetInstance <IProductService>();

                var shop = new ProductFrontend();

                shop.Type = Request.Form["type"].TryParseToInt32();
                //shop.Status = Request.Form["status"].TryParseToInt32();
                shop.Name        = Request.Form["spTitle"].TryParseToString();
                shop.Brief       = Request.Form["spBrief"].TryParseToString();
                shop.Url         = Request.Form["spUrl"].TryParseToString();
                shop.Subname     = Request.Form["spAdmin"].TryParseToString();
                shop.Start_Time  = Request.Form["shopHours"].TryParseToInt32(0);
                shop.Price       = Request.Form["shopsPrice"].TryParseToDecimal();
                shop.Category_Id = Request.Form["category_id"].TryParseToInt32(0);
                shop.Area        = Request.Form["area"].TryParseToString();

                var attrs = Request.Form.GetValues("attr[]");



                var productAttrs = new List <ProductAttr>();



                //处理Input=1
                foreach (var attr in attrs)
                {
                    var strAry = attr.Split('_');

                    if (strAry.Count() != 3)
                    {
                        continue;
                    }

                    var productAttr = new ProductAttr();
                    productAttr.Attr_Pid   = ShopId;
                    productAttr.Attr_Value = strAry[2];
                    productAttr.Attr_Id    = strAry[1].TryParseToInt32();
                    productAttr.Input      = strAry[0].TryParseToInt32();

                    productAttrs.Add(productAttr);
                }

                //处理Input=2,3
                foreach (var attr in attributes.Where(d => d.Pid == ShopId).ToList())
                {
                    if (attr.Input == 2 || attr.Input == 3)
                    {
                        var attrValues = Request.Form.GetValues(string.Format("input[{0}][{1}][]", attr.Input, attr.Id));

                        if (attrValues != null)
                        {
                            foreach (var attrVal in attrValues)
                            {
                                var productAttr = new ProductAttr();
                                productAttr.Attr_Pid   = ShopId;
                                productAttr.Attr_Value = attrVal;
                                productAttr.Attr_Id    = attr.Id;
                                productAttr.Input      = attr.Input;

                                productAttrs.Add(productAttr);
                            }
                        }
                    }
                }

                //shop = Request.Form["input"];
                // shop. = Request.Form["attr_id"];
                shop.Address_Id = Request.Form["address_id"].TryParseToInt32(0);

                var user = new UserConsignee();
                user.User_Id       = LoggedUser.Id;
                user.Consignee     = Request.Form["utruename"] ?? "";
                user.Mobile        = Request.Form["umobile"] ?? "";
                user.Phone         = Request.Form["utel"] ?? "";
                user.Qq            = Request.Form["uqq"] ?? "";
                user.Address       = "";
                user.Zip           = "";
                user.Email         = "";
                user.Fax           = "";
                user.Is_Def        = 1;
                user.Region_Values = "";

                shop.Content          = "";
                shop.Filename         = "";
                shop.Video            = "";
                shop.Buyer_Protection = "";
                shop.Mobile           = LoggedUser.Mobile;


                shop.UserConsignee = user;
                shop.Attrs         = productAttrs;

                shop.Admin_Id    = 1;
                shop.Guanlian_Id = 1;
                shop.Seller_Id   = LoggedUser.Id;

                productService.Add(shop);
                ViewState["Message"] = "发布网店成功";
            }
        }