Exemplo n.º 1
0
        private void AAbiuZJB(object obj, EventArgs eventArg)
        {
            int num = 0;

            if (!this.txtStartDate.SelectedDate.HasValue)
            {
                this.ShowMsg("请选择开始日期!", false);
                return;
            }
            if (!this.txtEndDate.SelectedDate.HasValue)
            {
                this.ShowMsg("请选择结束日期!", false);
                return;
            }
            if (this.txtStartDate.SelectedDate.Value.CompareTo(this.txtEndDate.SelectedDate.Value) > 0)
            {
                this.ShowMsg("开始日期不能晚于结束日期!", false);
                return;
            }
            if (this.txtReductionMoney.Text.Trim() == "" || !int.TryParse(this.txtReductionMoney.Text.Trim(), out num))
            {
                this.ShowMsg("减免金额请输入整数!", false);
                return;
            }
            if (this.txtMeetMoney.Text.Trim() == "" || !int.TryParse(this.txtMeetMoney.Text.Trim(), out num))
            {
                this.ShowMsg("满足金额请输入整数!", false);
                return;
            }
            if (int.Parse(this.txtReductionMoney.Text.Trim()) >= int.Parse(this.txtMeetMoney.Text.Trim()))
            {
                this.ShowMsg("减免金额不能大于等于满足金额!", false);
                return;
            }
            ActivitiesInfo activitiesInfo = new ActivitiesInfo()
            {
                ActivitiesName        = this.txtName.Text.Trim(),
                ActivitiesDescription = this.txtDescription.Text.Trim(),
                StartTime             = this.txtStartDate.SelectedDate.Value,
                EndTIme        = this.txtEndDate.SelectedDate.Value,
                MeetMoney      = decimal.Parse(this.txtMeetMoney.Text.Trim()),
                ReductionMoney = decimal.Parse(this.txtReductionMoney.Text.Trim())
            };

            if (this.dropCategories.SelectedValue.ToString() == "0" || this.dropCategories.SelectedValue.ToString() == "")
            {
                activitiesInfo.ActivitiesType = 0;
                activitiesInfo.Type           = 1;
            }
            else
            {
                int?selectedValue = this.dropCategories.SelectedValue;
                activitiesInfo.ActivitiesType = int.Parse(selectedValue.ToString());
                activitiesInfo.Type           = 0;
            }
            DataTable dataTable = new DataTable();

            dataTable = (activitiesInfo.Type != 1 ? VShopHelper.GetType(1) : VShopHelper.GetType(0));
            if (dataTable.Rows.Count > 0)
            {
                this.ShowMsg("类目和全部不能同时参加活动!", false);
                return;
            }
            if (VShopHelper.AddActivities(activitiesInfo) > 0)
            {
                base.Response.Redirect("ActivitiesList.aspx");
                return;
            }
            this.ShowMsg("添加失败", false);
        }
Exemplo n.º 2
0
        private void btnAddActivity_Click(object sender, EventArgs e)
        {
            int result = 0;

            if (!this.txtStartDate.SelectedDate.HasValue)
            {
                this.ShowMsg("请选择开始日期!", false);
            }
            else if (!this.txtEndDate.SelectedDate.HasValue)
            {
                this.ShowMsg("请选择结束日期!", false);
            }
            else if (this.txtStartDate.SelectedDate.Value.CompareTo(this.txtEndDate.SelectedDate.Value) > 0)
            {
                this.ShowMsg("开始日期不能晚于结束日期!", false);
            }
            else if ((this.txtReductionMoney.Text.Trim() == "") || !int.TryParse(this.txtReductionMoney.Text.Trim(), out result))
            {
                this.ShowMsg("减免金额请输入整数!", false);
            }
            else if ((this.txtMeetMoney.Text.Trim() == "") || !int.TryParse(this.txtMeetMoney.Text.Trim(), out result))
            {
                this.ShowMsg("满足金额请输入整数!", false);
            }
            else if (int.Parse(this.txtReductionMoney.Text.Trim()) >= int.Parse(this.txtMeetMoney.Text.Trim()))
            {
                this.ShowMsg("减免金额不能大于等于满足金额!", false);
            }
            else
            {
                ActivitiesInfo activity = new ActivitiesInfo {
                    ActivitiesName        = this.txtName.Text.Trim(),
                    ActivitiesDescription = this.txtDescription.Text.Trim(),
                    StartTime             = this.txtStartDate.SelectedDate.Value,
                    EndTIme        = this.txtEndDate.SelectedDate.Value,
                    MeetMoney      = decimal.Parse(this.txtMeetMoney.Text.Trim()),
                    ReductionMoney = decimal.Parse(this.txtReductionMoney.Text.Trim())
                };
                if ((this.dropCategories.SelectedValue.ToString() == "0") || (this.dropCategories.SelectedValue.ToString() == ""))
                {
                    activity.ActivitiesType = 0;
                    activity.Type           = 1;
                }
                else
                {
                    activity.ActivitiesType = int.Parse(this.dropCategories.SelectedValue.ToString());
                    activity.Type           = 0;
                }
                DataTable type = new DataTable();
                if (activity.Type == 1)
                {
                    type = VShopHelper.GetType(0);
                }
                else
                {
                    type = VShopHelper.GetType(1);
                }
                if (type.Rows.Count > 0)
                {
                    this.ShowMsg("类目和全部不能同时参加活动!", false);
                }
                else if (VShopHelper.AddActivities(activity) > 0)
                {
                    base.Response.Redirect("ActivitiesList.aspx");
                }
                else
                {
                    this.ShowMsg("添加失败", false);
                }
            }
        }