public void BatInsert(int proID, string json) { //先清除再重新写入 DBCenter.DelByWhere(TbName, "ProID=" + proID); if (string.IsNullOrEmpty(json) || json.Equals("[]")) { return; } DataTable dt = JsonConvert.DeserializeObject <DataTable>(json); for (int i = 0; i < dt.Rows.Count; i++) { M_Shop_Present ptMod = new M_Shop_Present().GetModelFromReader(dt.Rows[i]); ptMod.ProID = proID; Insert(ptMod); } }
public DataTable WhereLogical(W_Filter filter) { DataTable dt = Sel(filter.cartMod.ProID); dt.Columns.Add("ok", typeof(int)); //dt.Columns.Add("remind",typeof(string)); dt.Columns.Add("R_Num", typeof(int)); dt.Columns.Add("R_Price", typeof(double)); if (dt.Rows.Count > 0) { // 检测是否符合条件,并得出最终的赠送方案 for (int i = 0; i < dt.Rows.Count; i++) { DataRow dr = dt.Rows[i]; dr["ok"] = 0; M_Shop_Present ptMod = new M_Shop_Present().GetModelFromReader(dr); int pronum = filter.cartMod.Pronum; //------------------------------------- switch (ptMod.W_Type) { case 0: //买赠 { #region 买赠 //未满足条件 if (ptMod.W_StartNum > pronum || ptMod.P_Num < 1) { } else { //倍数 int multip = Convert.ToInt32(pronum / ptMod.W_StartNum); dr["R_Num"] = ptMod.P_Num * multip; dr["ok"] = 1; } #endregion } break; case 1: //折扣 { if (ptMod.W_StartNum > pronum) { } else { //金额统计在主方法中完成 int multip = Convert.ToInt32(pronum / ptMod.W_StartNum); //有几件商品可享受优惠 //计算出折扣金额 double price = DataConvert.CDouble(filter.cartMod.FarePrice); if (price <= 0) { throw new Exception("折扣金额不正确"); } double money = (price * multip * ptMod.W_StartNum) - ((price * multip * ptMod.W_StartNum) * (ptMod.P_Price / 100)); dr["ok"] = 1; dr["R_Price"] = money.ToString("F2"); filter.DiscountMoney += money; } } break; case 2: //第二件优惠(后期移除,功能与上方重叠) { ptMod.W_StartNum = 2; if (ptMod.W_StartNum > pronum) { } else { //金额统计在主方法中完成 int multip = Convert.ToInt32(pronum / ptMod.W_StartNum); //有几件商品可享受优惠 //计算出折扣金额 double price = Convert.ToDouble(filter.cartMod.FarePrice); double money_orgin = (price * multip * ptMod.W_StartNum); //未优惠过的原价 double money_after = ((price * multip) * (ptMod.P_Price / 100)) + (price * multip); //优惠后的价格 double money = money_orgin - money_after; dr["ok"] = 1; dr["R_Price"] = money.ToString("F2"); filter.DiscountMoney += money; } } break; } } dt.DefaultView.RowFilter = "ok='1'"; dt = dt.DefaultView.ToTable(); } return(dt); }
public bool UpdateByID(M_Shop_Present model) { return(DBCenter.UpdateByID(model, model.ID)); }
public int Insert(M_Shop_Present model) { return(DBCenter.Insert(model)); }