Пример #1
0
        /// <summary>
        /// 保存表单(新增、修改)
        /// </summary>
        /// <param name="keyValue">主键值</param>
        /// <param name="entity">实体对象</param>
        /// <returns></returns>
        public void SaveEntity(string keyValue, CrmTrailRecordEntity entity)
        {
            IRepository db = new RepositoryFactory().BaseRepository().BeginTrans();

            try
            {
                switch (entity.F_ObjectSort)
                {
                case 1:             //商机
                    CrmChanceEntity chanceEntity = new CrmChanceEntity();
                    chanceEntity.Modify(entity.F_ObjectId);
                    db.Update <CrmChanceEntity>(chanceEntity);
                    break;

                case 2:             //客户
                    CrmCustomerEntity customerEntity = new CrmCustomerEntity();
                    customerEntity.Modify(entity.F_ObjectId);
                    db.Update <CrmCustomerEntity>(customerEntity);
                    break;

                default:
                    break;
                }
                entity.Create();
                db.Insert(entity);

                db.Commit();
            }
            catch (Exception ex)
            {
                db.Rollback();
                if (ex is ExceptionEx)
                {
                    throw;
                }
                else
                {
                    throw ExceptionEx.ThrowServiceException(ex);
                }
            }
        }
Пример #2
0
 /// <summary>
 /// 保存表单(新增、修改)
 /// </summary>
 /// <param name="keyValue">主键值</param>
 /// <param name="entity">实体对象</param>
 /// <returns></returns>
 public void SaveEntity(string keyValue, CrmCustomerEntity entity)
 {
     try
     {
         if (!string.IsNullOrEmpty(keyValue))
         {
             entity.Modify(keyValue);
             this.BaseRepository().Update(entity);
         }
         else
         {
             IRepository db = new RepositoryFactory().BaseRepository().BeginTrans();
             try
             {
                 entity.Create();
                 db.Insert(entity);
                 db.Commit();
             }
             catch (Exception)
             {
                 db.Rollback();
                 throw;
             }
         }
     }
     catch (Exception ex)
     {
         if (ex is ExceptionEx)
         {
             throw;
         }
         else
         {
             throw ExceptionEx.ThrowServiceException(ex);
         }
     }
 }