Example #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);
                }
            }
        }
Example #2
0
        /// <summary>
        /// 保存表单(新增、修改)
        /// </summary>
        /// <param name="keyValue">主键值</param>
        /// <param name="crmOrderEntity">实体对象</param>
        /// <param name="CrmOrderProductEntity">明细实体对象</param>
        /// <returns></returns>
        public void SaveEntity(string keyValue, CrmOrderEntity crmOrderEntity, List <CrmOrderProductEntity> crmOrderProductList)
        {
            IRepository db = new RepositoryFactory().BaseRepository().BeginTrans();

            try
            {
                if (!string.IsNullOrEmpty(keyValue))
                {
                    //主表
                    crmOrderEntity.Modify(keyValue);
                    db.Update(crmOrderEntity);
                    //明细
                    db.Delete <CrmOrderProductEntity>(t => t.F_OrderId.Equals(keyValue));
                    foreach (CrmOrderProductEntity crmOrderProductEntity in crmOrderProductList)
                    {
                        crmOrderProductEntity.F_OrderId = crmOrderEntity.F_OrderId;
                        db.Insert(crmOrderProductEntity);
                    }
                }
                else
                {
                    //主表
                    crmOrderEntity.Create();
                    db.Insert(crmOrderEntity);
                    //coderuleService.UseRuleSeed(orderEntity.F_CreateUserId, "", ((int)CodeRuleEnum.Customer_OrderCode).ToString(), db);//占用单据号
                    //明细
                    foreach (CrmOrderProductEntity crmOrderProductEntity in crmOrderProductList)
                    {
                        crmOrderProductEntity.Create();
                        crmOrderProductEntity.F_OrderId = crmOrderEntity.F_OrderId;
                        db.Insert(crmOrderProductEntity);
                    }
                }
                db.Commit();
            }
            catch (Exception ex)
            {
                db.Rollback();
                if (ex is ExceptionEx)
                {
                    throw;
                }
                else
                {
                    throw ExceptionEx.ThrowServiceException(ex);
                }
            }
        }
Example #3
0
 /// <summary>
 /// 保存表单(新增、修改)
 /// </summary>
 /// <param name="keyValue">主键值</param>
 /// <param name="crmOrderEntity">实体对象</param>
 /// <param name="CrmOrderProductEntity">明细实体对象</param>
 /// <returns></returns>
 public void SaveEntity(string keyValue, CrmOrderEntity crmOrderEntity, List <CrmOrderProductEntity> crmOrderProductList)
 {
     try
     {
         crmOrderService.SaveEntity(keyValue, crmOrderEntity, crmOrderProductList);
     }
     catch (Exception ex)
     {
         if (ex is ExceptionEx)
         {
             throw;
         }
         else
         {
             throw ExceptionEx.ThrowBusinessException(ex);
         }
     }
 }