private void btnUpdate_Click(object sender, System.EventArgs e) { GiftInfo giftDetails = GiftHelper.GetGiftDetails(this.giftId); new System.Text.RegularExpressions.Regex("^(?!_)(?!.*?_$)(?!-)(?!.*?-$)[a-zA-Z0-9_一-龥-]+$"); decimal?costPrice; decimal?marketPrice; int needPoint; if (!this.ValidateValues(out costPrice, out marketPrice, out needPoint)) { return; } giftDetails.CostPrice = costPrice; giftDetails.MarketPrice = marketPrice; giftDetails.NeedPoint = needPoint; giftDetails.Name = Globals.HtmlEncode(this.txtGiftName.Text.Trim()); giftDetails.Unit = this.txtUnit.Text.Trim(); giftDetails.ShortDescription = Globals.HtmlEncode(this.txtShortDescription.Text.Trim()); giftDetails.LongDescription = this.fcDescription.Text.Trim(); giftDetails.Title = Globals.HtmlEncode(this.txtGiftTitle.Text.Trim()); giftDetails.Meta_Description = Globals.HtmlEncode(this.txtTitleDescription.Text.Trim()); giftDetails.Meta_Keywords = Globals.HtmlEncode(this.txtTitleKeywords.Text.Trim()); giftDetails.IsPromotion = this.chkPromotion.Checked; giftDetails.ImageUrl = this.uploader1.UploadedImageUrl; giftDetails.ThumbnailUrl40 = this.uploader1.ThumbnailUrl40; giftDetails.ThumbnailUrl60 = this.uploader1.ThumbnailUrl60; giftDetails.ThumbnailUrl100 = this.uploader1.ThumbnailUrl100; giftDetails.ThumbnailUrl160 = this.uploader1.ThumbnailUrl160; giftDetails.ThumbnailUrl180 = this.uploader1.ThumbnailUrl180; giftDetails.ThumbnailUrl220 = this.uploader1.ThumbnailUrl220; giftDetails.ThumbnailUrl310 = this.uploader1.ThumbnailUrl310; giftDetails.ThumbnailUrl410 = this.uploader1.ThumbnailUrl410; ValidationResults validationResults = Validation.Validate <GiftInfo>(giftDetails, new string[] { "ValGift" }); string text = string.Empty; if (!validationResults.IsValid) { foreach (ValidationResult current in (System.Collections.Generic.IEnumerable <ValidationResult>)validationResults) { text += Formatter.FormatErrorMessage(current.Message); } } if (!string.IsNullOrEmpty(text)) { this.ShowMsg(text, false); return; } GiftActionStatus giftActionStatus = GiftHelper.UpdateGift(giftDetails); GiftActionStatus giftActionStatus2 = giftActionStatus; switch (giftActionStatus2) { case GiftActionStatus.Success: this.ShowMsg("成功修改了一件礼品的基本信息", true); return; case GiftActionStatus.DuplicateName: this.ShowMsg("已经存在相同的礼品名称", false); return; case GiftActionStatus.DuplicateSKU: this.ShowMsg("已经存在相同的商家编码", false); return; default: if (giftActionStatus2 != GiftActionStatus.UnknowError) { return; } this.ShowMsg("未知错误", false); return; } }
private void btnUpdate_Click(object sender, EventArgs e) { GiftInfo giftDetails = GiftHelper.GetGiftDetails(this.giftId); if (ActivityHelper.ExistGiftNoReceive(this.giftId)) { this.liprize.Visible = true; this.ShowMsg("有用户存在此礼品未领取,如编辑领取的礼品将以最新信息的为准", false); } else if (ActivityHelper.ExistValueInActivity(this.giftId, ActivityEnumPrizeType.Gift)) { this.liprize.Visible = true; this.ShowMsg("有活动中正在使用此礼品最为奖品,如编辑中奖的礼品将以最新的信息为准", false); } int shippingTemplateId = 0; decimal weight = default(decimal); decimal volume = default(decimal); bool isExemptionPostage = false; Regex regex = new Regex("^(?!_)(?!.*?_$)(?!-)(?!.*?-$)[a-zA-Z0-9_一-龥-]+$"); decimal?costPrice = default(decimal?); decimal?marketPrice = default(decimal?); int needPoint = default(int); if (this.ValidateValues(out costPrice, out marketPrice, out needPoint, out shippingTemplateId, out weight, out volume, out isExemptionPostage)) { giftDetails.CostPrice = costPrice; giftDetails.MarketPrice = marketPrice; giftDetails.NeedPoint = needPoint; giftDetails.Name = Globals.HtmlEncode(this.txtGiftName.Text.Trim()); giftDetails.Unit = this.txtUnit.Text.Trim(); giftDetails.ShortDescription = Globals.HtmlEncode(this.txtShortDescription.Text.Trim()); giftDetails.LongDescription = this.fcDescription.Text.Trim(); giftDetails.Title = Globals.HtmlEncode(this.txtGiftTitle.Text.Trim()); giftDetails.Meta_Description = Globals.HtmlEncode(this.txtTitleDescription.Text.Trim()); giftDetails.Meta_Keywords = Globals.HtmlEncode(this.txtTitleKeywords.Text.Trim()); giftDetails.IsPromotion = this.chkPromotion.SelectedValue; giftDetails.IsExemptionPostage = isExemptionPostage; giftDetails.IsPointExchange = this.onoffIsPointExchange.SelectedValue; ProductImagesInfo productImagesInfo = this.SaveGiftImage(); if (productImagesInfo != null) { giftDetails.ImageUrl = productImagesInfo.ImageUrl1; this.hidOldImages.Value = giftDetails.ImageUrl; giftDetails.ThumbnailUrl40 = productImagesInfo.ThumbnailUrl40; giftDetails.ThumbnailUrl60 = productImagesInfo.ThumbnailUrl60; giftDetails.ThumbnailUrl100 = productImagesInfo.ThumbnailUrl100; giftDetails.ThumbnailUrl160 = productImagesInfo.ThumbnailUrl160; giftDetails.ThumbnailUrl180 = productImagesInfo.ThumbnailUrl180; giftDetails.ThumbnailUrl220 = productImagesInfo.ThumbnailUrl220; giftDetails.ThumbnailUrl310 = productImagesInfo.ThumbnailUrl310; giftDetails.ThumbnailUrl410 = productImagesInfo.ThumbnailUrl410; } else if (this.hidUploadImages.Value.Trim().Length == 0) { if (!string.IsNullOrEmpty(giftDetails.ImageUrl)) { this.hidUploadImages.Value = giftDetails.ImageUrl; } this.ShowMsg("必须上传礼品图片", false); return; } giftDetails.IsExemptionPostage = isExemptionPostage; giftDetails.Weight = weight; giftDetails.Volume = volume; giftDetails.ShippingTemplateId = shippingTemplateId; ValidationResults validationResults = Validation.Validate(giftDetails, "ValGift"); string text = string.Empty; if (!validationResults.IsValid) { foreach (ValidationResult item in (IEnumerable <ValidationResult>)validationResults) { text += Formatter.FormatErrorMessage(item.Message); } } if (!string.IsNullOrEmpty(text)) { this.ShowMsg(text, false); } else if (GiftHelper.UpdateGift(giftDetails)) { base.Response.Redirect("Gifts.aspx?flag=2"); } else { this.ShowMsg("已经存在相同的礼品名称", false); } } }
private void btnUpdate_Click(object sender, EventArgs e) { decimal? nullable; decimal? nullable2; int num; GiftInfo giftDetails = GiftHelper.GetGiftDetails(this.giftId); new Regex("^(?!_)(?!.*?_$)(?!-)(?!.*?-$)[a-zA-Z0-9_一-龥-]+$"); if (this.ValidateValues(out nullable, out nullable2, out num)) { giftDetails.CostPrice = nullable; giftDetails.MarketPrice = nullable2; giftDetails.NeedPoint = num; giftDetails.Name = Globals.HtmlEncode(this.txtGiftName.Text.Trim()); giftDetails.Stock = int.Parse(this.txtStock.Text.Trim()); giftDetails.Unit = this.txtUnit.Text.Trim(); giftDetails.ShortDescription = Globals.HtmlEncode(this.txtShortDescription.Text.Trim()); giftDetails.LongDescription = this.fcDescription.Text.Trim(); giftDetails.Title = Globals.HtmlEncode(this.txtGiftTitle.Text.Trim()); giftDetails.Meta_Description = Globals.HtmlEncode(this.txtTitleDescription.Text.Trim()); giftDetails.Meta_Keywords = Globals.HtmlEncode(this.txtTitleKeywords.Text.Trim()); giftDetails.IsPromotion = this.chkPromotion.Checked; giftDetails.ImageUrl = this.uploader1.UploadedImageUrl; giftDetails.ThumbnailUrl40 = this.uploader1.ThumbnailUrl40; giftDetails.ThumbnailUrl60 = this.uploader1.ThumbnailUrl60; giftDetails.ThumbnailUrl100 = this.uploader1.ThumbnailUrl100; giftDetails.ThumbnailUrl160 = this.uploader1.ThumbnailUrl160; giftDetails.ThumbnailUrl180 = this.uploader1.ThumbnailUrl180; giftDetails.ThumbnailUrl220 = this.uploader1.ThumbnailUrl220; giftDetails.ThumbnailUrl310 = this.uploader1.ThumbnailUrl310; giftDetails.ThumbnailUrl410 = this.uploader1.ThumbnailUrl410; ValidationResults results = Hishop.Components.Validation.Validation.Validate <GiftInfo>(giftDetails, new string[] { "ValGift" }); string str = string.Empty; if (!results.IsValid) { foreach (ValidationResult result in (IEnumerable <ValidationResult>)results) { str = str + Formatter.FormatErrorMessage(result.Message); } } if (!string.IsNullOrEmpty(str)) { this.ShowMsg(str, false); } else { switch (GiftHelper.UpdateGift(giftDetails)) { case GiftActionStatus.Success: this.ShowMsg("成功修改了一件礼品的基本信息", true); return; case GiftActionStatus.DuplicateName: this.ShowMsg("已经存在相同的礼品名称", false); return; case GiftActionStatus.DuplicateSKU: this.ShowMsg("已经存在相同的商家编码", false); return; case GiftActionStatus.UnknowError: this.ShowMsg("未知错误", false); return; } } } }
private void btnUpdate_Click(object sender, EventArgs e) { decimal? nullable; decimal num; decimal? nullable2; int num2; GiftInfo giftDetails = GiftHelper.GetGiftDetails(giftId); if (ValidateValues(out nullable, out num, out nullable2, out num2)) { giftDetails.PurchasePrice = num; giftDetails.CostPrice = nullable; giftDetails.MarketPrice = nullable2; giftDetails.NeedPoint = num2; giftDetails.Name = txtGiftName.Text.Trim(); giftDetails.Unit = txtUnit.Text.Trim(); giftDetails.ShortDescription = txtShortDescription.Text.Trim(); giftDetails.LongDescription = fcDescription.Text.Trim(); giftDetails.Title = txtGiftTitle.Text.Trim(); giftDetails.Meta_Description = txtTitleDescription.Text.Trim(); giftDetails.Meta_Keywords = txtTitleKeywords.Text.Trim(); giftDetails.IsDownLoad = ckdown.Checked; giftDetails.ImageUrl = uploader1.UploadedImageUrl; giftDetails.ThumbnailUrl40 = uploader1.ThumbnailUrl40; giftDetails.ThumbnailUrl60 = uploader1.ThumbnailUrl60; giftDetails.ThumbnailUrl100 = uploader1.ThumbnailUrl100; giftDetails.ThumbnailUrl160 = uploader1.ThumbnailUrl160; giftDetails.ThumbnailUrl180 = uploader1.ThumbnailUrl180; giftDetails.ThumbnailUrl220 = uploader1.ThumbnailUrl220; giftDetails.ThumbnailUrl310 = uploader1.ThumbnailUrl310; giftDetails.ThumbnailUrl410 = uploader1.ThumbnailUrl410; ValidationResults results = Hishop.Components.Validation.Validation.Validate <GiftInfo>(giftDetails, new string[] { "ValGift" }); string str = string.Empty; if (giftDetails.PurchasePrice < giftDetails.CostPrice) { str = str + Formatter.FormatErrorMessage("礼品采购价不能小于成本价"); } if (!results.IsValid) { foreach (ValidationResult result in (IEnumerable <ValidationResult>)results) { str = str + Formatter.FormatErrorMessage(result.Message); } } if (!string.IsNullOrEmpty(str)) { ShowMsg(str, false); } else { switch (GiftHelper.UpdateGift(giftDetails)) { case GiftActionStatus.Success: ShowMsg("成功修改了一件礼品的基本信息", true); return; case GiftActionStatus.DuplicateName: ShowMsg("已经存在相同的礼品名称", false); return; case GiftActionStatus.DuplicateSKU: ShowMsg("已经存在相同的商家编码", false); return; case GiftActionStatus.UnknowError: ShowMsg("未知错误", false); return; } } } }