示例#1
0
 /// <summary>
 /// 保存表单(新增)
 /// </summary>
 /// <param name="entity">实体对象</param>
 /// <returns></returns>
 public void SaveEntity(CrmExpensesEntity entity)
 {
     try
     {
         crmExpensesService.SaveEntity(entity);
     }
     catch (Exception ex)
     {
         if (ex is ExceptionEx)
         {
             throw;
         }
         else
         {
             throw ExceptionEx.ThrowServiceException(ex);
         }
     }
 }
        /// <summary>
        /// 保存表单(新增)
        /// </summary>
        /// <param name="entity">实体对象</param>
        /// <returns></returns>
        public void SaveEntity(CrmExpensesEntity entity)
        {
            CrmCashBalanceService crmCashBalanceService = new CrmCashBalanceService();

            IRepository db = new RepositoryFactory().BaseRepository().BeginTrans();

            try
            {
                //支出
                entity.Create();
                db.Insert(entity);

                //添加账户余额
                crmCashBalanceService.AddBalance(db, new CrmCashBalanceEntity
                {
                    F_ObjectId      = entity.F_ExpensesId,
                    F_ExecutionDate = entity.F_ExpensesDate,
                    F_CashAccount   = entity.F_ExpensesAccount,
                    F_Expenses      = entity.F_ExpensesPrice,
                    F_Abstract      = entity.F_ExpensesAbstract
                });

                db.Commit();
            }
            catch (Exception ex)
            {
                db.Rollback();
                if (ex is ExceptionEx)
                {
                    throw;
                }
                else
                {
                    throw ExceptionEx.ThrowServiceException(ex);
                }
            }
        }