public void SubmitForm(SpecialEntity specialEntity, string keyValue) { if (!string.IsNullOrEmpty(keyValue)) { if (service.IQueryable().Count(t => t.F_EnCode.Equals(specialEntity.F_EnCode) && !t.F_Id.Equals(keyValue)) > 0) { throw new Exception("修改失败!操作的对象编号已存在。"); } specialEntity.Modify(keyValue); service.Update(specialEntity); } else { if (service.IQueryable().Count(t => t.F_EnCode.Equals(specialEntity.F_EnCode)) > 0) { throw new Exception("添加失败!操作的对象编号已存在。"); } if (specialEntity.F_DeleteMark == null) { specialEntity.F_DeleteMark = false; } specialEntity.Create(); service.Insert(specialEntity); } }
public int UpdateAssetsEx(AssetsMain main, SpecialAttribute attr) { main.InputTime = DateTime.Now; main.ExtDataTable = "ASSETS_SPECIAL"; _assetsMainRep.Save(main); attr.AssetsNum = main.AssetsNum; _specialRep.Update(attr); var result = _assetsMainRep.FirstOrDefault(x => x.AssetsNum == main.AssetsNum); return(result.EntityId); }