Пример #1
0
        public void Update(Bas_Student student)
        {
            StudentBll studentBll = new StudentBll();
            var        entity     = studentBll.StudentRepository.Get(student.Bst_Id);

            if (entity != null)
            {
                if (!string.IsNullOrEmpty(student.Bst_Avatar))
                {
                    entity.Bst_Avatar = student.Bst_Avatar;
                }

                entity.Bst_NickName    = student.Bst_NickName;
                entity.Bst_Name        = student.Bst_Name;
                entity.Bst_Sex         = student.Bst_Sex;
                entity.Bst_Birthday    = student.Bst_Birthday;
                entity.Bst_Grade       = student.Bst_Grade;
                entity.Bst_StudySchool = student.Bst_StudySchool;
                entity.Bst_Province    = student.Bst_Province;
                entity.Bst_City        = student.Bst_City;
                entity.Bst_County      = student.Bst_County;
                entity.Bst_Address     = student.Bst_Address;
                entity.Bst_UpdateTime  = DateTime.Now;
            }
            studentBll.StudentRepository.Update(entity);
        }
Пример #2
0
 /// <summary>
 /// 更换手机
 /// </summary>
 /// <param name="studentId"></param>
 /// <param name="phone"></param>
 public void UpdateMobile(int studentId, string phone)
 {
     using (TransactionScope scope = new TransactionScope())
     {
         try
         {
             StudentBll studentBll = new StudentBll();
             var        student    = studentBll.StudentRepository.Get(studentId);
             if (student != null)
             {
                 student.Bst_Phone      = phone;
                 student.Bst_UpdateTime = DateTime.Now;
                 studentBll.StudentRepository.Update(student);
             }
             var studentPassport = GetPassportByStuIdAndType(studentId, StudentAccountSourceEnum.手机);
             if (studentPassport != null)
             {
                 studentPassport.Bsp_PassportKey = phone;
                 studentPassport.Bsp_UpdateTime  = DateTime.Now;
                 StudentPassportRepository.Update(studentPassport);
             }
             scope.Complete();
         }
         catch (Exception ex)
         {
             RollbackTran();
             throw ex;
         }
     }
 }
Пример #3
0
        /// <summary>
        /// 查询已领取注册券
        /// </summary>
        /// <param name="studentId"></param>
        /// <param name="schoolId"></param>
        /// <returns></returns>
        public List <DtoOwnCashVoucher> GetHaveRegisterVoucher(int studentId)
        {
            StudentBll studentBll = new StudentBll();
            var        student    = studentBll.StudentRepository.Get(studentId);
            var        ids        = StudentCashVoucherRepository.GetHaveRegisterVoucherId(studentId).Select(s => s.Ysv_CashVoucherId).ToList();

            return(CashVoucherRepository.GetAvailableRegisterVoucherByIds(ids));
        }
Пример #4
0
        /// <summary>
        /// 学生个人信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public DtoStudentInfo GetStudentInfoByAccount(string account)
        {
            StudentBll      studentBll      = new StudentBll();
            StudentApplyBll studentApplyBll = new StudentApplyBll();
            var             studentInfo     = studentBll.StudentRepository.GetStudentInfoByAccount(account);

            return(studentInfo);
        }
Пример #5
0
        public Bas_Student GetBySchoolId()
        {
            StudentBll studentBll = new StudentBll();
            var        student    = studentBll.StudentRepository.GetBySchoolId();

            AddStudentLogin(student.Bst_Id);
            UpdateSumStudent(student.Bst_Id);
            return(student);
        }
Пример #6
0
        public Bas_StudentPassport GetPassportByStuIdAndType(int studentId, StudentAccountSourceEnum passportType)
        {
            StudentBll studentBll      = new StudentBll();
            var        studentPassport = StudentPassportRepository.GetPassportByStuIdAndType(studentId, (int)passportType);

            if (studentPassport != null && studentPassport.Bsp_Status == (int)StudentAccountStatusEnum.启用)
            {
                return(studentPassport);
            }
            return(null);
        }
Пример #7
0
        /// <summary>
        /// 学生个人信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public DtoStudentInfo GetStudentInfo(int id)
        {
            StudentBll      studentBll      = new StudentBll();
            StudentApplyBll studentApplyBll = new StudentApplyBll();
            var             studentInfo     = studentBll.StudentRepository.GetStudentInfoById(id);

            if (studentInfo.Bst_SchoolId > 0)
            {
                return(studentInfo);
            }
            DtoStudentApplySchool studentApplySchool = studentApplyBll.GetApplyByStudentId(id);

            if (studentApplySchool != null)
            {
                studentInfo.ApplyStatus     = studentApplySchool.Yay_Status;
                studentInfo.ApplySchoolName = studentApplySchool.SchoolName;
            }
            return(studentInfo);
        }
