Exemplo n.º 1
0
        public IList <ProductTypeInfo> GetProductTypesList()
        {
            using (MyContext db = new MyContext())
            {
                var items = db.ProductType.ToList();
                IList <ProductTypeInfo> ProductTypeInfos = new List <ProductTypeInfo>();
                foreach (var item in items)
                {
                    ProductTypeInfo info = new ProductTypeInfo();
                    info.ID = item.ID;
                    info.ProductTypeName = item.ProductTypeName;
                    info.Description     = item.Description;

                    ProductTypeInfos.Add(info);
                }

                return(ProductTypeInfos);
            }
        }
Exemplo n.º 2
0
        public void CreateProductTypeTest()
        {
            Random rand         = new Random();
            String createString = "Super deep v turtle neck " + rand.Next(1000);

            List <string> errors         = new List <string>(); // TODO: Initialize to an appropriate value
            List <string> errorsExpected = new List <string>(); // TODO: Initialize to an appropriate value
            int           result         = BLProductType.CreateProductType(createString, ref errors);

            Assert.AreNotEqual(result, -1);
            AsynchLog.LogNow(errors);

            ProductTypeInfo ProductType = BLProductType.ReadProductType(result, ref errors);

            AsynchLog.LogNow(errors);

            Assert.AreEqual(ProductType.product_type_id, result);
            Assert.AreEqual(ProductType.product_type_name, createString);
        }
Exemplo n.º 3
0
        public static int AddProductType(ProductTypeInfo productType)
        {
            if (productType == null)
            {
                return(0);
            }
            Globals.EntityCoding(productType, true);
            int typeId = new ProductTypeDao().AddProductType(productType);

            if (typeId > 0)
            {
                if (productType.Brands.Count > 0)
                {
                    new ProductTypeDao().AddProductTypeBrands(typeId, productType.Brands);
                }
                EventLogs.WriteOperationLog(Privilege.AddProductType, string.Format(CultureInfo.InvariantCulture, "创建了一个新的商品类型:”{0}”", new object[] { productType.TypeName }));
            }
            return(typeId);
        }
Exemplo n.º 4
0
        public int AddProductType(ProductTypeInfo productType)
        {
            DbCommand sqlStringCommand = this.database.GetSqlStringCommand("INSERT INTO Ecshop_ProductTypes(TypeName, Remark) VALUES (@TypeName, @Remark); SELECT @@IDENTITY");

            this.database.AddInParameter(sqlStringCommand, "TypeName", DbType.String, productType.TypeName);
            this.database.AddInParameter(sqlStringCommand, "Remark", DbType.String, productType.Remark);
            object obj = this.database.ExecuteScalar(sqlStringCommand);
            int    result;

            if (obj != null)
            {
                result = Convert.ToInt32(obj);
            }
            else
            {
                result = 0;
            }
            return(result);
        }
Exemplo n.º 5
0
        public static bool UpdateProductType(ProductTypeInfo productType)
        {
            if (productType == null)
            {
                return(false);
            }
            Globals.EntityCoding(productType, true);
            bool flag = new ProductTypeDao().UpdateProductType(productType);

            if (flag)
            {
                if (new ProductTypeDao().DeleteProductTypeBrands(productType.TypeId))
                {
                    new ProductTypeDao().AddProductTypeBrands(productType.TypeId, productType.Brands);
                }
                EventLogs.WriteOperationLog(Privilege.EditProductType, string.Format(CultureInfo.InvariantCulture, "修改了编号为”{0}”的商品类型", new object[] { productType.TypeId }));
            }
            return(flag);
        }
Exemplo n.º 6
0
    //修改产品类型
    public void EditProductType()
    {
        int    ProductType_ID       = tools.CheckInt(Request.Form["ProductType_ID"]);
        string ProductType_Name     = tools.CheckStr(Request.Form["ProductType_Name"]);
        int    ProductType_Sort     = tools.CheckInt(Request.Form["ProductType_Sort"]);
        int    ProductType_IsActive = tools.CheckInt(Request.Form["ProductType_IsActive"]);
        string ProductType_Site     = Public.GetCurrentSite();
        string brand_select         = tools.CheckStr(Request.Form["ProductType_Brand"]) + ",";

        string[] Product_Brand = brand_select.Split(',');

        if (ProductType_Name == "")
        {
            Public.Msg("error", "错误信息", "请填写类型名称!", false, "{back}");
        }

        ProductTypeInfo entity = new ProductTypeInfo();

        entity.ProductType_ID       = ProductType_ID;
        entity.ProductType_Name     = ProductType_Name;
        entity.ProductType_Sort     = ProductType_Sort;
        entity.ProductType_IsActive = ProductType_IsActive;
        entity.ProductType_Site     = ProductType_Site;


        if (MyProductType.EditProductType(entity, Public.GetUserPrivilege()))
        {
            MyProductType.DelProductType_Brand(entity.ProductType_ID, Public.GetUserPrivilege());
            foreach (string i in Product_Brand)
            {
                if (tools.CheckInt(i) > 0)
                {
                    MyProductType.AddProductType_Brand(entity.ProductType_ID, tools.CheckInt(i), Public.GetUserPrivilege());
                }
            }
            Public.Msg("positive", "操作成功", "操作成功", true, "ProductType.aspx");
        }
        else
        {
            Public.Msg("error", "错误信息", "操作失败,请稍后重试", false, "{back}");
        }
    }
