public int DeleteByEventid(PromoDiscount model) { try { return _promoDisDao.DeleteByEventid(model); } catch (Exception ex) { throw new Exception("PromoDiscountMgr-->DeleteByEventid-->" + ex.Message, ex); } }
public List<PromoDiscount> GetPromoDiscount(PromoDiscount model) { StringBuilder sb = new StringBuilder(); try { List<PromoDiscount> list = new List<PromoDiscount>(); sb.Append(@"select rid,event_id,quantity,discount,special_price from promo_discount where 1=1 "); sb.AppendFormat(" and status=1 and event_id='{0}' order by quantity;", model.event_id); return _access.getDataTableForObj<PromoDiscount>(sb.ToString()); } catch (Exception ex) { throw new Exception("PromoDiscountDao-->GetPromoDiscount-->" + ex.Message + sb.ToString(), ex); } }
protected HttpResponseBase InsertPromoDis(PromoDiscount model) { string json = string.Empty; int maxQuantity, maxPrice, minDiscount, minQuantity, minPrice, maxDiscount; try { DataTable dt = _promoDiscountMgr.GetLimitByEventId(model.event_id, 0); if (dt != null) { try { maxQuantity = Convert.ToInt32(dt.Rows[0]["maxQ"].ToString()); } catch (Exception) { maxQuantity = 0; } try { maxPrice = Convert.ToInt32(dt.Rows[0]["maxS"].ToString()); } catch { maxPrice = 0; } try { minDiscount = int.Parse(dt.Rows[0]["minD"].ToString()); } catch (Exception) { minDiscount = 100; } try { minQuantity = Convert.ToInt32(dt.Rows[0]["minQ"].ToString()); } catch (Exception) { minQuantity = 0; } try { minPrice = Convert.ToInt32(dt.Rows[0]["minS"].ToString()); } catch { minPrice = 0; } try { maxDiscount = int.Parse(dt.Rows[0]["maxD"].ToString()); } catch (Exception) { maxDiscount = 100; } if ((model.quantity < minQuantity || minQuantity == 0) && model.discount == 100 && model.quantity != 0 && (dt.Rows.Count == 1 && dt.Rows[0]["minQ"].ToString() == "")) { if (_promoDiscountMgr.Save(model) > 0) { json = "{success:true,msg:0}";//返回json數據 } else { json = "{success:false,msg:0}";//返回json數據 } } else { if ((model.quantity > maxQuantity && (model.special_price > maxPrice || model.discount < minDiscount)) || (model.quantity < minQuantity && model.quantity != 0 && ((model.special_price < minPrice && model.special_price != 0) || (model.discount > maxDiscount && model.discount != 0)))) { if (_promoDiscountMgr.Save(model) > 0) { json = "{success:true,msg:0}";//返回json數據 } else { json = "{success:false,msg:0}";//返回json數據 } } else { json = "{success:false,msg:1}";//返回json數據 } } } } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{success:false,msg:0}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
/// <summary> /// 保存幾件幾元或者幾件幾折的活動條件 /// </summary> /// <returns></returns> public HttpResponseBase SavePromoDis() { PromoDiscount model = new PromoDiscount(); if (!string.IsNullOrEmpty(Request.Params["eventType"].ToString()) && !string.IsNullOrEmpty(Request.Params["id"].ToString())) { model.event_id = CommonFunction.GetEventId(Request.Params["eventType"].ToString(), Request.Params["id"].ToString()); } else { model.event_id = string.Empty; } if (!string.IsNullOrEmpty(Request.Params["jianshu"].ToString())) { model.quantity = Convert.ToInt32(Request.Params["jianshu"].ToString()); } else { model.quantity = 0; } if (Request.Params["price"] != null && !string.IsNullOrEmpty(Request.Params["price"].ToString())) { model.special_price = Convert.ToInt32(Request.Params["price"].ToString()); } else { model.special_price = 0; } if (Request.Params["discount"] != null && !string.IsNullOrEmpty(Request.Params["discount"].ToString())) { model.discount = Convert.ToInt32(Request.Params["discount"].ToString()); } else { model.discount = 0; } model.status = 1; if (string.IsNullOrEmpty(Request.Params["rid"]))//新增 { model.kuser = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id.ToString(); model.kdate = DateTime.Now; model.mdate = DateTime.Now; return InsertPromoDis(model); } else { model.rid = int.Parse(Request.Params["rid"]); model.muser = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id.ToString();//修改人 model.kdate = DateTime.Now; model.mdate = DateTime.Now; return UpdatePromoDis(model); } }
public HttpResponseBase PromoDiscountList() { /********************************************************/ List<PromoDiscount> stores = new List<PromoDiscount>(); string json = string.Empty; try { PromoDiscount query = new PromoDiscount(); string pid = string.Empty; if (!string.IsNullOrEmpty(Request.Params["ProType"].ToString()) && !string.IsNullOrEmpty(Request.Params["Proid"].ToString())) { pid = CommonFunction.GetEventId(Request.Params["ProType"].ToString(), Request.Params["Proid"].ToString()); } int totalCount = 0; query.event_id = pid; stores = _promoDiscountMgr.GetPromoDiscount(query); json = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(stores) + "}";//返回json數據 } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{success:true,totalCount:0,data:[]}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
/// <summary> /// 移除幾件幾元或幾件幾折 /// </summary> /// <returns></returns> public HttpResponseBase Deletezhe() { string jsonStr = String.Empty; PromotionsAmountDiscount query = new PromotionsAmountDiscount(); ProductCategory pmodel = new ProductCategory(); ProductCategorySet pmsmodel = new ProductCategorySet(); ProductCategorySet querypcs = new ProductCategorySet(); PromoDiscount querypd = new PromoDiscount(); PromoAll pamodel = new PromoAll(); ProdPromo ppmodel = new ProdPromo(); querypcs.Category_Id = pmodel.category_id; List<ProductCategorySet> smodel = _produCateSetMgr.Query(querypcs); if (!String.IsNullOrEmpty(Request.Params["rowid"])) { try { foreach (string rid in Request.Params["rowid"].ToString().Split('|'))//批次移除 { if (!string.IsNullOrEmpty(rid)) { //刪除peomotion_amount_discount //根據id 獲取整個model query = _promoAmountDiscountMgr.GetModelById(Convert.ToInt32(rid)); var eventid = CommonFunction.GetEventId(query.event_type, query.id.ToString()); if (_promoAmountDiscountMgr.Delete(query, eventid) > 0) { jsonStr = "{success:true}"; } else { jsonStr = "{success:false}"; } } } } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); jsonStr = "{success:false}"; } } this.Response.Clear(); this.Response.Write(jsonStr); this.Response.End(); return this.Response; }
public HttpResponseBase DeletePromoDis() { string jsonStr = String.Empty; if (!String.IsNullOrEmpty(Request.Params["rid_del"])) { try { string rid = Request.Params["rid_del"].ToString(); PromoDiscount query = new PromoDiscount(); if (!String.IsNullOrEmpty(rid)) { query.rid = Convert.ToInt32(rid); _promoDiscountMgr.DeleteByRid(Convert.ToInt32(rid)); } jsonStr = "{success:true}"; } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); jsonStr = "{success:false}"; } } this.Response.Clear(); this.Response.Write(jsonStr); this.Response.End(); return this.Response; }
/// <summary> /// 將status狀態修改爲0,即軟刪除 /// </summary> /// <param name="model"></param> /// <returns></returns> public int DeleteByEventid(PromoDiscount model) { string sql = "update promo_discount set status=0 where event_id= '" + model.event_id + "';"; try { return _access.execCommand(sql); } catch (Exception ex) { throw new Exception("PromoDiscountDao-->DeleteByEventid-->" + ex.Message + sql.ToString(), ex); } }
/// <summary> /// 刪除數據 /// </summary> /// <param name="model"></param> /// <returns></returns> public int Update(PromoDiscount model) { model.Replace4MySQL(); StringBuilder sbSql = new StringBuilder(); try { sbSql.Append(@" update promo_discount set "); sbSql.AppendFormat(" event_id='{0}', quantity={1},discount={2},special_price={3},kuser='******',kdate='{5}',muser='******',mdate='{7}' where rid={8};", model.event_id, model.quantity, model.discount, model.special_price, model.kuser, Common.CommonFunction.DateTimeToString(model.kdate), model.muser, Common.CommonFunction.DateTimeToString(model.mdate), model.rid); return _access.execCommand(sbSql.ToString()); } catch (Exception ex) { throw new Exception("PromoDiscountDao-->Update-->" + ex.Message + sbSql.ToString(), ex); } }
/// <summary> /// 保存數據 /// </summary> /// <param name="model"></param> /// <returns></returns> public int Save(PromoDiscount model) { model.Replace4MySQL(); StringBuilder sbSql = new StringBuilder(); try { sbSql.Append(@" insert into promo_discount ("); sbSql.Append(" event_id, quantity,discount,special_price,kuser,kdate,muser,mdate,status) "); sbSql.AppendFormat(" values('{0}',{1},{2},{3},'{4}','{5}','{6}','{7}','{8}');", model.event_id, model.quantity, model.discount, model.special_price, model.kuser, Common.CommonFunction.DateTimeToString(model.kdate), model.muser, Common.CommonFunction.DateTimeToString(model.mdate), model.status); return _access.execCommand(sbSql.ToString()); } catch (Exception ex) { throw new Exception("PromoDiscountDao-->Save-->" + ex.Message + sbSql.ToString(), ex); } }
public List<Model.PromoDiscount> GetPromoDiscount(PromoDiscount model) { return _promoDisDao.GetPromoDiscount(model); }