public List<Maticsoft.Model.Shop.Products.ProductAccessorie> DataTableToList(DataTable dt)
 {
     List<Maticsoft.Model.Shop.Products.ProductAccessorie> list = new List<Maticsoft.Model.Shop.Products.ProductAccessorie>();
     int count = dt.Rows.Count;
     if (count > 0)
     {
         for (int i = 0; i < count; i++)
         {
             Maticsoft.Model.Shop.Products.ProductAccessorie item = new Maticsoft.Model.Shop.Products.ProductAccessorie();
             if ((dt.Rows[i]["ProductId"] != null) && (dt.Rows[i]["ProductId"].ToString() != ""))
             {
                 item.ProductId = long.Parse(dt.Rows[i]["ProductId"].ToString());
             }
             if ((dt.Rows[i]["AccessoriesValueId"] != null) && (dt.Rows[i]["AccessoriesValueId"].ToString() != ""))
             {
                 item.AccessoriesValueId = int.Parse(dt.Rows[i]["AccessoriesValueId"].ToString());
             }
             if ((dt.Rows[i]["AccessoriesName"] != null) && (dt.Rows[i]["AccessoriesName"].ToString() != ""))
             {
                 item.AccessoriesName = dt.Rows[i]["AccessoriesName"].ToString();
             }
             if ((dt.Rows[i]["MaxQuantity"] != null) && (dt.Rows[i]["MaxQuantity"].ToString() != ""))
             {
                 item.MaxQuantity = new int?(int.Parse(dt.Rows[i]["MaxQuantity"].ToString()));
             }
             if ((dt.Rows[i]["MinQuantity"] != null) && (dt.Rows[i]["MinQuantity"].ToString() != ""))
             {
                 item.MinQuantity = new int?(int.Parse(dt.Rows[i]["MinQuantity"].ToString()));
             }
             if ((dt.Rows[i]["DiscountType"] != null) && (dt.Rows[i]["DiscountType"].ToString() != ""))
             {
                 item.DiscountType = new int?(int.Parse(dt.Rows[i]["DiscountType"].ToString()));
             }
             if ((dt.Rows[i]["DiscountAmount"] != null) && (dt.Rows[i]["DiscountAmount"].ToString() != ""))
             {
                 item.DiscountAmount = new decimal?(decimal.Parse(dt.Rows[i]["DiscountAmount"].ToString()));
             }
             list.Add(item);
         }
     }
     return list;
 }