Exemplo n.º 7
0
        public virtual ProductTypeInfo GetProductTypeByID(int ID)
        {
            ProductTypeInfo entity  = null;
            SqlDataReader   RdrList = null;

            try
            {
                string SqlList;
                SqlList = "SELECT * FROM ProductType WHERE ProductType_ID = " + ID;
                RdrList = DBHelper.ExecuteReader(SqlList);
                if (RdrList.Read())
                {
                    entity = new ProductTypeInfo();

                    entity.ProductType_ID       = Tools.NullInt(RdrList["ProductType_ID"]);
                    entity.ProductType_Name     = Tools.NullStr(RdrList["ProductType_Name"]);
                    entity.ProductType_Sort     = Tools.NullInt(RdrList["ProductType_Sort"]);
                    entity.ProductType_IsActive = Tools.NullInt(RdrList["ProductType_IsActive"]);
                    entity.ProductType_Site     = Tools.NullStr(RdrList["ProductType_Site"]);
                }
                RdrList.Close();
                RdrList = null;
                if (entity != null)
                {
                    entity.BrandInfos             = GetProductBrands(entity.ProductType_ID);
                    entity.ProductTypeExtendInfos = MyProductTypeExtend.GetProductTypeExtends(entity.ProductType_ID);
                }
                return(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (RdrList != null)
                {
                    RdrList.Close();
                    RdrList = null;
                }
            }
        }
Exemplo n.º 8
0
        public void CreateTypeMethodTest()
        {
            var type = new ProductTypeInfo
            {
                IsSupportColor         = true,
                IsSupportSize          = true,
                IsSupportVersion       = false,
                Name                   = "鞋子",
                SpecificationValueInfo = new List <SpecificationValueInfo> {
                    new SpecificationValueInfo {
                        Specification = SpecificationType.Color, Value = "红色,蓝色"
                    },
                    new SpecificationValueInfo {
                        Specification = SpecificationType.Size, Value = "S,M,XX"
                    }
                },
                AttributeInfo = new List <AttributeInfo> {
                    new AttributeInfo {
                        Name = "a", IsMulti = true, DisplaySequence = 1, AttributeValueInfo = new List <AttributeValueInfo>
                        {
                            new AttributeValueInfo {
                                Value = "aa", DisplaySequence = 1
                            },
                            new AttributeValueInfo {
                                Value = "aaa", DisplaySequence = 1
                            },
                        }
                    }
                },
                TypeBrandInfo = new List <TypeBrandInfo>
                {
                    new TypeBrandInfo {
                        BrandId = 1
                    },
                    new TypeBrandInfo {
                        BrandId = 11
                    }
                }
            };

            ServiceProvider.Instance <ITypeService> .Create.AddType(type);
        }
Exemplo n.º 9
0
        public void UpdateType(ProductTypeInfo model)
        {
            //更新品牌
            ProcessingBrand(model);

            //更新的属性、属性值
            ProcessingAttr(model);

            //更新规格
            ProcessingSpecificationValues(model);

            //更新常用属性
            ProcessingCommon(model);

            //提交保存
            Context.SaveChanges();

            Cache.Remove(CacheKeyCollection.CACHE_ATTRIBUTE_LIST);
            Cache.Remove(CacheKeyCollection.CACHE_ATTRIBUTEVALUE_LIST);
        }
Exemplo n.º 10
0
        private void ProcessingSpecificationValues(ProductTypeInfo model)
        {
            if (model.IsSupportColor)
            {
                this.UpdateSpecificationValues(model, SpecificationType.Color);
            }
            if (model.IsSupportSize)
            {
                this.UpdateSpecificationValues(model, SpecificationType.Size);
            }
            if (model.IsSupportVersion)
            {
                this.UpdateSpecificationValues(model, SpecificationType.Version);
            }
            ProductTypeInfo isSupportVersion = this.context.ProductTypeInfo.FindById <ProductTypeInfo>(model.Id);

            isSupportVersion.IsSupportVersion = model.IsSupportVersion;
            isSupportVersion.IsSupportColor   = model.IsSupportColor;
            isSupportVersion.IsSupportSize    = model.IsSupportSize;
        }
Exemplo n.º 11
0
        public override IList <ProductTypeInfo> GetProductTypes()
        {
            IList <ProductTypeInfo> list = new List <ProductTypeInfo>();
            DbCommand sqlStringCommand   = this.database.GetSqlStringCommand("SELECT * FROM Hishop_ProductTypes");

            using (IDataReader reader = this.database.ExecuteReader(sqlStringCommand))
            {
                while (reader.Read())
                {
                    ProductTypeInfo item = new ProductTypeInfo
                    {
                        TypeId   = (int)reader["TypeId"],
                        TypeName = (string)reader["TypeName"],
                        Remark   = (string)reader["Remark"]
                    };
                    list.Add(item);
                }
            }
            return(list);
        }
Exemplo n.º 12
0
        private static MvcHtmlString GenerateSize(ProductTypeInfo model)
        {
            StringBuilder htmlTag = new StringBuilder();
            //string input = "<label class=\"label-custom\"><input class=\"specCheckbox\" type=\"checkbox\" value=\"{0}\" {1} name=\"IsSupportSize\" />尺寸</label>";
            string input = "<label class=\"label-custom\"><input class=\"specCheckbox\" type=\"checkbox\" value=\"{0}\" {1} name=\"IsSupportSize\" /><input type=\"text\" class=\"form-control input-sm\" name=\"SizeAlias\" value=\"{2}\"  maxlength=\"10\" {3} /></label>";
            //string input = "<label class=\"label-custom\"><input class=\"specCheckbox\" type=\"checkbox\" value=\"{0}\" {1} name=\"IsSupportSize\" /><textarea class=\"input-sm\"  name=\"SizeAlias\" rows=\"1\">{2}</textarea></label>";
            string text = "<textarea class=\"form-control input-sm\" {0} name=\"SizeValue\" rows=\"2\">{1}</textarea>";

            if (model.IsSupportSize)
            {
                htmlTag.Append(string.Format(input, true, "checked", string.IsNullOrEmpty(model.SizeAlias) ? "尺寸" : model.SizeAlias, ""));
                htmlTag.Append(string.Format(text, "", model.SizeValue));
            }
            else
            {
                htmlTag.Append(string.Format(input, false, "", string.IsNullOrEmpty(model.SizeAlias) ? "尺寸" : model.SizeAlias, "disabled"));
                htmlTag.Append(string.Format(text, "disabled", model.SizeValue));
            }
            return(new MvcHtmlString(htmlTag.ToString()));
        }
        /// <summary>
        /// 根据提货码取订单
        /// </summary>
        /// <param name="pickcode"></param>
        /// <returns></returns>
        public object GetShopBranchOrder(string pickcode)
        {
            CheckUserLogin();
            var order = Application.OrderApplication.GetOrderByPickCode(pickcode);

            if (order == null)
            {
                return(Json(new { success = false, msg = "该提货码无效" }));
            }
            if (order.ShopBranchId.Value != CurrentShopBranch.Id)
            {
                return(Json(new { success = false, msg = "非本门店提货码,请买家核对提货信息" }));
            }
            if (order.OrderStatus == Himall.Model.OrderInfo.OrderOperateStatus.Finish && order.DeliveryType == CommonModel.Enum.DeliveryType.SelfTake)
            {
                return(Json(new { success = false, msg = "该提货码于" + order.FinishDate.ToString() + "已核销" }));
            }

            var orderItem = Application.OrderApplication.GetOrderItemsByOrderId(order.Id);

            foreach (var item in orderItem)
            {
                item.ThumbnailsUrl = Core.HimallIO.GetRomoteProductSizeImage(item.ThumbnailsUrl, 1, (int)Himall.CommonModel.ImageSize.Size_100);
                ProductTypeInfo typeInfo = ServiceProvider.Instance <ITypeService> .Create.GetTypeByProductId(item.ProductId);

                item.ColorAlias   = (typeInfo == null || string.IsNullOrEmpty(typeInfo.ColorAlias)) ? SpecificationType.Color.ToDescription() : typeInfo.ColorAlias;
                item.SizeAlias    = (typeInfo == null || string.IsNullOrEmpty(typeInfo.SizeAlias)) ? SpecificationType.Size.ToDescription() : typeInfo.SizeAlias;
                item.VersionAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.VersionAlias)) ? SpecificationType.Version.ToDescription() : typeInfo.VersionAlias;
            }
            //退款状态
            var refundobjs = OrderApplication.GetOrderRefunds(orderItem.Select(e => e.Id));
            //小于4表示商家未确认;与平台未审核,都算退款、退货中
            var refundProcessing = refundobjs.Where(e => (int)e.SellerAuditStatus < 4 || e.ManagerConfirmStatus == OrderRefundInfo.OrderRefundConfirmStatus.UnConfirm);

            if (refundProcessing.Count() > 0)
            {
                order.RefundStats = 1;
            }

            return(Json(new { success = true, order = order, orderItem = orderItem }));
        }
