コード例 #1
0
        /// <summary>
        /// 保存表单(新增)
        /// </summary>
        /// <param name="entity">实体对象</param>
        /// <returns></returns>
        public void SaveEntity(CrmReceivableEntity entity)
        {
            CrmCashBalanceService crmCashBalanceService = new CrmCashBalanceService();
            CrmOrderEntity        crmOrderEntity        = crmOrderService.GetCrmOrderEntity(entity.F_OrderId);

            IRepository db = this.BaseRepository().BeginTrans();

            try
            {
                //更改订单状态
                crmOrderEntity.F_ReceivedAmount = crmOrderEntity.F_ReceivedAmount + entity.F_PaymentPrice;
                if (crmOrderEntity.F_ReceivedAmount == crmOrderEntity.F_Accounts)
                {
                    crmOrderEntity.F_PaymentState = 3;
                }
                else
                {
                    crmOrderEntity.F_PaymentState = 2;
                }
                db.Update(crmOrderEntity);
                //添加收款
                entity.Create();
                db.Insert(entity);
                //添加账户余额
                crmCashBalanceService.AddBalance(db, new CrmCashBalanceEntity
                {
                    F_ObjectId      = entity.F_ReceivableId,
                    F_ExecutionDate = entity.F_PaymentTime,
                    F_CashAccount   = entity.F_PaymentAccount,
                    F_Receivable    = entity.F_PaymentPrice,
                    F_Abstract      = entity.F_Description
                });

                db.Commit();
            }
            catch (Exception ex)
            {
                db.Rollback();
                if (ex is ExceptionEx)
                {
                    throw;
                }
                else
                {
                    throw ExceptionEx.ThrowServiceException(ex);
                }
            }
        }
コード例 #2
0
        /// <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);
                }
            }
        }