EducationSchedulingStopDAL.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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.EducationSchedule;
  7. using System.Linq.Expressions;
  8. using EMIS.Entities;
  9. namespace EMIS.DataLogic.EducationSchedule
  10. {
  11. public class EducationSchedulingStopDAL
  12. {
  13. public EducationSchedulingStopRepository EducationSchedulingStopRepository { get; set; }
  14. public EducationSchedulingStopTeacherRepository EducationSchedulingStopTeacherRepository { get; set; }
  15. public EducationSchedulingRepository EducationSchedulingRepository { get; set; }
  16. public EducationSchedulingTeacherRepository EducationSchedulingTeacherRepository { get; set; }
  17. public EducationSchedulingWeekNumRepository EducationSchedulingWeekNumRepository { get; set; }
  18. public EducationSchedulingClassRepository EducationSchedulingClassRepository { get; set; }
  19. public EducationSchedulingAdjustmentRepository EducationSchedulingAdjustmentRepository { get; set; }
  20. public EducationSchedulingAdjustmentToTeacherRepository EducationSchedulingAdjustmentToTeacherRepository { get; set; }
  21. public EducationMissionClassRepository EducationMissionClassRepository { get; set; }
  22. public EducationMissionRepository EducationMissionRepository { get; set; }
  23. public CoursematerialRepository CoursematerialRepository { get; set; }
  24. public SchoolyearRepository SchoolyearRepository { get; set; }
  25. public CoursesTimeRepository CoursesTimeRepository { get; set; }
  26. public UserRepository UserRepository { get; set; }
  27. public ClassroomRepository ClassroomRepository { get; set; }
  28. public IQueryable<EducationSchedulingStopView> GetEducationSchedulingStopViewQueryable(
  29. Expression<Func<ES_EducationSchedulingStop, bool>> exp,
  30. Expression<Func<EM_EducationMission, bool>> missionExp,
  31. Expression<Func<EM_EducationMissionClass, bool>> missionClassExp)
  32. {
  33. var sql = (from stop in EducationSchedulingStopRepository.GetList(exp)
  34. join missionClass in EducationMissionClassRepository.Entities.Where(missionClassExp)
  35. on stop.EducationMissionClassID equals missionClass.EducationMissionClassID
  36. join mission in EducationMissionRepository.Entities.Where(missionExp)
  37. on missionClass.EducationMissionID equals mission.EducationMissionID
  38. join schoolyear in SchoolyearRepository.Entities on mission.SchoolyearID equals schoolyear.SchoolyearID
  39. join course in CoursematerialRepository.Entities on missionClass.CoursematerialID equals course.CoursematerialID
  40. join courseTime in CoursesTimeRepository.Entities on stop.CoursesTimeID equals courseTime.CoursesTimeID
  41. join classroom in ClassroomRepository.Entities on stop.ClassroomID equals classroom.ClassroomID
  42. join apply in UserRepository.Entities on stop.ApplyUserID equals apply.UserID into app
  43. from applyUser in app.DefaultIfEmpty()
  44. join cuser in UserRepository.Entities on stop.CreateUserID equals cuser.UserID into cu
  45. from CreateUser in cu.DefaultIfEmpty()
  46. select new EducationSchedulingStopView
  47. {
  48. EducationSchedulingStopID = stop.EducationSchedulingStopID,
  49. SchoolyearID = mission.SchoolyearID,
  50. SchoolyearCode = schoolyear.Code,
  51. CourseCode = course.CourseCode,
  52. CourseName = course.CourseName,
  53. EducationMissionClassID = missionClass.EducationMissionClassID,
  54. EducationMissionClassName = missionClass.Name,
  55. WeekNum = stop.WeekNum,
  56. Weekday = stop.Weekday,
  57. CoursesTimeID = stop.CoursesTimeID,
  58. StartTimes = courseTime.StartTimes,
  59. EndTimes = courseTime.EndTimes,
  60. ClassroomID = stop.ClassroomID,
  61. ClassroomName = classroom.Name,
  62. CreateUserName = CreateUser.Name,
  63. ApplyTime = stop.ApplyTime,
  64. applyUserName = applyUser.Name,
  65. RecordStatus = stop.RecordStatus
  66. });
  67. return sql;
  68. }
  69. public IQueryable<EducationSchedulingStopTeacherView> GetEducationSchedulingStopTeacherViewQueryable(
  70. Expression<Func<ES_EducationSchedulingStop, bool>> exp,
  71. Expression<Func<EM_EducationMission, bool>> missionExp,
  72. Expression<Func<EM_EducationMissionClass, bool>> missionClassExp)
  73. {
  74. var sql = (from stop in EducationSchedulingStopRepository.GetList(exp)
  75. join teacher in EducationSchedulingStopTeacherRepository.Entities
  76. on stop.EducationSchedulingStopID equals teacher.EducationSchedulingStopID
  77. join missionClass in EducationMissionClassRepository.Entities.Where(missionClassExp)
  78. on stop.EducationMissionClassID equals missionClass.EducationMissionClassID
  79. join mission in EducationMissionRepository.Entities.Where(missionExp)
  80. on missionClass.EducationMissionID equals mission.EducationMissionID
  81. join schoolyear in SchoolyearRepository.Entities on mission.SchoolyearID equals schoolyear.SchoolyearID
  82. join course in CoursematerialRepository.Entities on missionClass.CoursematerialID equals course.CoursematerialID
  83. join courseTime in CoursesTimeRepository.Entities on stop.CoursesTimeID equals courseTime.CoursesTimeID
  84. join classroom in ClassroomRepository.Entities on stop.ClassroomID equals classroom.ClassroomID
  85. join user in UserRepository.Entities on teacher.UserID equals user.UserID
  86. select new EducationSchedulingStopTeacherView
  87. {
  88. EducationSchedulingStopID = stop.EducationSchedulingStopID,
  89. UserID = user.UserID,
  90. LoginID = user.LoginID,
  91. Name = user.Name,
  92. TeachingMethod = teacher.TeachingMethod
  93. });
  94. return sql;
  95. }
  96. public IQueryable<EducationSchedulingWeekNumStopView> GetEducationSchedulingWeekNumStopView(
  97. Expression<Func<ES_EducationSchedulingWeekNum, bool>> exp, int stopApproveStatus)
  98. {
  99. var sql = (
  100. from weekNum in EducationSchedulingWeekNumRepository.GetList(exp)
  101. from scheduling in EducationSchedulingRepository.Entities.Where(x => x.EducationSchedulingID == weekNum.EducationSchedulingID)
  102. from scheduleClass in EducationSchedulingClassRepository.Entities.Where(x => scheduling.EducationSchedulingClassID == x.EducationSchedulingClassID)
  103. from missionClass in EducationMissionClassRepository.Entities.Where(x => scheduleClass.EducationMissionClassID == x.EducationMissionClassID)
  104. from stop in
  105. EducationSchedulingStopRepository.Entities.Where(x => x.RecordStatus == stopApproveStatus
  106. && x.EducationMissionClassID == missionClass.EducationMissionClassID && x.CoursesTimeID == scheduling.CoursesTimeID
  107. && x.Weekday == scheduling.Weekday && x.ClassroomID == scheduling.ClassroomID
  108. && x.WeekNum == weekNum.WeekNum
  109. && x.ES_EducationSchedulingStopTeacher.Count() == (
  110. from est in EducationSchedulingTeacherRepository.Entities
  111. .Where(w => w.EducationSchedulingID == scheduling.EducationSchedulingID)
  112. from esst in EducationSchedulingStopTeacherRepository.Entities
  113. .Where(w => w.EducationSchedulingStopID == x.EducationSchedulingStopID
  114. && w.UserID == est.UserID && w.TeachingMethod == est.TeachingMethod)
  115. select esst).Count()).DefaultIfEmpty()
  116. select new EducationSchedulingWeekNumStopView
  117. {
  118. EducationSchedulingWeekNumID = weekNum.EducationSchedulingWeekNumID,
  119. IsStop = (stop.EducationSchedulingStopID != null)
  120. }
  121. );
  122. return sql;
  123. }
  124. public IQueryable<EducationSchedulingAdjustmentStopView> GetEducationSchedulingAdjustmentStopView(
  125. Expression<Func<ES_EducationSchedulingAdjustment, bool>> exp, int stopApproveStatus)
  126. {
  127. var sql = (
  128. from adjust in EducationSchedulingAdjustmentRepository.GetList(exp)
  129. from missionClass in EducationMissionClassRepository.Entities.Where(x => x.EducationMissionClassID == adjust.EducationMissionClassID)
  130. from mission in EducationMissionRepository.Entities.Where(x => x.EducationMissionID == missionClass.EducationMissionID)
  131. from schedulingClass in EducationSchedulingClassRepository.Entities.Where(x => x.EducationMissionClassID == missionClass.EducationMissionClassID)
  132. from teacher in EducationSchedulingAdjustmentToTeacherRepository.Entities.Where(x =>
  133. x.EducationSchedulingAdjustmentID == adjust.EducationSchedulingAdjustmentID)
  134. from user in UserRepository.Entities.Where(x => x.UserID == teacher.UserID)
  135. from scheduling in EducationSchedulingRepository.Entities.Where(x =>
  136. x.EducationSchedulingClassID == schedulingClass.EducationSchedulingClassID
  137. && x.SchoolyearID == mission.SchoolyearID && x.Weekday == adjust.Weekday && x.CoursesTimeID == adjust.CoursesTimeID)
  138. from weekNum in EducationSchedulingWeekNumRepository.Entities.Where(x => x.EducationSchedulingID == scheduling.EducationSchedulingID
  139. && x.WeekNum == adjust.WeekNum)
  140. from stop in
  141. EducationSchedulingStopRepository.Entities.Where(x => x.RecordStatus == stopApproveStatus
  142. && x.EducationMissionClassID == missionClass.EducationMissionClassID && x.CoursesTimeID == scheduling.CoursesTimeID
  143. && x.Weekday == scheduling.Weekday && x.ClassroomID == scheduling.ClassroomID
  144. && x.WeekNum == weekNum.WeekNum
  145. && x.ES_EducationSchedulingStopTeacher.Count() == (
  146. from est in EducationSchedulingTeacherRepository.Entities
  147. .Where(w => w.EducationSchedulingID == scheduling.EducationSchedulingID)
  148. from esst in EducationSchedulingStopTeacherRepository.Entities
  149. .Where(w => w.EducationSchedulingStopID == x.EducationSchedulingStopID
  150. && w.UserID == est.UserID && w.TeachingMethod == est.TeachingMethod)
  151. select esst).Count()).DefaultIfEmpty()
  152. select new EducationSchedulingAdjustmentStopView
  153. {
  154. EducationSchedulingAdjustmentID = adjust.EducationSchedulingAdjustmentID,
  155. IsStop = (stop.EducationSchedulingStopID != null)
  156. }
  157. );
  158. return sql;
  159. }
  160. }
  161. }