Exemplo n.º 14
0
        private void UpdateSpecificationValues(ProductTypeInfo model, SpecificationType specEnum)
        {
            var newSpec = model.SpecificationValueInfo.Where(s => s.Specification == specEnum);
            var actual  = Context.SpecificationValueInfo
                          .Where(s => s.TypeId.Equals(model.Id) && s.Specification == specEnum).AsEnumerable();

            var deleteSpec = actual.Except(newSpec, new SpecValueComparer());

            foreach (var specV in deleteSpec.ToList())
            {
                Context.SpecificationValueInfo.Remove(specV);
            }


            var addSpec = newSpec.Except(actual, new SpecValueComparer());

            foreach (var specV in addSpec.ToList())
            {
                Context.SpecificationValueInfo.Add(specV);
            }
        }
Exemplo n.º 15
0
        public static List <ProductTypeInfo> ReadProductTypeList(ref List <string> errors)
        {
            SqlConnection          conn            = new SqlConnection(connection_string);
            ProductTypeInfo        ProductType     = null;
            List <ProductTypeInfo> ProductTypeList = new List <ProductTypeInfo>();

            try
            {
                string strSQL = "read_all_product_type";

                SqlDataAdapter mySA = new SqlDataAdapter(strSQL, conn);
                mySA.SelectCommand.CommandType = CommandType.StoredProcedure;

                DataSet myDS = new DataSet();
                mySA.Fill(myDS);

                if (myDS.Tables[0].Rows.Count == 0)
                {
                    return(null);
                }

                for (int i = 0; i < myDS.Tables[0].Rows.Count; i++)
                {
                    ProductType = new ProductTypeInfo(int.Parse(myDS.Tables[0].Rows[i]["product_type_id"].ToString()),
                                                      myDS.Tables[0].Rows[i]["product_type_name"].ToString());
                    ProductTypeList.Add(ProductType);
                }
            }
            catch (Exception e)
            {
                errors.Add("Error: " + e.ToString());
            }
            finally
            {
                conn.Dispose();
                conn = null;
            }

            return(ProductTypeList);
        }
