示例#1
0
 public static ProductActionStatus AddProduct(ProductInfo product, Dictionary<string, SKUItem> skus, Dictionary<int, IList<int>> attrs, IList<int> tagsId,string wid)
 {
     if (product == null)
     {
         return ProductActionStatus.UnknowError;
     }
     Globals.EntityCoding(product, true);
     int decimalLength = SettingsManager.GetMasterSettings(true,wid).DecimalLength;
     if (product.MarketPrice.HasValue)
     {
         product.MarketPrice = new decimal?(Math.Round(product.MarketPrice.Value, decimalLength));
     }
     ProductActionStatus unknowError = ProductActionStatus.UnknowError;
     using (DbConnection connection = DatabaseFactory.CreateDatabase().CreateConnection())
     {
         connection.Open();
         DbTransaction dbTran = connection.BeginTransaction();
         try
         {
             ProductDao dao = new ProductDao();
             int productId = dao.AddProduct(product, dbTran);
             if (productId == 0)
             {
                 dbTran.Rollback();
                 return ProductActionStatus.DuplicateSKU;
             }
             product.ProductId = productId;
             if (((skus != null) && (skus.Count > 0)) && !dao.AddProductSKUs(productId, skus, dbTran,wid))
             {
                 dbTran.Rollback();
                 return ProductActionStatus.SKUError;
             }
             if (((attrs != null) && (attrs.Count > 0)) && !dao.AddProductAttributes(productId, attrs, dbTran))
             {
                 dbTran.Rollback();
                 return ProductActionStatus.AttributeError;
             }
             if (((tagsId != null) && (tagsId.Count > 0)) && !new TagDao().AddProductTags(productId, tagsId, dbTran))
             {
                 dbTran.Rollback();
                 return ProductActionStatus.ProductTagEroor;
             }
             dbTran.Commit();
             unknowError = ProductActionStatus.Success;
         }
         catch (Exception)
         {
             dbTran.Rollback();
         }
         finally
         {
             connection.Close();
         }
     }
     if (unknowError == ProductActionStatus.Success)
     {
         EventLogs.WriteOperationLog(Privilege.AddProducts, string.Format(CultureInfo.InvariantCulture, "上架了一个新商品:”{0}”", new object[] { product.ProductName }));
     }
     return unknowError;
 }
示例#2
0
        public static ProductActionStatus AddProduct(ProductInfo product, Dictionary <string, SKUItem> skus, Dictionary <int, IList <int> > attrs)
        {
            if (null == product)
            {
                return(ProductActionStatus.UnknowError);
            }
            Globals.EntityCoding(product, true);
            int decimalLength = HiContext.Current.SiteSettings.DecimalLength;

            if (product.MarketPrice.HasValue)
            {
                product.MarketPrice = new decimal?(Math.Round(product.MarketPrice.Value, decimalLength));
            }
            product.LowestSalePrice = Math.Round(product.LowestSalePrice, decimalLength);
            ProductActionStatus unknowError = ProductActionStatus.UnknowError;

            using (DbConnection connection = DatabaseFactory.CreateDatabase().CreateConnection())
            {
                connection.Open();
                DbTransaction dbTran = connection.BeginTransaction();
                try
                {
                    ProductProvider provider  = ProductProvider.Instance();
                    int             productId = provider.AddProduct(product, dbTran);
                    if (productId == 0)
                    {
                        dbTran.Rollback();
                        return(ProductActionStatus.DuplicateSKU);
                    }
                    product.ProductId = productId;
                    if (((skus != null) && (skus.Count > 0)) && !provider.AddProductSKUs(productId, skus, dbTran))
                    {
                        dbTran.Rollback();
                        return(ProductActionStatus.SKUError);
                    }
                    if (((attrs != null) && (attrs.Count > 0)) && !provider.AddProductAttributes(productId, attrs, dbTran))
                    {
                        dbTran.Rollback();
                        return(ProductActionStatus.AttributeError);
                    }
                    dbTran.Commit();
                    unknowError = ProductActionStatus.Success;
                }
                catch (Exception)
                {
                    dbTran.Rollback();
                }
                finally
                {
                    connection.Close();
                }
            }
            if (unknowError == ProductActionStatus.Success)
            {
                EventLogs.WriteOperationLog(Privilege.AddProducts, string.Format(CultureInfo.InvariantCulture, "上架了一个新商品:”{0}”", new object[] { product.ProductName }));
            }
            return(unknowError);
        }
示例#3
0
 public static void ImportProducts(DataSet productData, int categoryId, int lineId, int?bandId, ProductSaleStatus saleStatus, bool includeCostPrice, bool includeStock, bool includeImages)
 {
     foreach (DataRow row in productData.Tables["products"].Rows)
     {
         int         mappedProductId           = (int)row["ProductId"];
         ProductInfo product                   = ConverToProduct(row, categoryId, lineId, bandId, saleStatus, includeImages);
         Dictionary <string, SKUItem>   skus   = ConverToSkus(mappedProductId, productData, includeCostPrice, includeStock);
         Dictionary <int, IList <int> > attrs  = ConvertToAttributes(mappedProductId, productData);
         ProductActionStatus            status = AddProduct(product, skus, attrs);
     }
 }
        private void ProcessTaobaoProductDown(HttpContext context)
        {
            long taobaoProductId = 0L;

            if (long.TryParse(context.Request.Form["TaobaoProductId"], out taobaoProductId) && ProductHelper.IsExitTaobaoProduct(taobaoProductId))
            {
                return;
            }
            ProductInfo productInfo = new ProductInfo();

            productInfo.AuditStatus = ProductAuditStatus.Pass;
            productInfo.CategoryId  = 0;
            productInfo.BrandId     = 0;
            productInfo.ProductName = HttpUtility.UrlDecode(context.Request.Form["ProductName"]).ToString().Replace("\\", "");
            productInfo.ProductCode = context.Request.Form["ProductCode"];
            productInfo.Description = HttpUtility.UrlDecode(context.Request.Form["Description"]).ToString().Replace("\\", "");
            if (context.Request.Form["SaleStatus"] == "onsale")
            {
                productInfo.SaleStatus = ProductSaleStatus.OnSale;
            }
            else
            {
                productInfo.SaleStatus = ProductSaleStatus.OnStock;
            }
            productInfo.AddedDate       = DateTime.Parse(context.Request.Form["AddedDate"]);
            productInfo.TaobaoProductId = taobaoProductId;
            string text = context.Request.Form["ImageUrls"];

            if (!string.IsNullOrEmpty(text))
            {
                this.DownloadImage(productInfo, text, context);
            }
            productInfo.TypeId = ProductTypeHelper.GetTypeId(context.Request.Form["TypeName"]);
            decimal weight = decimal.Parse(context.Request.Form["Weight"]);
            Dictionary <string, SKUItem> skus = this.GetSkus(productInfo, weight, context);
            ProductActionStatus          productActionStatus = ProductHelper.AddProduct(productInfo, skus, null, null, null, true, "");

            if (productActionStatus == ProductActionStatus.Success)
            {
                TaobaoProductInfo taobaoProduct = this.GetTaobaoProduct(context);
                taobaoProduct.ProductId = productInfo.ProductId;
                taobaoProduct.ProTitle  = productInfo.ProductName;
                taobaoProduct.Num       = productInfo.Stock;
                ProductHelper.UpdateToaobProduct(taobaoProduct);
            }
            context.Response.ContentType = "text/string";
            context.Response.Write(productActionStatus.ToString());
        }
示例#5
0
        public static ProductActionStatus AddProduct(ProductInfo product)
        {
            if (null == product)
            {
                return(ProductActionStatus.UnknowError);
            }
            Globals.EntityCoding(product, true);
            int decimalLength = HiContext.Current.SiteSettings.DecimalLength;

            if (product.MarketPrice.HasValue)
            {
                product.MarketPrice = new decimal?(Math.Round(product.MarketPrice.Value, decimalLength));
            }
            product.LowestSalePrice = Math.Round(product.LowestSalePrice, decimalLength);
            ProductActionStatus unknowError = ProductActionStatus.UnknowError;

            using (DbConnection connection = DatabaseFactory.CreateDatabase().CreateConnection())
            {
                connection.Open();
                DbTransaction dbTran = connection.BeginTransaction();
                try
                {
                    ProductProvider provider  = ProductProvider.Instance();
                    int             productId = provider.AddProduct(product, dbTran);
                    if (productId == 0)
                    {
                        dbTran.Rollback();
                        return(ProductActionStatus.DuplicateName);
                    }
                    dbTran.Commit();
                    unknowError = ProductActionStatus.Success;
                }
                catch (Exception ex)
                {
                    dbTran.Rollback();
                }
                finally
                {
                    connection.Close();
                }
            }

            if (unknowError == ProductActionStatus.Success)
            {
            }
            return(unknowError);
        }
        private void ProcessTaobaoProductDown(System.Web.HttpContext context)
        {
            ProductInfo productInfo = new ProductInfo();

            productInfo.CategoryId  = 0;
            productInfo.BrandId     = new int?(0);
            productInfo.ProductName = System.Web.HttpUtility.UrlDecode(context.Request.Form["ProductName"]);
            productInfo.ProductCode = context.Request.Form["ProductCode"];
            productInfo.Description = System.Web.HttpUtility.UrlDecode(context.Request.Form["Description"]);
            if (context.Request.Form["SaleStatus"] == "onsale")
            {
                productInfo.SaleStatus = ProductSaleStatus.OnSale;
            }
            else
            {
                productInfo.SaleStatus = ProductSaleStatus.OnStock;
            }
            productInfo.AddedDate       = System.DateTime.Parse(context.Request.Form["AddedDate"]);
            productInfo.TaobaoProductId = long.Parse(context.Request.Form["TaobaoProductId"]);
            string text = context.Request.Form["ImageUrls"];

            if (!string.IsNullOrEmpty(text))
            {
                this.DownloadImage(productInfo, text, context);
            }
            productInfo.TypeId = new int?(ProductTypeHelper.GetTypeId(context.Request.Form["TypeName"]));
            int weight = int.Parse(context.Request.Form["Weight"]);

            System.Collections.Generic.Dictionary <string, SKUItem> skus = this.GetSkus(productInfo, weight, context);
            productInfo.LowestSalePrice = skus.Values.First <SKUItem>().SalePrice;
            ProductActionStatus productActionStatus = ProductHelper.AddProduct(productInfo, skus, null, null);

            if (productActionStatus == ProductActionStatus.Success)
            {
                TaobaoProductInfo taobaoProduct = this.GetTaobaoProduct(context);
                taobaoProduct.ProductId = productInfo.ProductId;
                taobaoProduct.ProTitle  = productInfo.ProductName;
                taobaoProduct.Num       = (long)productInfo.Stock;
                if (productInfo.Stock <= 0)
                {
                    taobaoProduct.Num = long.Parse(context.Request.Form["Stock"]);
                }
                ProductHelper.UpdateToaobProduct(taobaoProduct);
            }
            context.Response.Write(productActionStatus.ToString());
        }
示例#7
0
        private void ProcessTaobaoProductDown(HttpContext context)
        {
            ProductInfo product = new ProductInfo
            {
                CategoryId  = 0,
                BrandId     = 0,
                ProductName = HttpUtility.UrlDecode(context.Request.Form["ProductName"]),
                ProductCode = context.Request.Form["ProductCode"],
                Description = HttpUtility.UrlDecode(context.Request.Form["Description"])
            };

            if (context.Request.Form["SaleStatus"] == "onsale")
            {
                product.SaleStatus = ProductSaleStatus.OnSale;
            }
            else
            {
                product.SaleStatus = ProductSaleStatus.OnStock;
            }
            product.AddedDate       = DateTime.Parse(context.Request.Form["AddedDate"]);
            product.TaobaoProductId = long.Parse(context.Request.Form["TaobaoProductId"]);
            string str = context.Request.Form["ImageUrls"];

            if (!string.IsNullOrEmpty(str))
            {
                this.DownloadImage(product, str, context);
            }
            product.TypeId = new int?(ProductTypeHelper.GetTypeId(context.Request.Form["TypeName"]));
            int weight = int.Parse(context.Request.Form["Weight"]);
            Dictionary <string, SKUItem> skus   = this.GetSkus(product, weight, context);
            ProductActionStatus          status = ProductHelper.AddProduct(product, skus, null, null);

            if (status == ProductActionStatus.Success)
            {
                TaobaoProductInfo taobaoProduct = this.GetTaobaoProduct(context);
                taobaoProduct.ProductId = product.ProductId;
                taobaoProduct.ProTitle  = product.ProductName;
                taobaoProduct.Num       = product.Stock;
                if (product.Stock <= 0)
                {
                    taobaoProduct.Num = long.Parse(context.Request.Form["Stock"]);
                }
                ProductHelper.UpdateToaobProduct(taobaoProduct);
            }
            context.Response.Write(status.ToString());
        }
