예제 #1
0
 public ViewResult CommonInterview(Guid id, int TrackNo)
 {
     StudentInfoEntity studentInfo = repository.StudentInfo.FirstOrDefault(s => s.StudentID == id);
     SaleTrackEntity SaleTrack;
     IEnumerable<SaleTrackParticipantsEntity> SaleTrackParticipants = null;
     if (repository.SaleTrack.SingleOrDefault(s => s.StudentID == id && s.TrackNo == TrackNo) != null)
     {
         SaleTrack = repository.SaleTrack.SingleOrDefault(s => s.StudentID == id && s.TrackNo == TrackNo);
         SaleTrackParticipants = repository.SaleTrackParticipants.Where(s => s.SaleTrackID == SaleTrack.TrackItemID).Select(s => s);
     }
     else
     {
         DateTime nextDate = repository.SaleTrack.SingleOrDefault(s => s.StudentID == id && s.TrackNo == TrackNo - 1).TrackDate;
         SaleTrack = new SaleTrackEntity
         {
             TrackItemID = Guid.NewGuid(),
             StudentID = id,
             Inputor = "Admin",
             StateName = "第"+TrackNo.ToString() + "次回访",
             TrackNo = (byte)TrackNo,
             TrackPattern = TrackPattern.面谈,
             TrackDate = nextDate.AddDays(1),
             ToDo = "第" + TrackNo.ToString() + "次回访",
             IsComplete = TrackIsComplete.否,
             Remark = "请输入备注信息 "
         };
         SaleTrackParticipants = Enumerable.Empty<SaleTrackParticipantsEntity>();
     }
     return View(new SaleTrackViewModel
     {
         StudentInfo = studentInfo,
         SaleTrack = SaleTrack,
         SaleTrackParticipants = SaleTrackParticipants,
         AdditionalIdentity = SaleParticipantIdentity.咨询顾问
     });
 }
예제 #2
0
 public ActionResult FirstInterview(Guid id)
 {
     StudentInfoEntity studentInfo = repository.StudentInfo.FirstOrDefault(s => s.StudentID == id);
     SaleTrackEntity SaleTrack;
     IEnumerable<SaleTrackParticipantsEntity> SaleTrackParticipants = null;
     if (repository.SaleTrack.SingleOrDefault(s => s.StudentID == id && s.TrackNo == 1) != null)
     {
         SaleTrack = repository.SaleTrack.SingleOrDefault(s => s.StudentID == id && s.TrackNo == 1);
         SaleTrackParticipants = repository.SaleTrackParticipants.Where(s => s.SaleTrackID == SaleTrack.TrackItemID).Select(s => s);
     }
     else
     {
         SaleTrack = new SaleTrackEntity
             {
                 TrackItemID = Guid.NewGuid(),
                 StudentID = id,
                 Inputor = "Admin",
                 StateName = "初访",
                 TrackPattern = TrackPattern.面谈,
                 TrackDate = studentInfo.CreateTime.AddDays(1),
                 ToDo = "了解客户需求,完成初访登记表!",
                 IsComplete = TrackIsComplete.否,
                 Remark = "请输入备注信息"
             };
         SaleTrackParticipants = Enumerable.Empty<SaleTrackParticipantsEntity>();
     }
     return View(new SaleTrackViewModel
         {
             StudentInfo = studentInfo,
             SaleTrack = SaleTrack,
             SaleTrackParticipants = SaleTrackParticipants,
             AdditionalIdentity = SaleParticipantIdentity.咨询顾问
         });
 }