Exemple #2
0
 private void SaveProductInfo()
 {
     if (string.IsNullOrWhiteSpace(this.Hidden_SelectValue.Value))
     {
         MessageBox.ShowFailTip(this, "请选择产品分类!");
     }
     else
     {
         string text = this.txtProductName.Text;
         int num = Globals.SafeInt(this.hfCurrentProductType.Value, -1);
         int num2 = Globals.SafeInt(this.hfCurrentProductBrand.Value, -1);
         int num3 = Globals.SafeInt(this.drpSupplier.SelectedValue, -1);
         int? nullable = new int?(Globals.SafeInt(this.ajaxRegion.SelectedValue, -1));
         string str2 = this.txtUnit.Text;
         decimal? nullable2 = new decimal?(Globals.SafeDecimal(this.txtMarketPrice.Text, (decimal) -1M));
         int num4 = Globals.SafeInt(this.txtDisplaySequence.Text, -1);
         string str3 = this.txtShortDescription.Text;
         string str4 = this.txtDescription.Text;
         string str5 = this.txtUrlRule.Text;
         string str6 = this.txtMeta_Title.Text;
         string str7 = this.txtMeta_Description.Text;
         string str8 = this.txtMeta_Keywords.Text;
         string str9 = this.txtSeoImageAlt.Text;
         string str10 = this.txtSeoImageTitle.Text;
         string str11 = this.hfProductImages.Value;
         string str12 = this.hfCurrentAttributes.Value;
         string str13 = this.hfCurrentBaseProductSKUs.Value;
         string str14 = this.hfCurrentProductSKUs.Value;
         bool flag = false;
         string str15 = this.hfSelectedAccessories.Value;
         string str16 = this.HiddenField_RelatedProductInfo.Value;
         string[] strArray = new string[0];
         int num5 = Globals.SafeInt(this.rblUpselling.SelectedValue, 0);
         if (!string.IsNullOrWhiteSpace(str3))
         {
             str3 = Globals.HtmlEncodeForSpaceWrap(str3);
         }
         if (!string.IsNullOrWhiteSpace(str11))
         {
             strArray = str11.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
         }
         if (string.IsNullOrWhiteSpace(str12))
         {
             MessageBox.Show(this, "属性信息不存在,请检查已填数据是否正确!");
         }
         else
         {
             List<Maticsoft.Model.Shop.Products.AttributeInfo> list = this.GetAttributeInfo4Json(JsonMapper.ToObject(str12));
             if (string.IsNullOrWhiteSpace(str13))
             {
                 MessageBox.Show(this, "基础SKU信息不存在,请检查已填数据是否正确!");
             }
             else
             {
                 List<Maticsoft.Model.Shop.Products.SKUInfo> list2 = null;
                 decimal? nullable3 = 0M;
                 flag = !string.IsNullOrWhiteSpace(str14);
                 if (flag)
                 {
                     list2 = this.GetSKUInfo4Json(JsonMapper.ToObject(str14));
                     if (this.salePriceList.Count > 0)
                     {
                         this.salePriceList.Sort();
                         nullable3 = new decimal?(Convert.ToDecimal(this.salePriceList[0]));
                     }
                 }
                 else
                 {
                     list2 = this.GetSKUInfo4Json(JsonMapper.ToObject(str13));
                     nullable3 = new decimal?(Globals.SafeDecimal(this.txtSalePrice.Text, (decimal) -1M));
                 }
                 Maticsoft.Model.Shop.Products.ProductInfo productInfo = new Maticsoft.Model.Shop.Products.ProductInfo();
                 string[] strArray2 = this.Hidden_SelectValue.Value.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                 productInfo.Product_Categories = strArray2;
                 productInfo.ProductName = text;
                 productInfo.CategoryId = 0;
                 productInfo.TypeId = new int?(num);
                 productInfo.BrandId = num2;
                 if (num3 > 0)
                 {
                     productInfo.SupplierId = num3;
                 }
                 else
                 {
                     productInfo.SupplierId = -1;
                 }
                 productInfo.RegionId = (nullable == -1) ? null : nullable;
                 productInfo.Unit = str2;
                 productInfo.MarketPrice = (nullable2 == -1M) ? 0 : nullable2;
                 productInfo.LowestSalePrice = nullable3.Value;
                 productInfo.DisplaySequence = num4;
                 productInfo.ProductCode = this.txtProductSKU.Text;
                 productInfo.AddedDate = DateTime.Now;
                 productInfo.SaleStatus = num5;
                 productInfo.ShortDescription = str3;
                 productInfo.Description = str4;
                 productInfo.SeoUrl = str5;
                 productInfo.Meta_Title = str6;
                 productInfo.Meta_Description = str7;
                 productInfo.Meta_Keywords = str8;
                 productInfo.SeoImageAlt = str9;
                 productInfo.SeoImageTitle = str10;
                 productInfo.Tags = "";
                 if (strArray.Length == 0)
                 {
                     productInfo.ImageUrl = productInfo.ThumbnailUrl1 = productInfo.ThumbnailUrl2 = "/Content/themes/base/Shop/images/none.png";
                 }
                 string newValue = string.Format("/Upload/Shop/Images/Product/{0}/", DateTime.Now.ToString("yyyyMMdd"));
                 string str18 = "/Upload/Shop/Images/ProductThumbs/" + DateTime.Now.ToString("yyyyMMdd") + "/";
                 ArrayList list3 = new ArrayList();
                 for (int i = 0; i < strArray.Length; i++)
                 {
                     if (i == 0)
                     {
                         string str19 = string.Format(strArray[i], "");
                         string str20 = strArray[i];
                         productInfo.ImageUrl = str19.Replace(this.tempFile, newValue);
                         productInfo.ThumbnailUrl1 = str20.Replace(this.tempFile, str18);
                         list3.Add(str19.Replace(this.tempFile, ""));
                         list3.Add(str20.Replace(this.tempFile, ""));
                     }
                     else
                     {
                         string str21 = string.Format(strArray[i], "");
                         string str22 = strArray[i];
                         Maticsoft.Model.Shop.Products.ProductImage item = new Maticsoft.Model.Shop.Products.ProductImage {
                             ImageUrl = str21.Replace(this.tempFile, newValue),
                             ThumbnailUrl1 = str22.Replace(this.tempFile, str18)
                         };
                         productInfo.ProductImages.Add(item);
                         list3.Add(str21.Replace(this.tempFile, ""));
                         list3.Add(str22.Replace(this.tempFile, ""));
                     }
                     Maticsoft.BLL.Shop.Products.ProductImage.MoveImage(strArray[i], newValue, str18);
                 }
                 productInfo.AttributeInfos = list;
                 productInfo.HasSKU = flag;
                 productInfo.SkuInfos = list2;
                 string[] strArray3 = str15.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                 List<Maticsoft.Model.Shop.Products.ProductAccessorie> list4 = new List<Maticsoft.Model.Shop.Products.ProductAccessorie>();
                 foreach (string str23 in strArray3)
                 {
                     Maticsoft.Model.Shop.Products.ProductAccessorie accessorie = new Maticsoft.Model.Shop.Products.ProductAccessorie {
                         AccessoriesName = this.txtAccessorieName.Text,
                         DiscountAmount = new decimal?(Globals.SafeDecimal(this.txtDiscountAmount.Text, (decimal) 0M)),
                         DiscountType = new int?(this.rdoDiscountType4D.Checked ? 0 : 1),
                         MaxQuantity = new int?(Globals.SafeInt(this.txtMaxQuantity.Text, 1)),
                         MinQuantity = new int?(Globals.SafeInt(this.txtMinQuantity.Text, 1)),
                         SkuId = str23
                     };
                     list4.Add(accessorie);
                 }
                 productInfo.ProductAccessories = list4;
                 string[] strArray4 = str16.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                 productInfo.RelatedProductId = strArray4;
                 productInfo.isRec = this.chbRec.Checked;
                 productInfo.isNow = this.chbNew.Checked;
                 productInfo.isHot = this.chbHot.Checked;
                 productInfo.isLowPrice = this.chbLowPrice.Checked;
                 if (!string.IsNullOrEmpty(this.Hidden_SelectPackage.Value))
                 {
                     Maticsoft.BLL.Shop.Package.Package package = new Maticsoft.BLL.Shop.Package.Package();
                     List<int> list5 = new List<int>();
                     string[] strArray5 = this.Hidden_SelectPackage.Value.Split(new char[] { ',' });
                     int packageId = 0;
                     foreach (string str24 in strArray5)
                     {
                         packageId = Globals.SafeInt(str24, 0);
                         if (package.Exists(packageId))
                         {
                             list5.Add(packageId);
                         }
                     }
                     productInfo.PackageId = list5;
                 }
                 long productId = 0L;
                 if (ProductManage.AddProduct(productInfo, out productId))
                 {
                     if (this.skuImageList.Count > 0)
                     {
                         FileManage.MoveFile(base.Server.MapPath(this.tempFile), base.Server.MapPath(this.skuImageFile), this.skuImageList);
                     }
                     string str25 = "";
                     str25 = this.chkSina.Checked ? "3" : "";
                     if (this.chkQQ.Checked)
                     {
                         str25 = str25 + (string.IsNullOrWhiteSpace(str25) ? "13" : ",13");
                     }
                     UserBind bind = new UserBind();
                     string url = string.Concat(new object[] { "http://", Globals.DomainFullName, "/Product/Detail/", productId });
                     bind.SendWeiBo(-1, str25, productInfo.ProductName, url, productInfo.ImageUrl);
                     base.Response.Redirect(string.Format("ProductsInStock.aspx?SaleStatus={0}", num5));
                 }
                 else
                 {
                     MessageBox.Show(this, "保存失败! 请重试.");
                 }
             }
         }
     }
 }
 private void SaveProductInfo()
 {
     if (string.IsNullOrWhiteSpace(this.Hidden_SelectValue.Value))
     {
         MessageBox.ShowFailTip(this, "请选择产品分类!");
     }
     else
     {
         string text = this.txtProductName.Text;
         int num = Globals.SafeInt(this.hfCurrentProductType.Value, -1);
         int num2 = Globals.SafeInt(this.hfCurrentProductBrand.Value, -1);
         int num3 = Globals.SafeInt(this.drpSupplier.SelectedValue, -1);
         int? nullable = new int?(Globals.SafeInt(this.ajaxRegion.SelectedValue, -1));
         string str2 = this.txtUnit.Text;
         decimal? nullable2 = new decimal?(Globals.SafeDecimal(this.txtMarketPrice.Text, (decimal) -1M));
         int num4 = Globals.SafeInt(this.txtDisplaySequence.Text, -1);
         string str3 = this.txtShortDescription.Text;
         string str4 = this.txtDescription.Text;
         string str5 = this.txtUrlRule.Text;
         string str6 = this.txtMeta_Title.Text;
         string str7 = this.txtMeta_Description.Text;
         string str8 = this.txtMeta_Keywords.Text;
         string str9 = this.txtSeoImageAlt.Text;
         string str10 = this.txtSeoImageTitle.Text;
         string str11 = this.hfProductImages.Value;
         string str12 = this.hfCurrentAttributes.Value;
         string str13 = this.hfCurrentBaseProductSKUs.Value;
         string str14 = this.hfCurrentProductSKUs.Value;
         bool flag = false;
         string str15 = this.hfSelectedAccessories.Value;
         string str16 = this.HiddenField_RelatedProductInfo.Value;
         string[] strArray = new string[0];
         if (!string.IsNullOrWhiteSpace(str3))
         {
             str3 = Globals.HtmlEncodeForSpaceWrap(str3);
         }
         if (!string.IsNullOrWhiteSpace(str11))
         {
             strArray = str11.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
         }
         if (string.IsNullOrWhiteSpace(str12))
         {
             MessageBox.Show(this, "属性信息不存在,请检查已填数据是否正确!");
         }
         else
         {
             List<Maticsoft.Model.Shop.Products.AttributeInfo> list = this.GetAttributeInfo4Json(JsonMapper.ToObject(str12));
             if (string.IsNullOrWhiteSpace(str13))
             {
                 MessageBox.Show(this, "基础SKU信息不存在,请检查已填数据是否正确!");
             }
             else
             {
                 List<Maticsoft.Model.Shop.Products.SKUInfo> list2 = null;
                 decimal? nullable3 = 0M;
                 flag = !string.IsNullOrWhiteSpace(str14);
                 if (flag)
                 {
                     list2 = this.GetSKUInfo4Json(JsonMapper.ToObject(str14));
                     if (this.salePriceList.Count > 0)
                     {
                         this.salePriceList.Sort();
                         nullable3 = new decimal?(Convert.ToDecimal(this.salePriceList[0]));
                     }
                 }
                 else
                 {
                     list2 = this.GetSKUInfo4Json(JsonMapper.ToObject(str13));
                     nullable3 = new decimal?(Globals.SafeDecimal(this.txtSalePrice.Text, (decimal) -1M));
                 }
                 Maticsoft.Model.Shop.Products.ProductInfo model = new Maticsoft.BLL.Shop.Products.ProductInfo().GetModel(this.ProductId);
                 string[] strArray2 = this.Hidden_SelectValue.Value.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                 model.Product_Categories = strArray2;
                 model.ProductName = text;
                 model.CategoryId = 0;
                 model.TypeId = new int?(num);
                 model.BrandId = num2;
                 if (num3 > 0)
                 {
                     model.SupplierId = num3;
                 }
                 else
                 {
                     model.SupplierId = -1;
                 }
                 model.RegionId = (nullable == -1) ? null : nullable;
                 model.Unit = str2;
                 model.MarketPrice = (nullable2 == -1M) ? null : nullable2;
                 model.LowestSalePrice = nullable3.Value;
                 model.DisplaySequence = num4;
                 model.ProductCode = this.txtProductSKU.Text;
                 model.AddedDate = DateTime.Now;
                 model.SaleStatus = Globals.SafeInt(this.rblUpselling.SelectedValue, 0);
                 model.ShortDescription = str3;
                 model.Description = str4;
                 model.SeoUrl = str5;
                 model.Meta_Title = str6;
                 model.Meta_Description = str7;
                 model.Meta_Keywords = str8;
                 model.SeoImageAlt = str9;
                 model.SeoImageTitle = str10;
                 model.Tags = "";
                 if (strArray.Length == 0)
                 {
                     model.ImageUrl = model.ThumbnailUrl1 = model.ThumbnailUrl2 = "/Content/themes/base/Shop/images/none.png";
                 }
                 string newValue = string.Format("/Upload/Shop/Images/Product/{0}/", DateTime.Now.ToString("yyyyMMdd"));
                 string str18 = "/Upload/Shop/Images/ProductThumbs/" + DateTime.Now.ToString("yyyyMMdd") + "/";
                 ArrayList list3 = new ArrayList();
                 for (int i = 0; i < strArray.Length; i++)
                 {
                     if (i == 0)
                     {
                         if (strArray[i].Contains(this.tempFile))
                         {
                             string str19 = string.Format(strArray[i], "");
                             string str20 = strArray[i];
                             model.ImageUrl = str19.Replace(this.tempFile, newValue);
                             model.ThumbnailUrl1 = str20.Replace(this.tempFile, str18);
                             list3.Add(str19.Replace(this.tempFile, ""));
                             list3.Add(str20.Replace(this.tempFile, ""));
                             Maticsoft.BLL.Shop.Products.ProductImage.MoveImage(strArray[i], newValue, str18);
                         }
                     }
                     else
                     {
                         string str21 = string.Format(strArray[i], "");
                         string str22 = strArray[i];
                         Maticsoft.Model.Shop.Products.ProductImage item = new Maticsoft.Model.Shop.Products.ProductImage {
                             ImageUrl = str21.Replace(this.tempFile, newValue),
                             ThumbnailUrl1 = str22.Replace(this.tempFile, str18)
                         };
                         model.ProductImages.Add(item);
                         list3.Add(str21.Replace(this.tempFile, ""));
                         list3.Add(str22.Replace(this.tempFile, ""));
                         Maticsoft.BLL.Shop.Products.ProductImage.MoveImage(strArray[i], newValue, str18);
                     }
                 }
                 model.AttributeInfos = list;
                 model.HasSKU = flag;
                 model.SkuInfos = list2;
                 string[] strArray3 = str15.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                 List<Maticsoft.Model.Shop.Products.ProductAccessorie> list4 = new List<Maticsoft.Model.Shop.Products.ProductAccessorie>();
                 foreach (string str23 in strArray3)
                 {
                     Maticsoft.Model.Shop.Products.ProductAccessorie accessorie = new Maticsoft.Model.Shop.Products.ProductAccessorie {
                         AccessoriesName = this.txtAccessorieName.Text,
                         DiscountAmount = new decimal?(Globals.SafeDecimal(this.txtDiscountAmount.Text, (decimal) 0M)),
                         DiscountType = new int?(this.rdoDiscountType4D.Checked ? 0 : 1),
                         MaxQuantity = new int?(Globals.SafeInt(this.txtMaxQuantity.Text, 1)),
                         MinQuantity = new int?(Globals.SafeInt(this.txtMinQuantity.Text, 1)),
                         SkuId = str23
                     };
                     list4.Add(accessorie);
                 }
                 model.ProductAccessories = list4;
                 string[] strArray4 = str16.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                 model.RelatedProductId = strArray4;
                 model.ProductId = this.ProductId;
                 if (ProductManage.ModifyProduct(model))
                 {
                     try
                     {
                         int count = list3.Count;
                         if (this.skuImageList.Count > 0)
                         {
                             FileManage.MoveFile(base.Server.MapPath(this.tempFile), base.Server.MapPath(this.skuImageFile), this.skuImageList);
                         }
                     }
                     catch (Exception)
                     {
                     }
                     base.Response.Redirect(string.Format("ProductsInStock.aspx?SaleStatus={0}", model.SaleStatus));
                 }
                 else
                 {
                     MessageBox.Show(this, "保存失败! 请重试.");
                 }
             }
         }
     }
 }
 public Maticsoft.Model.Shop.Products.ProductAccessorie GetModel(long ProductId, int AccessoriesValueId)
 {
     StringBuilder builder = new StringBuilder();
     builder.Append("SELECT  TOP 1 ProductId,AccessoriesValueId,AccessoriesName,MaxQuantity,MinQuantity,DiscountType,DiscountAmount FROM Shop_ProductAccessories ");
     builder.Append(" WHERE ProductId=@ProductId and AccessoriesValueId=@AccessoriesValueId ");
     SqlParameter[] cmdParms = new SqlParameter[] { new SqlParameter("@ProductId", SqlDbType.BigInt, 8), new SqlParameter("@AccessoriesValueId", SqlDbType.Int, 4) };
     cmdParms[0].Value = ProductId;
     cmdParms[1].Value = AccessoriesValueId;
     Maticsoft.Model.Shop.Products.ProductAccessorie accessorie = new Maticsoft.Model.Shop.Products.ProductAccessorie();
     DataSet set = DbHelperSQL.Query(builder.ToString(), cmdParms);
     if (set.Tables[0].Rows.Count <= 0)
     {
         return null;
     }
     if ((set.Tables[0].Rows[0]["ProductId"] != null) && (set.Tables[0].Rows[0]["ProductId"].ToString() != ""))
     {
         accessorie.ProductId = long.Parse(set.Tables[0].Rows[0]["ProductId"].ToString());
     }
     if ((set.Tables[0].Rows[0]["AccessoriesValueId"] != null) && (set.Tables[0].Rows[0]["AccessoriesValueId"].ToString() != ""))
     {
         accessorie.AccessoriesValueId = int.Parse(set.Tables[0].Rows[0]["AccessoriesValueId"].ToString());
     }
     if ((set.Tables[0].Rows[0]["AccessoriesName"] != null) && (set.Tables[0].Rows[0]["AccessoriesName"].ToString() != ""))
     {
         accessorie.AccessoriesName = set.Tables[0].Rows[0]["AccessoriesName"].ToString();
     }
     if ((set.Tables[0].Rows[0]["MaxQuantity"] != null) && (set.Tables[0].Rows[0]["MaxQuantity"].ToString() != ""))
     {
         accessorie.MaxQuantity = new int?(int.Parse(set.Tables[0].Rows[0]["MaxQuantity"].ToString()));
     }
     if ((set.Tables[0].Rows[0]["MinQuantity"] != null) && (set.Tables[0].Rows[0]["MinQuantity"].ToString() != ""))
     {
         accessorie.MinQuantity = new int?(int.Parse(set.Tables[0].Rows[0]["MinQuantity"].ToString()));
     }
     if ((set.Tables[0].Rows[0]["DiscountType"] != null) && (set.Tables[0].Rows[0]["DiscountType"].ToString() != ""))
     {
         accessorie.DiscountType = new int?(int.Parse(set.Tables[0].Rows[0]["DiscountType"].ToString()));
     }
     if ((set.Tables[0].Rows[0]["DiscountAmount"] != null) && (set.Tables[0].Rows[0]["DiscountAmount"].ToString() != ""))
     {
         accessorie.DiscountAmount = new decimal?(decimal.Parse(set.Tables[0].Rows[0]["DiscountAmount"].ToString()));
     }
     return accessorie;
 }