ExaminationExemptionDAL.cs 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Linq.Expressions;
  6. using EMIS.DataLogic.Repositories;
  7. using EMIS.ViewModel.ScoreManage;
  8. using EMIS.Entities;
  9. using EMIS.ViewModel;
  10. namespace EMIS.DataLogic.ScoreManage
  11. {
  12. public class ExaminationExemptionDAL
  13. {
  14. public SchoolyearRepository SchoolyearRepository { get; set; }
  15. public StudentRepository StudentRepository { get; set; }
  16. public CoursematerialRepository CoursematerialRepository { get; set; }
  17. public GrademajorRepository GrademajorRepository { get; set; }
  18. public FinalExaminationRepository FinalExaminationRepository { get; set; }
  19. public FinalExaminationStudentRepository FinalExaminationStudentRepository { get; set; }
  20. public ExecutablePlanRepository ExecutablePlanRepository { get; set; }
  21. public ExaminationExemptionRepository ExaminationExemptionRepository { get; set; }
  22. public EducationMissionRepository EducationMissionRepository { get; set; }
  23. public EducationMissionClassRepository EducationMissionClassRepository { get; set; }
  24. public IQueryable<ExaminationExemptionView> GetExaminationExemptionViewQueryable(Expression<Func<ER_ExaminationExemption, bool>> exp)
  25. {
  26. var query = (from ms in ExaminationExemptionRepository.GetList(exp)
  27. select new ExaminationExemptionView
  28. {
  29. ExaminationExemptionID = ms.ExaminationExemptionID,
  30. UserID = ms.UserID,
  31. LoginID = ms.CF_Student.Sys_User.LoginID,
  32. Name = ms.CF_Student.Sys_User.Name,
  33. ClassmajorName = ms.CF_Student.CF_Classmajor.Name,
  34. CollegeID = ms.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID,
  35. Year = ms.CF_Student.CF_Classmajor.CF_Grademajor.GradeID,
  36. StandardID = ms.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.StandardID,
  37. SchoolyearID = ms.SchoolyearID,
  38. SchoolyearCode = ms.CF_Schoolyear.Code,
  39. CoursematerialID = ms.CoursematerialID,
  40. CourseCode = ms.EM_Coursematerial.CourseCode,
  41. CourseName = ms.EM_Coursematerial.CourseName,
  42. ExamsCategoryID = ms.ExamsCategoryID,
  43. Reason = ms.Reason,
  44. RecordStatus = ms.RecordStatus,
  45. CreateTime = ms.CreateTime
  46. });
  47. return query;
  48. }
  49. public IQueryable<ExaminationExemptionCoursematerialView> GetExaminationExemptionCoursematerialViewQueryable(
  50. Expression<Func<EMIS.Entities.CF_Schoolyear, bool>> schoolyearExp, Expression<Func<CF_Student, bool>> studentExp)
  51. {
  52. var query = (
  53. from emc in EducationMissionClassRepository.Entities
  54. join em in EducationMissionRepository.Entities on emc.EducationMissionID equals em.EducationMissionID
  55. join sy in SchoolyearRepository.GetList(schoolyearExp)
  56. on em.SchoolyearID equals sy.SchoolyearID
  57. join cm in CoursematerialRepository.Entities on emc.CoursematerialID equals cm.CoursematerialID
  58. from esc in emc.EM_EducationSchedulingClass
  59. from esccs in esc.CF_Student
  60. join s in StudentRepository.GetList(studentExp) on esccs.UserID equals s.UserID
  61. group emc by new ExaminationExemptionCoursematerialView
  62. {
  63. CoursematerialID = cm.CoursematerialID,
  64. CourseCode = cm.CourseCode,
  65. CourseName = cm.CourseName
  66. } into g
  67. select g.Key
  68. )
  69. .Union(
  70. from exp in ExecutablePlanRepository.Entities
  71. join cm in CoursematerialRepository.Entities on exp.CoursematerialID equals cm.CoursematerialID
  72. join sy in SchoolyearRepository.GetList(schoolyearExp) on exp.SchoolyearID equals sy.SchoolyearID
  73. join gread in GrademajorRepository.Entities on exp.GrademajorID equals gread.GrademajorID
  74. join gs in
  75. (
  76. from g in GrademajorRepository.Entities
  77. from c in g.CF_Classmajor
  78. from s in c.CF_Student
  79. join user in StudentRepository.GetList(studentExp) on s.UserID equals user.UserID
  80. group s by g.GrademajorID into g
  81. select new
  82. {
  83. GrademajorID = g.Key,
  84. StudentCount = g.Count()
  85. }
  86. ) on exp.GrademajorID equals gs.GrademajorID
  87. group exp by new ExaminationExemptionCoursematerialView
  88. {
  89. CoursematerialID=cm.CoursematerialID,
  90. CourseCode=cm.CourseCode,
  91. CourseName=cm.CourseName
  92. }into g
  93. select g.Key
  94. )
  95. .Union(
  96. from fe in FinalExaminationRepository.Entities
  97. join cm in CoursematerialRepository.Entities on fe.CoursematerialID equals cm.CoursematerialID
  98. join sy in SchoolyearRepository.GetList(schoolyearExp) on fe.SchoolyearID equals sy.SchoolyearID
  99. from fes in fe.ER_FinalExaminationStudent
  100. join s in StudentRepository.GetList(studentExp) on fes.UserID equals s.UserID
  101. group fe by new ExaminationExemptionCoursematerialView
  102. {
  103. CoursematerialID = cm.CoursematerialID,
  104. CourseCode = cm.CourseCode,
  105. CourseName = cm.CourseName
  106. } into g
  107. select g.Key
  108. );
  109. return query;
  110. }
  111. }
  112. }