示例#8
0
        private void btnAdd_Click(object sender, System.EventArgs e)
        {
            decimal num;
            decimal num2;
            decimal num3;
            decimal?num4;
            decimal?marketPrice;
            int     stock;
            int     alertStock;
            decimal?num5;
            int     lineId;

            if (!this.ValidateConverts(this.chkSkuEnabled.Checked, out num, out num2, out num3, out num4, out marketPrice, out stock, out alertStock, out num5, out lineId))
            {
                return;
            }
            if (!this.chkSkuEnabled.Checked)
            {
                if (num3 <= 0m)
                {
                    this.ShowMsg("商品一口价必须大于0", false);
                    return;
                }
                if (num4.HasValue && num4.Value >= num3)
                {
                    this.ShowMsg("商品成本价必须小于商品一口价", false);
                    return;
                }
                if (!(num <= num2))
                {
                    this.ShowMsg("分销商采购价必须要小于其最低零售价", false);
                    return;
                }
            }
            string text = this.editDescription.Text;

            if (this.ckbIsDownPic.Checked)
            {
                text = base.DownRemotePic(text);
            }
            ProductInfo productInfo = new ProductInfo
            {
                CategoryId        = this.categoryId,
                TypeId            = this.dropProductTypes.SelectedValue,
                ProductName       = this.txtProductName.Text,
                ProductCode       = this.txtProductCode.Text,
                LineId            = lineId,
                LowestSalePrice   = num2,
                MarketPrice       = marketPrice,
                Unit              = this.txtUnit.Text,
                ImageUrl1         = this.uploader1.UploadedImageUrl,
                ImageUrl2         = this.uploader2.UploadedImageUrl,
                ImageUrl3         = this.uploader3.UploadedImageUrl,
                ImageUrl4         = this.uploader4.UploadedImageUrl,
                ImageUrl5         = this.uploader5.UploadedImageUrl,
                ThumbnailUrl40    = this.uploader1.ThumbnailUrl40,
                ThumbnailUrl60    = this.uploader1.ThumbnailUrl60,
                ThumbnailUrl100   = this.uploader1.ThumbnailUrl100,
                ThumbnailUrl160   = this.uploader1.ThumbnailUrl160,
                ThumbnailUrl180   = this.uploader1.ThumbnailUrl180,
                ThumbnailUrl220   = this.uploader1.ThumbnailUrl220,
                ThumbnailUrl310   = this.uploader1.ThumbnailUrl310,
                ThumbnailUrl410   = this.uploader1.ThumbnailUrl410,
                ShortDescription  = this.txtShortDescription.Text,
                Description       = (string.IsNullOrEmpty(text) || text.Length <= 0) ? null : text,
                PenetrationStatus = this.chkPenetration.Checked ? PenetrationStatus.Already : PenetrationStatus.Notyet,
                Title             = this.txtTitle.Text,
                MetaDescription   = this.txtMetaDescription.Text,
                MetaKeywords      = this.txtMetaKeywords.Text,
                AddedDate         = System.DateTime.Now,
                BrandId           = this.dropBrandCategories.SelectedValue,
                MainCategoryPath  = CatalogHelper.GetCategory(this.categoryId).Path + "|"
            };
            ProductSaleStatus saleStatus = ProductSaleStatus.OnSale;

            if (this.radInStock.Checked)
            {
                saleStatus = ProductSaleStatus.OnStock;
            }
            if (this.radUnSales.Checked)
            {
                saleStatus = ProductSaleStatus.UnSale;
            }
            if (this.radOnSales.Checked)
            {
                saleStatus = ProductSaleStatus.OnSale;
            }
            productInfo.SaleStatus = saleStatus;
            System.Collections.Generic.Dictionary <int, System.Collections.Generic.IList <int> > attrs = null;
            System.Collections.Generic.Dictionary <string, SKUItem> dictionary;
            if (this.chkSkuEnabled.Checked)
            {
                productInfo.HasSKU = true;
                dictionary         = base.GetSkus(this.txtSkus.Text);
            }
            else
            {
                dictionary = new System.Collections.Generic.Dictionary <string, SKUItem>
                {
                    {
                        "0",
                        new SKUItem
                        {
                            SkuId         = "0",
                            SKU           = this.txtSku.Text,
                            SalePrice     = num3,
                            CostPrice     = num4.HasValue ? num4.Value : 0m,
                            PurchasePrice = num,
                            Stock         = stock,
                            AlertStock    = alertStock,
                            Weight        = num5.HasValue ? num5.Value : 0m
                        }
                    }
                };
                if (this.txtMemberPrices.Text.Length > 0)
                {
                    base.GetMemberPrices(dictionary["0"], this.txtMemberPrices.Text);
                }
                if (this.txtDistributorPrices.Text.Length > 0)
                {
                    base.GetDistributorPrices(dictionary["0"], this.txtDistributorPrices.Text);
                }
            }
            if (!string.IsNullOrEmpty(this.txtAttributes.Text) && this.txtAttributes.Text.Length > 0)
            {
                attrs = base.GetAttributes(this.txtAttributes.Text);
            }
            ValidationResults validationResults = Validation.Validate <ProductInfo>(productInfo, new string[]
            {
                "AddProduct"
            });

            if (!validationResults.IsValid)
            {
                this.ShowMsg(validationResults);
                return;
            }
            System.Collections.Generic.IList <int> list = new System.Collections.Generic.List <int>();
            if (!string.IsNullOrEmpty(this.txtProductTag.Text.Trim()))
            {
                string   text2 = this.txtProductTag.Text.Trim();
                string[] array;
                if (text2.Contains(","))
                {
                    array = text2.Split(new char[]
                    {
                        ','
                    });
                }
                else
                {
                    array = new string[]
                    {
                        text2
                    };
                }
                string[] array2 = array;
                for (int i = 0; i < array2.Length; i++)
                {
                    string value = array2[i];
                    list.Add(System.Convert.ToInt32(value));
                }
            }
            ProductActionStatus productActionStatus = ProductHelper.AddProduct(productInfo, dictionary, attrs, list);

            if (productActionStatus == ProductActionStatus.Success)
            {
                this.ShowMsg("添加商品成功", true);
                base.Response.Redirect(Globals.GetAdminAbsolutePath(string.Format("/product/AddProductComplete.aspx?categoryId={0}&productId={1}", this.categoryId, productInfo.ProductId)), true);
                return;
            }
            if (productActionStatus == ProductActionStatus.AttributeError)
            {
                this.ShowMsg("添加商品失败,保存商品属性时出错", false);
                return;
            }
            if (productActionStatus == ProductActionStatus.DuplicateName)
            {
                this.ShowMsg("添加商品失败,商品名称不能重复", false);
                return;
            }
            if (productActionStatus == ProductActionStatus.DuplicateSKU)
            {
                this.ShowMsg("添加商品失败,商家编码不能重复", false);
                return;
            }
            if (productActionStatus == ProductActionStatus.SKUError)
            {
                this.ShowMsg("添加商品失败,商家编码不能重复", false);
                return;
            }
            if (productActionStatus == ProductActionStatus.ProductTagEroor)
            {
                this.ShowMsg("添加商品失败,保存商品标签时出错", false);
                return;
            }
            this.ShowMsg("添加商品失败,未知错误", false);
        }
		private void btnSave_Click(object sender, System.EventArgs e)
		{
			if (this.categoryId == 0)
			{
				this.categoryId = (int)this.ViewState["ProductCategoryId"];
			}
			int displaySequence;
			decimal num;
			decimal num2;
			decimal num3;
			decimal? num4;
			decimal? marketPrice;
			int stock;
			int alertStock;
			decimal? num5;
			if (!this.ValidateConverts(this.chkSkuEnabled.Checked, out displaySequence, out num, out num2, out num3, out num4, out marketPrice, out stock, out alertStock, out num5))
			{
				return;
			}
			decimal d = 0m;
			decimal.TryParse(this.txtCostPrice.Text, out d);
			if (d == 0m)
			{
				this.ShowMsg("供货价必填", false);
				return;
			}
			if (!this.chkSkuEnabled.Checked)
			{
				if (num3 <= 0m)
				{
					this.ShowMsg("商品一口价必须大于0", false);
					return;
				}
				if (num4.HasValue && num4.Value >= num3)
				{
					this.ShowMsg("商品成本价必须小于商品一口价", false);
					return;
				}
				if (!(num <= num2))
				{
					this.ShowMsg("分销商采购价必须要小于等于其最低零售价", false);
					return;
				}
			}
			string text = this.fckDescription.Text;
			if (this.ckbIsDownPic.Checked)
			{
				text = base.DownRemotePic(text);
			}
			ProductInfo productInfo = new ProductInfo
			{
				ProductId = this.productId,
				CategoryId = this.categoryId,
				TypeId = this.dropProductTypes.SelectedValue,
				ProductName = this.txtProductName.Text,
				ProductCode = this.txtProductCode.Text,
				DisplaySequence = displaySequence,
				LineId = this.dropProductLines.SelectedValue.Value,
				LowestSalePrice = num2,
				MarketPrice = marketPrice,
				Unit = this.txtUnit.Text,
				ImageUrl1 = this.uploader1.UploadedImageUrl,
				ImageUrl2 = this.uploader2.UploadedImageUrl,
				ImageUrl3 = this.uploader3.UploadedImageUrl,
				ImageUrl4 = this.uploader4.UploadedImageUrl,
				ImageUrl5 = this.uploader5.UploadedImageUrl,
				ThumbnailUrl40 = this.uploader1.ThumbnailUrl40,
				ThumbnailUrl60 = this.uploader1.ThumbnailUrl60,
				ThumbnailUrl100 = this.uploader1.ThumbnailUrl100,
				ThumbnailUrl160 = this.uploader1.ThumbnailUrl160,
				ThumbnailUrl180 = this.uploader1.ThumbnailUrl180,
				ThumbnailUrl220 = this.uploader1.ThumbnailUrl220,
				ThumbnailUrl310 = this.uploader1.ThumbnailUrl310,
				ThumbnailUrl410 = this.uploader1.ThumbnailUrl410,
				ShortDescription = this.txtShortDescription.Text,
				Description = (string.IsNullOrEmpty(text) || text.Length <= 0) ? null : text,
				PenetrationStatus = this.chkPenetration.Checked ? PenetrationStatus.Already : PenetrationStatus.Notyet,
				Title = this.txtTitle.Text,
				MetaDescription = this.txtMetaDescription.Text,
				MetaKeywords = this.txtMetaKeywords.Text,
				AddedDate = System.DateTime.Now,
				BrandId = this.dropBrandCategories.SelectedValue
			};
			ProductSaleStatus saleStatus = ProductSaleStatus.OnSale;
			if (this.radInStock.Checked)
			{
				saleStatus = ProductSaleStatus.OnStock;
			}
			if (this.radUnSales.Checked)
			{
				saleStatus = ProductSaleStatus.UnSale;
			}
			if (this.radOnSales.Checked)
			{
				saleStatus = ProductSaleStatus.OnSale;
			}
			productInfo.SaleStatus = saleStatus;
			CategoryInfo category = CatalogHelper.GetCategory(this.categoryId);
			if (category != null)
			{
				productInfo.MainCategoryPath = category.Path + "|";
			}
			System.Collections.Generic.Dictionary<int, System.Collections.Generic.IList<int>> attrs = null;
			System.Collections.Generic.Dictionary<string, SKUItem> dictionary;
			if (this.chkSkuEnabled.Checked)
			{
				productInfo.HasSKU = true;
				dictionary = base.GetSkus(this.txtSkus.Text);
			}
			else
			{
				dictionary = new System.Collections.Generic.Dictionary<string, SKUItem>
				{

					{
						"0",
						new SKUItem
						{
							SkuId = "0",
							SKU = this.txtSku.Text,
							SalePrice = num3,
							CostPrice = num4.HasValue ? num4.Value : 0m,
							PurchasePrice = num,
							Stock = stock,
							AlertStock = alertStock,
							Weight = num5.HasValue ? num5.Value : 0m
						}
					}
				};
				if (this.txtMemberPrices.Text.Length > 0)
				{
					base.GetMemberPrices(dictionary["0"], this.txtMemberPrices.Text);
				}
				if (this.txtDistributorPrices.Text.Length > 0)
				{
					base.GetDistributorPrices(dictionary["0"], this.txtDistributorPrices.Text);
				}
			}
			if (!string.IsNullOrEmpty(this.txtAttributes.Text) && this.txtAttributes.Text.Length > 0)
			{
				attrs = base.GetAttributes(this.txtAttributes.Text);
			}
			ValidationResults validationResults = Validation.Validate<ProductInfo>(productInfo);
			if (!validationResults.IsValid)
			{
				this.ShowMsg(validationResults);
				return;
			}
			if (this.ViewState["distributorUserIds"] == null)
			{
				this.ViewState["distributorUserIds"] = new System.Collections.Generic.List<int>();
			}
			int num6 = 0;
			if (productInfo.LineId > 0 && int.Parse(this.hdlineId.Value) > 0 && productInfo.LineId != int.Parse(this.hdlineId.Value))
			{
				num6 = 6;
			}
			if (!this.chkPenetration.Checked)
			{
				num6 = 5;
			}
			if (num6 == 5)
			{
				SendMessageHelper.SendMessageToDistributors(productInfo.ProductId.ToString(), num6);
			}
			else
			{
				if (num6 == 6)
				{
					this.toline = this.dropProductLines.SelectedItem.Text;
					SendMessageHelper.SendMessageToDistributors(this.hdlineId.Value + "|" + this.toline, num6);
				}
			}
			System.Collections.Generic.IList<int> list = new System.Collections.Generic.List<int>();
			if (!string.IsNullOrEmpty(this.txtProductTag.Text.Trim()))
			{
				string text2 = this.txtProductTag.Text.Trim();
				string[] array;
				if (text2.Contains(","))
				{
					array = text2.Split(new char[]
					{
						','
					});
				}
				else
				{
					array = new string[]
					{
						text2
					};
				}
				string[] array2 = array;
				for (int i = 0; i < array2.Length; i++)
				{
					string value = array2[i];
					list.Add(System.Convert.ToInt32(value));
				}
			}
			ProductActionStatus productActionStatus = ProductHelper.UpdateProduct(productInfo, dictionary, attrs, (System.Collections.Generic.IList<int>)this.ViewState["distributorUserIds"], list);
			if (productActionStatus == ProductActionStatus.Success)
			{
				this.litralProductTag.SelectedValue = list;
				this.ShowMsg("修改商品成功", true);
				return;
			}
			if (productActionStatus == ProductActionStatus.AttributeError)
			{
				this.ShowMsg("修改商品失败,保存商品属性时出错", false);
				return;
			}
			if (productActionStatus == ProductActionStatus.DuplicateName)
			{
				this.ShowMsg("修改商品失败,商品名称不能重复", false);
				return;
			}
			if (productActionStatus == ProductActionStatus.DuplicateSKU)
			{
				this.ShowMsg("修改商品失败,商家编码不能重复", false);
				return;
			}
			if (productActionStatus == ProductActionStatus.SKUError)
			{
				this.ShowMsg("修改商品失败,商家编码不能重复", false);
				return;
			}
			if (productActionStatus == ProductActionStatus.OffShelfError)
			{
				this.ShowMsg("修改商品失败, 子站没在零售价范围内的商品无法下架", false);
				return;
			}
			if (productActionStatus == ProductActionStatus.ProductTagEroor)
			{
				this.ShowMsg("修改商品失败,保存商品标签时出错", false);
				return;
			}
			this.ShowMsg("修改商品失败,未知错误", false);
		}