Exemplo n.º 16
0
        private void btnEditProductType_Click(object sender, EventArgs e)
        {
            ProductTypeInfo productType = new ProductTypeInfo();

            productType.TypeId   = typeId;
            productType.TypeName = txtTypeName.Text;
            productType.Remark   = txtRemark.Text;
            IList <int> list = new List <int>();

            foreach (ListItem item in chlistBrand.Items)
            {
                if (item.Selected)
                {
                    list.Add(int.Parse(item.Value));
                }
            }
            productType.Brands = list;
            if (ValidationProductType(productType) && ProductTypeHelper.UpdateProductType(productType))
            {
                ShowMsg("修改成功", true);
            }
        }
Exemplo n.º 17
0
        private void btnAddProductType_Click(object sender, EventArgs e)
        {
            ProductTypeInfo productTypeInfo = new ProductTypeInfo();

            productTypeInfo.TypeName = Globals.StripHtmlXmlTags(Globals.StripScriptTags(this.txtTypeName.Text).Replace(",", ",").Replace("\\", ""));
            if (string.IsNullOrEmpty(productTypeInfo.TypeName))
            {
                this.ShowMsg("类型名称不能为空,不允许包含脚本标签、HTML标签和\\,系统会自动过滤", false);
            }
            else if (ProductTypeHelper.HasSameProductTypeName(productTypeInfo.TypeName, 0))
            {
                this.ShowMsg("不能有重复的类型名称", false);
            }
            else
            {
                productTypeInfo.Remark = this.txtRemark.Text;
                IList <int> list = new List <int>();
                foreach (ListItem item in this.chlistBrand.Items)
                {
                    if (item.Selected)
                    {
                        list.Add(int.Parse(item.Value));
                    }
                }
                productTypeInfo.Brands = list;
                if (this.ValidationProductType(productTypeInfo))
                {
                    int num = ProductTypeHelper.AddProductType(productTypeInfo);
                    if (num > 0)
                    {
                        base.Response.Redirect(Globals.GetAdminAbsolutePath("/product/AddAttribute.aspx?typeId=" + num), true);
                    }
                    else
                    {
                        this.ShowMsg("添加商品类型失败", false);
                    }
                }
            }
        }
