/// <summary>
        /// 保存表单(新增、修改)
        /// </summary>
        /// <param name="keyValue">主键值</param>
        /// <param name="entity">实体对象</param>
        /// <returns></returns>
        public void SaveForm(string keyValue, TrailRecordEntity entity)
        {
            IRepository db = new RepositoryFactory().BaseRepository().BeginTrans();

            try
            {
                switch (entity.ObjectSort)
                {
                case 1:             //商机
                    ChanceEntity chanceEntity = new ChanceEntity();
                    chanceEntity.Modify(entity.ObjectId);
                    db.Update <ChanceEntity>(chanceEntity);
                    break;

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

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

                db.Commit();
            }
            catch (Exception)
            {
                db.Rollback();
                throw;
            }
        }
Exemple #2
0
        public void SubmitForm(CustomerEntity customerEntity, string keyValue)
        {
            if (!string.IsNullOrEmpty(keyValue))
            {
                //更新业务员跟单记录信息
                var lst = tranService.IQueryable().Where(t => t.CustomerId.Equals(keyValue));
                foreach (var item in lst)
                {
                    item.SalesmanCode = customerEntity.SalesmanCode;
                    item.Salesman     = customerEntity.Salesman;
                    item.Modify(item.Id);
                    tranService.SubmitForm(item, item.Id);
                }

                customerEntity.Modify(keyValue);
            }
            else
            {
                //先根据客户名称
                var expression = ExtLinq.True <CustomerEntity>();
                expression = expression.And(t => t.Company.Contains(customerEntity.Company.Trim()));
                expression = expression.And(t => t.Telphone.Contains(customerEntity.Telphone));
                var lst = service.IQueryable(expression);
                if (lst != null & lst.Count() > 0)
                {
                    throw new Exception("存在相同的客户信息!!!");
                }
                customerEntity.Create();
            }
            service.SubmitForm(customerEntity, keyValue);
        }
Exemple #3
0
        /// <summary>
        /// 保存表单(新增、修改)
        /// </summary>
        /// <param name="keyValue">主键值</param>
        /// <param name="entity">实体对象</param>
        /// <returns></returns>
        public void SaveForm(string keyValue, TrailRecordEntity entity)
        {
            IRepository db = new RepositoryFactory().BaseRepository().BeginTrans();

            try
            {
                switch (entity.ObjectSort)
                {
                case 1:             //商机
                    ChanceEntity chanceEntity = new ChanceEntity();
                    chanceEntity.Modify(entity.ObjectId);
                    db.Update <ChanceEntity>(chanceEntity);
                    break;

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

                case 3:             //手机号
                    TelphoneSourceEntity telEntity = new TelphoneSourceEntity();
                    telEntity.Modify(int.Parse(entity.ObjectId));
                    db.Update <TelphoneSourceEntity>(telEntity);
                    break;

                case 4:             //店铺
                    POS_ShopEntity shopEntity = new POS_ShopEntity();
                    shopEntity.Modify(entity.ObjectId);
                    db.Update <POS_ShopEntity>(shopEntity);
                    break;

                case 5:             //公司
                    POS_OfficeCompanyEntity officeCompanyEntity = new POS_OfficeCompanyEntity();
                    officeCompanyEntity.Modify(entity.ObjectId);
                    db.Update <POS_OfficeCompanyEntity>(officeCompanyEntity);
                    break;

                case 6:             //私池
                    Ku_CompanyEntity companyEntity = new Ku_CompanyEntity();
                    companyEntity.Modify(Convert.ToInt32(entity.ObjectId));
                    db.Update <Ku_CompanyEntity>(companyEntity);
                    break;

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

                db.Commit();
            }
            catch (Exception)
            {
                db.Rollback();
                throw;
            }
        }
Exemple #4
0
 public void SubmitForm(CustomerEntity userEntity, string keyValue)
 {
     if (!string.IsNullOrEmpty(keyValue))
     {
         userEntity.Modify(keyValue);
     }
     else
     {
         userEntity.Create();
     }
     service.SubmitForm(userEntity, keyValue);
 }
 public void SubmitForm(CustomerEntity itemsEntity, string keyValue)
 {
     if (!string.IsNullOrEmpty(keyValue))
     {
         itemsEntity.Modify(keyValue);
         service.Update(itemsEntity);
     }
     else
     {
         itemsEntity.Create();
         service.Insert(itemsEntity);
     }
 }
Exemple #6
0
 public void SubmitCustomerForm(CustomerEntity customerEntity, string keyValue)
 {
     if (!string.IsNullOrEmpty(keyValue))
     {
         customerEntity.Modify(keyValue);
         customerRepository.Update(customerEntity);
     }
     else
     {
         customerEntity.Create();
         customerRepository.Insert(customerEntity);
     }
 }
        public async Task SaveForm(CustomerEntity entity)
        {
            if (entity.Id.IsNullOrZero())
            {
                await entity.Create();

                await this.BaseRepository().Insert(entity);
            }
            else
            {
                await entity.Modify();

                await this.BaseRepository().Update(entity);
            }
        }
Exemple #8
0
        /// <summary>
        /// 保存表单(新增、修改)
        /// </summary>
        /// <param name="keyValue">主键值</param>
        /// <param name="entity">实体对象</param>
        /// <returns></returns>
        public void SaveForm(string keyValue, TrailRecordEntity entity)
        {
            IRepository db = new RepositoryFactory().BaseRepository().BeginTrans();

            try
            {
                switch (entity.ObjectSort)
                {
                case 1:             //商机
                    ChanceEntity chanceEntity = new ChanceEntity();
                    chanceEntity.Modify(entity.ObjectId);
                    db.Update <ChanceEntity>(chanceEntity);
                    break;

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

                case 3:             //洗号池
                    TelphoneWashEntity washEntity = new TelphoneWashEntity();
                    //washEntity.CallResult = entity.TrackTypeId;
                    washEntity.CallDescription = entity.TrackContent;
                    washEntity.CallTime        = entity.CreateDate;
                    washEntity.Modify(int.Parse(entity.ObjectId));
                    db.Update <TelphoneWashEntity>(washEntity);
                    break;

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

                db.Commit();
            }
            catch (Exception)
            {
                db.Rollback();
                throw;
            }
        }
Exemple #9
0
        /// <summary>
        /// 保存表单(新增、修改)
        /// </summary>
        /// <param name="keyValue">主键值</param>
        /// <param name="entity">实体对象</param>
        /// <returns></returns>
        public void SaveForm(string keyValue, TrailRecordEntity entity)
        {
            if (!string.IsNullOrWhiteSpace(keyValue))
            {
                entity.Modify(keyValue);
                this.BaseRepository().Update(entity);
                entity = this.GetEntity(entity.TrailId);
                #region 商机
                if (entity.ObjectSort == 1)
                {
                    IRepository db = new RepositoryFactory().BaseRepository();
                    db.BeginTrans();
                    try
                    {
                        ChanceEntity chanceEntity = new ChanceEntity();
                        chanceEntity.Modify(entity.ObjectId);
                        db.Update <ChanceEntity>(chanceEntity);
                        db.Commit();
                    }
                    catch (Exception)
                    {
                        db.Rollback();
                        throw;
                    }
                }

                #endregion

                #region 客户
                else if (entity.ObjectSort == 2)
                {
                    string userId = OperatorProvider.Provider.Current().LoginInfo.UserId;
                    //销售阶段
                    CustomerFollowEntity followEntity = new CustomerFollowEntity();
                    followEntity.Create();
                    followEntity.CustomerId       = entity.ObjectId;
                    followEntity.SaleStageId      = entity.SaleStageId;
                    followEntity.SaleStageName    = entity.SaleStageName;
                    followEntity.CustomerFollowId = entity.TrailId;


                    IRepository db = new RepositoryFactory().BaseRepository();
                    db.BeginTrans();
                    try
                    {
                        CustomerEntity customerEntity = new CustomerEntity();
                        customerEntity.Modify(entity.ObjectId);
                        db.Update <CustomerEntity>(customerEntity);


                        //更新日程
                        ScheduleEntity scheduleEntity = new ScheduleEntity();
                        scheduleEntity.ScheduleState = 1;
                        scheduleEntity.Modify(entity.TrailId);
                        db.Update(scheduleEntity);

                        //删除已有的客户销售阶段
                        db.Delete <CustomerFollowEntity>(t => t.CustomerId == entity.ObjectId && t.CreateUserId == userId);
                        //创建新销售阶段
                        db.Insert <CustomerFollowEntity>(followEntity);
                        db.Commit();
                    }
                    catch (Exception)
                    {
                        db.Rollback();
                        throw;
                    }
                }
                #endregion
            }
            else
            {
                entity.Create();

                #region 商机
                if (entity.ObjectSort == 1)
                {
                    IRepository db = new RepositoryFactory().BaseRepository();
                    db.BeginTrans();
                    try
                    {
                        ChanceEntity chanceEntity = new ChanceEntity();
                        chanceEntity.Modify(entity.ObjectId);
                        db.Update <ChanceEntity>(chanceEntity);
                        db.Insert(entity);
                        db.Commit();
                    }
                    catch (Exception)
                    {
                        db.Rollback();
                        throw;
                    }
                }

                #endregion

                #region 客户
                else if (entity.ObjectSort == 2)
                {
                    string userId = OperatorProvider.Provider.Current().LoginInfo.UserId;
                    //销售阶段
                    CustomerFollowEntity followEntity = new CustomerFollowEntity();
                    followEntity.Create();
                    followEntity.CustomerId    = entity.ObjectId;
                    followEntity.SaleStageId   = entity.SaleStageId;
                    followEntity.SaleStageName = entity.SaleStageName;

                    followEntity.CustomerFollowId = entity.TrailId;
                    IRepository db = new RepositoryFactory().BaseRepository();
                    db.BeginTrans();
                    try
                    {
                        CustomerEntity customerEntity = new CustomerEntity();
                        customerEntity.Modify(entity.ObjectId);
                        db.Update <CustomerEntity>(customerEntity);


                        db.Insert(entity);
                        #region 计划任务增加到日程
                        if (entity.TrailType == 1)
                        {
                            ScheduleEntity scheduleEntity = new ScheduleEntity();
                            scheduleEntity.ScheduleContent = entity.ObjectName + "-" + entity.SaleStageName + "-" + entity.TrackContent;
                            scheduleEntity.ScheduleState   = 0;
                            scheduleEntity.StartDate       = entity.StartTime.ToDate();
                            scheduleEntity.StartTime       = Convert.ToDateTime(entity.StartTime).ToString("HHmm");
                            scheduleEntity.EndDate         = entity.EndTime.ToDate();
                            scheduleEntity.EndTime         = Convert.ToDateTime(entity.EndTime).ToString("HHmm");
                            scheduleEntity.IsMailAlert     = 0;
                            scheduleEntity.IsMobileAlert   = 0;
                            scheduleEntity.IsWeChatAlert   = 0;
                            scheduleEntity.Create();
                            scheduleEntity.ScheduleId = entity.TrailId;
                            db.Insert(scheduleEntity);
                        }
                        else
                        {
                            //删除已有的客户销售阶段
                            db.Delete <CustomerFollowEntity>(t => t.CustomerId == entity.ObjectId && t.CreateUserId == userId);
                            //创建新销售阶段
                            db.Insert <CustomerFollowEntity>(followEntity);
                        }
                        #endregion
                        db.Commit();
                    }
                    catch (Exception)
                    {
                        db.Rollback();
                        throw;
                    }
                }
                #endregion
            }
        }