示例#10
0
        private void btnAdd_Click(object sender, System.EventArgs e)
        {
            int     displaySequence;
            decimal salePrice;
            decimal?costPrice;
            decimal?marketPrice;
            int     stock;
            int     factstock;
            decimal?num4;
            decimal?referralDeduct;
            decimal?subMemberDeduct;
            decimal?subReferralDeduct;
            decimal?deductFee;
            int     buyCardinality;
            decimal?grossweight;

            //销售类型
            int saletype = string.IsNullOrWhiteSpace(this.dropSaleType.SelectedValue) ? 1 : Convert.ToInt32(this.dropSaleType.SelectedValue);

            if (!this.ValidateConverts(this.chkSkuEnabled.Checked, out displaySequence, out salePrice, out costPrice, out marketPrice, out stock, out factstock, out num4, out referralDeduct, out subMemberDeduct, out subReferralDeduct, out deductFee, out buyCardinality, out grossweight))
            {
                return;
            }

            if (saletype != 2)
            {
                if (this.ddlImportSourceType.SelectedValue == null || this.ddlImportSourceType.SelectedValue == 0)
                {
                    this.ShowMsg("请选择原产地", false);
                    return;
                }
            }

            if (saletype != 2)
            {
                if (this.ddlSupplier.SelectedValue == null || this.ddlSupplier.SelectedValue == 0)
                {
                    this.ShowMsg("请选择供货商", false);
                    return;
                }
            }

            if (this.ddlUnit.SelectedValue == null || this.ddlUnit.SelectedValue == "")
            {
                this.ShowMsg("请选择计量单位", false);
                return;
            }
            if (this.ddlShipping.SelectedValue == null || this.ddlShipping.SelectedValue == 0)
            {
                this.ShowMsg("请选择运费模版", false);
                return;
            }
            int ConversionRelation;

            if (!int.TryParse(this.txtConversionRelation.Text, out ConversionRelation))
            {
                this.ShowMsg("输入换算关系不正确", false);
                return;
            }

            if (!this.chkSkuEnabled.Checked)
            {
                if (salePrice <= 0m)
                {
                    this.ShowMsg("商品一口价必须大于0", false);
                    return;
                }
                if (costPrice.HasValue && (costPrice.Value > salePrice || costPrice.Value < 0m))
                {
                    this.ShowMsg("商品成本价必须大于0且小于商品一口价", false);
                    return;
                }
                if (!costPrice.HasValue)              //|| !deductFee.HasValue
                {
                    this.ShowMsg("商品成本价不能为空", false); //与扣点
                    return;
                }
                if (string.IsNullOrEmpty(txtProductStandard.Text))
                {
                    this.ShowMsg("未开启多规格时,商品规格必填", false);
                    return;
                }
            }

            string text = Globals.StripScriptTags(this.txtProductName.Text.Trim());

            text = Globals.StripHtmlXmlTags(text).Replace("\\", "").Replace("'", "");
            if (string.IsNullOrEmpty(text) || text == "")
            {
                this.ShowMsg("商品名称不能为空,且不能包含脚本标签、HTML标签、XML标签、反斜杠(\\)、单引号(')!", false);
                return;
            }
            //判断是否存在广告关键字
            Dictionary <string, string> msg;

            if (!ValidateKeyWordHelper.ValidateKeyWord(new Dictionary <string, string>()
            {
                { "商品名称", this.txtProductName.Text }, { "商品简介", this.txtShortDescription.Text }
            }, out msg))
            {
                System.Text.StringBuilder showMsg = new System.Text.StringBuilder();
                foreach (string k in msg.Keys)
                {
                    showMsg.Append(k + "中不能包含广告词:" + msg[k] + ";");
                }
                this.ShowMsg(showMsg.ToString(), false);
                return;
            }
            string text2 = this.editDescription.Text;
            string text3 = this.editmobbileDescription.Text;

            if (this.ckbIsDownPic.Checked)
            {
                text2 = base.DownRemotePic(text2);
                text3 = base.DownRemotePic(text3);
            }

            System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex("<script[^>]*?>.*?</script>", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
            ProductInfo productInfo = new ProductInfo
            {
                CategoryId         = this.categoryId,
                TypeId             = this.dropProductTypes.SelectedValue,
                ProductName        = text,
                EnglishName        = this.txtEnglishName.Text,
                SysProductName     = this.txtsysProductName.Text.Trim(),
                ProductCode        = this.txtProductCode.Text,
                MarketPrice        = marketPrice,
                Unit               = this.ddlUnit.SelectedItem.Text,
                ImageUrl1          = this.uploader1.UploadedImageUrl,
                ImageUrl2          = this.uploader2.UploadedImageUrl,
                ImageUrl3          = this.uploader3.UploadedImageUrl,
                ImageUrl4          = this.uploader4.UploadedImageUrl,
                ImageUrl5          = this.uploader5.UploadedImageUrl,
                ThumbnailUrl40     = this.uploader1.ThumbnailUrl40,
                ThumbnailUrl60     = this.uploader1.ThumbnailUrl60,
                ThumbnailUrl100    = this.uploader1.ThumbnailUrl100,
                ThumbnailUrl160    = this.uploader1.ThumbnailUrl160,
                ThumbnailUrl180    = this.uploader1.ThumbnailUrl180,
                ThumbnailUrl220    = this.uploader1.ThumbnailUrl220,
                ThumbnailUrl310    = this.uploader1.ThumbnailUrl310,
                ThumbnailUrl410    = this.uploader1.ThumbnailUrl410,
                ShortDescription   = this.txtShortDescription.Text,
                IsCustomsClearance = this.ChkisCustomsClearance.Checked,
                Description        = (!string.IsNullOrEmpty(text2) && text2.Length > 0) ? regex.Replace(text2, "") : null,
                MobblieDescription = (!string.IsNullOrEmpty(text3) && text3.Length > 0) ? regex.Replace(text3, "") : null,
                Title              = this.txtTitle.Text,
                MetaDescription    = this.txtMetaDescription.Text,
                MetaKeywords       = this.txtMetaKeywords.Text,
                AddedDate          = System.DateTime.Now,
                BrandId            = this.dropBrandCategories.SelectedValue,
                MainCategoryPath   = CatalogHelper.GetCategory(this.categoryId).Path + "|",
                IsfreeShipping     = this.ChkisfreeShipping.Checked,
                ReferralDeduct     = referralDeduct,
                SubMemberDeduct    = subMemberDeduct,
                SubReferralDeduct  = subReferralDeduct,
                TaxRateId          = this.dropTaxRate.SelectedValue,
                TemplateId         = this.ddlShipping.SelectedValue,
                SupplierId         = this.ddlSupplier.SelectedValue,
                ImportSourceId     = this.ddlImportSourceType.SelectedValue,
                IsApproved         = true,
                BuyCardinality     = buyCardinality,
                UnitCode           = this.ddlUnit.SelectedValue,
                Manufacturer       = txtManufacturer.Text,
                ItemNo             = txtItemNo.Text,
                BarCode            = txtBarCode.Text,
                Ingredient         = txtIngredient.Text,
                ProductStandard    = txtProductStandard.Text,
                ConversionRelation = ConversionRelation,
                ProductTitle       = this.txtProductTitle.Text,
                SaleType           = saletype,
                IsPromotion        = this.ChkisPromotion.Checked,
                IsDisplayDiscount  = this.ChkisDisplayDiscount.Checked,
                Purchase           = int.Parse(this.Rd_Purchase.SelectedValue),
                SectionDay         = int.Parse(this.txtSectionDay.Text),
                PurchaseMaxNum     = int.Parse(this.txtMaxCount.Text.ToString())
            };
            ProductSaleStatus saleStatus = ProductSaleStatus.OnSale;

            if (this.radInStock.Checked)
            {
                saleStatus = ProductSaleStatus.OnStock;
            }
            if (this.radUnSales.Checked)
            {
                saleStatus = ProductSaleStatus.UnSale;
            }
            if (this.radOnSales.Checked)
            {
                saleStatus = ProductSaleStatus.OnSale;

                if (productInfo.SaleType != 2)
                {
                    this.ShowMsg("商品还未完成归类操作,不能出售", false);
                    return;
                }
            }

            productInfo.SaleStatus = saleStatus;


            //如果是组合商品,默认已审价
            if (productInfo.SaleType == 2)
            {
                productInfo.IsApprovedPrice = 1;
            }

            else
            {
                productInfo.IsApprovedPrice = 0;
            }
            System.Collections.Generic.Dictionary <int, System.Collections.Generic.IList <int> > attrs = null;
            System.Collections.Generic.Dictionary <string, SKUItem> dictionary;
            if (this.chkSkuEnabled.Checked)
            {
                productInfo.HasSKU = true;
                dictionary         = base.GetSkus(this.txtSkus.Text);
            }
            else
            {
                AutoCalcCostPriceAndDeductFee(salePrice, ref costPrice, ref deductFee);
                dictionary = new System.Collections.Generic.Dictionary <string, SKUItem>
                {
                    {
                        "0",
                        new SKUItem
                        {
                            SkuId       = "0",
                            SKU         = Globals.HtmlEncode(Globals.StripScriptTags(this.txtSku.Text.Trim()).Replace("\\", "")),
                            SalePrice   = salePrice,
                            CostPrice   = costPrice.HasValue ? costPrice.Value : 0m,
                            Stock       = stock,
                            FactStock   = factstock,
                            Weight      = num4.HasValue ? num4.Value : 0m,
                            DeductFee   = deductFee.HasValue ? deductFee.Value :0m,
                            GrossWeight = grossweight.HasValue?grossweight.Value:0m
                        }
                    }
                };
                if (this.txtMemberPrices.Text.Length > 0)
                {
                    base.GetMemberPrices(dictionary["0"], this.txtMemberPrices.Text);
                }
            }
            if (!string.IsNullOrEmpty(this.txtAttributes.Text) && this.txtAttributes.Text.Length > 0)
            {
                attrs = base.GetAttributes(this.txtAttributes.Text);
            }
            ValidationResults validationResults = Validation.Validate <ProductInfo>(productInfo, new string[]
            {
                "AddProduct"
            });

            if (!validationResults.IsValid)
            {
                this.ShowMsg(validationResults);
                return;
            }
            System.Collections.Generic.IList <int> list = new System.Collections.Generic.List <int>();
            if (!string.IsNullOrEmpty(this.txtProductTag.Text.Trim()))
            {
                string   text4 = this.txtProductTag.Text.Trim();
                string[] array;
                if (text4.Contains(","))
                {
                    array = text4.Split(new char[]
                    {
                        ','
                    });
                }
                else
                {
                    array = new string[]
                    {
                        text4
                    };
                }
                string[] array2 = array;
                for (int i = 0; i < array2.Length; i++)
                {
                    string value = array2[i];
                    list.Add(System.Convert.ToInt32(value));
                }
            }
            #region   ==组合商品
            List <ProductsCombination> combinations = new List <ProductsCombination>();
            string   combinationInfos = base.Request.Form["selectProductsinfo"];
            string[] curCom           = combinationInfos.Split(new char[]
            {
                ','
            });
            string[] curCom2 = curCom;
            for (int i = 0; i < curCom2.Length; i++)
            {
                string combinationInfo     = curCom2[i];
                ProductsCombination com    = new ProductsCombination();
                string[]            array3 = combinationInfo.Split(new char[]
                {
                    '|'
                });
                if (array3.Length == 10)
                {
                    com.SkuId         = array3[0];
                    com.ProductId     = array3[1] == "" ? 0 : Convert.ToInt32(array3[1]);
                    com.ProductName   = array3[2];
                    com.ThumbnailsUrl = array3[3];
                    decimal tempweight;
                    if (decimal.TryParse(array3[4], out tempweight))
                    {
                        com.Weight = tempweight;
                    }
                    com.SKU        = array3[5];
                    com.SKUContent = array3[6];
                    com.Quantity   = array3[8] == "" ? 0 : Convert.ToInt32(array3[8]);
                    decimal tempprice;
                    if (decimal.TryParse(array3[9], out tempprice))
                    {
                        com.Price = tempprice;
                    }
                    combinations.Add(com);
                }
            }
            productInfo.CombinationItemInfos = combinations;
            #endregion

            if (productInfo.SaleType == 2)
            {
                decimal CombinationTotalPrice = 0M;
                foreach (var item in productInfo.CombinationItemInfos)
                {
                    CombinationTotalPrice += item.Price * item.Quantity;
                }

                if (Math.Round(CombinationTotalPrice, 2) != Math.Round(salePrice, 2))
                {
                    this.ShowMsg("添加商品失败,组合商品一口价和组合商品明细总价不一致", false);
                    return;
                }
            }


            ProductActionStatus productActionStatus = ProductHelper.AddProduct(productInfo, dictionary, attrs, list, combinations);
            if (productActionStatus == ProductActionStatus.Success)
            {
                this.ShowMsg("添加商品成功", true);
                base.Response.Redirect(Globals.GetAdminAbsolutePath(string.Format("/product/AddProductComplete.aspx?categoryId={0}&productId={1}", this.categoryId, productInfo.ProductId)), true);
                return;
            }
            if (productActionStatus == ProductActionStatus.AttributeError)
            {
                this.ShowMsg("添加商品失败,保存商品属性时出错", false);
                return;
            }
            if (productActionStatus == ProductActionStatus.DuplicateName)
            {
                this.ShowMsg("添加商品失败,商品名称不能重复", false);
                return;
            }
            if (productActionStatus == ProductActionStatus.DuplicateSKU)
            {
                this.ShowMsg("添加商品失败,商家编码不能重复", false);
                return;
            }
            if (productActionStatus == ProductActionStatus.SKUError)
            {
                this.ShowMsg("添加商品失败,商品规格错误", false);
                return;
            }
            if (productActionStatus == ProductActionStatus.ProductTagEroor)
            {
                this.ShowMsg("添加商品失败,保存商品标签时出错", false);
                return;
            }
            this.ShowMsg("添加商品失败,未知错误", false);
        }
示例#11
0
        private void SubmitProduct(string opername)
        {
            string text = this.ucFlashUpload1.Value.Trim();

            this.ucFlashUpload1.Value = text;
            string[] array = text.Split(new char[]
            {
                ','
            });
            string[] array2 = new string[]
            {
                "",
                "",
                "",
                "",
                ""
            };
            int num = 0;

            while (num < array.Length && num < 5)
            {
                array2[num] = array[num];
                num++;
            }
            if (this.categoryid == 0)
            {
                this.categoryid = (int)this.ViewState["ProductCategoryId"];
            }
            bool    isSetCommission = !this.cbIsSetCommission.Checked;
            int     showSaleCounts  = 0;
            int     displaySequence;
            decimal num2;
            decimal?num3;
            decimal?marketPrice;
            int     stock;
            decimal?num4;
            decimal firstCommission;
            decimal secondCommission;
            decimal thirdCommission;
            decimal cubicMeter;
            decimal freightWeight;

            if (!this.ValidateConverts(this.txtProductName.Text.Trim(), this.chkSkuEnabled.Checked, out displaySequence, out num2, out num3, out marketPrice, out stock, out num4, out showSaleCounts, out firstCommission, out secondCommission, out thirdCommission, out cubicMeter, out freightWeight))
            {
                return;
            }
            Globals.Debuglog("商品规格:" + this.chkSkuEnabled.Checked.ToString(), "_Debuglog.txt");
            if (!this.chkSkuEnabled.Checked && num2 <= 0m)
            {
                this.ShowMsg("商品现价必须大于0", false);
                return;
            }
            string text2 = this.fckDescription.Text;

            if (this.ckbIsDownPic.Checked)
            {
                text2 = base.DownRemotePic(text2);
            }
            ProductInfo productInfo = new ProductInfo
            {
                ProductId         = this.productId,
                CategoryId        = this.categoryid,
                TypeId            = this.dropProductTypes.SelectedValue,
                ProductName       = this.txtProductName.Text.Trim().Replace("\\", ""),
                ProductShortName  = this.txtProductShortName.Text.Trim(),
                ProductCode       = this.txtProductCode.Text.Trim(),
                DisplaySequence   = displaySequence,
                MarketPrice       = marketPrice,
                Unit              = this.txtUnit.Text.Trim(),
                ImageUrl1         = array2[0],
                ImageUrl2         = array2[1],
                ImageUrl3         = array2[2],
                ImageUrl4         = array2[3],
                ImageUrl5         = array2[4],
                ThumbnailUrl40    = array2[0].Replace("/images/", "/thumbs40/40_"),
                ThumbnailUrl60    = array2[0].Replace("/images/", "/thumbs60/60_"),
                ThumbnailUrl100   = array2[0].Replace("/images/", "/thumbs100/100_"),
                ThumbnailUrl160   = array2[0].Replace("/images/", "/thumbs160/160_"),
                ThumbnailUrl180   = array2[0].Replace("/images/", "/thumbs180/180_"),
                ThumbnailUrl220   = array2[0].Replace("/images/", "/thumbs220/220_"),
                ThumbnailUrl310   = array2[0].Replace("/images/", "/thumbs310/310_"),
                ThumbnailUrl410   = array2[0].Replace("/images/", "/thumbs410/410_"),
                ShortDescription  = this.txtShortDescription.Text,
                IsfreeShipping    = this.ChkisfreeShipping.Checked,
                Description       = ((!string.IsNullOrEmpty(text2) && text2.Length > 0) ? text2 : null),
                AddedDate         = System.DateTime.Now,
                BrandId           = this.dropBrandCategories.SelectedValue,
                FirstCommission   = firstCommission,
                SecondCommission  = secondCommission,
                ThirdCommission   = thirdCommission,
                FreightTemplateId = (this.ChkisfreeShipping.Checked ? 0 : this.FreightTemplateDownList1.SelectedValue),
                IsSetCommission   = isSetCommission,
                CubicMeter        = cubicMeter,
                FreightWeight     = freightWeight
            };
            ProductSaleStatus saleStatus = ProductSaleStatus.OnSale;

            if (this.radInStock.Checked)
            {
                saleStatus = ProductSaleStatus.OnStock;
            }
            if (this.radUnSales.Checked)
            {
                saleStatus = ProductSaleStatus.UnSale;
            }
            if (this.radOnSales.Checked)
            {
                saleStatus = ProductSaleStatus.OnSale;
            }
            productInfo.SaleStatus = saleStatus;
            CategoryInfo category = CatalogHelper.GetCategory(this.categoryid);

            if (category != null)
            {
                productInfo.MainCategoryPath = category.Path + "|";
            }
            System.Collections.Generic.Dictionary <string, SKUItem> dictionary = null;
            System.Collections.Generic.Dictionary <int, System.Collections.Generic.IList <int> > attrs = null;
            if (this.chkSkuEnabled.Checked)
            {
                decimal minShowPrice = 0m;
                productInfo.HasSKU = true;
                dictionary         = base.GetSkus(this.txtSkus.Text);
                if (dictionary == null)
                {
                    this.ShowMsg("商品规格填写不完整!", false);
                    return;
                }
                decimal[] minSalePrice = new decimal[]
                {
                    79228162514264337593543950335m
                };
                foreach (SKUItem current in from sku in dictionary.Values
                         where sku.SalePrice < minSalePrice[0]
                         select sku)
                {
                    minSalePrice[0] = current.SalePrice;
                }
                minShowPrice = minSalePrice[0];
                decimal[] maxSalePrice = new decimal[]
                {
                    -79228162514264337593543950335m
                };
                foreach (SKUItem current2 in from sku in dictionary.Values
                         where sku.SalePrice > maxSalePrice[0]
                         select sku)
                {
                    maxSalePrice[0] = current2.SalePrice;
                }
                decimal maxShowPrice = maxSalePrice[0];
                productInfo.MinShowPrice = minShowPrice;
                productInfo.MaxShowPrice = maxShowPrice;
            }
            else
            {
                dictionary = new System.Collections.Generic.Dictionary <string, SKUItem>
                {
                    {
                        "0",
                        new SKUItem
                        {
                            SkuId     = "0",
                            SKU       = this.txtSku.Text,
                            SalePrice = num2,
                            CostPrice = (num3.HasValue ? num3.Value : 0m),
                            Stock     = stock,
                            Weight    = (num4.HasValue ? num4.Value : 0m)
                        }
                    }
                };
                if (this.txtMemberPrices.Text.Length > 0)
                {
                    base.GetMemberPrices(dictionary["0"], this.txtMemberPrices.Text);
                }
                productInfo.MinShowPrice = num2;
                productInfo.MaxShowPrice = num2;
            }
            if (!string.IsNullOrEmpty(this.txtAttributes.Text) && this.txtAttributes.Text.Length > 0)
            {
                attrs = base.GetAttributes(this.txtAttributes.Text);
            }
            ValidationResults validationResults = Validation.Validate <ProductInfo>(productInfo);

            if (!validationResults.IsValid)
            {
                this.ShowMsg(validationResults);
                return;
            }
            System.Collections.Generic.IList <int> list = new System.Collections.Generic.List <int>();
            if (!string.IsNullOrEmpty(this.txtProductTag.Text.Trim()))
            {
                string   text3 = this.txtProductTag.Text.Trim();
                string[] array3;
                if (text3.Contains(","))
                {
                    array3 = text3.Split(new char[]
                    {
                        ','
                    });
                }
                else
                {
                    array3 = new string[]
                    {
                        text3
                    };
                }
                string[] array4 = array3;
                for (int i = 0; i < array4.Length; i++)
                {
                    string value = array4[i];
                    list.Add(System.Convert.ToInt32(value));
                }
            }
            if (this.productId > 0)
            {
                ProductInfo productBaseInfo = ProductHelper.GetProductBaseInfo(this.productId);
                productInfo.SaleCounts     = productBaseInfo.SaleCounts;
                productInfo.ShowSaleCounts = productBaseInfo.ShowSaleCounts;
            }
            else
            {
                productInfo.SaleCounts     = 0;
                productInfo.ShowSaleCounts = showSaleCounts;
            }
            if (this.productId > 0)
            {
                ProductActionStatus productActionStatus = ProductHelper.UpdateProduct(productInfo, dictionary, attrs, list);
                if (productActionStatus == ProductActionStatus.Success)
                {
                    ProductHelper.UpdateShoppingCartsTemplateId(this.productId, productInfo.FreightTemplateId);
                    this.litralProductTag.SelectedValue = list;
                    if (opername == "next")
                    {
                        string url = this.thisUrl;
                        if (this.isnext != 1)
                        {
                            url = string.Concat(new object[]
                            {
                                "/Admin/goods/ProductEdit.aspx?productId=",
                                this.productId,
                                "&isnext=1&reurl=",
                                base.Server.UrlEncode(this.reurl)
                            });
                        }
                        base.Response.Redirect(url);
                        base.Response.End();
                        return;
                    }
                    this.spanJs.InnerHtml = "<script>$('#ctl00_ContentPlaceHolder1_btnSave,#preview,#prevBtn').attr('disabled', 'true');setTimeout(function () { $('#ctl00_ContentPlaceHolder1_btnSave,#preview,#prevBtn').removeAttr('disabled'); }, 5000);</script>";
                    this.ShowMsgAndReUrl("保存商品信息成功!", true, this.reurl);
                    return;
                }
                else
                {
                    if (productActionStatus == ProductActionStatus.AttributeError)
                    {
                        this.ShowMsg("保存商品失败,保存商品属性时出错", false);
                        return;
                    }
                    if (productActionStatus == ProductActionStatus.DuplicateName)
                    {
                        this.ShowMsg("保存商品失败,商品名称不能重复", false);
                        return;
                    }
                    if (productActionStatus == ProductActionStatus.DuplicateSKU)
                    {
                        this.ShowMsg("保存商品失败,商品编码不能重复", false);
                        return;
                    }
                    if (productActionStatus == ProductActionStatus.SKUError)
                    {
                        this.ShowMsg("保存商品失败,商品编码不能重复", false);
                        return;
                    }
                    if (productActionStatus == ProductActionStatus.OffShelfError)
                    {
                        this.ShowMsg("保存商品失败,子站没在零售价范围内的商品无法下架", false);
                        return;
                    }
                    if (productActionStatus == ProductActionStatus.ProductTagEroor)
                    {
                        this.ShowMsg("保存商品失败,保存商品标签时出错", false);
                        return;
                    }
                    this.ShowMsg("保存商品失败,未知错误", false);
                    return;
                }
            }
            else
            {
                string text4 = ProductHelper.AddProductNew(productInfo, dictionary, attrs, list);
                int    num5  = Globals.ToNum(text4);
                if (num5 > 0)
                {
                    base.Response.Redirect("productedit.aspx?productid=" + num5 + "&isnext=1");
                    base.Response.End();
                    return;
                }
                this.ShowMsg("保存商品失败," + text4, false);
                return;
            }
        }
示例#12
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            int     num2;
            int     num3;
            decimal num4;
            decimal?nullable;
            decimal?nullable2;
            decimal?nullable3;
            string  str = this.ucFlashUpload1.Value.Trim();

            this.ucFlashUpload1.Value = str;
            string[] strArray  = str.Split(new char[] { ',' });
            string[] strArray2 = new string[] { "", "", "", "", "" };
            for (int i = 0; (i < strArray.Length) && (i < 5); i++)
            {
                strArray2[i] = strArray[i];
            }
            if (this.categoryId == 0)
            {
                this.categoryId = (int)this.ViewState["ProductCategoryId"];
            }
            if (this.ValidateConverts(this.chkSkuEnabled.Checked, out num2, out num4, out nullable, out nullable2, out num3, out nullable3))
            {
                if (!this.chkSkuEnabled.Checked)
                {
                    if (num4 <= 0M)
                    {
                        this.ShowMsg("商品一口价必须大于0", false);
                        return;
                    }
                    if (nullable.HasValue && (nullable.Value >= num4))
                    {
                        this.ShowMsg("商品成本价必须小于商品一口价", false);
                        return;
                    }
                }
                string text = this.fckDescription.Text;
                if (this.ckbIsDownPic.Checked)
                {
                    text = base.DownRemotePic(text);
                }
                ProductInfo target = new ProductInfo {
                    ProductId        = this.productId,
                    CategoryId       = this.categoryId,
                    TypeId           = this.dropProductTypes.SelectedValue,
                    ProductName      = this.txtProductName.Text,
                    ProductCode      = this.txtProductCode.Text,
                    DisplaySequence  = num2,
                    MarketPrice      = nullable2,
                    Unit             = this.txtUnit.Text,
                    ImageUrl1        = strArray2[0],
                    ImageUrl2        = strArray2[1],
                    ImageUrl3        = strArray2[2],
                    ImageUrl4        = strArray2[3],
                    ImageUrl5        = strArray2[4],
                    ThumbnailUrl40   = strArray2[0].Replace("/images/", "/thumbs40/40_"),
                    ThumbnailUrl60   = strArray2[0].Replace("/images/", "/thumbs60/60_"),
                    ThumbnailUrl100  = strArray2[0].Replace("/images/", "/thumbs100/100_"),
                    ThumbnailUrl160  = strArray2[0].Replace("/images/", "/thumbs160/160_"),
                    ThumbnailUrl180  = strArray2[0].Replace("/images/", "/thumbs180/180_"),
                    ThumbnailUrl220  = strArray2[0].Replace("/images/", "/thumbs220/220_"),
                    ThumbnailUrl310  = strArray2[0].Replace("/images/", "/thumbs310/310_"),
                    ThumbnailUrl410  = strArray2[0].Replace("/images/", "/thumbs410/410_"),
                    ShortDescription = this.txtShortDescription.Text,
                    IsfreeShipping   = this.ChkisfreeShipping.Checked,
                    Description      = (!string.IsNullOrEmpty(text) && (text.Length > 0)) ? text : null,
                    AddedDate        = DateTime.Now,
                    BrandId          = this.dropBrandCategories.SelectedValue
                };
                ProductSaleStatus onSale = ProductSaleStatus.OnSale;
                if (this.radInStock.Checked)
                {
                    onSale = ProductSaleStatus.OnStock;
                }
                if (this.radUnSales.Checked)
                {
                    onSale = ProductSaleStatus.UnSale;
                }
                if (this.radOnSales.Checked)
                {
                    onSale = ProductSaleStatus.OnSale;
                }
                target.SaleStatus = onSale;
                CategoryInfo category = CatalogHelper.GetCategory(this.categoryId);
                if (category != null)
                {
                    target.MainCategoryPath = category.Path + "|";
                }
                Dictionary <string, SKUItem>   skus  = null;
                Dictionary <int, IList <int> > attrs = null;
                if (this.chkSkuEnabled.Checked)
                {
                    target.HasSKU = true;
                    skus          = base.GetSkus(this.txtSkus.Text);
                }
                else
                {
                    Dictionary <string, SKUItem> dictionary3 = new Dictionary <string, SKUItem>();
                    SKUItem item = new SKUItem {
                        SkuId     = "0",
                        SKU       = this.txtSku.Text,
                        SalePrice = num4,
                        CostPrice = nullable.HasValue ? nullable.Value : 0M,
                        Stock     = num3,
                        Weight    = nullable3.HasValue ? nullable3.Value : 0M
                    };
                    dictionary3.Add("0", item);
                    skus = dictionary3;
                    if (this.txtMemberPrices.Text.Length > 0)
                    {
                        base.GetMemberPrices(skus["0"], this.txtMemberPrices.Text);
                    }
                }
                if (!string.IsNullOrEmpty(this.txtAttributes.Text) && (this.txtAttributes.Text.Length > 0))
                {
                    attrs = base.GetAttributes(this.txtAttributes.Text);
                }
                ValidationResults validateResults = Hishop.Components.Validation.Validation.Validate <ProductInfo>(target);
                if (!validateResults.IsValid)
                {
                    this.ShowMsg(validateResults);
                }
                else
                {
                    IList <int> tagIds = new List <int>();
                    if (!string.IsNullOrEmpty(this.txtProductTag.Text.Trim()))
                    {
                        string   str3      = this.txtProductTag.Text.Trim();
                        string[] strArray3 = null;
                        if (str3.Contains(","))
                        {
                            strArray3 = str3.Split(new char[] { ',' });
                        }
                        else
                        {
                            strArray3 = new string[] { str3 };
                        }
                        foreach (string str4 in strArray3)
                        {
                            tagIds.Add(Convert.ToInt32(str4));
                        }
                    }
                    ProductInfo productBaseInfo = ProductHelper.GetProductBaseInfo(this.productId);
                    target.SaleCounts     = productBaseInfo.SaleCounts;
                    target.ShowSaleCounts = productBaseInfo.ShowSaleCounts;
                    ProductActionStatus status2 = ProductHelper.UpdateProduct(target, skus, attrs, tagIds, wid);
                    if (status2 == ProductActionStatus.Success)
                    {
                        this.litralProductTag.SelectedValue = tagIds;
                        if (base.Request.QueryString["reurl"] != null)
                        {
                            this.ReUrl = base.Request.QueryString["reurl"].ToString();
                        }
                        this.ShowMsgAndReUrl("修改商品成功", true, this.ReUrl);
                    }
                    else
                    {
                        switch (status2)
                        {
                        case ProductActionStatus.AttributeError:
                            this.ShowMsg("修改商品失败,保存商品属性时出错", false);
                            return;

                        case ProductActionStatus.DuplicateName:
                            this.ShowMsg("修改商品失败,商品名称不能重复", false);
                            return;

                        case ProductActionStatus.DuplicateSKU:
                            this.ShowMsg("修改商品失败,商家编码不能重复", false);
                            return;

                        case ProductActionStatus.SKUError:
                            this.ShowMsg("修改商品失败,商家编码不能重复", false);
                            return;

                        case ProductActionStatus.OffShelfError:
                            this.ShowMsg("修改商品失败, 子站没在零售价范围内的商品无法下架", false);
                            return;

                        case ProductActionStatus.ProductTagEroor:
                            this.ShowMsg("修改商品失败,保存商品标签时出错", false);
                            return;
                        }
                        this.ShowMsg("修改商品失败,未知错误", false);
                    }
                }
            }
        }
