using System; using System.Collections.Generic; using System.Linq; using System.Text; using EMIS.DataLogic.Repositories; using EMIS.ViewModel.MinorManage.MinorPlanManage; using System.Linq.Expressions; using EMIS.Entities; namespace EMIS.DataLogic.MinorManage.MinorPlanManage { public class MinorPlanApplyDAL { public GrademinorApplicationRepository GrademinorApplicationRepository { get; set; } public MinorPlanApplicationRepository MinorPlanApplicationRepository { get; set; } public MinorPlanApplicationTeachingModeTypeRepository MinorPlanApplicationTeachingModeTypeRepository { get; set; } public MinorPlanApplicationTeachingPlaceRepository MinorPlanApplicationTeachingPlaceRepository { get; set; } public MinorPlanApplicationTeachingSettingRepository MinorPlanApplicationTeachingSettingRepository { get; set; } public MinorCourseRepository MinorCourseRepository { get; set; } public UserRepository UserRepository { get; set; } public MinorCourseTeachingSettingRepository MinorCourseTeachingSettingRepository { get; set; } public MinorCourseTeachingModeTypeRepository MinorCourseTeachingModeTypeRepository { get; set; } public MinorCourseTeachingPlaceRepository MinorCourseTeachingPlaceRepository { get; set; } public GrademinorRepository GrademinorRepository { get; set; } public IQueryable GetMinorPlanApplyViewQueryable(Expression> exp) { var query = from GrademinorApply in GrademinorApplicationRepository.GetList(exp) join User in UserRepository.Entities on GrademinorApply.CreateUserID equals User.UserID into user from u in user.DefaultIfEmpty() select new MinorPlanApplyView { GradeMinorApplicationID = GrademinorApply.GradeMinorApplicationID, YearID = GrademinorApply.YearID, SchoolyearID=GrademinorApply.SchoolyearID, SchoolyearCode=GrademinorApply.CF_Schoolyear.Code, StandardID = GrademinorApply.StandardID, CollegeID = GrademinorApply.CollegeID, CollegeName = GrademinorApply.CF_College.Name, CollegeNo = GrademinorApply.CF_College.No, StudentLimit = GrademinorApply.StudentLimit, ApprovalStatus = GrademinorApply.RecordStatus, CreateUserID = GrademinorApply.CreateUserID, CreateTime = GrademinorApply.CreateTime, CreateUserName = u.Name }; return query; } /// /// 查询所有年级和专业课程信息 /// /// public IQueryable StandardAndMinorSpecialtyCourseView(Expression> exp,int? YearID) { var graduatingSemester = EMIS.Utility.Const.LOCAL_SETTING_ENTRANCESEMESTERID; if (graduatingSemester == null) { throw new Exception("入学学期(春季、上学期、秋季、下学期)未配置,请检查"); } var SchoolcodeID = Convert.ToInt32(graduatingSemester); var query = from MinorCourse in MinorCourseRepository.GetList(exp) join GrademinorApply in ( from GrademinorApply in GrademinorApplicationRepository.GetList(x => x.YearID == YearID) join MinorPlanApply in MinorPlanApplicationRepository.Entities on new { GrademinorApply.GradeMinorApplicationID } equals new { GradeMinorApplicationID = (Guid)MinorPlanApply.GrademinorApplicationID } select new { GradeMinorApplicationID = GrademinorApply.GradeMinorApplicationID, MinorPlanApplicationID=MinorPlanApply.MinorPlanApplicationID, CoursematerialID = MinorPlanApply.CoursematerialID, CollegeID = GrademinorApply.CollegeID, SchoolyearID = GrademinorApply.SchoolyearID, StandardID = GrademinorApply.StandardID, YearID=GrademinorApply.YearID } ) on new { MinorCourse.CoursematerialID, MinorCourse.StandardID } equals new { GrademinorApply.CoursematerialID, GrademinorApply.StandardID } into GrademinorApplication from GA in GrademinorApplication.DefaultIfEmpty() where GA.GradeMinorApplicationID == null && GA.MinorPlanApplicationID == null select new MinorPlanApplyView { GradeMinorApplicationID = GA.GradeMinorApplicationID, MinorPlanApplicationID = GA.MinorPlanApplicationID, MinorCourseID = MinorCourse.MinorCourseID, CollegeID = MinorCourse.CF_Department.CollegeID, CoursematerialID = MinorCourse.CoursematerialID, CourseCode = MinorCourse.EM_Coursematerial.CourseCode, CourseName = MinorCourse.EM_Coursematerial.CourseName, SchoolyearID = GA.SchoolyearID, YearID = GA.YearID, StandardID = MinorCourse.StandardID, CourseCategoryID = MinorCourse.CourseCategoryID, CourseQualityID = MinorCourse.CourseQualityID, SchoolcodeID = MinorCourse.SchoolcodeID, SchoolyearNumID = MinorCourse.SchoolyearNumID, StarttermID = ((MinorCourse.SchoolyearNumID - 1) * 2) + (MinorCourse.SchoolcodeID == SchoolcodeID ? 0 : 1) + 1, Credit = MinorCourse.EM_MinorCourseTeachingSetting.Credit ?? 0, TheoryCourse = MinorCourse.EM_MinorCourseTeachingSetting.TheoryCourse ?? 0, Practicehours = MinorCourse.EM_MinorCourseTeachingSetting.Practicehours ?? 0, Trialhours = MinorCourse.EM_MinorCourseTeachingSetting.Trialhours ?? 0, Totalhours = (MinorCourse.EM_MinorCourseTeachingSetting.TheoryCourse + MinorCourse.EM_MinorCourseTeachingSetting.Practicehours) ?? 0, TheoryWeeklyNum = MinorCourse.EM_MinorCourseTeachingSetting.TheoryWeeklyNum ?? 0, PracticeWeeklyNum = MinorCourse.EM_MinorCourseTeachingSetting.PracticeWeeklyNum ?? 0, TrialWeeklyNum = MinorCourse.EM_MinorCourseTeachingSetting.TrialWeeklyNum ?? 0, SchoolweeksNum = (MinorCourse.EM_MinorCourseTeachingSetting.TheoryWeeklyNum + MinorCourse.EM_MinorCourseTeachingSetting.PracticeWeeklyNum) ?? 0, StartWeeklyNum = MinorCourse.EM_MinorCourseTeachingSetting.StartWeeklyNum ?? 0, EndWeeklyNum = MinorCourse.EM_MinorCourseTeachingSetting.EndWeeklyNum ?? 0, WeeklyNum = MinorCourse.EM_MinorCourseTeachingSetting.WeeklyNum ?? 0, WeeklyHours = MinorCourse.EM_MinorCourseTeachingSetting.WeeklyHours ?? 0, DepartmentID = MinorCourse.DepartmentID, CourseStructureID = MinorCourse.CourseStructureID, CourseTypeID = MinorCourse.CourseTypeID, ExaminationModeID = MinorCourse.ExaminationModeID, TeachinglanguageID = MinorCourse.TeachinglanguageID, PracticeTypeID = MinorCourse.PracticeTypeID, CourseFineID = MinorCourse.CourseFineID, IsSpecialtycore = MinorCourse.IsSpecialtycore ?? false, IsCooperation = MinorCourse.IsCooperation ?? false, IsRequired = MinorCourse.IsRequired ?? false, IsElective = MinorCourse.IsElective ?? false, IsNetworkCourse = MinorCourse.IsNetworkCourse ?? false, IsNeedMaterial=true, HandleModeID=(int)EMIS.ViewModel.CF_HandleMode.MinorCourse, IsMainCourse = MinorCourse.IsMainCourse ?? false, IsEnable = MinorCourse.IsEnable ?? false, ResultTypeID = MinorCourse.ResultTypeID }; return query; } /// /// 查询已存在的课程信息 /// /// public IQueryable existStandardAndMinorSpecialtyCourseView(Expression> exp) { var graduatingSemester = EMIS.Utility.Const.LOCAL_SETTING_ENTRANCESEMESTERID; if (graduatingSemester == null) { throw new Exception("入学学期(春季、上学期、秋季、下学期)未配置,请检查"); } var SchoolcodeID = Convert.ToInt32(graduatingSemester); var query = from MinorCourse in MinorCourseRepository.GetList(x=>true) join GrademinorApply in ( from GrademinorApply in GrademinorApplicationRepository.GetList(exp) join MinorPlanApply in MinorPlanApplicationRepository.Entities on new { GrademinorApply.GradeMinorApplicationID } equals new { GradeMinorApplicationID = (Guid)MinorPlanApply.GrademinorApplicationID } select new { GradeMinorApplicationID = GrademinorApply.GradeMinorApplicationID, MinorPlanApplicationID = MinorPlanApply.MinorPlanApplicationID, CoursematerialID = MinorPlanApply.CoursematerialID, CollegeID = GrademinorApply.CollegeID, SchoolyearID = GrademinorApply.SchoolyearID, StandardID = GrademinorApply.StandardID, YearID = GrademinorApply.YearID, MinorCourse = MinorPlanApply } ) on new { MinorCourse.CoursematerialID, MinorCourse.StandardID } equals new { GrademinorApply.CoursematerialID, GrademinorApply.StandardID } into GrademinorApplication from GA in GrademinorApplication.DefaultIfEmpty() where GA.GradeMinorApplicationID != null && GA.MinorPlanApplicationID != null select new MinorPlanApplyView { GradeMinorApplicationID = GA.GradeMinorApplicationID, MinorPlanApplicationID = GA.MinorPlanApplicationID, MinorCourseID = MinorCourse.MinorCourseID, CollegeID = GA.CollegeID, CoursematerialID = GA.MinorCourse.CoursematerialID, CourseCode = MinorCourse.EM_Coursematerial.CourseCode, CourseName = MinorCourse.EM_Coursematerial.CourseName, SchoolyearID = GA.SchoolyearID, YearID = GA.YearID, StandardID = MinorCourse.StandardID, CourseCategoryID = GA.MinorCourse.CourseCategoryID, CourseQualityID = GA.MinorCourse.CourseQualityID, SchoolcodeID = MinorCourse.SchoolcodeID, SchoolyearNumID = MinorCourse.SchoolyearNumID, StarttermID = GA.MinorCourse.StarttermID, Credit = GA.MinorCourse.EM_MinorPlanApplicationTeachingSetting.Credit ?? 0, TheoryCourse = GA.MinorCourse.EM_MinorPlanApplicationTeachingSetting.TheoryCourse ?? 0, Practicehours = GA.MinorCourse.EM_MinorPlanApplicationTeachingSetting.Practicehours ?? 0, Trialhours = GA.MinorCourse.EM_MinorPlanApplicationTeachingSetting.Trialhours ?? 0, Totalhours = (GA.MinorCourse.EM_MinorPlanApplicationTeachingSetting.TheoryCourse + GA.MinorCourse.EM_MinorPlanApplicationTeachingSetting.Practicehours) ?? 0, TheoryWeeklyNum = GA.MinorCourse.EM_MinorPlanApplicationTeachingSetting.TheoryWeeklyNum ?? 0, PracticeWeeklyNum = GA.MinorCourse.EM_MinorPlanApplicationTeachingSetting.PracticeWeeklyNum ?? 0, TrialWeeklyNum = GA.MinorCourse.EM_MinorPlanApplicationTeachingSetting.TrialWeeklyNum ?? 0, SchoolweeksNum = (GA.MinorCourse.EM_MinorPlanApplicationTeachingSetting.TheoryWeeklyNum + GA.MinorCourse.EM_MinorPlanApplicationTeachingSetting.PracticeWeeklyNum) ?? 0, StartWeeklyNum = GA.MinorCourse.EM_MinorPlanApplicationTeachingSetting.StartWeeklyNum ?? 0, EndWeeklyNum = GA.MinorCourse.EM_MinorPlanApplicationTeachingSetting.EndWeeklyNum ?? 0, WeeklyNum = GA.MinorCourse.EM_MinorPlanApplicationTeachingSetting.WeeklyNum ?? 0, WeeklyHours = GA.MinorCourse.EM_MinorPlanApplicationTeachingSetting.WeeklyHours ?? 0, DepartmentID = MinorCourse.DepartmentID, CourseStructureID = GA.MinorCourse.CourseStructureID, CourseTypeID = GA.MinorCourse.CourseTypeID, ExaminationModeID = GA.MinorCourse.ExaminationModeID, TeachinglanguageID = GA.MinorCourse.TeachinglanguageID, PracticeTypeID = GA.MinorCourse.PracticeTypeID, CourseFineID = GA.MinorCourse.CourseFineID, IsSpecialtycore = GA.MinorCourse.IsSpecialtycore ?? false, IsCooperation = GA.MinorCourse.IsCooperation ?? false, IsRequired = GA.MinorCourse.IsRequired ?? false, IsElective = GA.MinorCourse.IsElective ?? false, IsNetworkCourse = GA.MinorCourse.IsNetworkCourse ?? false, IsMainCourse = GA.MinorCourse.IsMainCourse ?? false, IsEnable = MinorCourse.IsEnable ?? false, IsNeedMaterial = GA.MinorCourse.IsNeedMaterial ?? false, HandleModeID=GA.MinorCourse.HandleModeID, ResultTypeID = GA.MinorCourse.ResultTypeID }; return query; } public int GetStandardID_MinorPlanApplication_MinorSpecialtyPlan(List ids) { var query = from GrademinorApplication in GrademinorApplicationRepository.GetList(x => ids.Contains(x.GradeMinorApplicationID)) join Grademinor in GrademinorRepository.Entities on new { GrademinorApplication.YearID, GrademinorApplication.StandardID } equals new { Grademinor.YearID, Grademinor.StandardID } select Grademinor; return query.Count(); } public IQueryable GetDuplicateSpecialtyPlanApplyView(Expression> exp) { var query = (from GrademinorApplication in GetMinorPlanApplyViewQueryable(exp) join Grademinor in GrademinorRepository.Entities on new { GrademinorApplication.YearID, GrademinorApplication.StandardID } equals new { Grademinor.YearID, Grademinor.StandardID } select GrademinorApplication); return query; } } }