Exemplo n.º 1
0
 protected void Unnamed_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(this.cmb_CouponList.SelectedValue) || (this.cmb_CouponList.SelectedValue == "0"))
     {
         this.ShowMsg("请选择优惠券!", false);
     }
     else
     {
         int      couponId = int.Parse(this.cmb_CouponList.SelectedValue);
         DateTime date     = this.calendarStartDate.SelectedDate.Value.Date;
         DateTime time2    = this.calendarEndDate.SelectedDate.Value.Date.AddDays(1.0).AddSeconds(-1.0);
         string   text     = this.txt_MeetValue.Text;
         string   val      = this.txt_Number.Text;
         decimal  i        = 0M;
         int      num3     = 0;
         if (string.IsNullOrEmpty(this.txt_name.Text.Trim()))
         {
             this.ShowMsg("活动名称不能为空!", false);
         }
         else if (time2 < date)
         {
             this.ShowMsg("活动结束时间不能小于开始时间!", false);
         }
         else
         {
             CouponInfo coupon = CouponHelper.GetCoupon(couponId);
             if (coupon == null)
             {
                 this.ShowMsg("优惠券不存在!", false);
             }
             else if (time2 > coupon.EndDate)
             {
                 this.ShowMsg("活动结束时间不能大于优惠券的结束时间!", false);
             }
             else if (!text.bDecimal(ref i))
             {
                 this.ShowMsg("订单满足金额输入错误!", false);
             }
             else if (!val.bInt(ref num3))
             {
                 this.ShowMsg("优惠券张数输入错误!", false);
             }
             else if (string.IsNullOrEmpty(this.txt_img.Text))
             {
                 this.ShowMsg("请上传朋友圈显示图片!", false);
             }
             else if (string.IsNullOrEmpty(this.txt_title.Text.Trim()))
             {
                 this.ShowMsg("朋友圈分享标题不能为空!", false);
             }
             else if (string.IsNullOrEmpty(this.txt_des.Text.Trim()))
             {
                 this.ShowMsg("活动介绍不能为空!", false);
             }
             else
             {
                 ShareActivityInfo act = new ShareActivityInfo();
                 this.actId = int.Parse(this.shareActId.Value);
                 if (this.actId != 0)
                 {
                     act = ShareActHelper.GetAct(this.actId);
                 }
                 act.BeginDate    = date;
                 act.EndDate      = time2;
                 act.CouponId     = couponId;
                 act.CouponNumber = num3;
                 act.CouponName   = coupon.CouponName;
                 act.MeetValue    = i;
                 act.ActivityName = this.txt_name.Text;
                 act.ImgUrl       = this.txt_img.Text;
                 act.ShareTitle   = this.txt_title.Text;
                 act.Description  = this.txt_des.Text;
                 if (this.actId != 0)
                 {
                     string msg = "";
                     ShareActHelper.Update(act, ref msg);
                     this.ShowMsg("修改成功!", true);
                 }
                 else
                 {
                     string str4 = "";
                     ShareActHelper.Create(act, ref str4);
                     this.ShowMsg("保存成功!", true);
                 }
                 base.Response.Redirect("ShareActList.aspx");
             }
         }
     }
 }
Exemplo n.º 2
0
        protected void Unnamed_Click(object sender, System.EventArgs e)
        {
            if (string.IsNullOrEmpty(this.cmb_CouponList.SelectedValue) || this.cmb_CouponList.SelectedValue == "0")
            {
                this.ShowMsg("请选择优惠券!", false);
                return;
            }
            int couponId = int.Parse(this.cmb_CouponList.SelectedValue);

            System.DateTime value        = this.calendarStartDate.SelectedDate.Value;
            System.DateTime value2       = this.calendarEndDate.SelectedDate.Value;
            string          text         = this.txt_MeetValue.Text;
            string          text2        = this.txt_Number.Text;
            decimal         meetValue    = 0m;
            int             couponNumber = 0;

            if (string.IsNullOrEmpty(this.txt_name.Text.Trim()))
            {
                this.ShowMsg("活动名称不能为空!", false);
                return;
            }
            if (value2 < value)
            {
                this.ShowMsg("活动结束时间不能小于开始时间!", false);
                return;
            }
            CouponInfo coupon = CouponHelper.GetCoupon(couponId);

            if (coupon == null)
            {
                this.ShowMsg("优惠券不存在!", false);
                return;
            }
            if (value2 > coupon.EndDate)
            {
                this.ShowMsg(string.Concat(new object[]
                {
                    "活动结束时间",
                    value2,
                    "不能大于优惠券的结束时间",
                    coupon.EndDate,
                    "!"
                }), false);
                return;
            }
            if (!text.bDecimal(ref meetValue))
            {
                this.ShowMsg("订单满足金额输入错误!", false);
                return;
            }
            if (!text2.bInt(ref couponNumber))
            {
                this.ShowMsg("优惠券张数输入错误!", false);
                return;
            }
            if (string.IsNullOrEmpty(this.txt_img.Text))
            {
                this.ShowMsg("请上传朋友圈显示图片!", false);
                return;
            }
            if (string.IsNullOrEmpty(this.txt_title.Text.Trim()))
            {
                this.ShowMsg("朋友圈分享标题不能为空!", false);
                return;
            }
            if (string.IsNullOrEmpty(this.txt_des.Text.Trim()))
            {
                this.ShowMsg("活动介绍不能为空!", false);
                return;
            }
            ShareActivityInfo shareActivityInfo = new ShareActivityInfo();

            this.actId = int.Parse(this.shareActId.Value);
            if (this.actId != 0)
            {
                shareActivityInfo = ShareActHelper.GetAct(this.actId);
            }
            shareActivityInfo.BeginDate    = value;
            shareActivityInfo.EndDate      = value2;
            shareActivityInfo.CouponId     = couponId;
            shareActivityInfo.CouponNumber = couponNumber;
            shareActivityInfo.CouponName   = coupon.CouponName;
            shareActivityInfo.MeetValue    = meetValue;
            shareActivityInfo.ActivityName = this.txt_name.Text;
            shareActivityInfo.ImgUrl       = this.txt_img.Text;
            shareActivityInfo.ShareTitle   = this.txt_title.Text;
            shareActivityInfo.Description  = this.txt_des.Text;
            if (this.actId != 0)
            {
                string text3 = "";
                ShareActHelper.Update(shareActivityInfo, ref text3);
                this.ShowMsg("修改成功!", true);
            }
            else
            {
                string text4 = "";
                ShareActHelper.Create(shareActivityInfo, ref text4);
                this.ShowMsg("保存成功!", true);
            }
            base.Response.Redirect("ShareActList.aspx");
        }