示例#13
0
 public static void ImportProducts(DataTable productData, int categoryId, int lineId, string brandId, ProductSaleStatus saleStatus, bool isImportFromTaobao)
 {
     if ((productData != null) && (productData.Rows.Count > 0))
     {
         foreach (DataRow row in productData.Rows)
         {
             ProductInfo product = new ProductInfo {
                 CategoryId       = categoryId,
                 MainCategoryPath = CatalogHelper.GetCategory(categoryId).Path + "|",
                 ProductName      = (string)row["ProductName"],
                 ProductCode      = (string)row["SKU"],
                 BrandId          = brandId
             };
             if (row["Description"] != DBNull.Value)
             {
                 product.Description = (string)row["Description"];
             }
             product.AddedDate  = DateTime.Now;
             product.SaleStatus = saleStatus;
             product.HasSKU     = false;
             HttpContext current = HttpContext.Current;
             if (row["ImageUrl1"] != DBNull.Value)
             {
                 product.ImageUrl1 = (string)row["ImageUrl1"];
             }
             if (!string.IsNullOrEmpty(product.ImageUrl1) && (product.ImageUrl1.Length > 0))
             {
                 string[] strArray = ProcessImages(current, product.ImageUrl1);
                 product.ThumbnailUrl40  = strArray[0];
                 product.ThumbnailUrl60  = strArray[1];
                 product.ThumbnailUrl100 = strArray[2];
                 product.ThumbnailUrl160 = strArray[3];
                 product.ThumbnailUrl180 = strArray[4];
                 product.ThumbnailUrl220 = strArray[5];
                 product.ThumbnailUrl310 = strArray[6];
                 product.ThumbnailUrl410 = strArray[7];
             }
             if (row["ImageUrl2"] != DBNull.Value)
             {
                 product.ImageUrl2 = (string)row["ImageUrl2"];
             }
             if (!string.IsNullOrEmpty(product.ImageUrl2) && (product.ImageUrl2.Length > 0))
             {
                 ProcessImages(current, product.ImageUrl2);
             }
             if (row["ImageUrl3"] != DBNull.Value)
             {
                 product.ImageUrl3 = (string)row["ImageUrl3"];
             }
             if (!string.IsNullOrEmpty(product.ImageUrl3) && (product.ImageUrl3.Length > 0))
             {
                 ProcessImages(current, product.ImageUrl3);
             }
             if (row["ImageUrl4"] != DBNull.Value)
             {
                 product.ImageUrl4 = (string)row["ImageUrl4"];
             }
             if (!string.IsNullOrEmpty(product.ImageUrl4) && (product.ImageUrl4.Length > 0))
             {
                 ProcessImages(current, product.ImageUrl4);
             }
             if (row["ImageUrl5"] != DBNull.Value)
             {
                 product.ImageUrl5 = (string)row["ImageUrl5"];
             }
             if (!string.IsNullOrEmpty(product.ImageUrl5) && (product.ImageUrl5.Length > 0))
             {
                 ProcessImages(current, product.ImageUrl5);
             }
             SKUItem item = new SKUItem {
                 SkuId = "0",
                 SKU   = (string)row["SKU"]
             };
             if (row["Stock"] != DBNull.Value)
             {
                 item.Stock = (int)row["Stock"];
             }
             if (row["Weight"] != DBNull.Value)
             {
                 item.Weight = (decimal)row["Weight"];
             }
             item.SalePrice = (decimal)row["SalePrice"];
             Dictionary <string, SKUItem> skus = new Dictionary <string, SKUItem>();
             skus.Add(item.SkuId, item);
             ProductActionStatus status = AddProduct(product, skus, null, null);
             if (isImportFromTaobao && (status == ProductActionStatus.Success))
             {
                 TaobaoProductInfo taobaoProduct = new TaobaoProductInfo {
                     ProductId = product.ProductId,
                     ProTitle  = product.ProductName,
                     Cid       = (long)row["Cid"]
                 };
                 if (row["StuffStatus"] != DBNull.Value)
                 {
                     taobaoProduct.StuffStatus = (string)row["StuffStatus"];
                 }
                 taobaoProduct.Num           = (long)row["Num"];
                 taobaoProduct.LocationState = (string)row["LocationState"];
                 taobaoProduct.LocationCity  = (string)row["LocationCity"];
                 taobaoProduct.FreightPayer  = (string)row["FreightPayer"];
                 if (row["PostFee"] != DBNull.Value)
                 {
                     taobaoProduct.PostFee = (decimal)row["PostFee"];
                 }
                 if (row["ExpressFee"] != DBNull.Value)
                 {
                     taobaoProduct.ExpressFee = (decimal)row["ExpressFee"];
                 }
                 if (row["EMSFee"] != DBNull.Value)
                 {
                     taobaoProduct.EMSFee = (decimal)row["EMSFee"];
                 }
                 taobaoProduct.HasInvoice  = (bool)row["HasInvoice"];
                 taobaoProduct.HasWarranty = (bool)row["HasWarranty"];
                 taobaoProduct.HasDiscount = (bool)row["HasDiscount"];
                 taobaoProduct.ValidThru   = (long)row["ValidThru"];
                 if (row["ListTime"] != DBNull.Value)
                 {
                     taobaoProduct.ListTime = (DateTime)row["ListTime"];
                 }
                 else
                 {
                     taobaoProduct.ListTime = DateTime.Now;
                 }
                 if (row["PropertyAlias"] != DBNull.Value)
                 {
                     taobaoProduct.PropertyAlias = (string)row["PropertyAlias"];
                 }
                 if (row["InputPids"] != DBNull.Value)
                 {
                     taobaoProduct.InputPids = (string)row["InputPids"];
                 }
                 if (row["InputStr"] != DBNull.Value)
                 {
                     taobaoProduct.InputStr = (string)row["InputStr"];
                 }
                 if (row["SkuProperties"] != DBNull.Value)
                 {
                     taobaoProduct.SkuProperties = (string)row["SkuProperties"];
                 }
                 if (row["SkuQuantities"] != DBNull.Value)
                 {
                     taobaoProduct.SkuQuantities = (string)row["SkuQuantities"];
                 }
                 if (row["SkuPrices"] != DBNull.Value)
                 {
                     taobaoProduct.SkuPrices = (string)row["SkuPrices"];
                 }
                 if (row["SkuOuterIds"] != DBNull.Value)
                 {
                     taobaoProduct.SkuOuterIds = (string)row["SkuOuterIds"];
                 }
                 UpdateToaobProduct(taobaoProduct);
             }
         }
     }
 }
