/// <summary> /// 更新预购 /// </summary> /// <param name="model"></param> /// <returns></returns> public ActionResult UpdateExceptedBuyAction(string 型号, string 备注, int 接待, int id, string 空间) { if (Session["method"].ToString() == "Y") { string str = string.Format("<script>alert('重复操作!');parent.location.href='CustomerIndex';</script>"); return(Content(str)); } 销售_接待记录_意向明细 model = new 销售_接待记录_意向明细 { ID = id, 接待ID = 接待, 商品型号ID = productCodeBLL.GetModel(p => p.型号 == 型号).ID, 备注 = 备注, 空间 = 空间 }; if (ModelState.IsValid) { exceptedBuyBLL.Modify(model); Session["method"] = "Y"; } else { List <string> sb = new List <string>(); //获取所有错误的Key List <string> Keys = ModelState.Keys.ToList(); //获取每一个key对应的ModelStateDictionary foreach (var key in Keys) { var errors = ModelState[key].Errors.ToList(); //将错误描述添加到sb中 foreach (var error in errors) { sb.Add(error.ErrorMessage); } } string s = null; foreach (var item in sb) { s += item.ToString() + ";"; } return(Content("<script>alert('" + s + "');window.history.go(-1);</script>")); } BuildExceptedBuy(接待); ViewBag.AddReceptionid = 接待; var productList = productCodeBLL.GetModels(p => true).ToList(); SelectList productSelectListItems = new SelectList(productList, "型号", "型号"); ViewBag.ProductOptions = productSelectListItems; return(RedirectToAction("ExceptedBuyIndex", new { id = 接待 })); }
public ActionResult ExceptedBuyAdd(string exceptModel) { if (Session["method"].ToString() == "Y") { string str = string.Format("<script>alert('重复操作!');parent.location.href='CustomerIndex';</script>"); return(Json(str)); } List <CustomerExceptedBuyModel> list = JsonConvert.DeserializeObject <List <CustomerExceptedBuyModel> >(exceptModel); if (list.Count == 0) { return(Json("<script>alert('不存在你跟进的客户,你不能执行预购操作!');window.history.go(-1);</script>")); } foreach (var item in list) { 销售_接待记录_意向明细 model = new 销售_接待记录_意向明细 { 商品型号ID = productCodeBLL.GetModel(p => p.型号 == item.型号).ID, 备注 = item.备注, 接待ID = item.接待, 空间 = item.空间 }; if (ModelState.IsValid) { exceptedBuyBLL.Add(model); Session["method"] = "Y"; } else { List <string> sb = new List <string>(); //获取所有错误的Key List <string> Keys = ModelState.Keys.ToList(); //获取每一个key对应的ModelStateDictionary foreach (var key in Keys) { var errors = ModelState[key].Errors.ToList(); //将错误描述添加到sb中 foreach (var error in errors) { sb.Add(error.ErrorMessage); } } string s = null; foreach (var it in sb) { s += it.ToString() + ";"; } return(Json("<script>alert('" + s + "');window.history.go(-1);</script>")); } } //BuildExceptedBuy(model.接待ID); //ViewBag.receptionid = model.接待ID; //var productList = productCodeBLL.GetModels(p => true).ToList(); //SelectList productSelectListItems = new SelectList(productList, "型号", "型号"); //ViewBag.ProductOptions = productSelectListItems; //return RedirectToAction("ExceptedBuyIndex", new { id = list.FirstOrDefault().接待 }); return(Json("success")); }