Esempio n. 1
0
        protected void btnSave_Click(object sender, System.EventArgs e)
        {
            string text = this.txtActivityName.Text;

            System.DateTime?textToDate  = this.dateBeginTime.TextToDate;
            System.DateTime?textToDate2 = this.dateEndTime.TextToDate;
            string          text2       = this.txtDescription.Text;
            int             limitNumber = 0;

            System.Web.UI.WebControls.HiddenField hiddenField  = this.memberRange.FindControl("txt_Grades") as System.Web.UI.WebControls.HiddenField;
            System.Web.UI.WebControls.HiddenField hiddenField2 = this.memberRange.FindControl("txt_DefualtGroup") as System.Web.UI.WebControls.HiddenField;
            System.Web.UI.WebControls.HiddenField hiddenField3 = this.memberRange.FindControl("txt_CustomGroup") as System.Web.UI.WebControls.HiddenField;
            if (string.IsNullOrEmpty(text))
            {
                this.ShowMsg("活动名称不能为空!", false);
                return;
            }
            if (!textToDate.HasValue || !textToDate2.HasValue)
            {
                this.ShowMsg("开始时间和结束时间都不能为空!", false);
                return;
            }
            if (textToDate.Value >= textToDate2.Value)
            {
                this.ShowMsg("开始时间不能大于或等于结束时间!", false);
                return;
            }
            if (!int.TryParse(this.txtLimitNumber.Text, out limitNumber))
            {
                this.ShowMsg("每人限购格式不对!", false);
                return;
            }
            if (hiddenField.Value == "-1" && hiddenField2.Value == "-1" && hiddenField3.Value == "-1")
            {
                this.ShowMsg("请选择适用会员!", false);
                return;
            }
            LimitedTimeDiscountInfo limitedTimeDiscountInfo = new LimitedTimeDiscountInfo();

            limitedTimeDiscountInfo.ActivityName = text;
            limitedTimeDiscountInfo.BeginTime    = textToDate.Value;
            limitedTimeDiscountInfo.EndTime      = textToDate2.Value;
            limitedTimeDiscountInfo.Description  = text2;
            limitedTimeDiscountInfo.LimitNumber  = limitNumber;
            limitedTimeDiscountInfo.ApplyMembers = hiddenField.Value;
            limitedTimeDiscountInfo.DefualtGroup = hiddenField2.Value;
            limitedTimeDiscountInfo.CustomGroup  = hiddenField3.Value;
            limitedTimeDiscountInfo.CreateTime   = System.DateTime.Now;
            limitedTimeDiscountInfo.Status       = 1.ToString();
            int num = Globals.RequestQueryNum("id");

            if (num > 0)
            {
                limitedTimeDiscountInfo.LimitedTimeDiscountId = num;
                LimitedTimeDiscountHelper.UpdateLimitedTimeDiscount(limitedTimeDiscountInfo);
            }
            this.ShowMsgAndReUrl("保存成功!", true, "EditLimitedTimeDiscount.aspx?id=" + Globals.RequestQueryNum("id"));
        }
Esempio n. 2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string      text       = this.txtActivityName.Text;
            DateTime?   textToDate = this.dateBeginTime.TextToDate;
            DateTime?   nullable2  = this.dateEndTime.TextToDate;
            string      str2       = this.txtDescription.Text;
            int         result     = 0;
            HiddenField field      = this.memberRange.FindControl("txt_Grades") as HiddenField;
            HiddenField field2     = this.memberRange.FindControl("txt_DefualtGroup") as HiddenField;
            HiddenField field3     = this.memberRange.FindControl("txt_CustomGroup") as HiddenField;

            if (string.IsNullOrEmpty(text))
            {
                this.ShowMsg("活动名称不能为空!", false);
            }
            else if (!textToDate.HasValue || !nullable2.HasValue)
            {
                this.ShowMsg("开始时间和结束时间都不能为空!", false);
            }
            else if (textToDate.Value >= nullable2.Value)
            {
                this.ShowMsg("开始时间不能大于或等于结束时间!", false);
            }
            else if (!int.TryParse(this.txtLimitNumber.Text, out result))
            {
                this.ShowMsg("每人限购格式不对!", false);
            }
            else if (((field.Value == "-1") && (field2.Value == "-1")) && (field3.Value == "-1"))
            {
                this.ShowMsg("请选择适用会员!", false);
            }
            else
            {
                LimitedTimeDiscountInfo info = new LimitedTimeDiscountInfo {
                    ActivityName = text,
                    BeginTime    = textToDate.Value,
                    EndTime      = nullable2.Value,
                    Description  = str2,
                    LimitNumber  = result,
                    ApplyMembers = field.Value,
                    DefualtGroup = field2.Value,
                    CustomGroup  = field3.Value,
                    CreateTime   = DateTime.Now
                };
                info.Status = 1.ToString();
                int num2 = Globals.RequestQueryNum("id");
                if (num2 > 0)
                {
                    info.LimitedTimeDiscountId = num2;
                    LimitedTimeDiscountHelper.UpdateLimitedTimeDiscount(info);
                }
                this.ShowMsgAndReUrl("保存成功!", true, "EditLimitedTimeDiscount.aspx?id=" + Globals.RequestQueryNum("id"));
            }
        }