示例#14
0
        private void btnImport_Click(object sender, System.EventArgs e)
        {
            string text = this.dropFiles.SelectedValue;

            text = System.IO.Path.Combine(this._dataPath, text);
            if (!System.IO.File.Exists(text))
            {
                this.ShowMsg("选择的数据包文件有问题!", false);
                return;
            }
            int num  = 0;
            int num2 = 0;

            this.PrepareDataFiles(new object[]
            {
                text
            });
            System.Collections.Generic.List <System.Collections.Generic.List <string> > list = this.ReadCsv(this.csvPath, true, '\t', System.Text.Encoding.GetEncoding("GB2312"));
            int i     = 0;
            int count = list.Count;

            while (i < count)
            {
                ProductInfo productInfo = new ProductInfo();
                try
                {
                    System.Collections.Generic.List <string> list2 = list[i];
                    if (list2[18] != "")
                    {
                        System.Data.DataTable brandCategories = CatalogHelper.GetBrandCategories(list2[18]);
                        if (brandCategories.Rows.Count > 0)
                        {
                            productInfo.BrandId = new int?(System.Convert.ToInt32(brandCategories.Rows[0]["BrandId"]));
                        }
                    }
                    if (list2[1] != "")
                    {
                        System.Data.DataTable categoryes = CatalogHelper.GetCategoryes(list2[1]);
                        if (categoryes.Rows.Count > 0)
                        {
                            productInfo.CategoryId = System.Convert.ToInt32(categoryes.Rows[0]["CategoryId"]);
                        }
                        else
                        {
                            productInfo.CategoryId = 0;
                        }
                    }
                    else
                    {
                        productInfo.CategoryId = 0;
                    }
                    if (list2[7] != "")
                    {
                        string path = System.IO.Path.Combine(this.csvPath.Replace(".csv", ""), list2[7]);
                        using (System.IO.StreamReader streamReader = new System.IO.StreamReader(path, System.Text.Encoding.GetEncoding("gb2312")))
                        {
                            productInfo.Description = streamReader.ReadToEnd();
                        }
                    }
                    if (productInfo.CategoryId > 0)
                    {
                        productInfo.MainCategoryPath = CatalogHelper.GetCategory(productInfo.CategoryId).Path + "|";
                    }
                    productInfo.HasSKU    = (int.Parse(list2[19]) == 1);
                    productInfo.ImageUrl1 = "";
                    productInfo.ImageUrl2 = "";
                    productInfo.ImageUrl3 = "";
                    productInfo.ImageUrl4 = "";
                    productInfo.ImageUrl5 = "";
                    if (list2[12] != "")
                    {
                        System.IO.FileInfo fileInfo = new System.IO.FileInfo(System.IO.Path.Combine(this.csvPath.Replace(".csv", ""), list2[12]));
                        if (fileInfo.Exists)
                        {
                            this.GetImg(fileInfo.FullName, ref productInfo, 1);
                        }
                    }
                    if (list2[13] != "")
                    {
                        System.IO.FileInfo fileInfo2 = new System.IO.FileInfo(System.IO.Path.Combine(this.csvPath.Replace(".csv", ""), list2[13]));
                        if (fileInfo2.Exists)
                        {
                            this.GetImg(fileInfo2.FullName, ref productInfo, 2);
                        }
                    }
                    if (list2[14] != "")
                    {
                        System.IO.FileInfo fileInfo3 = new System.IO.FileInfo(System.IO.Path.Combine(this.csvPath.Replace(".csv", ""), list2[14]));
                        if (fileInfo3.Exists)
                        {
                            this.GetImg(fileInfo3.FullName, ref productInfo, 3);
                        }
                    }
                    if (list2[15] != "")
                    {
                        System.IO.FileInfo fileInfo4 = new System.IO.FileInfo(System.IO.Path.Combine(this.csvPath.Replace(".csv", ""), list2[15]));
                        if (fileInfo4.Exists)
                        {
                            this.GetImg(fileInfo4.FullName, ref productInfo, 4);
                        }
                    }
                    if (list2[16] != "")
                    {
                        System.IO.FileInfo fileInfo5 = new System.IO.FileInfo(System.IO.Path.Combine(this.csvPath.Replace(".csv", ""), list2[16]));
                        if (fileInfo5.Exists)
                        {
                            this.GetImg(fileInfo5.FullName, ref productInfo, 5);
                        }
                    }
                    if (list2[17] != "")
                    {
                        productInfo.MarketPrice = new decimal?(decimal.Parse(list2[17]));
                    }
                    if (list2[9] != "")
                    {
                        productInfo.MetaDescription = list2[9];
                    }
                    if (list2[10] != "")
                    {
                        productInfo.MetaKeywords = list2[10];
                    }
                    if (list2[4] != "")
                    {
                        productInfo.ProductCode = list2[4];
                    }
                    productInfo.ProductName = list2[3];
                    string text2 = list2[11];
                    string a;
                    if ((a = text2) != null)
                    {
                        if (!(a == "出售中"))
                        {
                            if (!(a == "下架区"))
                            {
                                if (a == "仓库中")
                                {
                                    productInfo.SaleStatus = ProductSaleStatus.OnStock;
                                }
                            }
                            else
                            {
                                productInfo.SaleStatus = ProductSaleStatus.UnSale;
                            }
                        }
                        else
                        {
                            productInfo.SaleStatus = ProductSaleStatus.OnSale;
                        }
                    }
                    if (list2[5] != "")
                    {
                        productInfo.ShortDescription = list2[5];
                    }
                    if (list2[8] != "")
                    {
                        productInfo.Title = list2[8];
                    }
                    if (list2[2] != "")
                    {
                        int typeId = ProductTypeHelper.GetTypeId(list2[2]);
                        if (typeId > 0)
                        {
                            productInfo.TypeId = new int?(typeId);
                        }
                    }
                    if (!productInfo.TypeId.HasValue)
                    {
                        productInfo.HasSKU = false;
                    }
                    if (list2[6] != "")
                    {
                        productInfo.Unit = list2[6];
                    }
                    System.Collections.Generic.Dictionary <string, SKUItem> dictionary = null;
                    System.Collections.Generic.Dictionary <int, System.Collections.Generic.IList <int> > dictionary2 = null;
                    System.Collections.Generic.IList <int> list3 = new System.Collections.Generic.List <int>();
                    if (list2[20] == "")
                    {
                        dictionary = new System.Collections.Generic.Dictionary <string, SKUItem>();
                        SKUItem sKUItem = new SKUItem();
                        sKUItem.SkuId     = "0";
                        sKUItem.CostPrice = decimal.Parse(list2[24].Split(new char[]
                        {
                            ';'
                        })[0]);
                        sKUItem.SalePrice = decimal.Parse(list2[25].Split(new char[]
                        {
                            ';'
                        })[0]);
                        sKUItem.SKU = list2[21].Split(new char[]
                        {
                            ';'
                        })[0];
                        sKUItem.Stock = int.Parse(list2[23].Split(new char[]
                        {
                            ';'
                        })[0]);
                        sKUItem.Weight = decimal.Parse(list2[22].Split(new char[]
                        {
                            ';'
                        })[0]);
                        dictionary.Add(sKUItem.SKU, sKUItem);
                    }
                    else
                    {
                        if (productInfo.TypeId.HasValue)
                        {
                            dictionary = new System.Collections.Generic.Dictionary <string, SKUItem>();
                            int value = productInfo.TypeId.Value;
                            if (productInfo.HasSKU)
                            {
                                ProductTypeHelper.GetAttributes(value, AttributeUseageMode.Choose);
                                string[] array = list2[20].Split(new char[]
                                {
                                    ';'
                                });
                                int num3 = array.Length;
                                for (int j = 0; j < num3; j++)
                                {
                                    SKUItem sKUItem2 = new SKUItem();
                                    sKUItem2.CostPrice = decimal.Parse(list2[24].Split(new char[]
                                    {
                                        ';'
                                    })[j]);
                                    sKUItem2.SalePrice = decimal.Parse(list2[25].Split(new char[]
                                    {
                                        ';'
                                    })[j]);
                                    sKUItem2.SKU = list2[21].Split(new char[]
                                    {
                                        ';'
                                    })[j];
                                    sKUItem2.Stock = int.Parse(list2[23].Split(new char[]
                                    {
                                        ';'
                                    })[j]);
                                    sKUItem2.Weight = decimal.Parse(list2[22].Split(new char[]
                                    {
                                        ';'
                                    })[j]);
                                    string text3 = array[j];
                                    System.Collections.Generic.Dictionary <int, int> dictionary3 = new System.Collections.Generic.Dictionary <int, int>();
                                    string[] array2 = text3.Split(new char[]
                                    {
                                        ','
                                    });
                                    for (int k = 0; k < array2.Length; k++)
                                    {
                                        string text4             = array2[k];
                                        string specificationName = text4.Split(new char[]
                                        {
                                            ':'
                                        })[0];
                                        string valueStr = text4.Split(new char[]
                                        {
                                            ':'
                                        })[1];
                                        int specificationId = ProductTypeHelper.GetSpecificationId(value, specificationName);
                                        if (specificationId <= 0)
                                        {
                                            productInfo.HasSKU = false;
                                            break;
                                        }
                                        int specificationValueId = ProductTypeHelper.GetSpecificationValueId(specificationId, valueStr);
                                        if (specificationValueId <= 0)
                                        {
                                            productInfo.HasSKU = false;
                                            break;
                                        }
                                        dictionary3.Add(specificationId, specificationValueId);
                                    }
                                    if (productInfo.HasSKU && dictionary3.Count > 0)
                                    {
                                        string text5 = "";
                                        foreach (System.Collections.Generic.KeyValuePair <int, int> current in dictionary3)
                                        {
                                            sKUItem2.SkuItems.Add(current.Key, current.Value);
                                            text5 = text5 + current.Value + "_";
                                        }
                                        sKUItem2.SkuId = text5.Substring(0, text5.Length - 1);
                                        dictionary.Add(sKUItem2.SKU, sKUItem2);
                                    }
                                }
                                if (dictionary.Count > 0)
                                {
                                    productInfo.HasSKU = true;
                                }
                            }
                            else
                            {
                                SKUItem sKUItem3 = new SKUItem();
                                sKUItem3.SkuId     = "0";
                                sKUItem3.CostPrice = decimal.Parse(list2[24].Split(new char[]
                                {
                                    ';'
                                })[0]);
                                sKUItem3.SalePrice = decimal.Parse(list2[25].Split(new char[]
                                {
                                    ';'
                                })[0]);
                                sKUItem3.SKU = list2[21].Split(new char[]
                                {
                                    ';'
                                })[0];
                                sKUItem3.Stock = int.Parse(list2[23].Split(new char[]
                                {
                                    ';'
                                })[0]);
                                sKUItem3.Weight = int.Parse(list2[22].Split(new char[]
                                {
                                    ';'
                                })[0]);
                                dictionary.Add(sKUItem3.SKU, sKUItem3);
                            }
                        }
                    }
                    if (list2[26] != "" && productInfo.TypeId.HasValue)
                    {
                        int value2 = productInfo.TypeId.Value;
                        dictionary2 = new System.Collections.Generic.Dictionary <int, System.Collections.Generic.IList <int> >();
                        System.Collections.Generic.IList <AttributeInfo> attributes = ProductTypeHelper.GetAttributes(value2, AttributeUseageMode.View);
                        foreach (AttributeInfo current2 in ProductTypeHelper.GetAttributes(value2, AttributeUseageMode.MultiView))
                        {
                            attributes.Add(current2);
                        }
                        string[] array2 = list2[26].Split(new char[]
                        {
                            ','
                        });
                        for (int k = 0; k < array2.Length; k++)
                        {
                            string text6  = array2[k];
                            string value3 = text6.Split(new char[]
                            {
                                ':'
                            })[0];
                            string valueStr2 = text6.Split(new char[]
                            {
                                ':'
                            })[1];
                            bool flag = false;
                            int  num4 = 0;
                            foreach (AttributeInfo current3 in attributes)
                            {
                                if (current3.AttributeName.Equals(value3))
                                {
                                    num4 = current3.AttributeId;
                                    flag = true;
                                    break;
                                }
                            }
                            if (flag)
                            {
                                int specificationValueId2 = ProductTypeHelper.GetSpecificationValueId(num4, valueStr2);
                                if (specificationValueId2 > 0)
                                {
                                    if (dictionary2.ContainsKey(num4))
                                    {
                                        dictionary2[num4].Add(specificationValueId2);
                                    }
                                    else
                                    {
                                        dictionary2.Add(num4, new System.Collections.Generic.List <int>
                                        {
                                            specificationValueId2
                                        });
                                    }
                                }
                            }
                        }
                    }
                    if (list2[27] != "")
                    {
                        list3 = new System.Collections.Generic.List <int>();
                        System.Data.DataTable tags = CatalogHelper.GetTags();
                        string[] array2            = list2[27].Split(new char[]
                        {
                            ','
                        });
                        for (int k = 0; k < array2.Length; k++)
                        {
                            string obj = array2[k];
                            foreach (System.Data.DataRow dataRow in tags.Rows)
                            {
                                if (dataRow["TagName"].Equals(obj))
                                {
                                    list3.Add(System.Convert.ToInt32(dataRow["TagId"]));
                                    break;
                                }
                            }
                        }
                    }
                    productInfo.AddedDate = System.DateTime.Now;
                    ProductActionStatus productActionStatus = ProductHelper.AddProduct(productInfo, dictionary, dictionary2, list3);
                    if (productActionStatus == ProductActionStatus.Success)
                    {
                        num++;
                    }
                    else
                    {
                        if (productActionStatus == ProductActionStatus.AttributeError)
                        {
                            num2++;
                        }
                        else
                        {
                            if (productActionStatus == ProductActionStatus.DuplicateName)
                            {
                                num2++;
                            }
                            else
                            {
                                if (productActionStatus == ProductActionStatus.DuplicateSKU)
                                {
                                    num2++;
                                }
                                else
                                {
                                    if (productActionStatus == ProductActionStatus.SKUError)
                                    {
                                        num2++;
                                    }
                                    else
                                    {
                                        num2++;
                                    }
                                }
                            }
                        }
                    }
                }
                catch
                {
                    num2++;
                }
                i++;
            }
            System.IO.DirectoryInfo directoryInfo = new System.IO.DirectoryInfo(this.csvPath.Replace(".csv", ""));
            directoryInfo.Delete(true);
            System.IO.File.Delete(this.csvPath);
            System.IO.File.Delete(text);
            this.BindFiles();
            if (num2 == 0)
            {
                this.ShowMsg("此次商品批量导入操作已成功!", true);
                return;
            }
            this.ShowMsg("此次商品批量导入操作," + num2 + "件商品导入失败!", false);
        }