Пример #8
0
        /// <summary>
        /// 获取学生该课的可使用的现金券
        /// </summary>
        /// <param name="studentId"></param>
        /// <param name="amount"></param>
        /// <param name="grade"></param>
        /// <param name="courseType"></param>
        /// <param name="courseId"></param>
        /// <returns></returns>
        public List <DtoOwnCashVoucher> GetStudentUseCashVoucher(int studentId, int amount, int grade, int courseType, int courseId)
        {
            List <DtoOwnCashVoucher> cashVoucherList = new List <DtoOwnCashVoucher>();
            StudentBll studentBll = new StudentBll();
            var        student    = studentBll.StudentRepository.Get(studentId);

            //获取所有的现金券的Id和类型
            var allCashVoucher = CashVoucherRepository.GetCashVoucherId(
                new DtoSimpleCourse {
                CourseId = courseId, Grade = grade, Amount = amount, CourseType = courseType
            },
                studentId,
                student.Bst_SchoolId);

            //根据id查询所有符合条件的现金券的基本信息
            cashVoucherList = CashVoucherRepository.GetAvailableCashVoucherByIds(allCashVoucher.Select(s => s.VoucherId).ToList());

            //获取学生已拥有的现金券Id
            var haveIds = allCashVoucher.Where(s => s.IsTaken == 1).Select(s => s.VoucherId).ToList();

            //查询学生现金券的信息
            var studentCashVouchers = StudentCashVoucherRepository.GetStudentCashVoucherByStudentIdAndVoucherId(studentId, haveIds);

            //给学生已拥有现金券赋值
            foreach (var item in cashVoucherList)
            {
                var studentCashVoucher = studentCashVouchers.Where(s => s.Ysv_CashVoucherId == item.Ycv_Id).FirstOrDefault();
                if (studentCashVoucher != null)
                {
                    item.Ysv_Id         = studentCashVoucher.Ysv_Id;
                    item.Ysv_ExpireDate = studentCashVoucher.Ysv_ExpireDate;
                    item.Ysv_TakenTime  = studentCashVoucher.Ysv_TakenTime;
                    item.IsAvailable    = (int)IsAvailableEnum.学生已拥有且可用的;
                }
                else
                {
                    item.IsAvailable = (int)IsAvailableEnum.学生可领取且可用的;
                }
            }
            return(cashVoucherList);
        }
Пример #9
0
        /// <summary>
        /// 添加学生
        /// </summary>
        /// <param name="name"></param>
        /// <param name="grade"></param>
        /// <param name="phone"></param>
        /// <param name="source"></param>
        /// <param name="operatorId"></param>
        /// <returns>学生Id</returns>
        private int AddStudent(string name, int grade, string phone, RegisterRegSourceEnum source, int operatorId)
        {
            StudentBll  studentBll = new StudentBll();
            Bas_Student student    = new Bas_Student();

            student.Bst_Name       = name;
            student.Bst_Grade      = grade;
            student.Bst_Phone      = phone;
            student.Bst_Sex        = (int)SexEnum.男;
            student.Bst_RegTime    = DateTime.Now;
            student.Bst_RegSource  = (int)source;
            student.Bst_Status     = (int)StudentAccountStatusEnum.启用;
            student.Bst_Birthday   = "1900-01-01"._ToDateTime();
            student.Bst_No         = studentBll.StudentRepository.GetStudentNo();
            student.Bst_UpdateTime = DateTime.Now;
            if ((int)source == 2)
            {
                student.Bst_RegOperator = operatorId;
            }
            return(studentBll.StudentRepository.Add(student));
        }
Пример #10
0
        /// <summary>
        /// 更新学生申请状态
        /// </summary>
        /// <param name="yayId"></param>
        /// <param name="toStatus"></param>
        /// <param name="oper"></param>
        /// <returns></returns>
        public bool UpdateApplyStatus(int yayId, int toStatus, int fromStatus, int oper)
        {
            bool result = false;
            DtoStudentApplySchool model = StudentApplySchoolRepository.GetById(yayId);

            if (model == null)
            {
                return(false);
            }
            using (TransactionScope scope = new TransactionScope())
            {
                try
                {
                    var updateApply   = StudentApplySchoolRepository.UpdateApplyStatus(yayId, toStatus, fromStatus, oper);
                    var updateStudent = true;
                    if (updateApply && toStatus == (int)ApplyStatusEnum.意)
                    {
                        updateStudent = StudentBll.UpdateSchool(model.Yay_StudentId, model.Yay_SchoolId);
                    }
                    if (updateApply && updateStudent)
                    {
                        scope.Complete();
                        result = true;
                    }
                    else
                    {
                        RollbackTran();
                    }
                }
                catch (Exception ex)
                {
                    RollbackTran();
                    throw;
                }
            }
            return(result);
        }
