/// <summary> /// 保存实体数据(新增、修改) /// </summary> /// <param name="keyValue">主键</param> /// <returns></returns> public void SaveEntity(string keyValue, Mes_BackStockHeadEntity entity, List <Mes_BackStockDetailEntity> mes_BackStockDetailList) { var db = this.BaseRepository().BeginTrans(); try { if (!string.IsNullOrEmpty(keyValue)) { var mes_BackStockHeadEntityTmp = GetMes_BackStockHeadEntity(keyValue); entity.Modify(keyValue); db.Update(entity); db.Delete <Mes_BackStockDetailEntity>(t => t.B_BackStockNo == mes_BackStockHeadEntityTmp.B_BackStockNo); foreach (var item in mes_BackStockDetailList) { item.Create(); item.B_BackStockNo = mes_BackStockHeadEntityTmp.B_BackStockNo; } db.Insert(mes_BackStockDetailList); } 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.B_BackStockNo = billNo; entity.Create(); db.Insert(entity); foreach (var item in mes_BackStockDetailList) { item.Create(); item.B_BackStockNo = entity.B_BackStockNo; } db.Insert(mes_BackStockDetailList); } 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_BackStockHeadEntity entity, List <Mes_BackStockDetailEntity> mes_BackStockDetailList) { try { backStockManagerService.SaveEntity(keyValue, entity, mes_BackStockDetailList); } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowBusinessException(ex); } } }