private void btnAddCutDown_Click(object sender, EventArgs e) { int num2; int num3; decimal num4; CutDownInfo cutDown = new CutDownInfo(); string str = string.Empty; if (this.dropCutDownProduct.SelectedValue > 0) { if (PromoteHelper.ProductCutDownExist(this.dropCutDownProduct.SelectedValue.Value)) { this.ShowMsg("已经存在此商品的团购活动,并且活动正在进行中", false); return; } cutDown.ProductId = this.dropCutDownProduct.SelectedValue.Value; } else { str = str + Formatter.FormatErrorMessage("请选择团购商品"); } if (!this.calendarStartDate.SelectedDate.HasValue) { str = str + Formatter.FormatErrorMessage("请选择开始日期"); } if (!this.calendarEndDate.SelectedDate.HasValue) { str = str + Formatter.FormatErrorMessage("请选择结束日期"); } else { cutDown.EndDate = this.calendarEndDate.SelectedDate.Value.AddHours((double)this.HourDropDownList1.SelectedValue.Value); if (DateTime.Compare(cutDown.EndDate, DateTime.Now) < 0) { str = str + Formatter.FormatErrorMessage("结束日期必须要晚于今天日期"); } else if (DateTime.Compare(this.calendarStartDate.SelectedDate.Value.AddHours((double)this.drophours.SelectedValue.Value), cutDown.EndDate) >= 0) { str = str + Formatter.FormatErrorMessage("开始日期必须要早于结束日期"); } else { cutDown.StartDate = this.calendarStartDate.SelectedDate.Value.AddHours((double)this.drophours.SelectedValue.Value); } } //每次砍价金额 if (!string.IsNullOrEmpty(this.TxtPerCutPrice.Text)) { decimal num; if (decimal.TryParse(this.TxtPerCutPrice.Text.Trim(), out num)) { cutDown.PerCutPrice = num; } else { str = str + Formatter.FormatErrorMessage("每次砍价金额填写格式不正确"); } } //最低金额 if (!string.IsNullOrEmpty(this.TxtMinPrice.Text)) { decimal num; if (decimal.TryParse(this.TxtMinPrice.Text.Trim(), out num)) { cutDown.MinPrice = num; } else { str = str + Formatter.FormatErrorMessage("最低金额填写格式不正确"); } } //最大砍价次数 if (int.TryParse(this.TxtMaxCount.Text.Trim(), out num2)) { cutDown.MaxCount = num2; } else { str = str + Formatter.FormatErrorMessage("最大砍价次数数量不能为空,只能为整数"); } //限购总数量 if (int.TryParse(this.TxtCount.Text.Trim(), out num3)) { cutDown.Count = num3; } else { str = str + Formatter.FormatErrorMessage("限购总数量不能为空,只能为整数"); } //最大购买数量不得小于商品的库存 //起始价格 if (!string.IsNullOrEmpty(this.TxtCurrentPrice.Text)) { decimal num; if (decimal.TryParse(this.TxtCurrentPrice.Text.Trim(), out num)) { cutDown.CurrentPrice = num; } else { str = str + Formatter.FormatErrorMessage("起始金额填写格式不正确"); } } if (!string.IsNullOrEmpty(str)) { this.ShowMsg(str, false); } else { cutDown.Content = this.txtContent.Text; if (PromoteHelper.AddCutDown(cutDown)) { this.ShowMsg("添加砍价活动成功", true); } else { this.ShowMsg("添加砍价活动失败", true); } } }