Пример #11
0
        /// <summary>
        /// 获取学生统计信息(页眉)
        /// </summary>
        /// <param name="studentId"></param>
        /// <returns></returns>
        public DtoSumStudentTip GetSumStudentTip(int studentId)
        {
            StudentBll studentBll = new StudentBll();

            return(studentBll.StudentRepository.GetSumStudentTip(studentId));
        }
Пример #12
0
        public Bas_StudentPassport GetByPassportKey(string passportKey)
        {
            StudentBll studentBll = new StudentBll();

            return(studentBll.StudentPassportRepository.GetByPassport(passportKey));
        }
Пример #13
0
        /// <summary>
        /// 保存课后任务或者练习题答案
        /// </summary>
        public void SaveResult(int studentId, int taskId, int useTime, List <StudentAnswerBase> answers, StudyTaskTypeEnum taskType = 0, int partId = 0)
        {
            Yw_StudentTask stk = StudentTaskRepository.GetByStudentTask(studentId, taskId);

            if (stk.Yuk_Status == (int)StudentTaskStatusEnum.已完成)
            {
                throw new AbhsException(ErrorCodeEnum.StudentTaskStatusInvalid, AbhsErrorMsg.ConstStudentTaskStatusInvalid);
            }

            int totalStars       = answers.Sum(x => x.ResultStars);
            int totalCoins       = CalcCoins(answers);
            int fiveStarsAnswers = answers.Count(x => x.ResultStars == 5);

            var finishTime = DateTime.Now;

            //更新学生任务记录表

            stk.Yuk_StartTime         = finishTime.AddSeconds(0 - useTime);//反算时间
            stk.Yuk_FinishTime        = finishTime;
            stk.Yuk_StudentScore      = totalStars;
            stk.Yuk_GainCoins         = totalCoins;
            stk.Yuk_RightSubjectCount = fiveStarsAnswers;

            if (answers.Count > 0)
            {
                stk.Yuk_Percent = (int)(Math.Round(fiveStarsAnswers * 1.0 / answers.Count, 2) * 100);
            }

            stk.Yuk_Status = (int)StudentTaskStatusEnum.已完成;
            StudentTaskRepository.Update(stk);

            StudentAnswerCard card = new StudentAnswerCard();

            card.UseTime          = useTime;
            card.SubmitTime       = finishTime.ToString("yyyy-MM-dd HH:mm:ss");
            card.Part             = partId;
            card.AnswerCollection = answers;
            card.TotalStars       = totalStars;
            card.TotalCoins       = totalCoins;

            //学生任务答题结果
            Yw_StudentStudyTaskAnswerExt answer = new Yw_StudentStudyTaskAnswerExt();

            answer.Yta_StudentId          = studentId;
            answer.Yta_StudentStudyTaskId = stk.Yuk_Id;
            answer.Yta_TaskId             = taskId;
            answer.Yta_Answer_Obj         = card;
            answer.Yta_CreateTime         = DateTime.Now;
            StuStudyTaskAnsRepo.Add(answer);

            //学生最近答题记录
            Yw_StudyTask task       = StudyTaskRepository.Get(taskId);
            StudentBll   studentBll = new StudentBll();
            List <int>   ids        = task.Ysk_SubjectIds.Split(',').Select(x => Convert.ToInt32(x)).ToList();

            studentBll.RefreshStudentRecentSubject(studentId, ids);

            StudentInfoBll bll = new StudentInfoBll();

            bll.AddCoins(studentId, totalCoins);

            if (taskType == StudyTaskTypeEnum.系统课后任务)
            {
                new StudentPracticeBll().PublishStudyTaskMessage(
                    task.Ysk_CourseId,
                    task.Ysk_LessonId,
                    studentId,
                    useTime,
                    answers.Count,
                    totalCoins);
            }
            else if (taskType == StudyTaskTypeEnum.课后练习)
            {
                new StudentPracticeBll().PublishStudyPractiseMessage(
                    task.Ysk_CourseId,
                    task.Ysk_LessonId,
                    studentId,
                    useTime,
                    answers.Count,
                    totalCoins);
            }

            //课程学习 = 1, 课后任务 = 2, 课后练习 = 3
            StudyWrongSourceEnum?source = null;

            switch (taskType)
            {
            case StudyTaskTypeEnum.系统课后任务:
            case StudyTaskTypeEnum.老师课后任务:
                source = StudyWrongSourceEnum.课后任务;
                break;

            case StudyTaskTypeEnum.课后练习:
                source = StudyWrongSourceEnum.课后练习;
                break;

            default:
                source = StudyWrongSourceEnum.课后任务;
                break;
            }
            new StudentWrongBookBll().SaveWrongBook(
                new List <StudentAnswerCard> {
                card
            },
                new DtoStudentWrongBook
            {
                CourseId         = task.Ysk_CourseId,
                LessonId         = task.Ysk_LessonId,
                LessonProgressId = task.Ysk_LessonProgressId,
                Source           = source.Value,
                StudentId        = studentId,
                StudyTaskId      = taskId
            });
        }