/// <summary>
        /// 保存实体数据(新增、修改)
        /// </summary>
        /// <param name="keyValue">主键</param>
        /// <returns></returns>
        public void SaveEntity(string keyValue, Mes_ProductOrderHeadEntity entity, List <Mes_ProductOrderDetailEntity> mes_ProductOrderDetaillist)
        {
            var db = this.BaseRepository().BeginTrans();

            try
            {
                #region  弃
                //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);
                //    foreach (var item in mes_ProductOrderDetaillist)
                //    {
                //        item.Create();
                //        item.P_OrderNo = mes_ProductOrderHeadEntityTmp.P_OrderNo;
                //    }
                //    db.Insert(mes_ProductOrderDetaillist);
                //}
                //else
                //{
                //    entity.Create();
                //    db.Insert(entity);
                //    foreach (var item in mes_ProductOrderDetaillist)
                //    {
                //        item.Create();
                //        item.P_OrderNo = entity.P_OrderNo;
                //    }
                //    db.Insert(mes_ProductOrderDetaillist);
                //}
                //db.Commit();
                #endregion

                if (!string.IsNullOrWhiteSpace(keyValue))
                {
                    db.Update(mes_ProductOrderDetaillist[0]);
                }
                db.Commit();
            }
            catch (Exception ex)
            {
                db.Rollback();
                if (ex is ExceptionEx)
                {
                    throw;
                }
                else
                {
                    throw ExceptionEx.ThrowServiceException(ex);
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 保存实体数据(新增、修改)
        /// </summary>
        /// <param name="keyValue">主键</param>
        /// <returns></returns>
        public void SaveEntity(string keyValue, Mes_ProductOrderHeadEntity entity, List <Mes_ProductOrderDetailEntity> mes_ProductOrderDetailList)
        {
            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);
                    foreach (Mes_ProductOrderDetailEntity item in mes_ProductOrderDetailList)
                    {
                        item.Create();
                        item.P_OrderNo = mes_ProductOrderHeadEntityTmp.P_OrderNo;
                        db.Insert(item);
                    }
                }
                else
                {
                    entity.Create();
                    db.Insert(entity);
                    foreach (Mes_ProductOrderDetailEntity item in mes_ProductOrderDetailList)
                    {
                        item.Create();
                        item.P_OrderNo = entity.P_OrderNo;
                        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_ProductOrderHeadEntity entity, List <Mes_ProductOrderDetailEntity> mes_ProductOrderDetaillist)
 {
     try
     {
         productOrderManagerService.SaveEntity(keyValue, entity, mes_ProductOrderDetaillist);
     }
     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)
 {
     try
     {
         mes_ProductOrderHeadService.SaveEntity(keyValue, entity, mes_ProductOrderDetailEntity);
     }
     catch (Exception ex)
     {
         if (ex is ExceptionEx)
         {
             throw;
         }
         else
         {
             throw ExceptionEx.ThrowBusinessException(ex);
         }
     }
 }