예제 #1
0
        public static bool DeleteGift(int giftId)
        {
            GiftInfo gift = new GiftInfo
            {
                GiftId = giftId
            };
            GiftActionStatus giftActionStatus = PromotionsProvider.Instance().CreateUpdateDeleteGift(gift, DataProviderAction.Delete);

            return(giftActionStatus == GiftActionStatus.Success);
        }
예제 #2
0
        public GiftActionStatus CreateUpdateDeleteGift(GiftInfo gift, DataProviderAction action)
        {
            GiftActionStatus result;

            if (null == gift)
            {
                result = GiftActionStatus.UnknowError;
            }
            else
            {
                DbCommand storedProcCommand = this.database.GetStoredProcCommand("cp_Gift_CreateUpdateDelete");
                this.database.AddInParameter(storedProcCommand, "Action", DbType.Int32, (int)action);
                this.database.AddOutParameter(storedProcCommand, "Status", DbType.Int32, 4);
                if (DataProviderAction.Create != action)
                {
                    this.database.AddInParameter(storedProcCommand, "GiftId", DbType.Int32, gift.GiftId);
                }
                else
                {
                    this.database.AddOutParameter(storedProcCommand, "GiftId", DbType.Int32, 4);
                }
                if (DataProviderAction.Delete != action)
                {
                    this.database.AddInParameter(storedProcCommand, "Name", DbType.String, gift.Name);
                    this.database.AddInParameter(storedProcCommand, "ShortDescription", DbType.String, gift.ShortDescription);
                    this.database.AddInParameter(storedProcCommand, "Unit", DbType.String, gift.Unit);
                    this.database.AddInParameter(storedProcCommand, "LongDescription", DbType.String, gift.LongDescription);
                    this.database.AddInParameter(storedProcCommand, "Title", DbType.String, gift.Title);
                    this.database.AddInParameter(storedProcCommand, "Meta_Description", DbType.String, gift.Meta_Description);
                    this.database.AddInParameter(storedProcCommand, "Meta_Keywords", DbType.String, gift.Meta_Keywords);
                    this.database.AddInParameter(storedProcCommand, "CostPrice", DbType.Currency, gift.CostPrice);
                    this.database.AddInParameter(storedProcCommand, "ImageUrl", DbType.String, gift.ImageUrl);
                    this.database.AddInParameter(storedProcCommand, "ThumbnailUrl40", DbType.String, gift.ThumbnailUrl40);
                    this.database.AddInParameter(storedProcCommand, "ThumbnailUrl60", DbType.String, gift.ThumbnailUrl60);
                    this.database.AddInParameter(storedProcCommand, "ThumbnailUrl100", DbType.String, gift.ThumbnailUrl100);
                    this.database.AddInParameter(storedProcCommand, "ThumbnailUrl160", DbType.String, gift.ThumbnailUrl160);
                    this.database.AddInParameter(storedProcCommand, "ThumbnailUrl180", DbType.String, gift.ThumbnailUrl180);
                    this.database.AddInParameter(storedProcCommand, "ThumbnailUrl220", DbType.String, gift.ThumbnailUrl220);
                    this.database.AddInParameter(storedProcCommand, "ThumbnailUrl310", DbType.String, gift.ThumbnailUrl310);
                    this.database.AddInParameter(storedProcCommand, "ThumbnailUrl410", DbType.String, gift.ThumbnailUrl410);
                    this.database.AddInParameter(storedProcCommand, "MarketPrice", DbType.Currency, gift.MarketPrice);
                    this.database.AddInParameter(storedProcCommand, "NeedPoint", DbType.Int32, gift.NeedPoint);
                    this.database.AddInParameter(storedProcCommand, "IsPromotion", DbType.Boolean, gift.IsPromotion);
                }
                else
                {
                    this.database.AddInParameter(storedProcCommand, "IsPromotion", DbType.Boolean, false);
                }
                this.database.ExecuteNonQuery(storedProcCommand);
                GiftActionStatus giftActionStatus = (GiftActionStatus)((int)this.database.GetParameterValue(storedProcCommand, "Status"));
                result = giftActionStatus;
            }
            return(result);
        }
예제 #3
0
        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);
            }
        }
예제 #4
0
        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;
            }
        }