/// <summary> /// 保存实体数据(新增、修改) /// </summary> /// <param name="keyValue">主键</param> /// <returns></returns> public void SaveEntity(string keyValue, Mes_ProductOrderHeadEntity entity, Mes_ProductOrderDetailEntity mes_ProductOrderDetailEntity) { try { mes_ProductOrderHeadService.SaveEntity(keyValue, entity, mes_ProductOrderDetailEntity); } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowBusinessException(ex); } } }
/// <summary> /// 保存实体数据(新增、修改) /// </summary> /// <param name="keyValue">主键</param> /// <returns></returns> public void SaveEntity(string keyValue, Mes_ProductOrderHeadEntity entity, Mes_ProductOrderDetailEntity mes_ProductOrderDetailEntity) { var db = this.BaseRepository().BeginTrans(); try { if (!string.IsNullOrEmpty(keyValue)) { var mes_ProductOrderHeadEntityTmp = GetMes_ProductOrderHeadEntity(keyValue); entity.Modify(keyValue); db.Update(entity); db.Delete <Mes_ProductOrderDetailEntity>(t => t.P_OrderNo == mes_ProductOrderHeadEntityTmp.P_OrderNo); mes_ProductOrderDetailEntity.Create(); mes_ProductOrderDetailEntity.P_OrderNo = mes_ProductOrderHeadEntityTmp.P_OrderNo; db.Insert(mes_ProductOrderDetailEntity); } else { entity.Create(); db.Insert(entity); mes_ProductOrderDetailEntity.Create(); mes_ProductOrderDetailEntity.P_OrderNo = entity.P_OrderNo; db.Insert(mes_ProductOrderDetailEntity); } db.Commit(); } catch (Exception ex) { db.Rollback(); if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowServiceException(ex); } } }