public ActionResult UpdateCityPaintItem(int pkid, string pid, string displayName, decimal price, string pkids) { PaintInfoModel model = new PaintInfoModel(); model.PKID = pkid; model.PID = pid; model.DisplayName = displayName; model.Price = price; model.IsCountry = false; bool result = CityPaintManager.UpdateCityPaintModel(model); if (!result) { return(Json(new { msg = "fail" })); } OprLogManager oprLog = new OprLogManager(); DataAccess.Entity.OprLog modelLog = new DataAccess.Entity.OprLog(); modelLog.Author = User.Identity.Name; modelLog.ObjectID = pkid; modelLog.ObjectType = "CityPaint"; modelLog.Operation = "修改油漆产品:" + model.DisplayName; try { oprLog.AddOprLog(modelLog); } catch { } var citys = CityPaintManager.SelectCityRegionList(pkids); List <CityPaintModel> cityPaintList = new List <CityPaintModel>(); if (citys != null && citys.Any()) { foreach (var city in citys) { CityPaintModel mo = new CityPaintModel(); mo.PaintId = pkid; mo.CityId = city.CityID; mo.ProvinceId = city.ProvinceID; mo.CityName = city.City; mo.CreatedTime = DateTime.Now; mo.UpdatedTime = DateTime.Now; cityPaintList.Add(mo); } } List <CityPaintModel> existList = new List <CityPaintModel>(); existList = CityPaintManager.SelectPaintCityList(pkid).ToList(); //获取所有待更新数据 var dt = GetDtForUpdate(cityPaintList, existList); bool allResult = CityPaintManager.BulkSaveCityPaint(dt); if (!allResult) { return(Json(new { msg = "油漆配置城市添加失败" })); } return(Json(new { msg = "success" })); }
public ActionResult CityPaintItem(string pkid = null) { List <SelectListItem> lsSelItem = new List <SelectListItem>(); IEnumerable <PaintModel> list = CityPaintManager.SelectPaintList(); if (list != null && list.Any()) { foreach (var paint in list) { SelectListItem sel = new SelectListItem(); sel = new SelectListItem(); sel.Value = paint.PID.ToString(); sel.Text = paint.DisplayName; lsSelItem.Add(sel); } } List <SelectListItem> listItem = new List <SelectListItem>(); PaintInfoModel model = new PaintInfoModel(); if (pkid != null) { model = CityPaintManager.GetCityPaintByPKID(Int32.Parse(pkid)); if (model.PID != null) { foreach (var ss in lsSelItem) { if (ss.Value == model.PID.ToString()) { ss.Selected = true; } listItem.Add(ss); } } else { listItem = lsSelItem; } } else { listItem = lsSelItem; } SelectList ddlSelData = new SelectList(listItem.AsEnumerable(), "Value", "Text", "请选择"); ViewData["ddlPaintTypeData"] = ddlSelData; #region 获取所有城市 var cityList = CityPaintManager.SelectAllCityRegionList().ToList(); if (pkid != null) { var selectedCityList = CityPaintManager.SelectPaintCityList(Convert.ToInt32(pkid)).ToList(); foreach (var city in cityList) { var cl = selectedCityList.Where(x => x.CityId == city.CityID); if (cl.Any()) { city.Selected = true; } } } model.CityList = cityList; #endregion return(View("CityPaintItem", model)); }