/// <summary> /// 保存实体数据(新增、修改) /// </summary> /// <param name="keyValue">主键</param> /// <returns></returns> public void SaveEntity(string keyValue, Mes_PurchaseHeadEntity entity, List <Mes_PurchaseDetailEntity> mes_PurchaseDetailList) { var db = this.BaseRepository().BeginTrans(); try { if (!string.IsNullOrEmpty(keyValue)) { var mes_PurchaseHeadEntityTmp = GetMes_PurchaseHeadEntity(keyValue); entity.Modify(keyValue); db.Update(entity); db.Delete <Mes_PurchaseDetailEntity>(t => t.P_PurchaseNo == mes_PurchaseHeadEntityTmp.P_PurchaseNo); foreach (Mes_PurchaseDetailEntity item in mes_PurchaseDetailList) { item.Create(); item.P_PurchaseNo = mes_PurchaseHeadEntityTmp.P_PurchaseNo; db.Insert(item); } } else { entity.Create(); db.Insert(entity); foreach (Mes_PurchaseDetailEntity item in mes_PurchaseDetailList) { item.Create(); item.P_PurchaseNo = entity.P_PurchaseNo; db.Insert(item); } } db.Commit(); } catch (Exception ex) { db.Rollback(); if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowServiceException(ex); } } }
/// <summary> /// 保存实体数据(新增、修改) /// </summary> /// <param name="keyValue">主键</param> /// <returns></returns> public void SaveEntity(string keyValue, Mes_PurchaseHeadEntity entity, List <Mes_PurchaseDetailEntity> mes_PurchaseDetailList) { try { purchaseHeadService.SaveEntity(keyValue, entity, mes_PurchaseDetailList); } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowBusinessException(ex); } } }