//添加 public int PromotionsCreate(SWfsProductPromotionTip obj) { return(DapperUtil.Insert <SWfsProductPromotionTip>(obj, true)); }
//修改 public bool PromotionsUpdate(SWfsProductPromotionTip obj) { return(DapperUtil.Update <SWfsProductPromotionTip>(obj)); }
public ActionResult PromotionsInsert(SWfsProductPromotionTip obj, int promotionInfoId) { if (PresentationHelper.GetPassport().UserName == null) { obj.CreateUsterId = ""; } else { obj.CreateUsterId = PresentationHelper.GetPassport().UserName; } obj.IsAllProduct = Request.Form["IsAllProduct"] == "1" ? true : false; string tt = Request.Form["ProductNo"]; string set = Request.Form["MemberSet"]; if (set == "0") { obj.MemberSet = set; } else { obj.MemberSet = ',' + set + ','; } string[] tx = tt.Split(','); tt = ""; obj.CreateDate = DateTime.Now; if (obj.PromotionInfoId == 0) { if (brandService.PromotionsCreate(obj) > 0) { for (int i = 0; i < tx.Length; i++) { //循环添加商品编号 brandService.PromotionTipRefCreate(new SWfsProductPromotionTipRef { PromotionInfoId = obj.PromotionInfoId, ProductNo = tx[i] }); } ViewData["tip"] = new HtmlString("<script>alert('添加成功'); window.location.href='PromotionsList.html'</script>"); } else { ViewData["tip"] = new HtmlString("<script>alert('添加失败')</script>"); } } else { if (brandService.PromotionsUpdate(obj)) { //修改时,先删除以前的商品编号 brandService.PromotionTipRefDelete(promotionInfoId = obj.PromotionInfoId); for (int i = 0; i < tx.Length; i++) { //循环添加商品编号 brandService.PromotionTipRefCreate(new SWfsProductPromotionTipRef { PromotionInfoId = obj.PromotionInfoId, ProductNo = tx[i] }); } ViewData["tip"] = new HtmlString("<script>alert('修改成功'); window.location.href='PromotionsList.html'</script>"); } else { ViewData["tip"] = new HtmlString("<script>alert('修改失败')</script>"); } } return(View(obj)); }