示例#15
0
        }//"下一步",编辑商品详情"按钮点击事件

        private void SubmitProduct(string opername)
        {
            int    IntegralToNow   = 0;   //积分兑换设置
            string integral        = "0"; //送积分
            string integralCeiling = "0"; //兑换积分上限
            int    LeaseGood       = 0;   //租赁商品
            int    ZeroBuy         = 0;   //零元购

            if (this.cbLeaseOpration.Checked == true)
            {
                LeaseGood = 0;
            }
            else
            {
                LeaseGood = 1;
            }

            if (this.cbZeroByOperation.Checked == true)//零元购
            {
                ZeroBuy = 0;
            }
            else
            {
                ZeroBuy = 1;
            }

            if (this.cbPointsSetUp.Checked == true) //积分兑换设置按钮被选中
            {
                IntegralToNow = 0;                  //不可使用积分兑换
            }
            else
            {
                if (this.txtIntegralCeiling.Text != "")
                {
                    IntegralToNow   = 1;                                   //可以使用积分兑换
                    integralCeiling = this.txtIntegralCeiling.Text.Trim(); //为兑换积分上限赋值
                }
            }

            if (this.cbIntegralOperation.Checked) //送积分设置被选中
            {
                integral = "0";                   //不支持送积分
            }
            else
            {
                if (this.txtIntegral.Text != "")
                {
                    integral = this.txtIntegral.Text.Trim();//为送积分赋值
                }
            }

            int    productId = this.productId;                   //获取商品编号
            string text      = this.ucFlashUpload1.Value.Trim(); //获取商品图片

            this.ucFlashUpload1.Value = text;
            string[] array = text.Split(new char[]
            {
                ','
            });
            string[] array2 = new string[]
            {
                "",
                "",
                "",
                "",
                ""
            };
            int num = 0;

            while (num < array.Length && num < 5)
            {
                array2[num] = array[num];
                num++;
            }
            if (this.categoryid == 0)
            {
                this.categoryid = (int)this.ViewState["ProductCategoryId"];
            }
            bool isSetCommission = !this.cbIsSetCommission.Checked;

            int     showSaleCounts = 0;
            int     displaySequence;
            decimal num2;
            decimal?num3;
            decimal?marketPrice;
            int     stock;
            decimal?num4;
            decimal firstCommission;
            decimal secondCommission;
            decimal thirdCommission;
            decimal cubicMeter;
            decimal freightWeight;

            if (!this.ValidateConverts(this.txtProductName.Text.Trim(), this.chkSkuEnabled.Checked, out displaySequence, out num2, out num3, out marketPrice, out stock, out num4, out showSaleCounts, out firstCommission, out secondCommission, out thirdCommission, out cubicMeter, out freightWeight))
            {
                return;
            }
            Globals.Debuglog("商品规格:" + this.chkSkuEnabled.Checked.ToString(), "_Debuglog.txt");
            if (!this.chkSkuEnabled.Checked && num2 <= 0m)
            {
                this.ShowMsg("商品现价必须大于0", false);
                return;
            }
            string text2 = this.fckDescription.Text;

            if (this.ckbIsDownPic.Checked)
            {
                text2 = base.DownRemotePic(text2);
            }
            ProductInfo productInfo = new ProductInfo
            {
                integral          = integral,//送积分
                ProductId         = this.productId,
                CategoryId        = this.categoryid,
                TypeId            = this.dropProductTypes.SelectedValue,
                ProductName       = this.txtProductName.Text.Trim().Replace("\\", ""),
                ProductShortName  = this.txtProductShortName.Text.Trim(),
                ProductCode       = this.txtProductCode.Text.Trim(),
                DisplaySequence   = displaySequence,
                MarketPrice       = marketPrice,
                Unit              = this.txtUnit.Text.Trim(),
                ImageUrl1         = array2[0],
                ImageUrl2         = array2[1],
                ImageUrl3         = array2[2],
                ImageUrl4         = array2[3],
                ImageUrl5         = array2[4],
                ThumbnailUrl40    = array2[0].Replace("/images/", "/thumbs40/40_"),
                ThumbnailUrl60    = array2[0].Replace("/images/", "/thumbs60/60_"),
                ThumbnailUrl100   = array2[0].Replace("/images/", "/thumbs100/100_"),
                ThumbnailUrl160   = array2[0].Replace("/images/", "/thumbs160/160_"),
                ThumbnailUrl180   = array2[0].Replace("/images/", "/thumbs180/180_"),
                ThumbnailUrl220   = array2[0].Replace("/images/", "/thumbs220/220_"),
                ThumbnailUrl310   = array2[0].Replace("/images/", "/thumbs310/310_"),
                ThumbnailUrl410   = array2[0].Replace("/images/", "/thumbs410/410_"),
                ShortDescription  = this.txtShortDescription.Text,
                IsfreeShipping    = this.ChkisfreeShipping.Checked,
                Description       = (!string.IsNullOrEmpty(text2) && text2.Length > 0) ? text2 : null,
                AddedDate         = System.DateTime.Now,
                BrandId           = this.dropBrandCategories.SelectedValue,
                FirstCommission   = firstCommission,
                SecondCommission  = secondCommission,
                ThirdCommission   = thirdCommission,
                FreightTemplateId = this.ChkisfreeShipping.Checked ? 0 : this.FreightTemplateDownList1.SelectedValue,
                IsSetCommission   = isSetCommission,
                CubicMeter        = cubicMeter,
                FreightWeight     = freightWeight
            };
            ProductSaleStatus saleStatus = ProductSaleStatus.OnSale;

            if (this.radInStock.Checked)
            {
                saleStatus = ProductSaleStatus.OnStock;
            }
            if (this.radUnSales.Checked)
            {
                saleStatus = ProductSaleStatus.UnSale;
            }
            if (this.radOnSales.Checked)
            {
                saleStatus = ProductSaleStatus.OnSale;
            }
            productInfo.SaleStatus = saleStatus;
            CategoryInfo category = CatalogHelper.GetCategory(this.categoryid);

            if (category != null)
            {
                productInfo.MainCategoryPath = category.Path + "|";
            }
            System.Collections.Generic.Dictionary <string, SKUItem> dictionary = null;
            System.Collections.Generic.Dictionary <int, System.Collections.Generic.IList <int> > attrs = null;
            if (this.chkSkuEnabled.Checked)
            {
                decimal minShowPrice = 0m;
                productInfo.HasSKU = true;
                dictionary         = base.GetSkus(this.txtSkus.Text);
                if (dictionary == null)
                {
                    this.ShowMsg("商品规格填写不完整!", false);
                    return;
                }
                decimal[] minSalePrice = new decimal[]
                {
                    79228162514264337593543950335m
                };
                foreach (SKUItem current in from sku in dictionary.Values
                         where sku.SalePrice < minSalePrice[0]
                         select sku)
                {
                    minSalePrice[0] = current.SalePrice;
                }
                minShowPrice = minSalePrice[0];
                decimal[] maxSalePrice = new decimal[]
                {
                    -79228162514264337593543950335m
                };
                foreach (SKUItem current2 in from sku in dictionary.Values
                         where sku.SalePrice > maxSalePrice[0]
                         select sku)
                {
                    maxSalePrice[0] = current2.SalePrice;
                }
                decimal maxShowPrice = maxSalePrice[0];
                productInfo.MinShowPrice = minShowPrice;
                productInfo.MaxShowPrice = maxShowPrice;
            }
            else
            {
                dictionary = new System.Collections.Generic.Dictionary <string, SKUItem>
                {
                    {
                        "0",
                        new SKUItem
                        {
                            SkuId     = "0",
                            SKU       = this.txtSku.Text,
                            SalePrice = num2,
                            CostPrice = num3.HasValue ? num3.Value : 0m,
                            Stock     = stock,
                            Weight    = num4.HasValue ? num4.Value : 0m
                        }
                    }
                };
                if (this.txtMemberPrices.Text.Length > 0)
                {
                    base.GetMemberPrices(dictionary["0"], this.txtMemberPrices.Text);
                }
                productInfo.MinShowPrice = num2;
                productInfo.MaxShowPrice = num2;
            }
            if (!string.IsNullOrEmpty(this.txtAttributes.Text) && this.txtAttributes.Text.Length > 0)
            {
                attrs = base.GetAttributes(this.txtAttributes.Text);
            }
            ValidationResults validationResults = Validation.Validate <ProductInfo>(productInfo);

            if (!validationResults.IsValid)
            {
                this.ShowMsg(validationResults);
                return;
            }
            System.Collections.Generic.IList <int> list = new System.Collections.Generic.List <int>();
            if (!string.IsNullOrEmpty(this.txtProductTag.Text.Trim()))
            {
                string   text3 = this.txtProductTag.Text.Trim();
                string[] array3;
                if (text3.Contains(","))
                {
                    array3 = text3.Split(new char[]
                    {
                        ','
                    });
                }
                else
                {
                    array3 = new string[]
                    {
                        text3
                    };
                }
                string[] array4 = array3;
                for (int i = 0; i < array4.Length; i++)
                {
                    string value = array4[i];
                    list.Add(System.Convert.ToInt32(value));
                }
            }
            if (this.productId > 0)
            {
                ProductInfo productBaseInfo = ProductHelper.GetProductBaseInfo(this.productId);
                productInfo.SaleCounts     = productBaseInfo.SaleCounts;
                productInfo.ShowSaleCounts = productBaseInfo.ShowSaleCounts;
            }
            else
            {
                productInfo.SaleCounts     = 0;
                productInfo.ShowSaleCounts = showSaleCounts;
            }
            if (this.productId > 0)
            {
                ProductActionStatus productActionStatus = ProductHelper.UpdateProduct(productInfo, dictionary, attrs, list);//修改商品详情
                if (productActionStatus == ProductActionStatus.Success)
                {
                    #region 根据商品编号修改积分
                    try
                    {
                        string         sql   = "update Hishop_products set [integral]=@integral,[IntegralCeiling]=@IntegralCeiling,[IntegralToNow]=@IntegralToNow,[ZeroBuy]=@ZeroBuy,[LeaseGood]=@LeaseGood where productId=@productId";//数据库修改积分
                        SqlParameter[] param = new SqlParameter[] {
                            new SqlParameter("@integral", integral),
                            new SqlParameter("@integralCeiling", integralCeiling),
                            new SqlParameter("@IntegralToNow", IntegralToNow),
                            new SqlParameter("@ZeroBuy", ZeroBuy),
                            new SqlParameter("@LeaseGood", LeaseGood),
                            new SqlParameter("@productId", this.productId)
                        };
                        int nums = help.ExecuteNonQuery(sql, CommandType.Text, param);
                        if (nums > 0)
                        {
                        }
                        else
                        {
                            this.ShowMsg(this.operatorName + "商品修改失败!", false);
                            return;
                        }
                    }
                    catch (Exception)
                    {
                        return;

                        throw;
                    }
                    #endregion

                    this.litralProductTag.SelectedValue = list;
                    if (opername == "next")
                    {
                        if (this.isnext != 1)
                        {
                            this.thisUrl = this.thisUrl.Replace("productid=" + this.productId, "productid=" + this.productId + "&isnext=1");
                        }
                        base.Response.Redirect(this.thisUrl);
                        base.Response.End();
                        return;
                    }
                    this.spanJs.InnerHtml = "<script>$('#ctl00_ContentPlaceHolder1_btnSave,#preview,#prevBtn').attr('disabled', 'true');setTimeout(function () { $('#ctl00_ContentPlaceHolder1_btnSave,#preview,#prevBtn').removeAttr('disabled'); }, 5000);</script>";
                    this.ShowMsgAndReUrl(this.operatorName + "商品信息成功!", true, this.reurl);
                    return;
                }
                else
                {
                    if (productActionStatus == ProductActionStatus.AttributeError)
                    {
                        this.ShowMsg(this.operatorName + "商品失败,保存商品属性时出错", false);
                        return;
                    }
                    if (productActionStatus == ProductActionStatus.DuplicateName)
                    {
                        this.ShowMsg(this.operatorName + "商品失败,商品名称不能重复", false);
                        return;
                    }
                    if (productActionStatus == ProductActionStatus.DuplicateSKU)
                    {
                        this.ShowMsg(this.operatorName + "商品失败,商家编码不能重复", false);
                        return;
                    }
                    if (productActionStatus == ProductActionStatus.SKUError)
                    {
                        this.ShowMsg(this.operatorName + "商品失败,商家编码不能重复", false);
                        return;
                    }
                    if (productActionStatus == ProductActionStatus.OffShelfError)
                    {
                        this.ShowMsg(this.operatorName + "商品失败,子站没在零售价范围内的商品无法下架", false);
                        return;
                    }
                    if (productActionStatus == ProductActionStatus.ProductTagEroor)
                    {
                        this.ShowMsg(this.operatorName + "商品失败,保存商品标签时出错", false);
                        return;
                    }
                    this.ShowMsg(this.operatorName + "商品失败,未知错误", false);
                    return;
                }
            }
            else
            {
                string text4 = ProductHelper.AddProductNew(productInfo, dictionary, attrs, list);
                int    num5  = Globals.ToNum(text4);
                if (num5 > 0)
                {
                    base.Response.Redirect("productedit.aspx?productid=" + num5 + "&isnext=1");
                    base.Response.End();
                    return;
                }
                this.ShowMsg(this.operatorName + "商品失败," + text4, false);
                return;
            }
        }//点击事件
