GraduationCourseDAL.cs 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.DataLogic.Repositories;
  6. using EMIS.ViewModel.GraduationManage.GraduationRequirement;
  7. using System.Linq.Expressions;
  8. using EMIS.Entities;
  9. using EMIS.ViewModel;
  10. namespace EMIS.DataLogic.GraduationManage.GraduationRequirement
  11. {
  12. public class GraduationCourseDAL
  13. {
  14. public GraduationCourseRepository GraduationCourseRepository { get; set; }
  15. public GrademajorRepository GrademajorRepository { get; set; }
  16. public CoursematerialRepository CoursematerialRepository { get; set; }
  17. public FacultymajorRepository FacultymajorRepository { get; set; }
  18. public CollegeRepository CollegeRepository { get; set; }
  19. public SchoolyearRepository SchoolyearRepository { get; set; }
  20. public SpecialtyPlanRepository SpecialtyPlanRepository { get; set; }
  21. /// <summary>
  22. /// 查询对应的毕业课程信息View
  23. /// </summary>
  24. /// <param name="exp"></param>
  25. /// <returns></returns>
  26. public IQueryable<GraduationCourseView> GetGraduationCourseQueryable(Expression<Func<ER_GraduationCourse, bool>> exp)
  27. {
  28. var query = from gc in GraduationCourseRepository.GetList(exp)
  29. join cou in CoursematerialRepository.Entities
  30. on gc.CoursematerialID equals cou.CoursematerialID
  31. join gr in GrademajorRepository.Entities
  32. on gc.GrademajorID equals gr.GrademajorID
  33. join fa in FacultymajorRepository.Entities
  34. on gr.FacultymajorID equals fa.FacultymajorID
  35. join col in CollegeRepository.Entities
  36. on fa.CollegeID equals col.CollegeID
  37. join sye in SchoolyearRepository.Entities
  38. on
  39. new { SchoolyearID = gr.GradeID.Value, SchoolcodeID = gr.SemesterID.Value }
  40. equals
  41. new { SchoolyearID = sye.Years, SchoolcodeID = sye.SchoolcodeID }
  42. into tempsyenter
  43. from syenter in tempsyenter.DefaultIfEmpty()
  44. select new GraduationCourseView
  45. {
  46. GraduationCourseID = gc.GraduationCourseID,
  47. GrademajorID = gc.GrademajorID,
  48. GrademajorCode = gr.Code,
  49. GrademajorName = gr.Name,
  50. FacultymajorID = gr.FacultymajorID,
  51. FacultymajorNo = fa.Code,
  52. FacultymajorName = fa.Name,
  53. CollegeID = fa.CollegeID,
  54. CollegeNo = col.No,
  55. CollegeName = col.Name,
  56. SchoolyearID = gr.GradeID,
  57. SchoolcodeID = gr.SemesterID,
  58. EnteringSchoolYearID = syenter.SchoolyearID,
  59. EnteringSchoolYearCode = syenter.Code,
  60. GraduatingSemesterID = gr.CF_Schoolyear.SchoolyearID,
  61. GraduatingSemesterCode = gr.CF_Schoolyear.Code,
  62. StandardID = fa.StandardID,
  63. EducationID = fa.EducationID,
  64. LearningformID = fa.LearningformID,
  65. LearnSystem = fa.LearnSystem,
  66. CoursematerialID = gc.CoursematerialID,
  67. CourseCode = cou.CourseCode,
  68. CourseName = cou.CourseName,
  69. CourseTypeID = gc.CourseTypeID,
  70. CourseCredit = gc.CourseCredit,
  71. RecordStatus = gc.RecordStatus,
  72. CreateUserID = gc.CreateUserID,
  73. CreateTime = gc.CreateTime,
  74. ModifyUserID = gc.ModifyUserID,
  75. ModifyTime = gc.ModifyTime
  76. };
  77. return query;
  78. }
  79. /// <summary>
  80. /// 查询对应的专业计划信息View(专业计划左连毕业课程,排除对应的毕业课程专业计划信息)
  81. /// </summary>
  82. /// <param name="expSpecialtyPlan"></param>
  83. /// <param name="expGrademajor"></param>
  84. /// <returns></returns>
  85. public IQueryable<GradSpecialtyPlanView> GetGradSpecialtyPlanQueryable(Expression<Func<EM_SpecialtyPlan, bool>> expSpecialtyPlan,
  86. Expression<Func<CF_Grademajor, bool>> expGrademajor)
  87. {
  88. var query = from sp in SpecialtyPlanRepository.GetList(expSpecialtyPlan)
  89. join gr in GrademajorRepository.GetList(expGrademajor)
  90. on sp.GrademajorID equals gr.GrademajorID
  91. join sy in SchoolyearRepository.Entities
  92. on sp.SchoolyearID equals sy.SchoolyearID
  93. join cou in CoursematerialRepository.Entities
  94. on sp.CoursematerialID equals cou.CoursematerialID
  95. join fa in FacultymajorRepository.Entities
  96. on gr.FacultymajorID equals fa.FacultymajorID
  97. join col in CollegeRepository.Entities
  98. on fa.CollegeID equals col.CollegeID
  99. join gc in GraduationCourseRepository.Entities
  100. on
  101. new { GrademajorID = sp.GrademajorID, CoursematerialID = sp.CoursematerialID, CourseTypeID = sp.CourseTypeID, CourseCredit = sp.EM_SpecialtyPlanTeachingSetting.Credit }
  102. equals
  103. new { GrademajorID = gc.GrademajorID, CoursematerialID = gc.CoursematerialID, CourseTypeID = gc.CourseTypeID, CourseCredit = gc.CourseCredit }
  104. into tempgc
  105. from spgc in tempgc.DefaultIfEmpty()
  106. where spgc.GraduationCourseID == null
  107. select new GradSpecialtyPlanView
  108. {
  109. SpecialtyPlanID = sp.SpecialtyPlanID,
  110. GraduationCourseID = spgc.GraduationCourseID,
  111. GrademajorID = gr.GrademajorID,
  112. GrademajorCode = gr.Code,
  113. GrademajorName = gr.Name,
  114. FacultymajorID = gr.FacultymajorID,
  115. FacultymajorNo = fa.Code,
  116. FacultymajorName = fa.Name,
  117. CollegeID = fa.CollegeID,
  118. CollegeNo = col.No,
  119. CollegeName = col.Name,
  120. GraduatingSemesterID = gr.CF_Schoolyear.SchoolyearID,
  121. GraduatingSemesterCode = gr.CF_Schoolyear.Code,
  122. GradeID = gr.GradeID,
  123. StandardID = fa.StandardID,
  124. EducationID = fa.EducationID,
  125. LearningformID = fa.LearningformID,
  126. LearnSystem = fa.LearnSystem,
  127. CoursematerialID = sp.CoursematerialID,
  128. CourseCode = cou.CourseCode,
  129. CourseName = cou.CourseName,
  130. CourseTypeID = sp.CourseTypeID,
  131. Credit = sp.EM_SpecialtyPlanTeachingSetting.Credit,
  132. TheoryCourse = sp.EM_SpecialtyPlanTeachingSetting.TheoryCourse,
  133. Practicehours = sp.EM_SpecialtyPlanTeachingSetting.Practicehours,
  134. Trialhours = sp.EM_SpecialtyPlanTeachingSetting.Trialhours,
  135. DepartmentID = sp.DepartmentID,
  136. DepartmentNo = sp.CF_Department.No,
  137. DepartmentName = sp.CF_Department.Name,
  138. SchoolyearID = sp.SchoolyearID,
  139. SchoolyearCode = sy.Code,
  140. Value = sy.Value,
  141. SchoolyearNumID = (sp.CF_Schoolyear.Value - ((gr.GradeID * 2 - 1) + gr.SemesterID - 1)) / 2 + 1,
  142. SchoolcodeID = sp.CF_Schoolyear.SchoolcodeID,
  143. StarttermID = sp.CF_Schoolyear.Value - ((gr.GradeID * 2 - 1) + gr.SemesterID - 1) + 1
  144. };
  145. return query;
  146. }
  147. }
  148. }