Пример #1
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            IList <int> list2;

            if (this.categoryId == 0)
            {
                this.categoryId = (int)this.ViewState["ProductCategoryId"];
            }
            if (this.categoryId == 0)
            {
                this.ShowMsg("请选择商品分类", false);
                return;
            }
            ProductInfo product = new ProductInfo();

            product.ProductId  = this.productId;
            product.CategoryId = this.categoryId;
            CategoryInfo category = SubsiteCatalogHelper.GetCategory(product.CategoryId);

            if (category != null)
            {
                product.MainCategoryPath = category.Path + "|";
            }
            product.ProductName      = this.txtProductName.Text;
            product.ShortDescription = this.txtShortDescription.Text;
            product.Description      = this.fckDescription.Text;
            product.Title            = this.txtTitle.Text;
            product.MetaDescription  = this.txtMetaDescription.Text;
            product.MetaKeywords     = this.txtMetaKeywords.Text;
            if (!string.IsNullOrEmpty(this.txtMarketPrice.Text))
            {
                product.MarketPrice = new decimal?(decimal.Parse(this.txtMarketPrice.Text));
            }
            Dictionary <string, decimal> skuSalePrice = null;

            if (!string.IsNullOrEmpty(this.txtSkuPrice.Text))
            {
                skuSalePrice = this.GetSkuPrices();
            }
            ProductSaleStatus onStock = ProductSaleStatus.OnStock;

            if (this.radInStock.Checked)
            {
                onStock = ProductSaleStatus.OnStock;
            }
            if (this.radUnSales.Checked)
            {
                onStock = ProductSaleStatus.UnSale;
            }
            if (this.radOnSales.Checked)
            {
                onStock = ProductSaleStatus.OnSale;
            }
            if (onStock != ProductSaleStatus.OnSale)
            {
                goto Label_0221;
            }
            bool        flag     = false;
            XmlDocument document = new XmlDocument();

            try
            {
                document.LoadXml(this.txtSkuPrice.Text);
                XmlNodeList list = document.SelectNodes("//item");
                if ((list != null) && (list.Count > 0))
                {
                    foreach (XmlNode node in list)
                    {
                        if (decimal.Parse(node.Attributes["price"].Value) < decimal.Parse(this.litLowestSalePrice.Text))
                        {
                            flag = true;
                            goto Label_0210;
                        }
                    }
                }
            }
            catch
            {
            }
Label_0210:
            if (flag)
            {
                this.ShowMsg("此商品的一口价已经低于了最低零售价,不允许上架", false);
                return;
            }
Label_0221:
            list2 = new List <int>();
            if (!string.IsNullOrEmpty(this.txtProductTag.Text.Trim()))
            {
                string   str      = this.txtProductTag.Text.Trim();
                string[] strArray = null;
                if (str.Contains(","))
                {
                    strArray = str.Split(new char[] { ',' });
                }
                else
                {
                    strArray = new string[] { str };
                }
                foreach (string str2 in strArray)
                {
                    list2.Add(Convert.ToInt32(str2));
                }
            }
            product.SaleStatus = onStock;
            int result = 0;

            int.TryParse(this.txtDisplaySequence.Text, out result);
            product.DisplaySequence = result;
            if (SubSiteProducthelper.UpdateProduct(product, skuSalePrice, list2))
            {
                this.litralProductTag.SelectedValue = list2;
                this.ShowMsg("修改商品成功", true);
            }
        }
Пример #2
0
        /// <summary>
        /// 更新按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            if (categoryId == 0)
            {
                categoryId = (int)ViewState["ProductCategoryId"];
            }

            if (categoryId == 0)
            {
                ShowMsg("请选择店铺分类", false);
                return;
            }

            ProductInfo product = new ProductInfo();

            product.ProductId  = productId;
            product.CategoryId = categoryId;

            CategoryInfo category = SubsiteCatalogHelper.GetCategory(product.CategoryId);

            if (category != null)
            {
                product.MainCategoryPath = category.Path + "|";
            }

            product.ProductName      = txtProductName.Text;
            product.ShortDescription = txtShortDescription.Text;
            product.Description      = fckDescription.Text;
            product.Title            = txtTitle.Text;
            product.MetaDescription  = txtMetaDescription.Text;
            product.MetaKeywords     = txtMetaKeywords.Text;
            product.DisplaySequence  = int.Parse(txtDisplaySequence.Text);

            if (!string.IsNullOrEmpty(txtMarketPrice.Text))
            {
                product.MarketPrice = new decimal?(decimal.Parse(txtMarketPrice.Text));
            }

            Dictionary <string, decimal> skuSalePrice = null;

            if (!string.IsNullOrEmpty(txtSkuPrice.Text))
            {
                skuSalePrice = GetSkuPrices();
            }

            ProductSaleStatus onStock = ProductSaleStatus.OnStock;

            if (radInStock.Checked)
            {
                onStock = ProductSaleStatus.OnStock;
            }

            if (radUnSales.Checked)
            {
                onStock = ProductSaleStatus.UnSale;
            }

            if (radOnSales.Checked)
            {
                onStock = ProductSaleStatus.OnSale;

                XmlDocument document = new XmlDocument();

                document.LoadXml(txtSkuPrice.Text);

                XmlNodeList list = document.SelectNodes("//item");

                if ((list != null) && (list.Count > 0))
                {
                    foreach (XmlNode node in list)
                    {
                        if (decimal.Parse(node.Attributes["price"].Value) < decimal.Parse(litLowestSalePrice.Text))
                        {
                            ShowMsg("此商品的一口价已经低于了最低零售价,不允许上架", false);
                            return;
                        }
                    }
                }
            }

            product.SaleStatus = onStock;

            if (SubSiteProducthelper.UpdateProduct(product, skuSalePrice))
            {
                ShowMsg("修改商品成功", true);
            }
            else
            {
                ShowMsg("修改商品失败", false);
            }
        }
