/// <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(CrmReceivableEntity entity)
 {
     try
     {
         crmReceivableService.SaveEntity(entity);
     }
     catch (Exception ex)
     {
         if (ex is ExceptionEx)
         {
             throw;
         }
         else
         {
             throw ExceptionEx.ThrowBusinessException(ex);
         }
     }
 }