Exemplo n.º 18
0
        private void ProcessingAttrUpdate(ProductTypeInfo model)
        {
            ProductTypeInfo productTypeInfo = context.ProductTypeInfo.FindById <ProductTypeInfo>(model.Id);

            foreach (AttributeInfo list in model.AttributeInfo.ToList())
            {
                if (!productTypeInfo.AttributeInfo.Any((AttributeInfo a) => {
                    if (!a.Id.Equals(list.Id))
                    {
                        return(false);
                    }
                    return(list.Id != 0);
                }))
                {
                    continue;
                }
                AttributeInfo name = productTypeInfo.AttributeInfo.FirstOrDefault((AttributeInfo a) => a.Id.Equals(list.Id));
                name.Name    = list.Name;
                name.IsMulti = list.IsMulti;
                IEnumerable <AttributeValueInfo> attributeValueInfos = name.AttributeValueInfo.Except <AttributeValueInfo>(list.AttributeValueInfo, new AttrValueComparer());
                if (attributeValueInfos != null && 0 < attributeValueInfos.Count())
                {
                    foreach (AttributeValueInfo attributeValueInfo in attributeValueInfos.ToList())
                    {
                        context.AttributeValueInfo.Remove(attributeValueInfo);
                    }
                }
                IEnumerable <AttributeValueInfo> attributeValueInfos1 = list.AttributeValueInfo.Except <AttributeValueInfo>(name.AttributeValueInfo, new AttrValueComparer());
                if (attributeValueInfos1 == null || 0 >= attributeValueInfos1.Count())
                {
                    continue;
                }
                foreach (AttributeValueInfo id in attributeValueInfos1.ToList())
                {
                    id.AttributeId = list.Id;
                    context.AttributeValueInfo.Add(id);
                }
            }
        }
Exemplo n.º 19
0
        public static ProductTypeInfo ReadProductTypeDetail(int product_type_id, ref List <string> errors)
        {
            SqlConnection   conn        = new SqlConnection(connection_string);
            ProductTypeInfo ProductType = null;

            try
            {
                string strSQL = "read_product_type";

                SqlDataAdapter mySA = new SqlDataAdapter(strSQL, conn);
                mySA.SelectCommand.CommandType = CommandType.StoredProcedure;
                mySA.SelectCommand.Parameters.Add(new SqlParameter("@product_type_id", SqlDbType.Int));

                mySA.SelectCommand.Parameters["@product_type_id"].Value = product_type_id;

                DataSet myDS = new DataSet();
                mySA.Fill(myDS);

                if (myDS.Tables[0].Rows.Count == 0)
                {
                    return(null);
                }

                ProductType = new ProductTypeInfo(int.Parse(myDS.Tables[0].Rows[0]["product_type_id"].ToString()),
                                                  myDS.Tables[0].Rows[0]["product_type_name"].ToString());
            }
            catch (Exception e)
            {
                errors.Add("Error: " + e.ToString());
            }
            finally
            {
                conn.Dispose();
                conn = null;
            }

            return(ProductType);
        }
Exemplo n.º 20
0
        private void btnEditProductType_Click(object sender, System.EventArgs e)
        {
            ProductTypeInfo productType = new ProductTypeInfo
            {
                TypeId   = this.typeId,
                TypeName = this.txtTypeName.Text,
                Remark   = this.txtRemark.Text
            };

            System.Collections.Generic.IList <int> list = new System.Collections.Generic.List <int>();
            foreach (System.Web.UI.WebControls.ListItem item in this.chlistBrand.Items)
            {
                if (item.Selected)
                {
                    list.Add(int.Parse(item.Value));
                }
            }
            productType.Brands = list;
            if (this.ValidationProductType(productType) && ProductTypeHelper.UpdateProductType(productType))
            {
                this.ShowMsg("修改成功", true);
            }
        }