예제 #3
0
 JsonResult GetFirstInterviewData(Guid id)
 {
     StudentInfoEntity studentInfo = repository.StudentInfo.FirstOrDefault(s => s.StudentID == id);
     AppRelationsEntity appRelation = repository.AppRelation.FirstOrDefault(a => a.StudentID == id);
     SaleTrackEntity SaleTrack;
     IEnumerable<SaleTrackParticipantsEntity> SaleTrackParticipants = null;
     if (repository.SaleTrack.SingleOrDefault(s => s.StudentID == id && s.TrackNo == 1) != null)
     {
         SaleTrack = repository.SaleTrack.SingleOrDefault(s => s.StudentID == id && s.TrackNo == 1);
         SaleTrackParticipants = repository.SaleTrackParticipants.Where(s => s.SaleTrackID == SaleTrack.TrackItemID).Select(s => s);
     }
     else
     {
         SaleTrack = new SaleTrackEntity
         {
             TrackItemID = Guid.NewGuid(),
             StudentID = id,
             Inputor = HttpContext.User.Identity.Name,
             StateName = "初访",
             TrackPattern = TrackPattern.面谈,
             TrackDate = studentInfo.CreateTime.AddDays(1),
             ToDo = "了解客户需求,完成初访登记表!",
             IsComplete = TrackIsComplete.否,
             SignIntention = appRelation.IsSign,
             Remark = ""
         };
         SaleTrackParticipants = Enumerable.Empty<SaleTrackParticipantsEntity>();
     }
     return Json(new SaleTrackAjaxViewModel {
         SaleTrackItem = SaleTrack,
         SaleTrackParticipant = SaleTrackParticipants
     }, JsonRequestBehavior.AllowGet);
 }
예제 #4
0
        /// <summary>
        /// 获取所有销售数据
        /// </summary>
        /// <returns></returns>
        public JsonResult List(string sort, string keyword)
        {
            string userName = HttpContext.User.Identity.Name;
            PermissionPValueEntity userPermission = userInfoRepository.GetUserPermission(userName);

            IEnumerable<StudentInfoViewModel> StudentsInfo = null;
            List<SaleTrackListItemModel> SaleTrackList = new List<SaleTrackListItemModel>();
            SaleTrackListItemModel saleTrackListItem = null;

            if (sort == "学生" && keyword != "")
            {
                StudentsInfo = repository.StudentInfo
                    .Where(s => s.NameCn == keyword)
                    .Join(repository.AppRelation, s => s.StudentID, a => a.StudentID, (s, a) => new StudentInfoViewModel { StudentInfo = s, AppRelation = a });
            }
            else if (sort == "销售负责人" && keyword != "")
            {
                Guid saleConsultantID = repository.UserInfo.FirstOrDefault(u => u.UserNameCn.Contains(keyword)).UserID;
                StudentsInfo = repository.AppRelation
                    .Where(a => a.SaleConsultant == saleConsultantID)
                    .Join(repository.StudentInfo, a => a.StudentID, s => s.StudentID, (a, s) => new StudentInfoViewModel { StudentInfo = s, AppRelation = a });
            }
            else if (sort == "已签约")
            {
                StudentsInfo = repository.AppRelation
                    .Where(a=>a.IsSign == IsSign.已签约)
                    .Join(repository.StudentInfo, a => a.StudentID, s => s.StudentID, (a, s) => new StudentInfoViewModel { AppRelation = a, StudentInfo = s })   //调用Join函数,连结两个集合,返回一个包对象
                    .OrderBy(r => r.StudentInfo.NameCn);
            }
            else if (sort == "未签约")
            {
                StudentsInfo = repository.AppRelation
                   .Where(a => a.IsSign != IsSign.已签约)
                   .Join(repository.StudentInfo, a => a.StudentID, s => s.StudentID, (a, s) => new StudentInfoViewModel { AppRelation = a, StudentInfo = s })   //调用Join函数,连结两个集合,返回一个包对象
                   .OrderBy(r => r.StudentInfo.NameCn);
            }
            else
            {
                StudentsInfo = repository.StudentInfo
                        .Join(repository.AppRelation, s => s.StudentID, a => a.StudentID, (s, a) => new StudentInfoViewModel { AppRelation = a, StudentInfo = s })   //调用Join函数,连结两个集合,返回一个包对象
                        .OrderByDescending(r => r.AppRelation.IsSign);
            }

            //如果不允许展示全部销售,就只展示自己负责销售的学生
            if (!userPermission.IsSaleListAll)
            {
                StudentsInfo = StudentsInfo.Where(s => s.AppRelation.SaleConsultantName == userName);
            }

            foreach (StudentInfoViewModel studentInfoViewModel in StudentsInfo)
            {
                saleTrackListItem = new SaleTrackListItemModel
                {
                    StudentInfo = studentInfoViewModel.StudentInfo,
                    AppRelation = studentInfoViewModel.AppRelation
                };
                Guid id = studentInfoViewModel.StudentInfo.StudentID;
                int maxTrackNo;
                SaleTrackEntity saleTrackEntity = null;

                if (repository.SaleTrack.Where(s => s.StudentID == id).Count() <= 0)
                {
                    maxTrackNo = 0;
                    saleTrackEntity = new SaleTrackEntity
                    {
                        TrackItemID = Guid.Empty,
                        StudentID = id,
                        TrackNo = 0,
                        Inputor = HttpContext.User.Identity.Name,
                        StateName = "未开始",
                        TrackPattern = TrackPattern.电话,
                        TrackDate = studentInfoViewModel.StudentInfo.CreateTime,
                        ToDo = "客户主动咨询",
                        IsComplete = TrackIsComplete.否,
                        SignIntention = studentInfoViewModel.AppRelation.IsSign,
                        Remark = ""
                    };
                }
                else
                {
                    maxTrackNo = repository.SaleTrack.Where(s => s.StudentID == id).Max(s => s.TrackNo);
                    saleTrackEntity = repository.SaleTrack.SingleOrDefault(s => s.StudentID == id && s.TrackNo == maxTrackNo);
                }
                saleTrackListItem.CurrentSaleTrack = saleTrackEntity;
                saleTrackListItem.FromCollection = repository.StudentFrom.Where(s => s.StudentID == id);

                SaleTrackList.Add(saleTrackListItem);
            }

            return Json(SaleTrackList, JsonRequestBehavior.AllowGet);
        }
