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

            try
            {
                if (!string.IsNullOrEmpty(keyValue))
                {
                    var mes_InWorkShopHeadEntityTmp = GetMes_InWorkShopHeadEntity(keyValue);
                    entity.Modify(keyValue);
                    db.Update(entity);
                    db.Delete <Mes_InWorkShopDetailEntity>(t => t.I_InNo == mes_InWorkShopHeadEntityTmp.I_InNo);
                    foreach (var item in mes_InWorkShopDetailList)
                    {
                        item.Create();
                        item.I_InNo = mes_InWorkShopHeadEntityTmp.I_InNo;
                    }
                    db.Insert(mes_InWorkShopDetailList);
                }
                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.I_InNo = billNo;
                    entity.Create();
                    db.Insert(entity);
                    foreach (var item in mes_InWorkShopDetailList)
                    {
                        item.Create();
                        item.I_InNo = entity.I_InNo;
                    }
                    db.Insert(mes_InWorkShopDetailList);
                }
                db.Commit();
            }
            catch (Exception ex)
            {
                db.Rollback();
                if (ex is ExceptionEx)
                {
                    throw;
                }
                else
                {
                    throw ExceptionEx.ThrowServiceException(ex);
                }
            }
        }
Пример #2
0
 /// <summary>
 /// 保存实体数据(新增、修改)
 /// </summary>
 /// <param name="keyValue">主键</param>
 /// <returns></returns>
 public void SaveEntity(string keyValue, Mes_InWorkShopHeadEntity entity, List <Mes_InWorkShopDetailEntity> mes_InWorkShopDetailList)
 {
     try
     {
         inWorkShopManagerService.SaveEntity(keyValue, entity, mes_InWorkShopDetailList);
     }
     catch (Exception ex)
     {
         if (ex is ExceptionEx)
         {
             throw;
         }
         else
         {
             throw ExceptionEx.ThrowBusinessException(ex);
         }
     }
 }