Exemplo n.º 1
0
 public static ProductActionStatus AddProduct(ProductInfo product, Dictionary<string, SKUItem> skus, Dictionary<int, IList<int>> attrs, IList<int> tagsId)
 {
     if (null == product)
     {
         return ProductActionStatus.UnknowError;
     }
     Globals.EntityCoding(product, true);
     int decimalLength = SettingsManager.GetMasterSettings(true).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))
             {
                 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;
 }
Exemplo n.º 2
0
 public int AddProduct(ProductInfo product, DbTransaction dbTran)
 {
     DbCommand storedProcCommand = this.database.GetStoredProcCommand("cp_Product_Create");
     this.database.AddInParameter(storedProcCommand, "CategoryId", DbType.Int32, product.CategoryId);
     this.database.AddInParameter(storedProcCommand, "MainCategoryPath", DbType.String, product.MainCategoryPath);
     this.database.AddInParameter(storedProcCommand, "TypeId", DbType.Int32, product.TypeId);
     this.database.AddInParameter(storedProcCommand, "ProductName", DbType.String, product.ProductName);
     this.database.AddInParameter(storedProcCommand, "ProductCode", DbType.String, product.ProductCode);
     this.database.AddInParameter(storedProcCommand, "ShortDescription", DbType.String, product.ShortDescription);
     this.database.AddInParameter(storedProcCommand, "Unit", DbType.String, product.Unit);
     this.database.AddInParameter(storedProcCommand, "Description", DbType.String, product.Description);
     this.database.AddInParameter(storedProcCommand, "SaleStatus", DbType.Int32, (int) product.SaleStatus);
     this.database.AddInParameter(storedProcCommand, "AddedDate", DbType.DateTime, product.AddedDate);
     this.database.AddInParameter(storedProcCommand, "ImageUrl1", DbType.String, product.ImageUrl1);
     this.database.AddInParameter(storedProcCommand, "ImageUrl2", DbType.String, product.ImageUrl2);
     this.database.AddInParameter(storedProcCommand, "ImageUrl3", DbType.String, product.ImageUrl3);
     this.database.AddInParameter(storedProcCommand, "ImageUrl4", DbType.String, product.ImageUrl4);
     this.database.AddInParameter(storedProcCommand, "ImageUrl5", DbType.String, product.ImageUrl5);
     this.database.AddInParameter(storedProcCommand, "ThumbnailUrl40", DbType.String, product.ThumbnailUrl40);
     this.database.AddInParameter(storedProcCommand, "ThumbnailUrl60", DbType.String, product.ThumbnailUrl60);
     this.database.AddInParameter(storedProcCommand, "ThumbnailUrl100", DbType.String, product.ThumbnailUrl100);
     this.database.AddInParameter(storedProcCommand, "ThumbnailUrl160", DbType.String, product.ThumbnailUrl160);
     this.database.AddInParameter(storedProcCommand, "ThumbnailUrl180", DbType.String, product.ThumbnailUrl180);
     this.database.AddInParameter(storedProcCommand, "ThumbnailUrl220", DbType.String, product.ThumbnailUrl220);
     this.database.AddInParameter(storedProcCommand, "ThumbnailUrl310", DbType.String, product.ThumbnailUrl310);
     this.database.AddInParameter(storedProcCommand, "ThumbnailUrl410", DbType.String, product.ThumbnailUrl410);
     this.database.AddInParameter(storedProcCommand, "MarketPrice", DbType.Currency, product.MarketPrice);
     this.database.AddInParameter(storedProcCommand, "BrandId", DbType.Int32, product.BrandId);
     this.database.AddInParameter(storedProcCommand, "HasSKU", DbType.Boolean, product.HasSKU);
     this.database.AddInParameter(storedProcCommand, "IsfreeShipping", DbType.Boolean, product.IsfreeShipping);
     this.database.AddInParameter(storedProcCommand, "TaobaoProductId", DbType.Int64, product.TaobaoProductId);
     this.database.AddOutParameter(storedProcCommand, "ProductId", DbType.Int32, 4);
     this.database.ExecuteNonQuery(storedProcCommand, dbTran);
     return (int) this.database.GetParameterValue(storedProcCommand, "ProductId");
 }
