/// <summary> /// 保存实体数据(新增、修改) /// </summary> /// <param name="keyValue">主键</param> /// <returns></returns> public void SaveEntity(string keyValue, Mes_OrgResHeadEntity entity, List <Mes_OrgResDetailEntity> mes_OrgResDetailList) { var db = this.BaseRepository().BeginTrans(); try { if (!string.IsNullOrEmpty(keyValue)) { var mes_OrgResHeadEntityTmp = GetMes_OrgResHeadEntity(keyValue); entity.Modify(keyValue); db.Update(entity); db.Delete <Mes_OrgResDetailEntity>(t => t.O_OrgResNo == mes_OrgResHeadEntityTmp.O_OrgResNo); foreach (var item in mes_OrgResDetailList) { item.Create(); item.O_OrgResNo = mes_OrgResHeadEntityTmp.O_OrgResNo; } db.Insert(mes_OrgResDetailList); } else { var dp = new DynamicParameters(new {}); dp.Add("@BillType", "组装与拆分单"); dp.Add("@Doucno", "", DbType.String, ParameterDirection.Output); db.ExecuteByProc("sp_GetDoucno", dp); var billNo = dp.Get <string>("@Doucno"); //存储过程返回单号 entity.O_OrgResNo = billNo; entity.Create(); db.Insert(entity); foreach (var item in mes_OrgResDetailList) { item.Create(); item.O_OrgResNo = entity.O_OrgResNo; } db.Insert(mes_OrgResDetailList); } 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_OrgResHeadEntity entity, List <Mes_OrgResDetailEntity> mes_OrgResDetailList) { try { orgResMangerService.SaveEntity(keyValue, entity, mes_OrgResDetailList); } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowBusinessException(ex); } } }