Exemplo n.º 21
0
        private void UpdateSpecificationValues(ProductTypeInfo model, SpecificationType specEnum)
        {
            IEnumerable <SpecificationValueInfo> specificationValueInfo =
                from s in model.SpecificationValueInfo
                where s.Specification == specEnum
                select s;
            IEnumerable <SpecificationValueInfo> specificationValueInfos = (
                from s in context.SpecificationValueInfo
                where s.TypeId.Equals(model.Id) && (int)s.Specification == (int)specEnum
                select s).AsEnumerable <SpecificationValueInfo>();
            IEnumerable <SpecificationValueInfo> specificationValueInfos1 = specificationValueInfos.Except <SpecificationValueInfo>(specificationValueInfo, new SpecValueComparer());

            foreach (SpecificationValueInfo list in specificationValueInfos1.ToList())
            {
                context.SpecificationValueInfo.Remove(list);
            }
            IEnumerable <SpecificationValueInfo> specificationValueInfos2 = specificationValueInfo.Except <SpecificationValueInfo>(specificationValueInfos, new SpecValueComparer());

            foreach (SpecificationValueInfo list1 in specificationValueInfos2.ToList())
            {
                context.SpecificationValueInfo.Add(list1);
            }
        }
Exemplo n.º 22
0
 protected void btnAdd_Click(object sender, EventArgs e)
 {
     if (isPValid())
     {
         try
         {
             int             OpId    = Convert.ToInt32(Request["OfferPriceId"].ToString());
             ProductTypeInfo product = new ProductTypeInfo();
             product.OfferPriceId = OpId;
             product.ProductName  = txtName.Text.ToString();
             product.Model        = txtModel.Text.ToString();
             product.Num          = txtNum.Text.ToString();
             product.Price        = txtPrice.Text.ToString();
             product.Unit         = ddlPUnit.SelectedItem.Text;
             float fNum   = float.Parse(txtNum.Text.ToString());
             float fPrice = float.Parse(txtPrice.Text.ToString());
             float fSum   = fNum * fPrice;
             product.Sums = fSum.ToString();
             product.Save();
             gvProductBind();
             string str = OfferPriceInfo.GetProductMoneySum(OpId);
             if (str == "")
             {
                 lblMoneySum.Text = "0元";
             }
             else
             {
                 lblMoneySum.Text = OfferPriceInfo.GetProductMoneySum(OpId) + "元";
             }
             Clear();
         }
         catch (Exception Ex)
         {
             ClientScript.RegisterStartupScript(this.GetType(), "Save", "alert('新增失败:" + Ex.Message + "');", true);
         }
     }
 }
Exemplo n.º 23
0
        public IList <ProductTypeInfo> GetProductTypesList(int pageIndex, int pageSize, out int Total)
        {
            using (MyContext db = new MyContext())
            {
                Total = (from c in db.ProductType
                         orderby c.ID
                         select c).Count();
                var items = (from c in db.ProductType
                             orderby c.ID
                             select c).Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList();
                IList <ProductTypeInfo> ProductTypeInfos = new List <ProductTypeInfo>();
                foreach (var item in items)
                {
                    ProductTypeInfo info = new ProductTypeInfo();
                    info.ID = item.ID;
                    info.ProductTypeName = item.ProductTypeName;
                    info.Description     = item.Description;

                    ProductTypeInfos.Add(info);
                }

                return(ProductTypeInfos);
            }
        }
Exemplo n.º 24
0
        public static int AddProductType(ProductTypeInfo productType)
        {
            if (productType == null)
            {
                return(0);
            }
            ProductTypeDao productTypeDao = new ProductTypeDao();

            Globals.EntityCoding(productType, true);
            int num = (int)productTypeDao.Add(productType, null);

            if (num > 0)
            {
                if (productType.Brands.Count > 0)
                {
                    productTypeDao.AddProductTypeBrands(num, productType.Brands);
                }
                EventLogs.WriteOperationLog(Privilege.AddProductType, string.Format(CultureInfo.InvariantCulture, "创建了一个新的商品类型:”{0}”", new object[1]
                {
                    productType.TypeName
                }), false);
            }
            return(num);
        }
