Exemple #1
0
        /// <summary>
        /// 商机转换客户
        /// </summary>
        /// <param name="keyValue">主键</param>
        /// <param name="customerCode">客户编号</param>
        public void ToCustomer(string keyValue, string customerCode)
        {
            CrmChanceEntity chanceEntity = this.GetEntity(keyValue);
            IEnumerable <CrmTrailRecordEntity> trailRecordList = crmTrailRecordService.GetList(keyValue);
            IRepository db = new RepositoryFactory().BaseRepository().BeginTrans();

            try
            {
                chanceEntity.Modify(keyValue);
                chanceEntity.F_IsToCustom = 1;
                db.Update <CrmChanceEntity>(chanceEntity);
                CrmCustomerEntity customerEntity = new CrmCustomerEntity();
                customerEntity.Create();
                customerEntity.F_EnCode         = customerCode;
                customerEntity.F_FullName       = chanceEntity.F_CompanyName;
                customerEntity.F_TraceUserId    = chanceEntity.F_TraceUserId;
                customerEntity.F_TraceUserName  = chanceEntity.F_TraceUserName;
                customerEntity.F_CustIndustryId = chanceEntity.F_CompanyNatureId;
                customerEntity.F_CompanySite    = chanceEntity.F_CompanySite;
                customerEntity.F_CompanyDesc    = chanceEntity.F_CompanyDesc;
                customerEntity.F_CompanyAddress = chanceEntity.F_CompanyAddress;
                customerEntity.F_Province       = chanceEntity.F_Province;
                customerEntity.F_City           = chanceEntity.F_City;
                customerEntity.F_Contact        = chanceEntity.F_Contacts;
                customerEntity.F_Mobile         = chanceEntity.F_Mobile;
                customerEntity.F_Tel            = chanceEntity.F_Tel;
                customerEntity.F_Fax            = chanceEntity.F_Fax;
                customerEntity.F_QQ             = chanceEntity.F_QQ;
                customerEntity.F_Email          = chanceEntity.F_Email;
                customerEntity.F_Wechat         = chanceEntity.F_Wechat;
                customerEntity.F_Hobby          = chanceEntity.F_Hobby;
                customerEntity.F_Description    = chanceEntity.F_Description;
                customerEntity.F_CustLevelId    = "C";
                customerEntity.F_CustDegreeId   = "往来客户";
                db.Insert <CrmCustomerEntity>(customerEntity);

                foreach (CrmTrailRecordEntity item in trailRecordList)
                {
                    item.F_TrailId    = Guid.NewGuid().ToString();
                    item.F_ObjectId   = customerEntity.F_CustomerId;
                    item.F_ObjectSort = 2;
                    db.Insert <CrmTrailRecordEntity>(item);
                }
                db.Commit();
            }
            catch (Exception ex)
            {
                db.Rollback();
                if (ex is ExceptionEx)
                {
                    throw;
                }
                else
                {
                    throw ExceptionEx.ThrowServiceException(ex);
                }
            }
        }
Exemple #2
0
 /// <summary>
 /// 保存表单(新增、修改)
 /// </summary>
 /// <param name="keyValue">主键值</param>
 /// <param name="entity">实体对象</param>
 /// <returns></returns>
 public void SaveEntity(string keyValue, CrmChanceEntity entity)
 {
     try
     {
         crmChanceService.SaveEntity(keyValue, entity);
     }
     catch (Exception ex)
     {
         if (ex is ExceptionEx)
         {
             throw;
         }
         else
         {
             throw ExceptionEx.ThrowBusinessException(ex);
         }
     }
 }
Exemple #3
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);
                }
            }
        }
Exemple #4
0
 /// <summary>
 /// 商机作废
 /// </summary>
 /// <param name="keyValue">主键值</param>
 public void Invalid(string keyValue)
 {
     try
     {
         CrmChanceEntity entity = new CrmChanceEntity();
         entity.Modify(keyValue);
         entity.F_ChanceState = 0;
         this.BaseRepository().Update(entity);
     }
     catch (Exception ex)
     {
         if (ex is ExceptionEx)
         {
             throw;
         }
         else
         {
             throw ExceptionEx.ThrowServiceException(ex);
         }
     }
 }
Exemple #5
0
 /// <summary>
 /// 保存表单(新增、修改)
 /// </summary>
 /// <param name="keyValue">主键值</param>
 /// <param name="entity">实体对象</param>
 /// <returns></returns>
 public void SaveEntity(string keyValue, CrmChanceEntity 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);
         }
     }
 }