Exemplo n.º 1
0
        /// <summary>
        /// 数据校验
        /// <para>作     者:Huang GaoLiang  </para>
        /// <para>创建时间:2018-09-07  </para>
        /// </summary>
        /// <param name="schoolTimeId">上课时间段主键编号</param>
        /// <param name="termId">学期编号</param>
        /// <exception cref="AMS.Core.BussinessException">
        /// 异常ID:8,该时间段已排课,不可删除
        /// </exception>
        private static void CanDelete(long schoolTimeId, long termId)
        {
            // 1、查询已生效的数据
            TblTimClassTimeRepository cousClassRepository = new TblTimClassTimeRepository();
            TblTimClassTime           cousClass           = cousClassRepository.LoadList(m => m.SchoolTimeId == schoolTimeId).FirstOrDefault();

            // 如果查询的班级课表数据不存在
            if (cousClass != null)
            {
                throw new BussinessException((byte)ModelType.Datum, 8);
            }
            // 2、草稿中已被使用的也不能删除
            TermCourseTimetableAuditService auditService = new TermCourseTimetableAuditService(termId);

            if (auditService.IsAuditing || auditService.CanSubmitToAudit)
            {
                List <TblAutClassTime> autClassTimeList = new TermCourseTimetableAuditService(termId).GetAutClassTimeListById(schoolTimeId);

                // 如果查询的班级课表数据存在
                if (autClassTimeList.Any())
                {
                    throw new BussinessException((byte)ModelType.Datum, 8);
                }
            }
        }
        /// <summary>
        /// 获取已排课时间段
        /// <para>作    者:zhiwei.Tang</para>
        /// <para>创建时间:2018-11-06</para>
        /// </summary>
        /// <param name="termId">学期id</param>
        /// <param name="classRoomId">教室Id</param>
        /// <returns>上课时间段Id列表</returns>
        private static List <long> GetAlreadyClassTime(long termId, long classRoomId)
        {
            TblDatClassRepository     classRepository     = new TblDatClassRepository();
            TblTimClassTimeRepository classTimeRepository = new TblTimClassTimeRepository();

            List <TblDatClass> classs = classRepository.GetTermIdByClass(termId)
                                        .Where(x => x.ClassRoomId == classRoomId)
                                        .ToList();

            List <long> classIds = classs.Select(x => x.ClassId).ToList();

            List <TblTimClassTime> classTimes = classTimeRepository.GetByClassId(classIds)
                                                .Result
                                                .Where(x => classIds.Contains(x.ClassId))
                                                .ToList();

            return(classTimes.Select(x => x.SchoolTimeId).Distinct().ToList());
        }