Exemplo n.º 25
0
        /// <summary>
        /// 根据选择分类获取对应的品牌列表
        /// </summary>
        protected void GetBrandList()
        {
            int                     classId          = RequestHelper.GetQueryString <int>("classId");
            string                  brandname        = RequestHelper.GetQueryString <string>("brandname");
            int                     proTypeID        = ProductClassBLL.GetProductClassType(classId);
            ProductTypeInfo         aci              = ProductTypeBLL.Read(proTypeID);
            List <ProductBrandInfo> productBrandList = new List <ProductBrandInfo>();

            if (aci.Id > 0)
            {
                string[] strArray = aci.BrandIds.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                int[]    intArray;

                intArray         = Array.ConvertAll <string, int>(strArray, s => int.Parse(s));
                productBrandList = ProductBrandBLL.ReadList(intArray);
                if (!string.IsNullOrEmpty(brandname))
                {
                    productBrandList = productBrandList.Where(k => k.Name.ToLower().Contains(brandname.ToLower())).ToList();
                }
            }
            Response.Clear();
            ResponseHelper.Write(Newtonsoft.Json.JsonConvert.SerializeObject(new { count = productBrandList.Count, dataList = productBrandList }));
            Response.End();
        }
Exemplo n.º 26
0
        private void ProcessingAttrDeleteAndAdd(ProductTypeInfo model)
        {
            ProductTypeInfo      productTypeInfo = this.context.ProductTypeInfo.FindById <ProductTypeInfo>(model.Id);
            List <AttributeInfo> list            = productTypeInfo.AttributeInfo.Except <AttributeInfo>(model.AttributeInfo, new AttrComparer()).ToList <AttributeInfo>();

            foreach (AttributeInfo attributeInfo in list)
            {
                IQueryable <AttributeValueInfo> attributeValueInfos = this.context.AttributeValueInfo.FindBy <AttributeValueInfo>((AttributeValueInfo a) => a.AttributeId.Equals(attributeInfo.Id));
                foreach (AttributeValueInfo attributeValueInfo in attributeValueInfos.ToList <AttributeValueInfo>())
                {
                    this.context.AttributeValueInfo.Remove(attributeValueInfo);
                }
                this.context.AttributeInfo.Remove(attributeInfo);
            }
            List <AttributeInfo> attributeInfos = model.AttributeInfo.Except <AttributeInfo>(productTypeInfo.AttributeInfo, new AttrComparer()).ToList <AttributeInfo>();

            if ((attributeInfos == null ? false : attributeInfos.Count <AttributeInfo>() > 0))
            {
                foreach (AttributeInfo attributeInfo1 in attributeInfos)
                {
                    this.context.AttributeInfo.Add(attributeInfo1);
                }
            }
        }
