Exemple #1
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);
        }
Exemple #2
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);
        }