Exemplo n.º 3
0
        private void BindImages(ProductInfo prductImageInfo)
        {
            productName.Text = prductImageInfo.ProductName;

            productName.NavigateUrl = Utils.ApplicationPath + "/ProductDetails.aspx?ProductId=" + prductImageInfo.ProductId;

            imgBig.Src = image1url.Value = Utils.ApplicationPath + prductImageInfo.ImageUrl1;

            image2url.Value = Utils.ApplicationPath + prductImageInfo.ImageUrl2;

            image3url.Value = Utils.ApplicationPath + prductImageInfo.ImageUrl3;

            image4url.Value = Utils.ApplicationPath + prductImageInfo.ImageUrl4;

            image5url.Value = Utils.ApplicationPath + prductImageInfo.ImageUrl5;

            if (!string.IsNullOrEmpty(prductImageInfo.ImageUrl1))
            {
                image1.ImageUrl = prductImageInfo.ImageUrl1.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs40/40_");
            }

            if (!string.IsNullOrEmpty(prductImageInfo.ImageUrl2))
            {
                image2.ImageUrl = prductImageInfo.ImageUrl2.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs40/40_");
            }

            if (!string.IsNullOrEmpty(prductImageInfo.ImageUrl3))
            {
                image3.ImageUrl = prductImageInfo.ImageUrl3.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs40/40_");
            }

            if (!string.IsNullOrEmpty(prductImageInfo.ImageUrl4))
            {
                image4.ImageUrl = prductImageInfo.ImageUrl4.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs40/40_");
            }

            if (!string.IsNullOrEmpty(prductImageInfo.ImageUrl5))
            {
                image5.ImageUrl = prductImageInfo.ImageUrl5.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs40/40_");
            }

            if ((((prductImageInfo.ImageUrl1 == null) && (prductImageInfo.ImageUrl2 == null)) && ((prductImageInfo.ImageUrl3 == null) && (prductImageInfo.ImageUrl4 == null))) && (prductImageInfo.ImageUrl5 == null))
            {
                SiteSettings masterSettings = SettingsManager.GetMasterSettings(true);
                imgBig.Src = Globals.ApplicationPath + masterSettings.DefaultProductImage;
                imgBig.Align = "center";
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// 商品加载
 /// </summary>
 /// <param name="product"></param>
 void LoadProudct(ProductInfo product)
 {
     txtProductName.Text = product.ProductName;
     txtDisplaySequence.Text = product.DisplaySequence.ToString();
     litLowestSalePrice.Text = product.LowestSalePrice.ToString("F2");
     if (product.MarketPrice.HasValue)
     {
         txtMarketPrice.Text = product.MarketPrice.Value.ToString("F2");
     }
     litProductCode.Text = product.ProductCode;
     litUnit.Text = product.Unit;
     txtShortDescription.Text = product.ShortDescription;
     fckDescription.Text = product.Description;
     txtTitle.Text = product.Title;
     txtMetaDescription.Text = product.MetaDescription;
     txtMetaKeywords.Text = product.MetaKeywords;
     if (product.SaleStatus == ProductSaleStatus.OnSale)
     {
         radOnSales.Checked = true;
     }
     else if (product.SaleStatus == ProductSaleStatus.UnSale)
     {
         radUnSales.Checked = true;
     }
     else
     {
         radInStock.Checked = true;
     }
     uploader1.UploadedImageUrl = product.ImageUrl1;
     uploader2.UploadedImageUrl = product.ImageUrl2;
     uploader3.UploadedImageUrl = product.ImageUrl3;
     uploader4.UploadedImageUrl = product.ImageUrl4;
     uploader5.UploadedImageUrl = product.ImageUrl5;
 }
Exemplo n.º 5
0
 static void DeleteProductImage(ProductInfo product)
 {
     if (product != null)
     {
         if (!string.IsNullOrEmpty(product.ImageUrl1))
         {
             ResourcesHelper.DeleteImage(product.ImageUrl1);
             ResourcesHelper.DeleteImage(product.ImageUrl1.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs40/40_"));
             ResourcesHelper.DeleteImage(product.ImageUrl1.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs60/60_"));
             ResourcesHelper.DeleteImage(product.ImageUrl1.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs100/100_"));
             ResourcesHelper.DeleteImage(product.ImageUrl1.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs160/160_"));
             ResourcesHelper.DeleteImage(product.ImageUrl1.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs180/180_"));
             ResourcesHelper.DeleteImage(product.ImageUrl1.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs220/220_"));
             ResourcesHelper.DeleteImage(product.ImageUrl1.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs310/310_"));
             ResourcesHelper.DeleteImage(product.ImageUrl1.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs410/410_"));
         }
         if (!string.IsNullOrEmpty(product.ImageUrl2))
         {
             ResourcesHelper.DeleteImage(product.ImageUrl2);
             ResourcesHelper.DeleteImage(product.ImageUrl2.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs40/40_"));
             ResourcesHelper.DeleteImage(product.ImageUrl2.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs60/60_"));
             ResourcesHelper.DeleteImage(product.ImageUrl2.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs100/100_"));
             ResourcesHelper.DeleteImage(product.ImageUrl2.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs160/160_"));
             ResourcesHelper.DeleteImage(product.ImageUrl2.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs180/180_"));
             ResourcesHelper.DeleteImage(product.ImageUrl2.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs220/220_"));
             ResourcesHelper.DeleteImage(product.ImageUrl2.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs310/310_"));
             ResourcesHelper.DeleteImage(product.ImageUrl2.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs410/410_"));
         }
         if (!string.IsNullOrEmpty(product.ImageUrl3))
         {
             ResourcesHelper.DeleteImage(product.ImageUrl3);
             ResourcesHelper.DeleteImage(product.ImageUrl3.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs40/40_"));
             ResourcesHelper.DeleteImage(product.ImageUrl3.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs60/60_"));
             ResourcesHelper.DeleteImage(product.ImageUrl3.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs100/100_"));
             ResourcesHelper.DeleteImage(product.ImageUrl3.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs160/160_"));
             ResourcesHelper.DeleteImage(product.ImageUrl3.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs180/180_"));
             ResourcesHelper.DeleteImage(product.ImageUrl3.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs220/220_"));
             ResourcesHelper.DeleteImage(product.ImageUrl3.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs310/310_"));
             ResourcesHelper.DeleteImage(product.ImageUrl3.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs410/410_"));
         }
         if (!string.IsNullOrEmpty(product.ImageUrl4))
         {
             ResourcesHelper.DeleteImage(product.ImageUrl4);
             ResourcesHelper.DeleteImage(product.ImageUrl4.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs40/40_"));
             ResourcesHelper.DeleteImage(product.ImageUrl4.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs60/60_"));
             ResourcesHelper.DeleteImage(product.ImageUrl4.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs100/100_"));
             ResourcesHelper.DeleteImage(product.ImageUrl4.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs160/160_"));
             ResourcesHelper.DeleteImage(product.ImageUrl4.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs180/180_"));
             ResourcesHelper.DeleteImage(product.ImageUrl4.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs220/220_"));
             ResourcesHelper.DeleteImage(product.ImageUrl4.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs310/310_"));
             ResourcesHelper.DeleteImage(product.ImageUrl4.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs410/410_"));
         }
         if (!string.IsNullOrEmpty(product.ImageUrl5))
         {
             ResourcesHelper.DeleteImage(product.ImageUrl5);
             ResourcesHelper.DeleteImage(product.ImageUrl5.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs40/40_"));
             ResourcesHelper.DeleteImage(product.ImageUrl5.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs60/60_"));
             ResourcesHelper.DeleteImage(product.ImageUrl5.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs100/100_"));
             ResourcesHelper.DeleteImage(product.ImageUrl5.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs160/160_"));
             ResourcesHelper.DeleteImage(product.ImageUrl5.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs180/180_"));
             ResourcesHelper.DeleteImage(product.ImageUrl5.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs220/220_"));
             ResourcesHelper.DeleteImage(product.ImageUrl5.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs310/310_"));
             ResourcesHelper.DeleteImage(product.ImageUrl5.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs410/410_"));
         }
     }
 }
Exemplo n.º 6
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            int stock = 0;// num;
            int alertStock = 0;// num2;
            int lineId = 0;// num3;
            decimal purchasePrice = 0m;// num4;
            decimal lowestSalePrice = 0m;// num5;
            decimal salePrice = 0m;// num6;
            decimal? costPrice = null;// nullable;
            decimal? marketPrice = null;// nullable2;
            int? weight = null;// nullable3;

            // (bool skuEnabled, out int displaySequence, out decimal purchasePrice, out decimal lowestSalePrice, out decimal salePrice, out decimal? costPrice, out decimal? marketPrice, out int stock, out int alertStock, out int? weight)

            if (ValidateConverts(chkSkuEnabled.Checked, out purchasePrice, out lowestSalePrice, out salePrice, out costPrice, out marketPrice, out stock, out alertStock, out weight, out lineId))
            {
                if (!chkSkuEnabled.Checked)
                {
                    if (salePrice <= 0M)
                    {
                        ShowMsg("商品一口价必须大于0", false);
                        return;
                    }
                    if (costPrice.HasValue && (costPrice.Value >= salePrice))
                    {
                        ShowMsg("商品成本价必须小于商品一口价", false);
                        return;
                    }
                    if (purchasePrice > lowestSalePrice)
                    {
                        ShowMsg("分销商采购价必须要小于其最低零售价", false);
                        return;
                    }
                }
                string text = editDescription.Text;
                if (ckbIsDownPic.Checked)
                {
                    text = base.DownRemotePic(text);
                }
                ProductInfo target = new ProductInfo();
                target.CategoryId = categoryId;
                target.TypeId = dropProductTypes.SelectedValue;
                target.ProductName = txtProductName.Text;
                target.ProductCode = txtProductCode.Text;
                target.LineId = lineId;// num3;
                target.LowestSalePrice = lowestSalePrice;// num5;
                target.MarketPrice = marketPrice;// nullable2;
                target.Unit = txtUnit.Text;
                target.ImageUrl1 = uploader1.UploadedImageUrl;
                target.ImageUrl2 = uploader2.UploadedImageUrl;
                target.ImageUrl3 = uploader3.UploadedImageUrl;
                target.ImageUrl4 = uploader4.UploadedImageUrl;
                target.ImageUrl5 = uploader5.UploadedImageUrl;
                target.ThumbnailUrl40 = uploader1.ThumbnailUrl40;
                target.ThumbnailUrl60 = uploader1.ThumbnailUrl60;
                target.ThumbnailUrl100 = uploader1.ThumbnailUrl100;
                target.ThumbnailUrl160 = uploader1.ThumbnailUrl160;
                target.ThumbnailUrl180 = uploader1.ThumbnailUrl180;
                target.ThumbnailUrl220 = uploader1.ThumbnailUrl220;
                target.ThumbnailUrl310 = uploader1.ThumbnailUrl310;
                target.ThumbnailUrl410 = uploader1.ThumbnailUrl410;
                target.ShortDescription = txtShortDescription.Text;
                target.Description = (!string.IsNullOrEmpty(text) && (text.Length > 0)) ? text : null;
                target.PenetrationStatus = chkPenetration.Checked ? PenetrationStatus.Already : PenetrationStatus.Notyet;
                target.Title = txtTitle.Text;
                target.MetaDescription = txtMetaDescription.Text;
                target.MetaKeywords = txtMetaKeywords.Text;
                target.AddedDate = DateTime.Now;
                target.BrandId = dropBrandCategories.SelectedValue;
                target.MainCategoryPath = CatalogHelper.GetCategory(categoryId).Path + "|";
                //ProductInfo info = info3;
                //ProductInfo target = info;
                ProductSaleStatus onSale = ProductSaleStatus.OnSale;
                if (radInStock.Checked)
                {
                    onSale = ProductSaleStatus.OnStock;
                }
                if (radUnSales.Checked)
                {
                    onSale = ProductSaleStatus.UnSale;
                }
                if (radOnSales.Checked)
                {
                    onSale = ProductSaleStatus.OnSale;
                }
                target.SaleStatus = onSale;
                Dictionary<string, SKUItem> skus = null;
                Dictionary<int, IList<int>> attrs = null;
                if (chkSkuEnabled.Checked)
                {
                    target.HasSKU = true;
                    skus = base.GetSkus(txtSkus.Text);
                }
                else
                {
                   // Dictionary<string, SKUItem> dictionary3 = new Dictionary<string, SKUItem>();
                    skus = new Dictionary<string, SKUItem>();
                    SKUItem item = new SKUItem();

                    item.SkuId = "0";
                    item.SKU = txtSku.Text;
                    item.SalePrice = salePrice;// num6;
                    item.CostPrice = costPrice.HasValue ? costPrice.Value : 0M;
                    item.PurchasePrice = purchasePrice;
                    item.Stock = stock;// num;
                    item.AlertStock = alertStock;// num2;
                    item.Weight = weight.HasValue ? weight.Value : 0;

                    //dictionary3.Add("0", item);
                    //skus = dictionary3;

                    skus.Add("0", item);

                    if (txtMemberPrices.Text.Length > 0)
                    {
                        base.GetMemberPrices(skus["0"], txtMemberPrices.Text);
                    }
                    if (txtDistributorPrices.Text.Length > 0)
                    {
                        base.GetDistributorPrices(skus["0"], txtDistributorPrices.Text);
                    }
                }
                if (!(string.IsNullOrEmpty(txtAttributes.Text) || (txtAttributes.Text.Length <= 0)))
                {
                    attrs = base.GetAttributes(txtAttributes.Text);
                }
                ValidationResults validateResults = Hishop.Components.Validation.Validation.Validate<ProductInfo>(target, new string[] { "AddProduct" });
                if (!validateResults.IsValid)
                {
                    ShowMsg(validateResults);
                }
                else
                {
                    switch (ProductHelper.AddProduct(target, skus, attrs))
                    {
                        case ProductActionStatus.Success:
                            {
                                ShowMsg("添加商品成功", true);
                                Response.Redirect(Globals.GetAdminAbsolutePath(string.Format("/product/AddProductComplete.aspx?categoryId={0}&productId={1}", categoryId, target.ProductId)), true);
                                return;
                            }
                        case ProductActionStatus.DuplicateName:
                            {
                                ShowMsg("添加商品失败,商品名称不能重复", false);
                                return;
                            }
                        case ProductActionStatus.DuplicateSKU:
                            {
                                ShowMsg("添加商品失败,商家编码不能重复", false);
                                return;
                            }
                        case ProductActionStatus.SKUError:
                            {
                                ShowMsg("添加商品失败,商家编码不能重复", false);
                                return;
                            }
                        case ProductActionStatus.AttributeError:
                            {
                                ShowMsg("添加商品失败,保存商品属性时出错", false);
                                return;
                            }
                    }
                    ShowMsg("添加商品失败,未知错误", false);
                }
            }
        }
Exemplo n.º 7
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;
 }
Exemplo n.º 8
0
 static ProductInfo ConverToProduct(DataRow productRow, int categoryId, int lineId, int? bandId, ProductSaleStatus saleStatus, bool includeImages)
 {
     ProductInfo info2 = new ProductInfo();
     info2.CategoryId = categoryId;
     info2.TypeId = new int?((int)productRow["SelectedTypeId"]);
     info2.ProductName = (string)productRow["ProductName"];
     info2.ProductCode = (string)productRow["ProductCode"];
     info2.LineId = lineId;
     info2.BrandId = bandId;
     info2.LowestSalePrice = (decimal)productRow["LowestSalePrice"];
     info2.Unit = (string)productRow["Unit"];
     info2.ShortDescription = (string)productRow["ShortDescription"];
     info2.Description = (string)productRow["Description"];
     info2.PenetrationStatus = PenetrationStatus.Notyet;
     info2.Title = (string)productRow["Title"];
     info2.MetaDescription = (string)productRow["Meta_Description"];
     info2.MetaKeywords = (string)productRow["Meta_Keywords"];
     info2.AddedDate = DateTime.Now;
     info2.SaleStatus = saleStatus;
     info2.HasSKU = (bool)productRow["HasSKU"];
     info2.MainCategoryPath = CatalogHelper.GetCategory(categoryId).Path + "|";
     info2.ImageUrl1 = (string)productRow["ImageUrl1"];
     info2.ImageUrl2 = (string)productRow["ImageUrl2"];
     info2.ImageUrl3 = (string)productRow["ImageUrl3"];
     info2.ImageUrl4 = (string)productRow["ImageUrl4"];
     info2.ImageUrl5 = (string)productRow["ImageUrl5"];
     ProductInfo info = info2;
     if (productRow["MarketPrice"] != DBNull.Value)
     {
         info.MarketPrice = new decimal?((decimal)productRow["MarketPrice"]);
     }
     if (includeImages)
     {
         string[] strArray;
         HttpContext current = HttpContext.Current;
         if (!(string.IsNullOrEmpty(info.ImageUrl1) || (info.ImageUrl1.Length <= 0)))
         {
             strArray = ProcessImages(current, info.ImageUrl1);
             info.ThumbnailUrl40 = strArray[0];
             info.ThumbnailUrl60 = strArray[1];
             info.ThumbnailUrl100 = strArray[2];
             info.ThumbnailUrl160 = strArray[3];
             info.ThumbnailUrl180 = strArray[4];
             info.ThumbnailUrl220 = strArray[5];
             info.ThumbnailUrl310 = strArray[6];
             info.ThumbnailUrl410 = strArray[7];
         }
         if (!(string.IsNullOrEmpty(info.ImageUrl2) || (info.ImageUrl2.Length <= 0)))
         {
             strArray = ProcessImages(current, info.ImageUrl2);
         }
         if (!(string.IsNullOrEmpty(info.ImageUrl3) || (info.ImageUrl3.Length <= 0)))
         {
             strArray = ProcessImages(current, info.ImageUrl3);
         }
         if (!(string.IsNullOrEmpty(info.ImageUrl4) || (info.ImageUrl4.Length <= 0)))
         {
             strArray = ProcessImages(current, info.ImageUrl4);
         }
         if (!(string.IsNullOrEmpty(info.ImageUrl5) || (info.ImageUrl5.Length <= 0)))
         {
             strArray = ProcessImages(current, info.ImageUrl5);
         }
     }
     return info;
 }
Exemplo n.º 9
0
 public static ProductInfo PopulateProduct(IDataReader reader)
 {
     if (reader == null)
     {
         return null;
     }
     ProductInfo info = new ProductInfo {
         CategoryId = (int) reader["CategoryId"],
         ProductId = (int) reader["ProductId"]
     };
     if (DBNull.Value != reader["TypeId"])
     {
         info.TypeId = new int?((int) reader["TypeId"]);
     }
     info.ProductName = (string) reader["ProductName"];
     if (DBNull.Value != reader["ProductCode"])
     {
         info.ProductCode = (string) reader["ProductCode"];
     }
     if (DBNull.Value != reader["ShortDescription"])
     {
         info.ShortDescription = (string) reader["ShortDescription"];
     }
     if (DBNull.Value != reader["Unit"])
     {
         info.Unit = (string) reader["Unit"];
     }
     if (DBNull.Value != reader["Description"])
     {
         info.Description = (string) reader["Description"];
     }
     info.SaleStatus = (ProductSaleStatus) ((int) reader["SaleStatus"]);
     info.AddedDate = (DateTime) reader["AddedDate"];
     info.VistiCounts = (int) reader["VistiCounts"];
     info.SaleCounts = (int) reader["SaleCounts"];
     info.ShowSaleCounts = (int) reader["ShowSaleCounts"];
     info.DisplaySequence = (int) reader["DisplaySequence"];
     if (DBNull.Value != reader["ImageUrl1"])
     {
         info.ImageUrl1 = (string) reader["ImageUrl1"];
     }
     if (DBNull.Value != reader["ImageUrl2"])
     {
         info.ImageUrl2 = (string) reader["ImageUrl2"];
     }
     if (DBNull.Value != reader["ImageUrl3"])
     {
         info.ImageUrl3 = (string) reader["ImageUrl3"];
     }
     if (DBNull.Value != reader["ImageUrl4"])
     {
         info.ImageUrl4 = (string) reader["ImageUrl4"];
     }
     if (DBNull.Value != reader["ImageUrl5"])
     {
         info.ImageUrl5 = (string) reader["ImageUrl5"];
     }
     if (DBNull.Value != reader["ThumbnailUrl40"])
     {
         info.ThumbnailUrl40 = (string) reader["ThumbnailUrl40"];
     }
     if (DBNull.Value != reader["ThumbnailUrl60"])
     {
         info.ThumbnailUrl60 = (string) reader["ThumbnailUrl60"];
     }
     if (DBNull.Value != reader["ThumbnailUrl100"])
     {
         info.ThumbnailUrl100 = (string) reader["ThumbnailUrl100"];
     }
     if (DBNull.Value != reader["ThumbnailUrl160"])
     {
         info.ThumbnailUrl160 = (string) reader["ThumbnailUrl160"];
     }
     if (DBNull.Value != reader["ThumbnailUrl180"])
     {
         info.ThumbnailUrl180 = (string) reader["ThumbnailUrl180"];
     }
     if (DBNull.Value != reader["ThumbnailUrl220"])
     {
         info.ThumbnailUrl220 = (string) reader["ThumbnailUrl220"];
     }
     if (DBNull.Value != reader["ThumbnailUrl310"])
     {
         info.ThumbnailUrl310 = (string) reader["ThumbnailUrl310"];
     }
     if (DBNull.Value != reader["ThumbnailUrl410"])
     {
         info.ThumbnailUrl410 = (string) reader["ThumbnailUrl410"];
     }
     if (DBNull.Value != reader["MarketPrice"])
     {
         info.MarketPrice = new decimal?((decimal) reader["MarketPrice"]);
     }
     if (DBNull.Value != reader["BrandId"])
     {
         info.BrandId = new int?((int) reader["BrandId"]);
     }
     if (reader["MainCategoryPath"] != DBNull.Value)
     {
         info.MainCategoryPath = (string) reader["MainCategoryPath"];
     }
     if (reader["ExtendCategoryPath"] != DBNull.Value)
     {
         info.ExtendCategoryPath = (string) reader["ExtendCategoryPath"];
     }
     info.HasSKU = (bool) reader["HasSKU"];
     if (reader["TaobaoProductId"] != DBNull.Value)
     {
         info.TaobaoProductId = (long) reader["TaobaoProductId"];
     }
     return info;
 }
Exemplo n.º 10
0
 private static ProductInfo ConverToProduct(DataRow productRow, int categoryId, int lineId, int? bandId, ProductSaleStatus saleStatus, bool includeImages)
 {
     ProductInfo info = new ProductInfo {
         CategoryId = categoryId,
         TypeId = new int?((int) productRow["SelectedTypeId"]),
         ProductName = (string) productRow["ProductName"],
         ProductCode = (string) productRow["ProductCode"],
         BrandId = bandId,
         Unit = (string) productRow["Unit"],
         ShortDescription = (string) productRow["ShortDescription"],
         Description = (string) productRow["Description"],
         AddedDate = DateTime.Now,
         SaleStatus = saleStatus,
         HasSKU = (bool) productRow["HasSKU"],
         MainCategoryPath = CatalogHelper.GetCategory(categoryId).Path + "|",
         ImageUrl1 = (string) productRow["ImageUrl1"],
         ImageUrl2 = (string) productRow["ImageUrl2"],
         ImageUrl3 = (string) productRow["ImageUrl3"],
         ImageUrl4 = (string) productRow["ImageUrl4"],
         ImageUrl5 = (string) productRow["ImageUrl5"]
     };
     if (productRow["MarketPrice"] != DBNull.Value)
     {
         info.MarketPrice = new decimal?((decimal) productRow["MarketPrice"]);
     }
     if (includeImages)
     {
         string[] strArray;
         HttpContext current = HttpContext.Current;
         if (!(string.IsNullOrEmpty(info.ImageUrl1) || (info.ImageUrl1.Length <= 0)))
         {
             strArray = ProcessImages(current, info.ImageUrl1);
             info.ThumbnailUrl40 = strArray[0];
             info.ThumbnailUrl60 = strArray[1];
             info.ThumbnailUrl100 = strArray[2];
             info.ThumbnailUrl160 = strArray[3];
             info.ThumbnailUrl180 = strArray[4];
             info.ThumbnailUrl220 = strArray[5];
             info.ThumbnailUrl310 = strArray[6];
             info.ThumbnailUrl410 = strArray[7];
         }
         if (!(string.IsNullOrEmpty(info.ImageUrl2) || (info.ImageUrl2.Length <= 0)))
         {
             strArray = ProcessImages(current, info.ImageUrl2);
         }
         if (!(string.IsNullOrEmpty(info.ImageUrl3) || (info.ImageUrl3.Length <= 0)))
         {
             strArray = ProcessImages(current, info.ImageUrl3);
         }
         if (!(string.IsNullOrEmpty(info.ImageUrl4) || (info.ImageUrl4.Length <= 0)))
         {
             strArray = ProcessImages(current, info.ImageUrl4);
         }
         if (!(string.IsNullOrEmpty(info.ImageUrl5) || (info.ImageUrl5.Length <= 0)))
         {
             strArray = ProcessImages(current, info.ImageUrl5);
         }
     }
     return info;
 }
Exemplo n.º 11
0
 private void LoadProduct(ProductInfo product, Dictionary<int, IList<int>> attrs)
 {
     this.dropProductTypes.SelectedValue = product.TypeId;
     this.dropBrandCategories.SelectedValue = product.BrandId;
     this.txtDisplaySequence.Text = product.DisplaySequence.ToString();
     this.txtProductName.Text = Globals.HtmlDecode(product.ProductName);
     this.txtProductCode.Text = product.ProductCode;
     this.txtUnit.Text = product.Unit;
     if (product.MarketPrice.HasValue)
     {
         this.txtMarketPrice.Text = product.MarketPrice.Value.ToString("F2");
     }
     this.txtShortDescription.Text = product.ShortDescription;
     this.fckDescription.Text = product.Description;
     if (product.SaleStatus == ProductSaleStatus.OnSale)
     {
         this.radOnSales.Checked = true;
     }
     else if (product.SaleStatus == ProductSaleStatus.UnSale)
     {
         this.radUnSales.Checked = true;
     }
     else
     {
         this.radInStock.Checked = true;
     }
     this.ChkisfreeShipping.Checked = product.IsfreeShipping;
     this.uploader1.UploadedImageUrl = product.ImageUrl1;
     this.uploader2.UploadedImageUrl = product.ImageUrl2;
     this.uploader3.UploadedImageUrl = product.ImageUrl3;
     this.uploader4.UploadedImageUrl = product.ImageUrl4;
     this.uploader5.UploadedImageUrl = product.ImageUrl5;
     if ((attrs != null) && (attrs.Count > 0))
     {
         StringBuilder builder = new StringBuilder();
         builder.Append("<xml><attributes>");
         foreach (int num in attrs.Keys)
         {
             builder.Append("<item attributeId=\"").Append(num.ToString(CultureInfo.InvariantCulture)).Append("\" usageMode=\"").Append(((int)ProductTypeHelper.GetAttribute(num).UsageMode).ToString()).Append("\" >");
             foreach (int num2 in attrs[num])
             {
                 builder.Append("<attValue valueId=\"").Append(num2.ToString(CultureInfo.InvariantCulture)).Append("\" />");
             }
             builder.Append("</item>");
         }
         builder.Append("</attributes></xml>");
         this.txtAttributes.Text = builder.ToString();
     }
     this.chkSkuEnabled.Checked = product.HasSKU;
     if (product.HasSKU)
     {
         StringBuilder builder2 = new StringBuilder();
         builder2.Append("<xml><productSkus>");
         foreach (string str in product.Skus.Keys)
         {
             SKUItem item = product.Skus[str];
             string str2 = ("<item skuCode=\"" + item.SKU + "\" salePrice=\"" + item.SalePrice.ToString("F2") + "\" costPrice=\"" + ((item.CostPrice > 0M) ? item.CostPrice.ToString("F2") : "") + "\" qty=\"" + item.Stock.ToString(CultureInfo.InvariantCulture) + "\" weight=\"" + ((item.Weight > 0M) ? item.Weight.ToString("F2") : "") + "\">") + "<skuFields>";
             foreach (int num3 in item.SkuItems.Keys)
             {
                 string[] strArray2 = new string[] { "<sku attributeId=\"", num3.ToString(CultureInfo.InvariantCulture), "\" valueId=\"", item.SkuItems[num3].ToString(CultureInfo.InvariantCulture), "\" />" };
                 string str3 = string.Concat(strArray2);
                 str2 = str2 + str3;
             }
             str2 = str2 + "</skuFields>";
             if (item.MemberPrices.Count > 0)
             {
                 str2 = str2 + "<memberPrices>";
                 foreach (int num4 in item.MemberPrices.Keys)
                 {
                     decimal num14 = item.MemberPrices[num4];
                     str2 = str2 + string.Format("<memberGrande id=\"{0}\" price=\"{1}\" />", num4.ToString(CultureInfo.InvariantCulture), num14.ToString("F2"));
                 }
                 str2 = str2 + "</memberPrices>";
             }
             str2 = str2 + "</item>";
             builder2.Append(str2);
         }
         builder2.Append("</productSkus></xml>");
         this.txtSkus.Text = builder2.ToString();
     }
     SKUItem defaultSku = product.DefaultSku;
     this.txtSku.Text = product.SKU;
     this.txtSalePrice.Text = defaultSku.SalePrice.ToString("F2");
     this.txtCostPrice.Text = (defaultSku.CostPrice > 0M) ? defaultSku.CostPrice.ToString("F2") : "";
     this.txtStock.Text = defaultSku.Stock.ToString(CultureInfo.InvariantCulture);
     this.txtWeight.Text = (defaultSku.Weight > 0M) ? defaultSku.Weight.ToString("F2") : "";
     if (defaultSku.MemberPrices.Count > 0)
     {
         this.txtMemberPrices.Text = "<xml><gradePrices>";
         foreach (int num5 in defaultSku.MemberPrices.Keys)
         {
             decimal num19 = defaultSku.MemberPrices[num5];
             this.txtMemberPrices.Text = this.txtMemberPrices.Text + string.Format("<grande id=\"{0}\" price=\"{1}\" />", num5.ToString(CultureInfo.InvariantCulture), num19.ToString("F2"));
         }
         this.txtMemberPrices.Text = this.txtMemberPrices.Text + "</gradePrices></xml>";
     }
 }
Exemplo n.º 12
0
 void LoadPageSearch(ProductInfo productDetails)
 {
     if (!string.IsNullOrEmpty(productDetails.MetaKeywords))
     {
         MetaTags.AddMetaKeywords(productDetails.MetaKeywords, HiContext.Current.Context);
     }
     if (!string.IsNullOrEmpty(productDetails.MetaDescription))
     {
         MetaTags.AddMetaDescription(productDetails.MetaDescription, HiContext.Current.Context);
     }
     if (!string.IsNullOrEmpty(productDetails.Title))
     {
         PageTitle.AddTitle(productDetails.Title, HiContext.Current.Context);
     }
     else
     {
         PageTitle.AddTitle(productDetails.ProductName, HiContext.Current.Context);
     }
 }
Exemplo n.º 13
0
 public static bool UpdateProduct(ProductInfo product, Dictionary<string, decimal> skuSalePrice)
 {
     bool flag;
     if (null == product)
     {
         return false;
     }
     Globals.EntityCoding(product, true);
     int decimalLength = HiContext.Current.SiteSettings.DecimalLength;
     if (product.MarketPrice.HasValue)
     {
         product.MarketPrice = new decimal?(Math.Round(product.MarketPrice.Value, decimalLength));
     }
     using (DbConnection connection = DatabaseFactory.CreateDatabase().CreateConnection())
     {
         connection.Open();
         DbTransaction dbTran = connection.BeginTransaction();
         try
         {
             if (!SubsiteProductProvider.Instance().UpdateProduct(product, dbTran))
             {
                 dbTran.Rollback();
                 return false;
             }
             if (!SubsiteProductProvider.Instance().AddSkuSalePrice(product.ProductId, skuSalePrice, dbTran))
             {
                 dbTran.Rollback();
                 return false;
             }
             dbTran.Commit();
             flag = true;
         }
         catch
         {
             dbTran.Rollback();
             flag = false;
         }
     }
     return flag;
 }
Exemplo n.º 14
0
 public bool UpdateProduct(ProductInfo product, DbTransaction dbTran)
 {
     DbCommand storedProcCommand = this.database.GetStoredProcCommand("cp_Product_Update");
     this.database.AddInParameter(storedProcCommand, "CategoryId", DbType.Int32, product.CategoryId);
     this.database.AddInParameter(storedProcCommand, "MainCategoryPath", DbType.String, product.MainCategoryPath);
     this.database.AddInParameter(storedProcCommand, "TypeId", DbType.Int32, product.TypeId);
     this.database.AddInParameter(storedProcCommand, "ProductName", DbType.String, product.ProductName);
     this.database.AddInParameter(storedProcCommand, "ProductCode", DbType.String, product.ProductCode);
     this.database.AddInParameter(storedProcCommand, "ShortDescription", DbType.String, product.ShortDescription);
     this.database.AddInParameter(storedProcCommand, "Unit", DbType.String, product.Unit);
     this.database.AddInParameter(storedProcCommand, "Description", DbType.String, product.Description);
     this.database.AddInParameter(storedProcCommand, "SaleStatus", DbType.Int32, (int) product.SaleStatus);
     this.database.AddInParameter(storedProcCommand, "DisplaySequence", DbType.Currency, product.DisplaySequence);
     this.database.AddInParameter(storedProcCommand, "ImageUrl1", DbType.String, product.ImageUrl1);
     this.database.AddInParameter(storedProcCommand, "ImageUrl2", DbType.String, product.ImageUrl2);
     this.database.AddInParameter(storedProcCommand, "ImageUrl3", DbType.String, product.ImageUrl3);
     this.database.AddInParameter(storedProcCommand, "ImageUrl4", DbType.String, product.ImageUrl4);
     this.database.AddInParameter(storedProcCommand, "ImageUrl5", DbType.String, product.ImageUrl5);
     this.database.AddInParameter(storedProcCommand, "ThumbnailUrl40", DbType.String, product.ThumbnailUrl40);
     this.database.AddInParameter(storedProcCommand, "ThumbnailUrl60", DbType.String, product.ThumbnailUrl60);
     this.database.AddInParameter(storedProcCommand, "ThumbnailUrl100", DbType.String, product.ThumbnailUrl100);
     this.database.AddInParameter(storedProcCommand, "ThumbnailUrl160", DbType.String, product.ThumbnailUrl160);
     this.database.AddInParameter(storedProcCommand, "ThumbnailUrl180", DbType.String, product.ThumbnailUrl180);
     this.database.AddInParameter(storedProcCommand, "ThumbnailUrl220", DbType.String, product.ThumbnailUrl220);
     this.database.AddInParameter(storedProcCommand, "ThumbnailUrl310", DbType.String, product.ThumbnailUrl310);
     this.database.AddInParameter(storedProcCommand, "ThumbnailUrl410", DbType.String, product.ThumbnailUrl410);
     this.database.AddInParameter(storedProcCommand, "MarketPrice", DbType.Currency, product.MarketPrice);
     this.database.AddInParameter(storedProcCommand, "BrandId", DbType.Int32, product.BrandId);
     this.database.AddInParameter(storedProcCommand, "HasSKU", DbType.Boolean, product.HasSKU);
     this.database.AddInParameter(storedProcCommand, "IsfreeShipping", DbType.Boolean, product.IsfreeShipping);
     this.database.AddInParameter(storedProcCommand, "SaleCounts", DbType.Int32, product.SaleCounts);
     this.database.AddInParameter(storedProcCommand, "ShowSaleCounts", DbType.Int32, product.ShowSaleCounts);
     this.database.AddInParameter(storedProcCommand, "ProductId", DbType.Int32, product.ProductId);
     if (dbTran != null)
     {
         return (this.database.ExecuteNonQuery(storedProcCommand, dbTran) > 0);
     }
     return (this.database.ExecuteNonQuery(storedProcCommand) > 0);
 }
Exemplo n.º 15
0
 public abstract int AddProduct(ProductInfo product, DbTransaction dbTran);
Exemplo n.º 16
0
 public abstract bool UpdateProduct(ProductInfo product, DbTransaction dbTran);
Exemplo n.º 17
0
        /// <summary>
        /// 保存按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSave_Click(object sender, EventArgs e)
        {
            int displaySequence = 0;
            int stock = 0;// num2;
            int alertStock = 0;// num3;
            decimal purchasePrice = 0m;
            decimal lowestSalePrice = 0m;// num5;
            decimal salePrice = 0m;// num6;
            decimal? costPrice = null;// nullable;
            decimal? marketPrice = null;// nullable2;
            int? weight = null;// nullable3;

            if (categoryId == 0)
            {
                categoryId = (int)ViewState["ProductCategoryId"];
            }

               // (bool skuEnabled, out int displaySequence, out decimal purchasePrice, out decimal lowestSalePrice, out decimal salePrice, out decimal? costPrice, out decimal? marketPrice, out int stock, out int alertStock, out int? weight)

            if (ValidateConverts(chkSkuEnabled.Checked, out displaySequence, out purchasePrice, out lowestSalePrice, out salePrice, out costPrice, out marketPrice, out stock, out alertStock, out weight))
            {
                if (!chkSkuEnabled.Checked)
                {
                    if (salePrice <= 0M)
                    {
                        ShowMsg("商品一口价必须大于0", false);
                        return;
                    }
                    if (costPrice.HasValue && (costPrice.Value >= salePrice))
                    {
                        ShowMsg("商品成本价必须小于商品一口价", false);
                        return;
                    }
                    if (purchasePrice > lowestSalePrice)
                    {
                        ShowMsg("分销商采购价必须要小于等于其最低零售价", false);
                        return;
                    }
                }
                string text = fckDescription.Text;
                if (ckbIsDownPic.Checked)
                {
                    text = base.DownRemotePic(text);
                }
                ProductInfo productInfo = new ProductInfo();
                productInfo.ProductId = productId;
                productInfo.CategoryId = categoryId;
                productInfo.TypeId = dropProductTypes.SelectedValue;
                productInfo.ProductName = txtProductName.Text;
                productInfo.ProductCode = txtProductCode.Text;
                productInfo.DisplaySequence = displaySequence;
                productInfo.LineId = dropProductLines.SelectedValue.Value;
                productInfo.LowestSalePrice = lowestSalePrice;
                productInfo.MarketPrice = marketPrice;// nullable2;
                productInfo.Unit = txtUnit.Text;
                productInfo.ImageUrl1 = uploader1.UploadedImageUrl;
                productInfo.ImageUrl2 = uploader2.UploadedImageUrl;
                productInfo.ImageUrl3 = uploader3.UploadedImageUrl;
                productInfo.ImageUrl4 = uploader4.UploadedImageUrl;
                productInfo.ImageUrl5 = uploader5.UploadedImageUrl;
                productInfo.ThumbnailUrl40 = uploader1.ThumbnailUrl40;
                productInfo.ThumbnailUrl60 = uploader1.ThumbnailUrl60;
                productInfo.ThumbnailUrl100 = uploader1.ThumbnailUrl100;
                productInfo.ThumbnailUrl160 = uploader1.ThumbnailUrl160;
                productInfo.ThumbnailUrl180 = uploader1.ThumbnailUrl180;
                productInfo.ThumbnailUrl220 = uploader1.ThumbnailUrl220;
                productInfo.ThumbnailUrl310 = uploader1.ThumbnailUrl310;
                productInfo.ThumbnailUrl410 = uploader1.ThumbnailUrl410;
                productInfo.ShortDescription = txtShortDescription.Text;
                productInfo.Description = (!string.IsNullOrEmpty(text) && (text.Length > 0)) ? text : null;
                productInfo.PenetrationStatus = chkPenetration.Checked ? PenetrationStatus.Already : PenetrationStatus.Notyet;
                productInfo.Title = txtTitle.Text;
                productInfo.MetaDescription = txtMetaDescription.Text;
                productInfo.MetaKeywords = txtMetaKeywords.Text;
                productInfo.AddedDate = DateTime.Now;
                productInfo.BrandId = dropBrandCategories.SelectedValue;
                //ProductInfo info = productInfo;
                //ProductInfo target = info;
                productInfo.BrandId = dropBrandCategories.SelectedValue;
                ProductSaleStatus onSale = ProductSaleStatus.OnSale;
                if (radInStock.Checked)
                {
                    onSale = ProductSaleStatus.OnStock;
                }
                if (radUnSales.Checked)
                {
                    onSale = ProductSaleStatus.UnSale;
                }
                if (radOnSales.Checked)
                {
                    onSale = ProductSaleStatus.OnSale;
                }
                productInfo.SaleStatus = onSale;
                CategoryInfo category = CatalogHelper.GetCategory(categoryId);
                if (category != null)
                {
                    productInfo.MainCategoryPath = category.Path + "|";
                }
                Dictionary<string, SKUItem> skus = new Dictionary<string,SKUItem>();
                Dictionary<int, IList<int>> attrs = null;
                if (chkSkuEnabled.Checked)
                {
                    productInfo.HasSKU = true;
                    skus = base.GetSkus(txtSkus.Text);
                }
                else
                {
                    //Dictionary<string, SKUItem> skuList = new Dictionary<string, SKUItem>();

                    SKUItem item = new SKUItem();
                    item.SkuId = "0";
                    item.SKU = txtSku.Text;
                    item.SalePrice = salePrice;
                    item.CostPrice = costPrice.HasValue ? costPrice.Value : 0M;
                    item.PurchasePrice = purchasePrice;// num4;
                    item.Stock = stock;// num2;
                    item.AlertStock = alertStock;// num3;
                    item.Weight = weight.HasValue ? weight.Value : 0;

                    //skuList.Add("0", item);
                    skus.Add("0", item);
                    //skus = dictionary3;

                    if (txtMemberPrices.Text.Length > 0)
                    {
                        base.GetMemberPrices(skus["0"], txtMemberPrices.Text);
                    }
                    if (txtDistributorPrices.Text.Length > 0)
                    {
                        base.GetDistributorPrices(skus["0"], txtDistributorPrices.Text);
                    }
                }
                if (!(string.IsNullOrEmpty(txtAttributes.Text) || (txtAttributes.Text.Length <= 0)))
                {
                    attrs = base.GetAttributes(txtAttributes.Text);
                }
                ValidationResults validateResults = Hishop.Components.Validation.Validation.Validate<ProductInfo>(productInfo);
                if (!validateResults.IsValid)
                {
                    ShowMsg(validateResults);
                }
                else
                {
                    if (ViewState["distributorUserIds"] == null)
                    {
                        ViewState["distributorUserIds"] = new List<int>();
                    }
                    int type = 0;
                    if (((productInfo.LineId > 0) && (int.Parse(hdlineId.Value) > 0)) && (productInfo.LineId != int.Parse(hdlineId.Value)))
                    {
                        type = 6;
                    }
                    if (!chkPenetration.Checked)
                    {
                        type = 5;
                    }
                    if (type == 5)
                    {
                        AdminPage.SendMessageToDistributors(productInfo.ProductId.ToString(), type);
                    }
                    else if (type == 6)
                    {
                        toline = dropProductLines.SelectedItem.Text;
                        AdminPage.SendMessageToDistributors(hdlineId.Value + "|" + toline, type);
                    }
                    switch (ProductHelper.UpdateProduct(productInfo, skus, attrs, (IList<int>)ViewState["distributorUserIds"]))
                    {
                        case ProductActionStatus.Success:
                            ShowMsg("修改商品成功", true);
                            base.Response.Redirect(Globals.GetAdminAbsolutePath(string.Format("/product/EditProductComplete.aspx?productId={0}", productInfo.ProductId)), true);
                            return;

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

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

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

                        case ProductActionStatus.AttributeError:
                            ShowMsg("修改商品失败,保存商品属性时出错", false);
                            return;

                        case ProductActionStatus.OffShelfError:
                            ShowMsg("修改商品失败, 子站没在零售价范围内的商品无法下架", false);
                            return;
                    }
                    ShowMsg("修改商品失败,未知错误", false);
                }
            }
        }
Exemplo n.º 18
0
 private void LoadProduct(ProductInfo product, Dictionary<int, IList<int>> attrs)
 {
     dropProductTypes.SelectedValue = product.TypeId;
     dropProductLines.SelectedValue = new int?(product.LineId);
     hdlineId.Value = product.LineId.ToString();
     dropBrandCategories.SelectedValue = product.BrandId;
     txtDisplaySequence.Text = product.DisplaySequence.ToString();
     txtProductName.Text = product.ProductName;
     txtProductCode.Text = product.ProductCode;
     txtUnit.Text = product.Unit;
     if (product.MarketPrice.HasValue)
     {
         txtMarketPrice.Text = product.MarketPrice.Value.ToString("F2");
     }
     txtShortDescription.Text = product.ShortDescription;
     fckDescription.Text = product.Description;
     txtTitle.Text = product.Title;
     txtMetaDescription.Text = product.MetaDescription;
     txtMetaKeywords.Text = product.MetaKeywords;
     txtLowestSalePrice.Text = product.LowestSalePrice.ToString("F2");
     chkPenetration.Checked = product.PenetrationStatus == PenetrationStatus.Already;
     if (product.SaleStatus == ProductSaleStatus.OnSale)
     {
         radOnSales.Checked = true;
     }
     else if (product.SaleStatus == ProductSaleStatus.UnSale)
     {
         radUnSales.Checked = true;
     }
     else
     {
         radInStock.Checked = true;
     }
     uploader1.UploadedImageUrl = product.ImageUrl1;
     uploader2.UploadedImageUrl = product.ImageUrl2;
     uploader3.UploadedImageUrl = product.ImageUrl3;
     uploader4.UploadedImageUrl = product.ImageUrl4;
     uploader5.UploadedImageUrl = product.ImageUrl5;
     if ((attrs != null) && (attrs.Count > 0))
     {
         StringBuilder builder = new StringBuilder();
         builder.Append("<xml><attributes>");
         foreach (int num in attrs.Keys)
         {
             builder.Append("<item attributeId=\"").Append(num.ToString(CultureInfo.InvariantCulture)).Append("\" usageMode=\"").Append(((int)ProductTypeHelper.GetAttribute(num).UsageMode).ToString()).Append("\" >");
             foreach (int num2 in attrs[num])
             {
                 builder.Append("<attValue valueId=\"").Append(num2.ToString(CultureInfo.InvariantCulture)).Append("\" />");
             }
             builder.Append("</item>");
         }
         builder.Append("</attributes></xml>");
         txtAttributes.Text = builder.ToString();
     }
     chkSkuEnabled.Checked = product.HasSKU;
     if (product.HasSKU)
     {
         StringBuilder builder2 = new StringBuilder();
         builder2.Append("<xml><productSkus>");
         foreach (string str in product.Skus.Keys)
         {
             SKUItem item = product.Skus[str];
             string str2 = "<item skuCode=\"" + item.SKU + "\" salePrice=\"" + item.SalePrice.ToString("F2") + "\" costPrice=\"" + ((item.CostPrice > 0M) ? item.CostPrice.ToString("F2") : "") + "\" purchasePrice=\"" + item.PurchasePrice.ToString("F2") + "\" qty=\"" + item.Stock.ToString(CultureInfo.InvariantCulture) + "\" alertQty=\"" + item.AlertStock.ToString(CultureInfo.InvariantCulture) + "\" weight=\"" + ((item.Weight > 0) ? item.Weight.ToString(CultureInfo.InvariantCulture) : "") + "\"><skuFields>";
             foreach (int num3 in item.SkuItems.Keys)
             {
                 string[] strArray = new string[] { "<sku attributeId=\"", num3.ToString(CultureInfo.InvariantCulture), "\" valueId=\"", item.SkuItems[num3].ToString(CultureInfo.InvariantCulture), "\" />" };
                 string str3 = string.Concat(strArray);
                 str2 = str2 + str3;
             }
             str2 = str2 + "</skuFields>";
             if (item.MemberPrices.Count > 0)
             {
                 str2 = str2 + "<memberPrices>";
                 foreach (int num4 in item.MemberPrices.Keys)
                 {
                     decimal num5 = item.MemberPrices[num4];
                     str2 = str2 + string.Format("<memberGrande id=\"{0}\" price=\"{1}\" />", num4.ToString(CultureInfo.InvariantCulture), num5.ToString("F2"));
                 }
                 str2 = str2 + "</memberPrices>";
             }
             if (item.DistributorPrices.Count > 0)
             {
                 str2 = str2 + "<distributorPrices>";
                 foreach (int num6 in item.DistributorPrices.Keys)
                 {
                     decimal num7 = item.DistributorPrices[num6];
                     str2 = str2 + string.Format("<distributorGrande id=\"{0}\" price=\"{1}\" />", num6.ToString(CultureInfo.InvariantCulture), num7.ToString("F2"));
                 }
                 str2 = str2 + "</distributorPrices>";
             }
             str2 = str2 + "</item>";
             builder2.Append(str2);
         }
         builder2.Append("</productSkus></xml>");
         txtSkus.Text = builder2.ToString();
     }
     SKUItem defaultSku = product.DefaultSku;
     txtSku.Text = product.ProductCode;
     txtSalePrice.Text = defaultSku.SalePrice.ToString("F2");
     txtCostPrice.Text = (defaultSku.CostPrice > 0M) ? defaultSku.CostPrice.ToString("F2") : "";
     txtPurchasePrice.Text = defaultSku.PurchasePrice.ToString("F2");
     txtStock.Text = defaultSku.Stock.ToString(CultureInfo.InvariantCulture);
     txtAlertStock.Text = defaultSku.AlertStock.ToString(CultureInfo.InvariantCulture);
     txtWeight.Text = (defaultSku.Weight > 0) ? defaultSku.Weight.ToString(CultureInfo.InvariantCulture) : "";
     if (defaultSku.MemberPrices.Count > 0)
     {
         txtMemberPrices.Text = "<xml><gradePrices>";
         foreach (int num8 in defaultSku.MemberPrices.Keys)
         {
             decimal num9 = defaultSku.MemberPrices[num8];
             txtMemberPrices.Text = txtMemberPrices.Text + string.Format("<grande id=\"{0}\" price=\"{1}\" />", num8.ToString(CultureInfo.InvariantCulture), num9.ToString("F2"));
         }
         txtMemberPrices.Text = txtMemberPrices.Text + "</gradePrices></xml>";
     }
     if (defaultSku.DistributorPrices.Count > 0)
     {
         txtDistributorPrices.Text = "<xml><gradePrices>";
         foreach (int num10 in defaultSku.DistributorPrices.Keys)
         {
             decimal num11 = defaultSku.DistributorPrices[num10];
             txtDistributorPrices.Text = txtDistributorPrices.Text + string.Format("<grande id=\"{0}\" price=\"{1}\" />", num10.ToString(CultureInfo.InvariantCulture), num11.ToString("F2"));
         }
         txtDistributorPrices.Text = txtDistributorPrices.Text + "</gradePrices></xml>";
     }
 }
Exemplo n.º 19
0
 public override bool UpdateProduct(ProductInfo product, DbTransaction dbTran)
 {
     DbCommand storedProcCommand = database.GetStoredProcCommand("sub_Product_Update");
     database.AddInParameter(storedProcCommand, "CategoryId", DbType.Int32, product.CategoryId);
     database.AddInParameter(storedProcCommand, "MainCategoryPath", DbType.String, product.MainCategoryPath);
     database.AddInParameter(storedProcCommand, "ProductName", DbType.String, product.ProductName);
     database.AddInParameter(storedProcCommand, "ShortDescription", DbType.String, product.ShortDescription);
     database.AddInParameter(storedProcCommand, "Description", DbType.String, product.Description);
     database.AddInParameter(storedProcCommand, "Title", DbType.String, product.Title);
     database.AddInParameter(storedProcCommand, "Meta_Description", DbType.String, product.MetaDescription);
     database.AddInParameter(storedProcCommand, "Meta_Keywords", DbType.String, product.MetaKeywords);
     database.AddInParameter(storedProcCommand, "MarketPrice", DbType.Currency, product.MarketPrice);
     database.AddInParameter(storedProcCommand, "SaleStatus", DbType.Int32, (int)product.SaleStatus);
     database.AddInParameter(storedProcCommand, "DisplaySequence", DbType.Currency, product.DisplaySequence);
     database.AddInParameter(storedProcCommand, "ProductId", DbType.Int32, product.ProductId);
     database.AddInParameter(storedProcCommand, "DistributorUserId", DbType.Int32, HiContext.Current.User.UserId);
     if (dbTran != null)
     {
         return (database.ExecuteNonQuery(storedProcCommand, dbTran) > 0);
     }
     return (database.ExecuteNonQuery(storedProcCommand) > 0);
 }
Exemplo n.º 20
0
 public static ProductInfo PopulateSubProduct(IDataReader reader)
 {
     if (reader == null)
     {
         return null;
     }
     ProductInfo info = new ProductInfo();
     info.CategoryId = (int) reader["CategoryId"];
     info.ProductId = (int) reader["ProductId"];
     if (DBNull.Value != reader["TypeId"])
     {
         info.TypeId = new int?((int) reader["TypeId"]);
     }
     info.ProductName = (string) reader["ProductName"];
     if (DBNull.Value != reader["ProductCode"])
     {
         info.ProductCode = (string) reader["ProductCode"];
     }
     if (DBNull.Value != reader["ShortDescription"])
     {
         info.ShortDescription = (string) reader["ShortDescription"];
     }
     if (DBNull.Value != reader["Description"])
     {
         info.Description = (string) reader["Description"];
     }
     if (DBNull.Value != reader["Title"])
     {
         info.Title = (string) reader["Title"];
     }
     if (DBNull.Value != reader["Meta_Description"])
     {
         info.MetaDescription = (string) reader["Meta_Description"];
     }
     if (DBNull.Value != reader["Meta_Keywords"])
     {
         info.MetaKeywords = (string) reader["Meta_Keywords"];
     }
     if (DBNull.Value != reader["ThumbnailUrl40"])
     {
         info.ThumbnailUrl40 = (string) reader["ThumbnailUrl40"];
     }
     if (DBNull.Value != reader["ThumbnailUrl60"])
     {
         info.ThumbnailUrl60 = (string) reader["ThumbnailUrl60"];
     }
     if (DBNull.Value != reader["ThumbnailUrl100"])
     {
         info.ThumbnailUrl100 = (string) reader["ThumbnailUrl100"];
     }
     if (DBNull.Value != reader["ThumbnailUrl160"])
     {
         info.ThumbnailUrl160 = (string) reader["ThumbnailUrl160"];
     }
     if (DBNull.Value != reader["ThumbnailUrl180"])
     {
         info.ThumbnailUrl180 = (string) reader["ThumbnailUrl180"];
     }
     if (DBNull.Value != reader["ThumbnailUrl220"])
     {
         info.ThumbnailUrl220 = (string) reader["ThumbnailUrl220"];
     }
     if (DBNull.Value != reader["ThumbnailUrl310"])
     {
         info.ThumbnailUrl310 = (string) reader["ThumbnailUrl310"];
     }
     if (DBNull.Value != reader["ThumbnailUrl410"])
     {
         info.ThumbnailUrl410 = (string) reader["ThumbnailUrl410"];
     }
     if (DBNull.Value != reader["MarketPrice"])
     {
         info.MarketPrice = new decimal?((decimal) reader["MarketPrice"]);
     }
     info.LowestSalePrice = (decimal) reader["LowestSalePrice"];
     if (DBNull.Value != reader["BrandId"])
     {
         info.BrandId = new int?((int) reader["BrandId"]);
     }
     info.SaleStatus = (ProductSaleStatus) ((int) reader["SaleStatus"]);
     info.PenetrationStatus = (PenetrationStatus) Convert.ToInt16(reader["PenetrationStatus"]);
     info.VistiCounts = (int) reader["VistiCounts"];
     info.DisplaySequence = (int) reader["DisplaySequence"];
     info.LineId = (int) reader["LineId"];
     return info;
 }
Exemplo n.º 21
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);
            }
        }
Exemplo n.º 22
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            int num;
            int num2;
            decimal num3;
            decimal? nullable;
            decimal? nullable2;
            decimal? nullable3;
            if (this.categoryId == 0)
            {
                this.categoryId = (int)this.ViewState["ProductCategoryId"];
            }
            if (this.ValidateConverts(this.chkSkuEnabled.Checked, out num, out num3, out nullable, out nullable2, out num2, out nullable3))
            {
                if (!this.chkSkuEnabled.Checked)
                {
                    if (num3 <= 0M)
                    {
                        this.ShowMsg("商品一口价必须大于0", false);
                        return;
                    }
                    if (nullable.HasValue && (nullable.Value >= num3))
                    {
                        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 = num,
                    MarketPrice = nullable2,
                    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,
                    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 = num3,
                        CostPrice = nullable.HasValue ? nullable.Value : 0M,
                        Stock = num2,
                        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 str2 = this.txtProductTag.Text.Trim();
                        string[] strArray = null;
                        if (str2.Contains(","))
                        {
                            strArray = str2.Split(new char[] { ',' });
                        }
                        else
                        {
                            strArray = new string[] { str2 };
                        }
                        foreach (string str3 in strArray)
                        {
                            tagIds.Add(Convert.ToInt32(str3));
                        }
                    }
                    switch (ProductHelper.UpdateProduct(target, skus, attrs, tagIds))
                    {
                        case ProductActionStatus.Success:
                            this.litralProductTag.SelectedValue = tagIds;
                            this.ShowMsg("修改商品成功", true);
                            return;

                        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);
                }
            }
        }
Exemplo n.º 23
0
 public override bool UpdateProduct(ProductInfo product, DbTransaction dbTran)
 {
     DbCommand storedProcCommand = database.GetStoredProcCommand("cp_Product_Update");
     database.AddInParameter(storedProcCommand, "CategoryId", DbType.Int32, product.CategoryId);
     database.AddInParameter(storedProcCommand, "MainCategoryPath", DbType.String, product.MainCategoryPath);
     database.AddInParameter(storedProcCommand, "TypeId", DbType.Int32, product.TypeId);
     database.AddInParameter(storedProcCommand, "ProductName", DbType.String, product.ProductName);
     database.AddInParameter(storedProcCommand, "ProductCode", DbType.String, product.ProductCode);
     database.AddInParameter(storedProcCommand, "ShortDescription", DbType.String, product.ShortDescription);
     database.AddInParameter(storedProcCommand, "Unit", DbType.String, product.Unit);
     database.AddInParameter(storedProcCommand, "Description", DbType.String, product.Description);
     database.AddInParameter(storedProcCommand, "Title", DbType.String, product.Title);
     database.AddInParameter(storedProcCommand, "Meta_Description", DbType.String, product.MetaDescription);
     database.AddInParameter(storedProcCommand, "Meta_Keywords", DbType.String, product.MetaKeywords);
     database.AddInParameter(storedProcCommand, "SaleStatus", DbType.Int32, (int)product.SaleStatus);
     database.AddInParameter(storedProcCommand, "DisplaySequence", DbType.Currency, product.DisplaySequence);
     database.AddInParameter(storedProcCommand, "ImageUrl1", DbType.String, product.ImageUrl1);
     database.AddInParameter(storedProcCommand, "ImageUrl2", DbType.String, product.ImageUrl2);
     database.AddInParameter(storedProcCommand, "ImageUrl3", DbType.String, product.ImageUrl3);
     database.AddInParameter(storedProcCommand, "ImageUrl4", DbType.String, product.ImageUrl4);
     database.AddInParameter(storedProcCommand, "ImageUrl5", DbType.String, product.ImageUrl5);
     database.AddInParameter(storedProcCommand, "ThumbnailUrl40", DbType.String, product.ThumbnailUrl40);
     database.AddInParameter(storedProcCommand, "ThumbnailUrl60", DbType.String, product.ThumbnailUrl60);
     database.AddInParameter(storedProcCommand, "ThumbnailUrl100", DbType.String, product.ThumbnailUrl100);
     database.AddInParameter(storedProcCommand, "ThumbnailUrl160", DbType.String, product.ThumbnailUrl160);
     database.AddInParameter(storedProcCommand, "ThumbnailUrl180", DbType.String, product.ThumbnailUrl180);
     database.AddInParameter(storedProcCommand, "ThumbnailUrl220", DbType.String, product.ThumbnailUrl220);
     database.AddInParameter(storedProcCommand, "ThumbnailUrl310", DbType.String, product.ThumbnailUrl310);
     database.AddInParameter(storedProcCommand, "ThumbnailUrl410", DbType.String, product.ThumbnailUrl410);
     database.AddInParameter(storedProcCommand, "LineId", DbType.Int32, product.LineId);
     database.AddInParameter(storedProcCommand, "MarketPrice", DbType.Currency, product.MarketPrice);
     database.AddInParameter(storedProcCommand, "LowestSalePrice", DbType.Currency, product.LowestSalePrice);
     database.AddInParameter(storedProcCommand, "PenetrationStatus", DbType.Int16, (int)product.PenetrationStatus);
     database.AddInParameter(storedProcCommand, "BrandId", DbType.Int32, product.BrandId);
     database.AddInParameter(storedProcCommand, "HasSKU", DbType.Boolean, product.HasSKU);
     database.AddInParameter(storedProcCommand, "ProductId", DbType.Int32, product.ProductId);
     return (database.ExecuteNonQuery(storedProcCommand, dbTran) > 0);
 }
Exemplo n.º 24
0
 void LoadProductInfo(ProductInfo productDetails, string brandName)
 {
     if ((this.common_Location != null) && !string.IsNullOrEmpty(productDetails.MainCategoryPath))
     {
         this.common_Location.CateGoryPath = productDetails.MainCategoryPath.Remove(productDetails.MainCategoryPath.Length - 1);
         this.common_Location.ProductName = productDetails.ProductName;
     }
     this.litProductName.Text = productDetails.ProductName;
     this.lblProductCode.Text = productDetails.ProductCode;
     this.lblSku.Text = productDetails.SKU;
     this.lblSku.Value = productDetails.SkuId;
     this.lblStock.Stock = productDetails.Stock;
     this.litUnit.Text = productDetails.Unit;
     if (productDetails.Weight > 0)
     {
         this.litWeight.Text = string.Format("{0} g", productDetails.Weight);
     }
     else
     {
         this.litWeight.Text = "无";
     }
     this.litBrosedNum.Text = productDetails.VistiCounts.ToString();
     this.litBrand.Text = brandName;
     if (productDetails.MinSalePrice == productDetails.MaxSalePrice)
     {
         this.lblBuyPrice.Text = productDetails.MinSalePrice.ToString("F2");
     }
     else
     {
         this.lblBuyPrice.Text = productDetails.MinSalePrice.ToString("F2") + " - " + productDetails.MaxSalePrice.ToString("F2");
     }
     this.lblMarkerPrice.Money = productDetails.MarketPrice;
     this.litDescription.Text = productDetails.Description;
     if (this.litShortDescription != null)
     {
         this.litShortDescription.Text = productDetails.ShortDescription;
     }
 }
Exemplo n.º 25
0
 public override ProductInfo GetProductDetails(int productId)
 {
     ProductInfo info = new ProductInfo();
     DbCommand sqlStringCommand = database.GetSqlStringCommand("SELECT * FROM Hishop_Products WHERE ProductId = @ProductId");
     database.AddInParameter(sqlStringCommand, "ProductId", DbType.Int32, productId);
     using (IDataReader reader = database.ExecuteReader(sqlStringCommand))
     {
         if (reader.Read())
         {
             info = DataMapper.PopulateProduct(reader);
         }
     }
     return info;
 }
Exemplo n.º 26
0
 public static void ImportProducts(DataTable productData, int categoryId, int lineId, int? brandId, ProductSaleStatus saleStatus)
 {
     if ((productData != null) && (productData.Rows.Count > 0))
     {
         foreach (DataRow row in productData.Rows)
         {
             string[] strArray;
             ProductInfo product = new ProductInfo();
             product.CategoryId = categoryId;
             product.MainCategoryPath = CatalogHelper.GetCategory(categoryId).Path + "|";
             product.ProductName = (string)row["ProductName"];
             product.ProductCode = (string)row["SKU"];
             product.LineId = lineId;
             product.BrandId = brandId;
             if (row["Description"] != DBNull.Value)
             {
                 product.Description = (string)row["Description"];
             }
             product.PenetrationStatus = PenetrationStatus.Notyet;
             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)))
             {
                 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)))
             {
                 strArray = ProcessImages(current, product.ImageUrl2);
             }
             if (row["ImageUrl3"] != DBNull.Value)
             {
                 product.ImageUrl3 = (string)row["ImageUrl3"];
             }
             if (!(string.IsNullOrEmpty(product.ImageUrl3) || (product.ImageUrl3.Length <= 0)))
             {
                 strArray = ProcessImages(current, product.ImageUrl3);
             }
             if (row["ImageUrl4"] != DBNull.Value)
             {
                 product.ImageUrl4 = (string)row["ImageUrl4"];
             }
             if (!(string.IsNullOrEmpty(product.ImageUrl4) || (product.ImageUrl4.Length <= 0)))
             {
                 strArray = ProcessImages(current, product.ImageUrl4);
             }
             if (row["ImageUrl5"] != DBNull.Value)
             {
                 product.ImageUrl5 = (string)row["ImageUrl5"];
             }
             if (!(string.IsNullOrEmpty(product.ImageUrl5) || (product.ImageUrl5.Length <= 0)))
             {
                 strArray = ProcessImages(current, product.ImageUrl5);
             }
             SKUItem item = new SKUItem();
             item.SkuId = "_0";
             item.SKU = (string)row["SKU"];
             product.LowestSalePrice = item.PurchasePrice = item.SalePrice = (decimal)row["SalePrice"];
             if (row["Stock"] != DBNull.Value)
             {
                 item.Stock = (int)row["Stock"];
             }
             if (row["Weight"] != DBNull.Value)
             {
                 item.Weight = (int)row["Weight"];
             }
             Dictionary<string, SKUItem> skus = new Dictionary<string, SKUItem>();
             skus.Add(item.SkuId, item);
             AddProduct(product, skus, null);
         }
     }
 }
Exemplo n.º 27
0
 public static void ImportProducts(DataTable productData, int categoryId, int lineId, int? brandId, ProductSaleStatus saleStatus, bool isImportFromTaobao)
 {
     if ((productData != null) && (productData.Rows.Count > 0))
     {
         foreach (DataRow row in productData.Rows)
         {
             string[] strArray;
             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)))
             {
                 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)))
             {
                 strArray = ProcessImages(current, product.ImageUrl2);
             }
             if (row["ImageUrl3"] != DBNull.Value)
             {
                 product.ImageUrl3 = (string) row["ImageUrl3"];
             }
             if (!(string.IsNullOrEmpty(product.ImageUrl3) || (product.ImageUrl3.Length <= 0)))
             {
                 strArray = ProcessImages(current, product.ImageUrl3);
             }
             if (row["ImageUrl4"] != DBNull.Value)
             {
                 product.ImageUrl4 = (string) row["ImageUrl4"];
             }
             if (!(string.IsNullOrEmpty(product.ImageUrl4) || (product.ImageUrl4.Length <= 0)))
             {
                 strArray = ProcessImages(current, product.ImageUrl4);
             }
             if (row["ImageUrl5"] != DBNull.Value)
             {
                 product.ImageUrl5 = (string) row["ImageUrl5"];
             }
             if (!(string.IsNullOrEmpty(product.ImageUrl5) || (product.ImageUrl5.Length <= 0)))
             {
                 strArray = 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);
             }
         }
     }
 }