Exemplo n.º 27
0
        public virtual ProductTypeInfo GetProductTypeMax()
        {
            ProductTypeInfo entity  = null;
            SqlDataReader   RdrList = null;

            try
            {
                string SqlList;
                SqlList = "SELECT top 1 * FROM ProductType order by ProductType_ID desc";
                RdrList = DBHelper.ExecuteReader(SqlList);
                if (RdrList.Read())
                {
                    entity = new ProductTypeInfo();

                    entity.ProductType_ID       = Tools.NullInt(RdrList["ProductType_ID"]);
                    entity.ProductType_Name     = Tools.NullStr(RdrList["ProductType_Name"]);
                    entity.ProductType_Sort     = Tools.NullInt(RdrList["ProductType_Sort"]);
                    entity.ProductType_IsActive = Tools.NullInt(RdrList["ProductType_IsActive"]);
                    entity.ProductType_Site     = Tools.NullStr(RdrList["ProductType_Site"]);
                }

                return(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (RdrList != null)
                {
                    RdrList.Close();
                    RdrList = null;
                }
            }
        }
Exemplo n.º 28
0
        public virtual bool EditProductType(ProductTypeInfo entity)
        {
            string    SqlAdd = null;
            DataTable DtAdd  = null;
            DataRow   DrAdd  = null;

            SqlAdd = "SELECT * FROM ProductType WHERE ProductType_ID = " + entity.ProductType_ID;
            DtAdd  = DBHelper.Query(SqlAdd);
            try
            {
                if (DtAdd.Rows.Count > 0)
                {
                    DrAdd = DtAdd.Rows[0];
                    DrAdd["ProductType_ID"]       = entity.ProductType_ID;
                    DrAdd["ProductType_Name"]     = entity.ProductType_Name;
                    DrAdd["ProductType_Sort"]     = entity.ProductType_Sort;
                    DrAdd["ProductType_IsActive"] = entity.ProductType_IsActive;
                    DrAdd["ProductType_Site"]     = entity.ProductType_Site;

                    DBHelper.SaveChanges(SqlAdd, DtAdd);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                DtAdd.Dispose();
            }
            return(true);
        }
Exemplo n.º 29
0
 public virtual bool EditProductType(ProductTypeInfo entity, RBACUserInfo UserPrivilege)
 {
     return(MyDAL.EditProductType(entity));
 }
Exemplo n.º 30
0
        public object GetCartProduct(string openId = "")
        {
            CheckUserLogin();
            var cartHelper     = ServiceProvider.Instance <ICartService> .Create;
            var cart           = cartHelper.GetCart(CurrentUser.Id);
            var productService = ServiceProvider.Instance <IProductService> .Create;
            var shopService    = ServiceProvider.Instance <IShopService> .Create;
            var vshopService   = ServiceProvider.Instance <IVShopService> .Create;
            var siteSetting    = ServiceProvider.Instance <ISiteSettingService> .Create.GetSiteSettings();

            var typeservice = ServiceProvider.Instance <ITypeService> .Create;
            List <CartProductModel> products = new List <CartProductModel>();
            //会员折扣
            decimal discount = 1.0M;//默认折扣为1(没有折扣)

            if (CurrentUser != null)
            {
                discount = CurrentUser.MemberDiscount;
            }
            decimal prodPrice     = 0.0M;                                                                                    //优惠价格
            var     limitProducts = LimitTimeApplication.GetPriceByProducrIds(cart.Items.Select(e => e.ProductId).ToList()); //限时购价格

            foreach (var item in cart.Items)
            {
                var product = productService.GetProduct(item.ProductId);
                var shop    = shopService.GetShop(product.ShopId);

                if (null != shop)
                {
                    var     vshop = vshopService.GetVShopByShopId(shop.Id);
                    SKUInfo sku   = productService.GetSku(item.SkuId);
                    if (sku == null)
                    {
                        continue;
                    }
                    //处理限时购、会员折扣价格
                    var prod = limitProducts.FirstOrDefault(e => e.ProductId == item.ProductId);
                    prodPrice = sku.SalePrice;

                    if (prod != null)
                    {
                        prodPrice = prod.MinPrice;
                    }
                    else
                    {
                        if (shop.IsSelf)
                        {//官方自营店才计算会员折扣
                            prodPrice = sku.SalePrice * discount;
                        }
                    }
                    ProductTypeInfo typeInfo     = typeservice.GetType(product.TypeId);
                    string          colorAlias   = (typeInfo == null || string.IsNullOrEmpty(typeInfo.ColorAlias)) ? SpecificationType.Color.ToDescription() : typeInfo.ColorAlias;
                    string          sizeAlias    = (typeInfo == null || string.IsNullOrEmpty(typeInfo.SizeAlias)) ? SpecificationType.Size.ToDescription() : typeInfo.SizeAlias;
                    string          versionAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.VersionAlias)) ? SpecificationType.Version.ToDescription() : typeInfo.VersionAlias;

                    if (sku != null)
                    {
                        var _tmp = new CartProductModel
                        {
                            CartItemId   = item.Id.ToString(),
                            SkuId        = item.SkuId,
                            Id           = product.Id.ToString(),
                            ImgUrl       = Core.HimallIO.GetRomoteProductSizeImage(product.RelativePath, 1, (int)Himall.CommonModel.ImageSize.Size_150),
                            Name         = product.ProductName,
                            Price        = prodPrice.ToString("F2"),
                            Count        = item.Quantity.ToString(),
                            ShopId       = shop.Id.ToString(),
                            Size         = sku.Size,
                            Color        = sku.Color,
                            Version      = sku.Version,
                            VShopId      = vshop == null ? "0" : vshop.Id.ToString(),
                            ShopName     = shop.ShopName,
                            ShopLogo     = vshop == null ? "" : Core.HimallIO.GetRomoteImagePath(vshop.Logo),
                            Url          = Core.HimallIO.GetRomoteImagePath("/m-IOS/product/detail/") + item.ProductId,
                            IsValid      = (product.AuditStatus == ProductInfo.ProductAuditStatus.Audited && product.SaleStatus == ProductInfo.ProductSaleStatus.OnSale) ? 1 : 0,
                            ColorAlias   = colorAlias,
                            SizeAlias    = sizeAlias,
                            VersionAlias = versionAlias,
                            AddTime      = item.AddTime
                        };
                        products.Add(_tmp);
                    }
                }
            }

            products = products.OrderBy(item => item.ShopId).ThenByDescending(o => o.AddTime).ToList();
            var cartShop  = products.GroupBy(item => item.ShopId);
            var cartModel = new { Status = "OK", Data = cartShop };

            return(Json(cartModel));//原api返回
        }