示例#16
0
        public static ProductActionStatus UpdateProduct(ProductInfo product, Dictionary <string, SKUItem> skus, Dictionary <int, IList <int> > attrs, IList <int> distributorUserIds)
        {
            if (null == product)
            {
                return(ProductActionStatus.UnknowError);
            }
            Globals.EntityCoding(product, true);
            int decimalLength = HiContext.Current.SiteSettings.DecimalLength;

            if (product.MarketPrice.HasValue)
            {
                product.MarketPrice = new decimal?(Math.Round(product.MarketPrice.Value, decimalLength));
            }
            product.LowestSalePrice = Math.Round(product.LowestSalePrice, decimalLength);
            ProductActionStatus unknowError = ProductActionStatus.UnknowError;

            using (DbConnection connection = DatabaseFactory.CreateDatabase().CreateConnection())
            {
                connection.Open();
                DbTransaction dbTran = connection.BeginTransaction();
                try
                {
                    ProductProvider provider = ProductProvider.Instance();
                    if (!provider.UpdateProduct(product, dbTran))
                    {
                        dbTran.Rollback();
                        return(ProductActionStatus.DuplicateSKU);
                    }
                    if (!provider.DeleteProductSKUS(product.ProductId, dbTran))
                    {
                        dbTran.Rollback();
                        return(ProductActionStatus.SKUError);
                    }
                    if (((skus != null) && (skus.Count > 0)) && !provider.AddProductSKUs(product.ProductId, skus, dbTran))
                    {
                        dbTran.Rollback();
                        return(ProductActionStatus.SKUError);
                    }
                    if (!provider.AddProductAttributes(product.ProductId, attrs, dbTran))
                    {
                        dbTran.Rollback();
                        return(ProductActionStatus.AttributeError);
                    }
                    if (!provider.OffShelfProductExcludedSalePrice(product.ProductId, product.LowestSalePrice, dbTran))
                    {
                        dbTran.Rollback();
                        return(ProductActionStatus.OffShelfError);
                    }
                    dbTran.Commit();
                    unknowError = ProductActionStatus.Success;
                }
                catch (Exception)
                {
                    dbTran.Rollback();
                }
                finally
                {
                    connection.Close();
                }
            }
            if (unknowError == ProductActionStatus.Success)
            {
                ProductProvider.Instance().DeleteSkuUnderlingPrice();
                if (product.PenetrationStatus == PenetrationStatus.Notyet)
                {
                    List <int> productIds = new List <int>();
                    productIds.Add(product.ProductId);
                    DeleteCanclePenetrationProducts(productIds, null);
                }
                if ((distributorUserIds != null) && (distributorUserIds.Count != 0))
                {
                    foreach (int num2 in distributorUserIds)
                    {
                        DeleteNotinProductLines(num2);
                    }
                }
                EventLogs.WriteOperationLog(Privilege.EditProducts, string.Format(CultureInfo.InvariantCulture, "修改了编号为 “{0}” 的商品", new object[] { product.ProductId }));
            }
            return(unknowError);
        }
