コード例 #1
0
 /// <summary>
 /// 保存实体数据(新增、修改)
 /// </summary>
 /// <param name="keyValue">主键</param>
 /// <returns></returns>
 public void SaveEntity(string keyValue, Mes_CollarHeadEntity entity, List <Mes_CollarDetailEntity> mes_CollarDetailEntityList)
 {
     try
     {
         pickingMaterService.SaveEntity(keyValue, entity, mes_CollarDetailEntityList);
     }
     catch (Exception ex)
     {
         if (ex is ExceptionEx)
         {
             throw;
         }
         else
         {
             throw ExceptionEx.ThrowBusinessException(ex);
         }
     }
 }
コード例 #2
0
        /// <summary>
        /// 保存实体数据(新增、修改)
        /// </summary>
        /// <param name="keyValue">主键</param>
        /// <returns></returns>
        public void SaveEntity(string keyValue, Mes_CollarHeadEntity entity, Mes_CollarDetailEntity mes_CollarDetailEntity)
        {
            var db = this.BaseRepository().BeginTrans();

            try
            {
                if (!string.IsNullOrEmpty(keyValue))
                {
                    var mes_CollarHeadEntityTmp = GetMes_CollarHeadEntity(keyValue);
                    entity.Modify(keyValue);
                    db.Update(entity);
                    db.Delete <Mes_CollarDetailEntity>(t => t.C_CollarNo == mes_CollarHeadEntityTmp.C_CollarNo);
                    mes_CollarDetailEntity.Create();
                    mes_CollarDetailEntity.C_CollarNo = mes_CollarHeadEntityTmp.C_CollarNo;
                    db.Insert(mes_CollarDetailEntity);
                }
                else
                {
                    entity.Create();
                    db.Insert(entity);
                    mes_CollarDetailEntity.Create();
                    mes_CollarDetailEntity.C_CollarNo = entity.C_CollarNo;
                    db.Insert(mes_CollarDetailEntity);
                }
                db.Commit();
            }
            catch (Exception ex)
            {
                db.Rollback();
                if (ex is ExceptionEx)
                {
                    throw;
                }
                else
                {
                    throw ExceptionEx.ThrowServiceException(ex);
                }
            }
        }