Пример #3
0
        private void btnUpdate_Click(object sender, System.EventArgs e)
        {
            if (this.categoryId == 0)
            {
                this.categoryId = (int)this.ViewState["ProductCategoryId"];
            }
            if (this.categoryId == 0)
            {
                this.ShowMsg("请选择商品分类", false);
                return;
            }
            ProductInfo productInfo = new ProductInfo();

            productInfo.ProductId  = this.productId;
            productInfo.CategoryId = this.categoryId;
            CategoryInfo category = SubsiteCatalogHelper.GetCategory(productInfo.CategoryId);

            if (category != null)
            {
                productInfo.MainCategoryPath = category.Path + "|";
            }
            productInfo.ProductName      = this.txtProductName.Text;
            productInfo.ShortDescription = this.txtShortDescription.Text;
            productInfo.Description      = this.fckDescription.Text;
            productInfo.Title            = this.txtTitle.Text;
            productInfo.MetaDescription  = this.txtMetaDescription.Text;
            productInfo.MetaKeywords     = this.txtMetaKeywords.Text;
            if (!string.IsNullOrEmpty(this.txtMarketPrice.Text))
            {
                productInfo.MarketPrice = new decimal?(decimal.Parse(this.txtMarketPrice.Text));
            }
            System.Collections.Generic.Dictionary <string, decimal> skuSalePrice = null;
            if (!string.IsNullOrEmpty(this.txtSkuPrice.Text))
            {
                skuSalePrice = this.GetSkuPrices();
            }
            ProductSaleStatus productSaleStatus = ProductSaleStatus.OnStock;

            if (this.radInStock.Checked)
            {
                productSaleStatus = ProductSaleStatus.OnStock;
            }
            if (this.radUnSales.Checked)
            {
                productSaleStatus = ProductSaleStatus.UnSale;
            }
            if (this.radOnSales.Checked)
            {
                productSaleStatus = ProductSaleStatus.OnSale;
            }
            if (productSaleStatus == ProductSaleStatus.OnSale)
            {
                bool flag = false;
                System.Xml.XmlDocument xmlDocument = new System.Xml.XmlDocument();
                try
                {
                    xmlDocument.LoadXml(this.txtSkuPrice.Text);
                    System.Xml.XmlNodeList xmlNodeList = xmlDocument.SelectNodes("//item");
                    if (xmlNodeList != null && xmlNodeList.Count > 0)
                    {
                        foreach (System.Xml.XmlNode xmlNode in xmlNodeList)
                        {
                            decimal d = decimal.Parse(xmlNode.Attributes["price"].Value);
                            if (d < decimal.Parse(this.litLowestSalePrice.Text))
                            {
                                flag = true;
                                break;
                            }
                        }
                    }
                }
                catch
                {
                }
                if (flag)
                {
                    this.ShowMsg("此商品的一口价已经低于了最低零售价,不允许上架", false);
                    return;
                }
            }
            System.Collections.Generic.IList <int> list = new System.Collections.Generic.List <int>();
            if (!string.IsNullOrEmpty(this.txtProductTag.Text.Trim()))
            {
                string   text = this.txtProductTag.Text.Trim();
                string[] array;
                if (text.Contains(","))
                {
                    array = text.Split(new char[]
                    {
                        ','
                    });
                }
                else
                {
                    array = new string[]
                    {
                        text
                    };
                }
                string[] array2 = array;
                for (int i = 0; i < array2.Length; i++)
                {
                    string value = array2[i];
                    list.Add(System.Convert.ToInt32(value));
                }
            }
            productInfo.SaleStatus = productSaleStatus;
            int displaySequence = 0;

            int.TryParse(this.txtDisplaySequence.Text, out displaySequence);
            productInfo.DisplaySequence = displaySequence;
            if (SubSiteProducthelper.UpdateProduct(productInfo, skuSalePrice, list))
            {
                this.litralProductTag.SelectedValue = list;
                this.ShowMsg("修改商品成功", true);
            }
        }