示例#17
0
        private void btnSave_Click(object sender, System.EventArgs e)
        {
            if (this.categoryId == 0)
            {
                this.categoryId = (int)this.ViewState["ProductCategoryId"];
            }
            int     displaySequence;
            decimal salePrice;
            decimal?costPrice;
            decimal?marketPrice;
            int     stock;
            int     factstock;
            decimal?num3;
            decimal?referralDeduct;
            decimal?subMemberDeduct;
            decimal?subReferralDeduct;
            decimal?deductFee;
            int     buyCardinality;
            decimal?grossweight;

            if (!this.ValidateConverts(this.chkSkuEnabled.Checked, out displaySequence, out salePrice, out costPrice, out marketPrice, out stock, out factstock, out num3, out referralDeduct, out subMemberDeduct, out subReferralDeduct, out deductFee, out buyCardinality, out grossweight))
            {
                return;
            }
            decimal adminFraction = 0m;

            if (string.IsNullOrWhiteSpace(txtAdminFraction.Text) || !decimal.TryParse(txtAdminFraction.Text, out adminFraction))
            {
                this.ShowMsg("请输入正确的提升权重值", false);
                return;
            }
            int ConversionRelation;

            if (!int.TryParse(this.txtConversionRelation.Text, out ConversionRelation))
            {
                this.ShowMsg("输入换算关系不正确", false);
                return;
            }
            string text = Globals.StripScriptTags(this.txtProductName.Text.Trim());

            text = Globals.StripHtmlXmlTags(text).Replace("\\", "").Replace("'", "");
            if (string.IsNullOrEmpty(text) || text == "")
            {
                this.ShowMsg("商品名称不能为空,且不能包含脚本标签、HTML标签、XML标签、反斜杠(\\)、单引号(')!", false);
                return;
            }
            if (!this.chkSkuEnabled.Checked)
            {
                if (salePrice <= 0m)
                {
                    this.ShowMsg("商品一口价必须大于0", false);
                    return;
                }
                if (costPrice.HasValue && (costPrice.Value > salePrice || costPrice.Value < 0m))
                {
                    this.ShowMsg("商品成本价必须大于0且小于商品一口价", false);
                    return;
                }
                if (!costPrice.HasValue)              //|| !deductFee.HasValue
                {
                    this.ShowMsg("商品成本价不能为空", false); //与扣点
                    return;
                }
                if (string.IsNullOrEmpty(txtProductStandard.Text))
                {
                    this.ShowMsg("未开启多规格时,商品规格必填", false);
                    return;
                }
            }
            //判断是否存在广告关键字
            Dictionary <string, string> msg;

            if (!ValidateKeyWordHelper.ValidateKeyWord(new Dictionary <string, string>()
            {
                { "商品名称", this.txtProductName.Text }, { "商品简介", this.txtShortDescription.Text }
            }, out msg))
            {
                string showM = "";
                foreach (string k in msg.Keys)
                {
                    showM += k + "中不能包含广告词:" + msg[k] + ";";
                }
                this.ShowMsg(showM, false);
                return;
            }



            string text2 = this.fckDescription.Text;
            string text3 = this.fckmobbileDescription.Text;

            if (this.ckbIsDownPic.Checked)
            {
                text2 = base.DownRemotePic(text2);
                text3 = base.DownRemotePic(text3);
            }

            System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex("<script[^>]*?>.*?</script>", System.Text.RegularExpressions.RegexOptions.IgnoreCase);


            ProductInfo productInfo = ProductHelper.GetProductDetails(this.productId);


            if (productInfo.ConversionRelation != ConversionRelation)
            {
                if (productInfo.Stock > 0)
                {
                    this.ShowMsg("销售库存大于0不允许修改换算系数", false);
                    return;
                }
            }
            //ProductInfo productInfo = new ProductInfo
            //{
            productInfo.ProductId          = this.productId;
            productInfo.CategoryId         = this.categoryId;
            productInfo.TypeId             = this.dropProductTypes.SelectedValue;
            productInfo.ProductName        = text;
            productInfo.ProductCode        = this.txtProductCode.Text;
            productInfo.AdminFraction      = adminFraction;
            productInfo.DisplaySequence    = displaySequence;
            productInfo.MarketPrice        = marketPrice;
            productInfo.Unit               = this.ddlUnit.SelectedItem.Text;
            productInfo.ImageUrl1          = this.uploader1.UploadedImageUrl;
            productInfo.ImageUrl2          = this.uploader2.UploadedImageUrl;
            productInfo.ImageUrl3          = this.uploader3.UploadedImageUrl;
            productInfo.ImageUrl4          = this.uploader4.UploadedImageUrl;
            productInfo.ImageUrl5          = this.uploader5.UploadedImageUrl;
            productInfo.ThumbnailUrl40     = this.uploader1.ThumbnailUrl40;
            productInfo.ThumbnailUrl60     = this.uploader1.ThumbnailUrl60;
            productInfo.ThumbnailUrl100    = this.uploader1.ThumbnailUrl100;
            productInfo.ThumbnailUrl160    = this.uploader1.ThumbnailUrl160;
            productInfo.ThumbnailUrl180    = this.uploader1.ThumbnailUrl180;
            productInfo.ThumbnailUrl220    = this.uploader1.ThumbnailUrl220;
            productInfo.ThumbnailUrl310    = this.uploader1.ThumbnailUrl310;
            productInfo.ThumbnailUrl410    = this.uploader1.ThumbnailUrl410;
            productInfo.ShortDescription   = this.txtShortDescription.Text;
            productInfo.IsfreeShipping     = this.ChkisfreeShipping.Checked;
            productInfo.IsCustomsClearance = this.ChkisCustomsClearance.Checked;

            productInfo.IsDisplayDiscount = this.ChkisDisplayDiscount.Checked;

            productInfo.IsPromotion = this.ChkisPromotion.Checked;

            productInfo.Description        = (!string.IsNullOrEmpty(text2) && text2.Length > 0) ? regex.Replace(text2, "") : null;
            productInfo.MobblieDescription = (!string.IsNullOrEmpty(text3) && text3.Length > 0) ? regex.Replace(text3, "") : null;
            productInfo.Title              = this.txtTitle.Text;
            productInfo.MetaDescription    = this.txtMetaDescription.Text;
            productInfo.MetaKeywords       = this.txtMetaKeywords.Text;
            productInfo.AddedDate          = System.DateTime.Now;
            productInfo.BrandId            = this.dropBrandCategories.SelectedValue;
            productInfo.ReferralDeduct     = referralDeduct;
            productInfo.SubMemberDeduct    = subMemberDeduct;
            productInfo.SubReferralDeduct  = subReferralDeduct;
            productInfo.TaxRateId          = this.dropTaxRate.SelectedValue;
            productInfo.TemplateId         = this.ddlShipping.SelectedValue;
            productInfo.SupplierId         = this.ddlSupplier.SelectedValue;
            productInfo.ImportSourceId     = this.ddlImportSourceType.SelectedValue;
            productInfo.BuyCardinality     = buyCardinality;
            productInfo.UnitCode           = this.ddlUnit.SelectedValue;
            productInfo.Manufacturer       = txtManufacturer.Text;
            productInfo.ItemNo             = txtItemNo.Text;
            productInfo.BarCode            = txtBarCode.Text;
            productInfo.Ingredient         = txtIngredient.Text;
            productInfo.ProductStandard    = txtProductStandard.Text;
            productInfo.ConversionRelation = ConversionRelation;
            productInfo.ProductTitle       = this.txtProductTitle.Text;//商品副标题
            productInfo.SaleType           = string.IsNullOrWhiteSpace(this.dropSaleType.SelectedValue) ? 1 : Convert.ToInt32(this.dropSaleType.SelectedValue);
            productInfo.EnglishName        = this.txtEnglishName.Text;
            productInfo.SysProductName     = this.txtsysProductName.Text;
            productInfo.Purchase           = int.Parse(this.Rd_Purchase.SelectedValue);
            productInfo.SectionDay         = int.Parse(this.txtSectionDay.Text);
            productInfo.PurchaseMaxNum     = int.Parse(this.txtMaxCount.Text.ToString());

            //};
            ProductSaleStatus saleStatus = ProductSaleStatus.OnSale;

            if (this.radInStock.Checked)
            {
                saleStatus = ProductSaleStatus.OnStock;
            }
            if (this.radUnSales.Checked)
            {
                saleStatus = ProductSaleStatus.UnSale;
            }
            if (this.radOnSales.Checked)
            {
                saleStatus = ProductSaleStatus.OnSale;

                if (productInfo.SaleStatus != ProductSaleStatus.OnSale && ProductHelper.IsExitNoClassifyProduct(this.productId.ToString()))
                {
                    if (productInfo.SaleType != 2)
                    {
                        this.ShowMsg("商品还未完成归类操作,不能出售", false);
                        return;
                    }
                }
            }
            productInfo.SaleStatus = saleStatus;
            CategoryInfo category = CatalogHelper.GetCategory(this.categoryId);

            if (category != null)
            {
                productInfo.MainCategoryPath = category.Path + "|";
            }
            System.Collections.Generic.Dictionary <int, System.Collections.Generic.IList <int> > attrs = null;
            System.Collections.Generic.Dictionary <string, SKUItem> dictionary;
            if (this.chkSkuEnabled.Checked)
            {
                productInfo.HasSKU = true;
                dictionary         = base.GetSkus(this.txtSkus.Text);

                if (!string.IsNullOrEmpty(ArrhidProductRegistrationNumber.Value))
                {
                    Dictionary <string, string>[] dic = Newtonsoft.Json.JsonConvert.DeserializeObject <Dictionary <string, string>[]>(ArrhidProductRegistrationNumber.Value);

                    foreach (string item in dictionary.Keys)
                    {
                        foreach (Dictionary <string, string> d in dic)
                        {
                            if (d["SKU"] == dictionary[item].SKU)
                            {
                                dictionary[item].ProductRegistrationNumber = d["ProductRegistrationNumber"];
                                dictionary[item].LJNo = d["LJNo"];
                                int wmsstock;
                                int.TryParse(d["WMSStock"], out wmsstock);
                                dictionary[item].WMSStock = wmsstock;
                                //decimal dcgrossweight=0m;
                                //decimal.TryParse(d["GrossWeight"], out dcgrossweight);
                                //dictionary[item].GrossWeight = dcgrossweight;
                                //decimal dcweight = 0m;
                                //decimal.TryParse(d["Weight"], out dcweight);
                                //dictionary[item].Weight = dcweight;
                                break;
                            }
                        }
                    }
                }
            }
            else
            {
                AutoCalcCostPriceAndDeductFee(salePrice, ref costPrice, ref deductFee);
                dictionary = new System.Collections.Generic.Dictionary <string, SKUItem>
                {
                    {
                        "0",
                        new SKUItem
                        {
                            SkuId     = "0",
                            SKU       = Globals.HtmlEncode(Globals.StripScriptTags(this.txtSku.Text.Trim()).Replace("\\", "")),
                            SalePrice = salePrice,
                            CostPrice = costPrice.HasValue ? costPrice.Value : 0m,
                            Stock     = stock,
                            FactStock = factstock,
                            Weight    = num3.HasValue ? num3.Value : 0m,
                            DeductFee = deductFee.HasValue ? deductFee.Value : 0m,
                            ProductRegistrationNumber = hidProductRegistrationNumber.Value,
                            LJNo        = hidLJNo.Value,
                            WMSStock    = productInfo.DefaultSku.WMSStock,
                            GrossWeight = grossweight.HasValue?grossweight.Value:0m
                        }
                    }
                };
                if (this.txtMemberPrices.Text.Length > 0)
                {
                    base.GetMemberPrices(dictionary["0"], this.txtMemberPrices.Text);
                }
            }
            if (!string.IsNullOrEmpty(this.txtAttributes.Text) && this.txtAttributes.Text.Length > 0)
            {
                attrs = base.GetAttributes(this.txtAttributes.Text);
            }
            ValidationResults validationResults = Validation.Validate <ProductInfo>(productInfo);

            if (!validationResults.IsValid)
            {
                this.ShowMsg(validationResults);
                return;
            }
            System.Collections.Generic.IList <int> list = new System.Collections.Generic.List <int>();
            if (!string.IsNullOrEmpty(this.txtProductTag.Text.Trim()))
            {
                string   text4 = this.txtProductTag.Text.Trim();
                string[] array;
                if (text4.Contains(","))
                {
                    array = text4.Split(new char[]
                    {
                        ','
                    });
                }
                else
                {
                    array = new string[]
                    {
                        text4
                    };
                }
                string[] array2 = array;
                for (int i = 0; i < array2.Length; i++)
                {
                    string value = array2[i];
                    list.Add(System.Convert.ToInt32(value));
                }
            }

            #region   ==组合商品
            List <ProductsCombination> combinations = new List <ProductsCombination>();
            string   combinationInfos = base.Request.Form["selectProductsinfo"];
            string[] curCom           = combinationInfos.Split(new char[]
            {
                ','
            });
            string[] curCom2 = curCom;
            for (int i = 0; i < curCom2.Length; i++)
            {
                string combinationInfo     = curCom2[i];
                ProductsCombination com    = new ProductsCombination();
                string[]            array3 = combinationInfo.Split(new char[]
                {
                    '|'
                });
                if (array3.Length == 10)
                {
                    com.SkuId         = array3[0];
                    com.ProductId     = array3[1] == "" ? 0 : Convert.ToInt32(array3[1]);
                    com.ProductName   = array3[2];
                    com.ThumbnailsUrl = array3[3];
                    decimal tempweight;
                    if (decimal.TryParse(array3[4], out tempweight))
                    {
                        com.Weight = tempweight;
                    }
                    com.SKU        = array3[5];
                    com.SKUContent = array3[6];
                    com.Quantity   = array3[8] == "" ? 0 : Convert.ToInt32(array3[8]);
                    decimal tempprice;
                    if (decimal.TryParse(array3[9], out tempprice))
                    {
                        com.Price = tempprice;
                    }
                    combinations.Add(com);
                }
            }
            productInfo.CombinationItemInfos = combinations;
            #endregion

            if (productInfo.SaleType == 2)
            {
                decimal CombinationTotalPrice = 0M;
                foreach (var item in productInfo.CombinationItemInfos)
                {
                    CombinationTotalPrice += item.Price * item.Quantity;
                }

                if (Math.Round(CombinationTotalPrice, 2) != Math.Round(salePrice, 2))
                {
                    this.ShowMsg("添加商品失败,组合商品一口价和组合商品明细总价不一致", false);
                    return;
                }
            }

            ProductActionStatus productActionStatus = ProductHelper.UpdateProduct(productInfo, dictionary, attrs, list, combinations);
            if (productActionStatus == ProductActionStatus.Success)
            {
                this.litralProductTag.SelectedValue = list;
                this.ShowMsg("修改商品成功", true);
                base.Response.Redirect(Globals.GetAdminAbsolutePath(string.Format("/product/AddProductComplete.aspx?categoryId={0}&productId={1}&IsEdit=1", this.categoryId, productInfo.ProductId)), true);
                return;
            }
            if (productActionStatus == ProductActionStatus.AttributeError)
            {
                this.ShowMsg("修改商品失败,保存商品属性时出错", false);
                return;
            }
            if (productActionStatus == ProductActionStatus.DuplicateName)
            {
                this.ShowMsg("修改商品失败,商品名称不能重复", false);
                return;
            }
            if (productActionStatus == ProductActionStatus.DuplicateSKU)
            {
                this.ShowMsg("修改商品失败,商家编码不能重复", false);
                return;
            }
            if (productActionStatus == ProductActionStatus.SKUError)
            {
                this.ShowMsg("修改商品失败,商家编码不能重复", false);
                return;
            }
            if (productActionStatus == ProductActionStatus.ProductTagEroor)
            {
                this.ShowMsg("修改商品失败,保存商品标签时出错", false);
                return;
            }
            this.ShowMsg("修改商品失败,未知错误", false);
        }