Ejemplo n.º 1
0
        /// <summary>
        /// 保存表单(新增)
        /// </summary>
        /// <param name="keyValue">主键值</param>
        /// <param name="entity">实体对象</param>
        /// <returns></returns>
        public void SaveForm(ExpensesEntity entity)
        {
            ICashBalanceService icashbalanceservice = new CashBalanceService();

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

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


                //添加账户余额
                icashbalanceservice.AddBalance(db, new CashBalanceEntity
                {
                    ObjectId      = entity.ExpensesId,
                    ExecutionDate = entity.ExpensesDate,
                    CashAccount   = entity.ExpensesAccount,
                    Expenses      = entity.ExpensesPrice,
                    Abstract      = entity.ExpensesAbstract
                });

                db.Commit();
            }
            catch (Exception)
            {
                db.Rollback();
                throw;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 保存表单(新增)
        /// </summary>
        /// <param name="entity">实体对象</param>
        /// <returns></returns>
        public void SaveForm(ReceivableEntity entity)
        {
            ICashBalanceService icashbalanceservice = new CashBalanceService();
            OrderEntity         orderEntity         = orderIService.GetEntity(entity.OrderId);

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

            try
            {
                //更改订单状态
                orderEntity.ReceivedAmount = orderEntity.ReceivedAmount + entity.PaymentPrice;
                if (orderEntity.ReceivedAmount == orderEntity.Accounts)
                {
                    orderEntity.PaymentState = 3;
                }
                else
                {
                    orderEntity.PaymentState = 2;
                }
                db.Update(orderEntity);
                //添加收款
                entity.Create();
                db.Insert(entity);
                //添加账户余额
                icashbalanceservice.AddBalance(db, new CashBalanceEntity
                {
                    ObjectId      = entity.ReceivableId,
                    ExecutionDate = entity.PaymentTime,
                    CashAccount   = entity.PaymentAccount,
                    Receivable    = entity.PaymentPrice,
                    Abstract      = entity.Description
                });

                db.Commit();
            }
            catch (Exception)
            {
                db.Rollback();
                throw;
            }
        }