protected void btnSubmit_Click(object sender, EventArgs e) { int i = 0; int num2 = 0; int num3 = 1; DateTime now = DateTime.Now; DateTime time2 = DateTime.Now; if (!this.bInt(this.txt_id.Text, ref i)) { this.ShowMsg("没有找到这张优惠券的信息!", false); } if (!this.bInt(this.txt_totalNum.Text, ref num2)) { this.ShowMsg("请输入正确的发放总量!", false); } if (!this.bInt(this.ddl_maxNum.SelectedValue, ref num3)) { num3 = 1; } if (!this.calendarStartDate2.SelectedDate.HasValue) { this.ShowMsg("请输入正确的生效时间!", false); } if (!this.calendarEndDate2.SelectedDate.HasValue) { this.ShowMsg("请输入正确的过期时间!", false); } if (num3 >= num2) { this.ShowMsg("每人限领数量不能大于或者等于总发放量!", false); } else { CouponEdit coupon = new CouponEdit { maxReceivNum = new int?(num3), totalNum = new int?(num2), begin = this.calendarStartDate2.SelectedDate, end = this.calendarEndDate2.SelectedDate }; string msg = ""; string str2 = CouponHelper.UpdateCoupon(i, coupon, ref msg); if (this.txt_used.Text == "true") { CouponHelper.setCouponFinished(i, !bFininshed); this.txt_used.Text = ""; this.BindData(); this.ShowMsg("启用优惠券成功!", true); } else if (str2 == "1") { this.ShowMsgAndReUrl("编辑优惠券成功!", true, this.reUrl); } else { this.ShowMsg(str2, false); } } }
protected void btnSubmit_Click(object sender, System.EventArgs e) { int couponId = 0; int num = 0; int num2 = 1; System.DateTime arg_0B_0 = System.DateTime.Now; System.DateTime arg_11_0 = System.DateTime.Now; if (!this.bInt(this.txt_id.Text, ref couponId)) { this.ShowMsg("没有找到这张优惠券的信息!", false); } if (!this.bInt(this.txt_totalNum.Text, ref num)) { this.ShowMsg("请输入正确的发放总量!", false); } if (!this.bInt(this.ddl_maxNum.SelectedValue, ref num2)) { num2 = 1; } if (!this.calendarStartDate2.SelectedDate.HasValue) { this.ShowMsg("请输入正确的生效时间!", false); } if (!this.calendarEndDate2.SelectedDate.HasValue) { this.ShowMsg("请输入正确的过期时间!", false); } if (num2 >= num) { this.ShowMsg("每人限领数量不能大于或者等于总发放量!", false); return; } CouponEdit couponEdit = new CouponEdit(); couponEdit.maxReceivNum = new int?(num2); couponEdit.totalNum = new int?(num); couponEdit.begin = this.calendarStartDate2.SelectedDate; couponEdit.end = this.calendarEndDate2.SelectedDate; string text = ""; string text2 = CouponHelper.UpdateCoupon(couponId, couponEdit, ref text); if (this.txt_used.Text == "true") { CouponHelper.setCouponFinished(couponId, !CouponsList.bFininshed); this.txt_used.Text = ""; this.BindData(); this.ShowMsg("启用优惠券成功!", true); return; } if (text2 == "1") { this.ShowMsgAndReUrl("编辑优惠券成功!", true, this.reUrl); return; } this.ShowMsg(text2, false); }
public bool UpdateCoupon(int couponId, CouponEdit content, ref string msg) { try { CouponInfo couponDetails = this.GetCouponDetails(couponId); int num = 0; if (couponDetails != null) { int receiveNum = couponDetails.ReceiveNum; string str = ""; if (content.maxReceivNum.HasValue) { str = str + string.Format(", maxReceivNum={0}", content.maxReceivNum); } if (content.totalNum.HasValue) { num = content.totalNum.Value - (couponDetails.StockNum + couponDetails.ReceiveNum); if ((num + couponDetails.StockNum) <= 0) { msg = "修改的优惠券总量少于已发放的数量"; return(false); } str = str + string.Format(", StockNum=StockNum + {0}", num); } if (content.begin.HasValue) { str = str + string.Format(", BeginDate='{0}'", content.begin.Value.ToString("yyyy-MM-dd HH:mm:ss")); } if (content.end.HasValue) { str = str + string.Format(", EndDate='{0}'", content.end.Value.ToString("yyyy-MM-dd HH:mm:ss")); } if (str.Length > 1) { DbCommand sqlStringCommand = this.database.GetSqlStringCommand(string.Format("UPDATE Hishop_Coupon_Coupons SET {0} WHERE CouponId={1}", str.Substring(1), couponId)); this.database.ExecuteNonQuery(sqlStringCommand); if (num < 0) { sqlStringCommand = this.database.GetSqlStringCommand(string.Format("UPDATE Hishop_Coupon_Coupons SET stockNum=0 WHERE stockNum<0 and CouponId={0}", couponId)); this.database.ExecuteNonQuery(sqlStringCommand); } return(true); } msg = "没有找到编辑内容"; return(false); } msg = "没有这个优惠券"; return(false); } catch (Exception exception) { msg = "编辑优惠券失败(" + exception.Message + ")"; return(false); } }
public ActionResult Edit([Bind(Prefix = "Item")] CouponEdit model) { IMessageProvider msg = null; if (ModelState.IsValid(model)) { this.ModelState.Clear(); msg = model.Save(); } return(View(new EcardModelItem <CouponEdit>(model, msg))); }
public string UpdateCoupon(int couponId, CouponEdit content, ref string msg) { string result; try { CouponInfo couponDetails = this.GetCouponDetails(couponId); if (couponDetails != null) { string text = ""; if (content.maxReceivNum.HasValue) { text += string.Format(",maxReceivNum={0}", content.maxReceivNum); } if (content.totalNum.HasValue) { if (content.totalNum < couponDetails.ReceiveNum) { result = "修改的优惠券总量少于已发放的数量"; return(result); } text += string.Format(",StockNum={0}", content.totalNum); } if (content.begin.HasValue) { text += string.Format(",BeginDate='{0}'", content.begin.Value.ToString("yyyy-MM-dd HH:mm:ss")); } if (content.end.HasValue) { text += string.Format(",EndDate='{0}'", content.end.Value.ToString("yyyy-MM-dd HH:mm:ss")); } if (text.Length > 1) { System.Data.Common.DbCommand sqlStringCommand = this.database.GetSqlStringCommand(string.Format("UPDATE Hishop_Coupon_Coupons SET {0} WHERE CouponId={1}", text.Substring(1), couponId)); this.database.ExecuteNonQuery(sqlStringCommand); result = "1"; } else { result = "没有找到编辑内容"; } } else { result = "没有这个优惠券"; } } catch (Exception ex) { result = "编辑优惠券失败(" + ex.Message + ")"; } return(result); }
public string UpdateCoupon(int couponId, CouponEdit content, ref string msg) { try { CouponInfo couponDetails = this.GetCouponDetails(couponId); if (couponDetails != null) { string str = ""; if (content.maxReceivNum.HasValue) { str = str + string.Format(",maxReceivNum={0}", content.maxReceivNum); } if (content.totalNum.HasValue) { int?totalNum = content.totalNum; int receiveNum = couponDetails.ReceiveNum; if ((totalNum.GetValueOrDefault() < receiveNum) && totalNum.HasValue) { return("修改的优惠券总量少于已发放的数量"); } str = str + string.Format(",StockNum={0}", content.totalNum); } if (content.begin.HasValue) { str = str + string.Format(",BeginDate='{0}'", content.begin.Value.ToString("yyyy-MM-dd HH:mm:ss")); } if (content.end.HasValue) { str = str + string.Format(",EndDate='{0}'", content.end.Value.ToString("yyyy-MM-dd HH:mm:ss")); } if (str.Length > 1) { DbCommand sqlStringCommand = this.database.GetSqlStringCommand(string.Format("UPDATE Hishop_Coupon_Coupons SET {0} WHERE CouponId={1}", str.Substring(1), couponId)); this.database.ExecuteNonQuery(sqlStringCommand); return("1"); } return("没有找到编辑内容"); } return("没有这个优惠券"); } catch (Exception exception) { return("编辑优惠券失败(" + exception.Message + ")"); } }
public static string UpdateCoupon(int couponId, CouponEdit coupon, ref string msg) { Globals.EntityCoding(coupon, true); return((new CouponDao()).UpdateCoupon(couponId, coupon, ref msg)); }