protected void btnbtnAddCountDown_Click(object sender, EventArgs e) { CountDownInfo countDownInfo = new CountDownInfo(); string str = string.Empty; if (dropGroupBuyProduct.SelectedValue > 0) { if (SubsitePromoteHelper.ProductCountDownExist(dropGroupBuyProduct.SelectedValue.Value)) { ShowMsg("已经存在此商品的限时抢购活动", false); return; } countDownInfo.ProductId = dropGroupBuyProduct.SelectedValue.Value; } else { str = str + Formatter.FormatErrorMessage("请选择限时抢购商品"); } if (!calendarEndDate.SelectedDate.HasValue) { str = str + Formatter.FormatErrorMessage("请选择结束日期"); } else { countDownInfo.EndDate = calendarEndDate.SelectedDate.Value; } if (!string.IsNullOrEmpty(txtPrice.Text)) { decimal num; if (decimal.TryParse(txtPrice.Text.Trim(), out num)) { countDownInfo.CountDownPrice = num; } else { str = str + Formatter.FormatErrorMessage("价格填写格式不正确"); } } if (!string.IsNullOrEmpty(str)) { ShowMsg(str, false); } else { countDownInfo.Content = txtContent.Text; if (SubsitePromoteHelper.AddCountDown(countDownInfo)) { ShowMsg("添加限时抢购活动成功", true); } else { ShowMsg("添加限时抢购活动失败", true); } } }
private void btnbtnAddCountDown_Click(object sender, EventArgs e) { int num; CountDownInfo countDownInfo = new CountDownInfo(); string str = string.Empty; if (this.dropGroupBuyProduct.SelectedValue > 0) { if (SubsitePromoteHelper.ProductCountDownExist(this.dropGroupBuyProduct.SelectedValue.Value)) { this.ShowMsg("已经存在此商品的限时抢购活动", false); return; } countDownInfo.ProductId = this.dropGroupBuyProduct.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 { countDownInfo.EndDate = this.calendarEndDate.SelectedDate.Value.AddHours((double)this.HourDropDownList1.SelectedValue.Value); if (DateTime.Compare(countDownInfo.EndDate, DateTime.Now) <= 0) { str = str + Formatter.FormatErrorMessage("结束日期必须要晚于今天日期"); } else if (DateTime.Compare(this.calendarStartDate.SelectedDate.Value.AddHours((double)this.drophours.SelectedValue.Value), countDownInfo.EndDate) >= 0) { str = str + Formatter.FormatErrorMessage("开始日期必须要早于结束日期"); } else { countDownInfo.StartDate = this.calendarStartDate.SelectedDate.Value.AddHours((double)this.drophours.SelectedValue.Value); } } if (int.TryParse(this.txtMaxCount.Text.Trim(), out num)) { countDownInfo.MaxCount = num; } else { str = str + Formatter.FormatErrorMessage("限购数量不能为空,只能为整数"); } if (!string.IsNullOrEmpty(this.txtPrice.Text)) { decimal num2; if (decimal.TryParse(this.txtPrice.Text.Trim(), out num2)) { countDownInfo.CountDownPrice = num2; } else { str = str + Formatter.FormatErrorMessage("价格填写格式不正确"); } } if (!string.IsNullOrEmpty(str)) { this.ShowMsg(str, false); } else { countDownInfo.Content = this.txtContent.Text; if (SubsitePromoteHelper.AddCountDown(countDownInfo)) { this.ShowMsg("添加限时抢购活动成功", true); } else { this.ShowMsg("添加限时抢购活动失败", true); } } }