Ejemplo n.º 1
0
        /// <summary>
        /// 保存实体数据(新增、修改)
        /// </summary>
        /// <param name="keyValue">主键</param>
        /// <returns></returns>
        public void SaveEntity(string keyValue, Mes_BomHeadEntity entity)
        {
            var db = this.BaseRepository().BeginTrans();

            try
            {
                if (!string.IsNullOrEmpty(keyValue))
                {
                    //var mes_BomHeadEntityTmp = GetMes_BomHeadEntity(keyValue);
                    entity.Modify(keyValue);
                    db.Update(entity);
                    //db.Delete<Mes_BomRecordEntity>(t=>t.B_FormulaCode == mes_BomHeadEntityTmp.B_FormulaCode);
                    //foreach (Mes_BomRecordEntity item in mes_BomRecordList)
                    //{
                    //    item.Create();
                    //    item.B_FormulaCode = mes_BomHeadEntityTmp.B_FormulaCode;
                    //    db.Insert(item);
                    //}
                }
                else
                {
                    entity.Create();
                    db.Insert(entity);
                    var bomRecord = new Mes_BomRecordEntity()
                    {
                        B_FormulaCode = entity.B_FormulaCode,

                        B_GoodsCode = entity.B_GoodsCode,
                        B_GoodsName = entity.B_GoodsName
                    };
                    bomRecord.Create();
                    db.Insert(bomRecord);
                    //foreach (Mes_BomRecordEntity item in mes_BomRecordList)
                    //{
                    //    item.Create();
                    //    item.B_FormulaCode = entity.B_FormulaCode;
                    //    db.Insert(item);
                    //}
                }
                db.Commit();
            }
            catch (Exception ex)
            {
                db.Rollback();
                if (ex is ExceptionEx)
                {
                    throw;
                }
                else
                {
                    throw ExceptionEx.ThrowServiceException(ex);
                }
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 保存实体数据(新增、修改)
 /// </summary>
 /// <param name="keyValue">主键</param>
 /// <returns></returns>
 public void SaveEntity(string keyValue, Mes_BomHeadEntity entity)
 {
     try
     {
         bomHeadService.SaveEntity(keyValue, entity);
     }
     catch (Exception ex)
     {
         if (ex is ExceptionEx)
         {
             throw;
         }
         else
         {
             throw ExceptionEx.ThrowBusinessException(ex);
         }
     }
 }