private void btnCreate_Click(object sender, System.EventArgs e) { decimal?costPrice; decimal purchasePrice; decimal?marketPrice; int needPoint; if (!this.ValidateValues(out costPrice, out purchasePrice, out marketPrice, out needPoint)) { return; } GiftInfo giftInfo = new GiftInfo { PurchasePrice = purchasePrice, CostPrice = costPrice, MarketPrice = marketPrice, NeedPoint = needPoint, Name = Globals.HtmlEncode(this.txtGiftName.Text.Trim()), Unit = this.txtUnit.Text.Trim(), ShortDescription = Globals.HtmlEncode(this.txtShortDescription.Text.Trim()), LongDescription = string.IsNullOrEmpty(this.fcDescription.Text) ? null : this.fcDescription.Text.Trim(), Title = Globals.HtmlEncode(this.txtGiftTitle.Text.Trim()), Meta_Description = Globals.HtmlEncode(this.txtTitleDescription.Text.Trim()), Meta_Keywords = Globals.HtmlEncode(this.txtTitleKeywords.Text.Trim()), IsDownLoad = this.chkDownLoad.Checked, IsPromotion = this.chkPromotion.Checked }; giftInfo.ImageUrl = this.uploader1.UploadedImageUrl; giftInfo.ThumbnailUrl40 = this.uploader1.ThumbnailUrl40; giftInfo.ThumbnailUrl60 = this.uploader1.ThumbnailUrl60; giftInfo.ThumbnailUrl100 = this.uploader1.ThumbnailUrl100; giftInfo.ThumbnailUrl160 = this.uploader1.ThumbnailUrl160; giftInfo.ThumbnailUrl180 = this.uploader1.ThumbnailUrl180; giftInfo.ThumbnailUrl220 = this.uploader1.ThumbnailUrl220; giftInfo.ThumbnailUrl310 = this.uploader1.ThumbnailUrl310; giftInfo.ThumbnailUrl410 = this.uploader1.ThumbnailUrl410; ValidationResults validationResults = Validation.Validate <GiftInfo>(giftInfo, new string[] { "ValGift" }); string text = string.Empty; if (giftInfo.PurchasePrice < giftInfo.CostPrice) { text += Formatter.FormatErrorMessage("礼品采购价不能小于成本价"); } 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.AddGift(giftInfo); if (giftActionStatus == GiftActionStatus.Success) { this.ShowMsg("成功的添加了一件礼品", true); return; } if (giftActionStatus == GiftActionStatus.UnknowError) { this.ShowMsg("未知错误", false); return; } if (giftActionStatus == GiftActionStatus.DuplicateSKU) { this.ShowMsg("已经存在相同的商家编码", false); return; } if (giftActionStatus == GiftActionStatus.DuplicateName) { this.ShowMsg("已经存在相同的礼品名称", false); } }
private void btnCreate_Click(object sender, EventArgs e) { decimal?nullable; decimal?nullable2; int num; if (this.ValidateValues(out nullable, out nullable2, out num)) { GiftInfo target = new GiftInfo { CostPrice = nullable, MarketPrice = nullable2, NeedPoint = num, Name = Globals.HtmlEncode(this.txtGiftName.Text.Trim()), Unit = this.txtUnit.Text.Trim(), ShortDescription = Globals.HtmlEncode(this.txtShortDescription.Text.Trim()), LongDescription = string.IsNullOrEmpty(this.fcDescription.Text) ? null : this.fcDescription.Text.Trim(), Title = Globals.HtmlEncode(this.txtGiftTitle.Text.Trim()), Meta_Description = Globals.HtmlEncode(this.txtTitleDescription.Text.Trim()), Meta_Keywords = Globals.HtmlEncode(this.txtTitleKeywords.Text.Trim()), IsPromotion = this.chkPromotion.Checked, Stock = int.Parse(this.txtStock.Text.Trim()) }; target.ImageUrl = this.uploader1.UploadedImageUrl; target.ThumbnailUrl40 = this.uploader1.ThumbnailUrl40; target.ThumbnailUrl60 = this.uploader1.ThumbnailUrl60; target.ThumbnailUrl100 = this.uploader1.ThumbnailUrl100; target.ThumbnailUrl160 = this.uploader1.ThumbnailUrl160; target.ThumbnailUrl180 = this.uploader1.ThumbnailUrl180; target.ThumbnailUrl220 = this.uploader1.ThumbnailUrl220; target.ThumbnailUrl310 = this.uploader1.ThumbnailUrl310; target.ThumbnailUrl410 = this.uploader1.ThumbnailUrl410; ValidationResults results = Hishop.Components.Validation.Validation.Validate <GiftInfo>(target, 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.AddGift(target)) { case GiftActionStatus.Success: this.ShowMsg("成功的添加了一件礼品", true); return; case GiftActionStatus.UnknowError: this.ShowMsg("未知错误", false); return; case GiftActionStatus.DuplicateSKU: this.ShowMsg("已经存在相同的商家编码", false); return; case GiftActionStatus.DuplicateName: this.ShowMsg("已经存在相同的礼品名称", false); break; } } } }
private void btnCreate_Click(object sender, EventArgs e) { decimal?nullable; decimal num; decimal?nullable2; int num2; if (ValidateValues(out nullable, out num, out nullable2, out num2)) { GiftInfo target = new GiftInfo(); target.PurchasePrice = num; target.CostPrice = nullable; target.MarketPrice = nullable2; target.NeedPoint = num2; target.Name = txtGiftName.Text.Trim(); target.Unit = txtUnit.Text.Trim(); target.ShortDescription = txtShortDescription.Text.Trim(); target.LongDescription = string.IsNullOrEmpty(fcDescription.Text) ? null : fcDescription.Text.Trim(); target.Title = txtGiftTitle.Text.Trim(); target.Meta_Description = txtTitleDescription.Text.Trim(); target.Meta_Keywords = txtTitleKeywords.Text.Trim(); target.IsDownLoad = ckdown.Checked; target.ImageUrl = uploader1.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; ValidationResults results = Hishop.Components.Validation.Validation.Validate <GiftInfo>(target, new string[] { "ValGift" }); string str = string.Empty; if (target.PurchasePrice < target.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.AddGift(target)) { case GiftActionStatus.Success: ShowMsg("成功的添加了一件礼品", true); return; case GiftActionStatus.DuplicateName: ShowMsg("已经存在相同的礼品名称", false); return; case GiftActionStatus.DuplicateSKU: ShowMsg("已经存在相同的商家编码", false); return; case GiftActionStatus.UnknowError: ShowMsg("未知错误", false); return; } } } }
private void btnCreate_Click(object sender, EventArgs e) { int shippingTemplateId = 0; decimal weight = default(decimal); decimal volume = default(decimal); bool isExemptionPostage = false; 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)) { GiftInfo giftInfo = new GiftInfo { CostPrice = costPrice, MarketPrice = marketPrice, NeedPoint = needPoint, Name = Globals.HtmlEncode(this.txtGiftName.Text.Trim()), Unit = this.txtUnit.Text.Trim(), ShortDescription = Globals.HtmlEncode(this.txtShortDescription.Text.Trim()), LongDescription = (string.IsNullOrEmpty(this.fcDescription.Text) ? null : this.fcDescription.Text.Trim()), Title = Globals.HtmlEncode(this.txtGiftTitle.Text.Trim()), Meta_Description = Globals.HtmlEncode(this.txtTitleDescription.Text.Trim()), Meta_Keywords = Globals.HtmlEncode(this.txtTitleKeywords.Text.Trim()), IsPromotion = this.chkPromotion.SelectedValue, IsExemptionPostage = isExemptionPostage, ShippingTemplateId = shippingTemplateId, Weight = weight, Volume = volume, IsPointExchange = this.onoffIsPointExchange.SelectedValue }; ProductImagesInfo productImagesInfo = this.SaveGiftImage(); if (productImagesInfo != null) { giftInfo.ImageUrl = productImagesInfo.ImageUrl1; this.hidOldImages.Value = giftInfo.ImageUrl; giftInfo.ThumbnailUrl40 = productImagesInfo.ThumbnailUrl40; giftInfo.ThumbnailUrl60 = productImagesInfo.ThumbnailUrl60; giftInfo.ThumbnailUrl100 = productImagesInfo.ThumbnailUrl100; giftInfo.ThumbnailUrl160 = productImagesInfo.ThumbnailUrl160; giftInfo.ThumbnailUrl180 = productImagesInfo.ThumbnailUrl180; giftInfo.ThumbnailUrl220 = productImagesInfo.ThumbnailUrl220; giftInfo.ThumbnailUrl310 = productImagesInfo.ThumbnailUrl310; giftInfo.ThumbnailUrl410 = productImagesInfo.ThumbnailUrl410; } else if (this.hidUploadImages.Value.Trim().Length == 0) { this.ShowMsg("必须上传礼品图片", false); return; } ValidationResults validationResults = Validation.Validate(giftInfo, "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.AddGift(giftInfo)) { base.Response.Redirect("Gifts.aspx?flag=1"); } else { this.ShowMsg("已经存在相同的礼品名称", false); } } }