예제 #5
0
        public void SaveSaleTrack(SaleTrackEntity saleTrackItem)
        {
            SaleTrackEntity originSaleTrackItem = context.SaleTrack.SingleOrDefault(s => s.TrackItemID == saleTrackItem.TrackItemID);
            if (originSaleTrackItem == null)
            {
                int nextTrackNo = context.SaleTrack.Count(s => s.StudentID == saleTrackItem.StudentID) == 0 ? 1 : context.SaleTrack.Where(s => s.StudentID == saleTrackItem.StudentID).Max(s => s.TrackNo);
                saleTrackItem.TrackNo = (byte)nextTrackNo;
                context.SaleTrack.Add(saleTrackItem);
            }
            else
            {
                context.Entry(originSaleTrackItem).CurrentValues.SetValues(saleTrackItem);
            }

            context.SaveChanges();
        }
예제 #6
0
        public void SaveSaleTrack(SaleTrackEntity saleTrackItem, IEnumerable<SaleTrackParticipantsEntity> saleTrackParticipants)
        {
            SaleTrackEntity originSaleTrackItem = context.SaleTrack.SingleOrDefault(s => s.TrackItemID == saleTrackItem.TrackItemID);
            if (originSaleTrackItem == null)
            {
                int nextTrackNo = context.SaleTrack.Count(s => s.StudentID == saleTrackItem.StudentID) == 0 ? 1 : context.SaleTrack.Where(s => s.StudentID == saleTrackItem.StudentID).Max(s => s.TrackNo)+1;
                saleTrackItem.TrackNo = (byte)nextTrackNo;
                context.SaleTrack.Add(saleTrackItem);
            }
            else
            {
                context.SaleTrackParticipants.RemoveRange(context.SaleTrackParticipants.Where(s => s.SaleTrackID == originSaleTrackItem.TrackItemID).Select(s => s));
                context.Entry(originSaleTrackItem).CurrentValues.SetValues(saleTrackItem);
            }
            if (saleTrackParticipants != null && saleTrackParticipants.Count() > 0)
            {
                context.SaleTrackParticipants.AddRange(saleTrackParticipants);  //添加参与人
            }

            context.SaveChanges();
        }