コード例 #1
0
ファイル: PointExchange.cs プロジェクト: llenroc/kangaroo
        protected void saveBtn_Click(object sender, System.EventArgs e)
        {
            System.Web.UI.WebControls.HiddenField hiddenField  = this.SetMemberRange.FindControl("txt_Grades") as System.Web.UI.WebControls.HiddenField;
            System.Web.UI.WebControls.HiddenField hiddenField2 = this.SetMemberRange.FindControl("txt_DefualtGroup") as System.Web.UI.WebControls.HiddenField;
            System.Web.UI.WebControls.HiddenField hiddenField3 = this.SetMemberRange.FindControl("txt_CustomGroup") as System.Web.UI.WebControls.HiddenField;
            string value  = hiddenField.Value;
            string value2 = hiddenField2.Value;
            string value3 = hiddenField3.Value;
            string text   = this.txt_name.Text;

            System.DateTime?selectedDate  = this.calendarStartDate.SelectedDate;
            System.DateTime?selectedDate2 = this.calendarEndDate.SelectedDate;
            string          text2         = this.txt_img.Text;

            if (string.IsNullOrEmpty(text) || text.Length > 30)
            {
                this.ShowMsg("请输入活动名称,长度不能超过30个字符!", false);
                return;
            }
            if (value.Equals("-1") && value2.Equals("-1") && value3.Equals("-1"))
            {
                this.ShowMsg("请选择会员范围!", false);
                return;
            }
            if (selectedDate2 < selectedDate)
            {
                this.ShowMsg("结束时间不能早于开始时间!", false);
                return;
            }
            if (!selectedDate.HasValue || !selectedDate2.HasValue)
            {
                this.ShowMsg("开始时间或者结束时间不能为空!", false);
                return;
            }
            if (string.IsNullOrEmpty(text2))
            {
                this.ShowMsg("请上传封面图片!", false);
                return;
            }
            PointExChangeInfo pointExChangeInfo = new PointExChangeInfo();

            if (this.eId != 0)
            {
                pointExChangeInfo = PointExChangeHelper.Get(this.eId);
            }
            pointExChangeInfo.BeginDate    = selectedDate.Value;
            pointExChangeInfo.EndDate      = selectedDate2.Value;
            pointExChangeInfo.Name         = text;
            pointExChangeInfo.MemberGrades = value;
            pointExChangeInfo.DefualtGroup = value2;
            pointExChangeInfo.CustomGroup  = value3;
            pointExChangeInfo.ImgUrl       = text2;
            int    num = this.eId;
            string str = "";

            if (this.eId == 0)
            {
                pointExChangeInfo.ProductNumber = 0;
                int num2 = PointExChangeHelper.Create(pointExChangeInfo, ref str);
                if (num2 == 0)
                {
                    this.ShowMsg("保存失败(" + str + ")", false);
                    return;
                }
                num = num2;
                this.ShowMsg("保存成功!", true);
            }
            else
            {
                bool flag = PointExChangeHelper.Update(pointExChangeInfo, ref str);
                if (!flag)
                {
                    this.ShowMsg("保存失败(" + str + ")", false);
                    return;
                }
                this.ShowMsg("保存成功!", true);
            }
            base.Response.Redirect("AddProductToPointExchange.aspx?id=" + num.ToString());
        }
