/// <summary> /// 保存实体数据(新增、修改) /// </summary> /// <param name="keyValue">主键</param> /// <returns></returns> public void SaveEntity(string keyValue, Mes_OtherOutHeadEntity strEntity, List <Mes_OtherOutDetailEntity> mes_OtherOutDetailList) { var db = this.BaseRepository().BeginTrans(); try { string a = null; if (!string.IsNullOrEmpty(keyValue)) { var mes_OtherOutHeadEntityTmp = GetEntity(keyValue); strEntity.Modify(keyValue); db.Update(strEntity); db.Delete <Mes_OtherOutDetailEntity>(t => t.O_OtherOutNo == mes_OtherOutHeadEntityTmp.O_OtherOutNo); foreach (Mes_OtherOutDetailEntity item in mes_OtherOutDetailList) { item.O_Price = a.ToDecimal(); item.Create(); item.O_OtherOutNo = mes_OtherOutHeadEntityTmp.O_OtherOutNo; db.Insert(item); } } 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"); //存储过程返回单号 strEntity.O_OtherOutNo = billNo; strEntity.Create(); db.Insert(strEntity); foreach (Mes_OtherOutDetailEntity item in mes_OtherOutDetailList) { item.O_Price = a.ToDecimal();; item.Create(); item.O_OtherOutNo = strEntity.O_OtherOutNo; db.Insert(item); } } db.Commit(); } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowServiceException(ex); } } }
/// <summary> /// 保存实体数据(新增、修改) /// </summary> /// <param name="keyValue">主键</param> /// <returns></returns> public void SaveEntity(string keyValue, Mes_OtherOutHeadEntity strEntity, List <Mes_OtherOutDetailEntity> mes_OtherOutDetailList) { try { mes_OtherOutHeadService.SaveEntity(keyValue, strEntity, mes_OtherOutDetailList); } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowBusinessException(ex); } } }