public ActionResult Edit(totalitems model) { ControllerResult result = ControllerResult.SuccResult; string errorMsg = string.Empty; var editResult = itemNameService.EditTotalItem(model, out errorMsg); if (!editResult) { result.IsSucc = false; result.ErroMsg = errorMsg; } else { LogUserAction("对id为{0}进行了修改检测项目参数操作,检测项目参数名称{1}".Fmt(model.Id, model.ItemName)); } return(Content(result.ToJson())); }
public bool NewTotalItem(totalitems item, out string errorMsg) { errorMsg = string.Empty; bool ItemNames = false; var itemnames = GetAllItemCodes(); foreach (var itemname in itemnames) { if (itemname.itemcode != null) { if (item.itemcode.Contains(itemname.itemcode)) { errorMsg = "已有该检查项目编号!"; return(false); } else { ItemNames = true; } } } if (ItemNames) { using (var db = dbFactory.Open()) { try { errorMsg = string.Empty; db.Insert(new totalitems { typecode = item.typecode, ItemName = item.ItemName, itemtype = item.itemtype, itemcode = item.itemcode }); cacheItemCodes.Clear(); return(true); } catch (Exception ex) { errorMsg = ex.Message; return(false); } } } else { return(false); } }
public bool EditTotalItem(totalitems item, out string errorMsg) { errorMsg = string.Empty; try { int updateCount = totalItemRep.UpdateOnly(item, l => l.Id == item.Id, r => new { r.ItemName, r.itemcode, r.itemtype }); return(true); } catch (Exception ex) { errorMsg = ex.Message; return(false); } }
public ActionResult NewCheckItem(totalitems model) { ControllerResult result = ControllerResult.SuccResult; string errorMsg = string.Empty; bool newResult = itemNameService.NewTotalItem(model, out errorMsg); if (!newResult) { result = ControllerResult.FailResult; result.ErroMsg = errorMsg; } else { LogUserAction("进行了新建检测项目操作,检测类别编号为{0},检测项目编号{1},检测项目名称{2}".Fmt(model.typecode, model.itemcode, model.ItemName)); } return(Content(result.ToJson())); }