コード例 #2
0
        protected void saveBtn_Click(object sender, EventArgs e)
        {
            string   text  = this.txt_name.Text;
            string   str2  = this.txt_Grades.Value;
            DateTime date  = this.calendarStartDate.SelectedDate.Value.Date;
            DateTime time2 = this.calendarEndDate.SelectedDate.Value.Date.AddDays(1.0).AddSeconds(-1.0);
            string   str3  = this.txt_img.Text;

            if (string.IsNullOrEmpty(text) || (text.Length > 30))
            {
                this.ShowMsg("请输入活动名称,长度不能超过30个字符!", false);
            }
            else if (string.IsNullOrEmpty(str2))
            {
                this.ShowMsg("请选择会员等级!", false);
            }
            else if (time2 < date)
            {
                this.ShowMsg("结束时间不能早于开始时间!", false);
            }
            else if (string.IsNullOrEmpty(str3))
            {
                this.ShowMsg("请上传封面图片!", false);
            }
            else
            {
                PointExChangeInfo exchange = new PointExChangeInfo();
                if (this.eId != 0)
                {
                    exchange = PointExChangeHelper.Get(this.eId);
                }
                exchange.BeginDate    = date;
                exchange.EndDate      = time2;
                exchange.Name         = text;
                exchange.MemberGrades = str2;
                exchange.ImgUrl       = str3;
                int    eId = this.eId;
                string msg = "";
                if (this.eId == 0)
                {
                    exchange.ProductNumber = 0;
                    int num2 = PointExChangeHelper.Create(exchange, ref msg);
                    if (num2 == 0)
                    {
                        this.ShowMsg("保存失败(" + msg + ")", false);
                        return;
                    }
                    eId = num2;
                    this.ShowMsg("保存成功!", true);
                }
                else if (PointExChangeHelper.Update(exchange, ref msg))
                {
                    this.ShowMsg("保存成功!", true);
                }
                else
                {
                    this.ShowMsg("保存失败(" + msg + ")", false);
                    return;
                }
                base.Response.Redirect("AddProductToPointExchange.aspx?id=" + eId.ToString());
            }
        }
コード例 #3
0
        protected void saveBtn_Click(object sender, EventArgs e)
        {
            HiddenField field        = this.SetMemberRange.FindControl("txt_Grades") as HiddenField;
            HiddenField field2       = this.SetMemberRange.FindControl("txt_DefualtGroup") as HiddenField;
            HiddenField field3       = this.SetMemberRange.FindControl("txt_CustomGroup") as HiddenField;
            string      str          = field.Value;
            string      str2         = field2.Value;
            string      str3         = field3.Value;
            string      text         = this.txt_name.Text;
            DateTime?   selectedDate = this.calendarStartDate.SelectedDate;
            DateTime?   nullable2    = this.calendarEndDate.SelectedDate;
            string      str5         = this.txt_img.Text;

            if (string.IsNullOrEmpty(text) || (text.Length > 30))
            {
                this.ShowMsg("请输入活动名称,长度不能超过30个字符!", false);
            }
            else if ((str.Equals("-1") && str2.Equals("-1")) && str3.Equals("-1"))
            {
                this.ShowMsg("请选择会员范围!", false);
            }
            else
            {
                DateTime?nullable3 = nullable2;
                DateTime?nullable4 = selectedDate;
                if ((nullable3.HasValue & nullable4.HasValue) ? (nullable3.GetValueOrDefault() < nullable4.GetValueOrDefault()) : false)
                {
                    this.ShowMsg("结束时间不能早于开始时间!", false);
                }
                else if (!selectedDate.HasValue || !nullable2.HasValue)
                {
                    this.ShowMsg("开始时间或者结束时间不能为空!", false);
                }
                else if (string.IsNullOrEmpty(str5))
                {
                    this.ShowMsg("请上传封面图片!", false);
                }
                else
                {
                    PointExChangeInfo exchange = new PointExChangeInfo();
                    if (this.eId != 0)
                    {
                        exchange = PointExChangeHelper.Get(this.eId);
                    }
                    exchange.BeginDate    = selectedDate.Value;
                    exchange.EndDate      = nullable2.Value;
                    exchange.Name         = text;
                    exchange.MemberGrades = str;
                    exchange.DefualtGroup = str2;
                    exchange.CustomGroup  = str3;
                    exchange.ImgUrl       = str5;
                    int    eId = this.eId;
                    string msg = "";
                    if (this.eId == 0)
                    {
                        exchange.ProductNumber = 0;
                        int num2 = PointExChangeHelper.Create(exchange, ref msg);
                        if (num2 == 0)
                        {
                            this.ShowMsg("保存失败(" + msg + ")", false);
                            return;
                        }
                        eId = num2;
                        this.ShowMsg("保存成功!", true);
                    }
                    else if (PointExChangeHelper.Update(exchange, ref msg))
                    {
                        this.ShowMsg("保存成功!", true);
                    }
                    else
                    {
                        this.ShowMsg("保存失败(" + msg + ")", false);
                        return;
                    }
                    base.Response.Redirect("AddProductToPointExchange.aspx?id=" + eId.ToString());
                }
            }
        }