Пример #1
0
        /// <summary>
        /// 保存实体数据(新增、修改)
        /// </summary>
        /// <param name="keyValue">主键</param>
        /// <returns></returns>
        public void SaveEntity(string keyValue, Mes_ScrapHeadEntity entity, List <Mes_ScrapDetailEntity> detailList)
        {
            var db = this.BaseRepository().BeginTrans();

            try
            {
                if (!string.IsNullOrEmpty(keyValue))
                {
                    var headEntity = GetMes_ScrapHeadEntity(keyValue);
                    entity.Modify(keyValue);
                    db.Update(entity);
                    db.Delete <Mes_ScrapDetailEntity>(t => t.S_ScrapNo == headEntity.S_ScrapNo);
                    foreach (var item in detailList)
                    {
                        item.Create();
                        item.S_ScrapNo = headEntity.S_ScrapNo;
                    }
                    db.Insert(detailList);
                }
                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.S_ScrapNo = billNo;
                    entity.Create();
                    db.Insert(entity);
                    foreach (var item in detailList)
                    {
                        item.Create();
                        item.S_ScrapNo = entity.S_ScrapNo;
                    }
                    db.Insert(detailList);
                }
                db.Commit();
            }
            catch (Exception ex)
            {
                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_ScrapHeadEntity entity, List <Mes_ScrapDetailEntity> detailList)
 {
     try
     {
         scrapManagerService.SaveEntity(keyValue, entity, detailList);
     }
     catch (Exception ex)
     {
         if (ex is ExceptionEx)
         {
             throw;
         }
         else
         {
             throw ExceptionEx.ThrowBusinessException(ex);
         }
     }
 }