private void GetPackageNode(HttpContext context) { Maticsoft.BLL.Shop.Package.Package package = new Maticsoft.BLL.Shop.Package.Package(); int num = Globals.SafeInt(context.Request.Params["id"], 0); string str = context.Request.Params["q"]; JsonObject obj2 = new JsonObject(); StringBuilder builder = new StringBuilder(); if (num > 0) { builder.Append(" CategoryId =" + num); } if (!string.IsNullOrEmpty(str)) { if (builder.Length > 0) { builder.Append(" and "); } builder.Append(" Name like '%" + str + "%'"); } DataSet list = null; if (builder.Length > 0) { list = package.GetList(builder.ToString()); } if ((list == null) || (list.Tables[0].Rows.Count < 1)) { obj2.Accumulate("STATUS", "NODATA"); context.Response.Write(obj2.ToString()); } else { obj2.Accumulate("STATUS", "OK"); obj2.Accumulate("DATA", list.Tables[0]); context.Response.Write(obj2.ToString()); } }
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 supplierId = base.SupplierId; 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.hfProductImages.Value; string str6 = this.hfCurrentAttributes.Value; string str7 = this.hfCurrentBaseProductSKUs.Value; string str8 = this.hfCurrentProductSKUs.Value; bool flag = false; string[] strArray = new string[0]; if (!string.IsNullOrWhiteSpace(str3)) { str3 = Globals.HtmlEncodeForSpaceWrap(str3); } if (!string.IsNullOrWhiteSpace(str5)) { strArray = str5.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); } if (string.IsNullOrWhiteSpace(str6)) { MessageBox.Show(this, "属性信息不存在,请检查已填数据是否正确!"); } else { List<Maticsoft.Model.Shop.Products.AttributeInfo> list = this.GetAttributeInfo4Json(JsonMapper.ToObject(str6)); if (string.IsNullOrWhiteSpace(str7)) { MessageBox.Show(this, "基础SKU信息不存在,请检查已填数据是否正确!"); } else { List<Maticsoft.Model.Shop.Products.SKUInfo> list2 = null; decimal? nullable3 = 0M; flag = !string.IsNullOrWhiteSpace(str8); if (flag) { list2 = this.GetSKUInfo4Json(JsonMapper.ToObject(str8)); if (this.salePriceList.Count > 0) { this.salePriceList.Sort(); nullable3 = new decimal?(Convert.ToDecimal(this.salePriceList[0])); } } else { list2 = this.GetSKUInfo4Json(JsonMapper.ToObject(str7)); 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 (supplierId > 0) { productInfo.SupplierId = supplierId; } 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 = -1; productInfo.ShortDescription = str3; productInfo.Description = str4; 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 str10 = "/Upload/Shop/Images/ProductThumbs/" + DateTime.Now.ToString("yyyyMMdd") + "/"; ArrayList list3 = new ArrayList(); for (int i = 0; i < strArray.Length; i++) { if (i == 0) { string str11 = string.Format(strArray[i], ""); string str12 = strArray[i]; productInfo.ImageUrl = str11.Replace(this.tempFile, newValue); productInfo.ThumbnailUrl1 = str12.Replace(this.tempFile, str10); list3.Add(str11.Replace(this.tempFile, "")); list3.Add(str12.Replace(this.tempFile, "")); } else { string str13 = string.Format(strArray[i], ""); string str14 = strArray[i]; Maticsoft.Model.Shop.Products.ProductImage item = new Maticsoft.Model.Shop.Products.ProductImage { ImageUrl = str13.Replace(this.tempFile, newValue), ThumbnailUrl1 = str14.Replace(this.tempFile, str10) }; productInfo.ProductImages.Add(item); list3.Add(str13.Replace(this.tempFile, "")); list3.Add(str14.Replace(this.tempFile, "")); } Maticsoft.BLL.Shop.Products.ProductImage.MoveImage(strArray[i], newValue, str10); } productInfo.AttributeInfos = list; productInfo.HasSKU = flag; productInfo.SkuInfos = list2; 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> list4 = new List<int>(); string[] strArray3 = this.Hidden_SelectPackage.Value.Split(new char[] { ',' }); int packageId = 0; foreach (string str15 in strArray3) { packageId = Globals.SafeInt(str15, 0); if (package.Exists(packageId)) { list4.Add(packageId); } } productInfo.PackageId = list4; } 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 str16 = ""; str16 = this.chkSina.Checked ? "3" : ""; if (this.chkQQ.Checked) { str16 = str16 + (string.IsNullOrWhiteSpace(str16) ? "13" : ",13"); } UserBind bind = new UserBind(); string url = string.Concat(new object[] { "http://", Globals.DomainFullName, "/Product/Detail/", productId }); bind.SendWeiBo(-1, str16, productInfo.ProductName, url, productInfo.ImageUrl); base.Response.Redirect(string.Format("InStock.aspx?SaleStatus=-1", new object[0])); } else { MessageBox.Show(this, "保存失败! 请重试."); } } } } }
private void ShowInfo(int packageId) { Maticsoft.Model.Shop.Package.Package model = new Maticsoft.BLL.Shop.Package.Package().GetModel(packageId); this.txtName.Text = model.Name; this.txtRemark.Text = model.Remark; this.txtDescription.Text = model.Description; this.ddlCategory.SelectedValue = model.CategoryId.ToString(); }