LevelScoreDAL.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Linq.Expressions;
  5. using System.Text;
  6. using EMIS.Entities;
  7. using EMIS.ViewModel.ScoreManage.LevelScoreManage;
  8. using EMIS.DataLogic.Repositories;
  9. namespace EMIS.DataLogic.ScoreManage.LevelScoreManage
  10. {
  11. public class LevelScoreDAL
  12. {
  13. public LevelScoreRepository LevelScoreRepository { get; set; }
  14. public ExaminationSubjectRepository ExaminationSubjectRepository { get; set; }
  15. public LevelSettingRepository LevelSettingRepository { get; set; }
  16. public SchoolyearRepository SchoolyearRepository { get; set; }
  17. public StudentRepository StudentRepository { get; set; }
  18. public ClassmajorRepository ClassmajorRepository { get; set; }
  19. public GrademajorRepository GrademajorRepository { get; set; }
  20. public FacultymajorRepository FacultymajorRepository { get; set; }
  21. public CollegeRepository CollegeRepository { get; set; }
  22. public CampusRepository CampusRepository { get; set; }
  23. public UserRepository UserRepository { get; set; }
  24. /// <summary>
  25. /// 查询对应的等级成绩信息LevelScoreView
  26. /// </summary>
  27. /// <param name="expLevelScore"></param>
  28. /// <returns></returns>
  29. public IQueryable<LevelScoreView> GetLevelScoreViewQueryable(Expression<Func<ER_LevelScore, bool>> expLevelScore)
  30. {
  31. var query = from lvsco in LevelScoreRepository.GetList(expLevelScore)
  32. join stu in StudentRepository.Entities
  33. on lvsco.UserID equals stu.UserID
  34. join exsub in ExaminationSubjectRepository.Entities
  35. on lvsco.ExaminationSubjectID equals exsub.ExaminationSubjectID
  36. join sy in SchoolyearRepository.Entities
  37. on lvsco.SchoolyearID equals sy.SchoolyearID
  38. join lvst in LevelSettingRepository.Entities
  39. on exsub.ExaminationSubjectID equals lvst.ExaminationSubjectID into templvst
  40. from exsubst in templvst.DefaultIfEmpty()
  41. join cl in ClassmajorRepository.Entities
  42. on stu.ClassmajorID equals cl.ClassmajorID
  43. join gr in GrademajorRepository.Entities
  44. on cl.GrademajorID equals gr.GrademajorID
  45. join fa in FacultymajorRepository.Entities
  46. on gr.FacultymajorID equals fa.FacultymajorID
  47. join col in CollegeRepository.Entities
  48. on fa.CollegeID equals col.CollegeID
  49. join cam in CampusRepository.Entities
  50. on col.CampusID equals cam.CampusID
  51. join us in UserRepository.Entities
  52. on stu.UserID equals us.UserID
  53. join usc in UserRepository.Entities
  54. on lvsco.CreateUserID equals usc.UserID into tempusc
  55. from uscu in tempusc.DefaultIfEmpty()
  56. join usm in UserRepository.Entities
  57. on lvsco.ModifyUserID equals usm.UserID into tempusm
  58. from usmu in tempusm.DefaultIfEmpty()
  59. where exsubst.LevelSettingID == null || (exsubst.LevelSettingID != null
  60. && ((exsubst.MinScore < lvsco.TotalScore && exsubst.MinScoreOperator == "<" && lvsco.TotalScore < exsubst.MaxScore && exsubst.MaxScoreOperator == "<")
  61. || (exsubst.MinScore < lvsco.TotalScore && exsubst.MinScoreOperator == "<" && lvsco.TotalScore <= exsubst.MaxScore && exsubst.MaxScoreOperator == "<=")
  62. || (exsubst.MinScore <= lvsco.TotalScore && exsubst.MinScoreOperator == "<=" && lvsco.TotalScore < exsubst.MaxScore && exsubst.MaxScoreOperator == "<")
  63. || (exsubst.MinScore <= lvsco.TotalScore && exsubst.MinScoreOperator == "<=" && exsubst.MaxScoreOperator == "<=" && lvsco.TotalScore <= exsubst.MaxScore)))
  64. select new LevelScoreView
  65. {
  66. LevelScoreID = lvsco.LevelScoreID,
  67. UserID = lvsco.UserID,
  68. StudentNo = us.LoginID,
  69. Name = us.Name,
  70. SexID = stu.SexID,
  71. BirthDate = stu.BirthDate,
  72. NationID = stu.NationID,
  73. PoliticsID = stu.PoliticsID,
  74. InSchoolStatusID = stu.InSchoolStatusID,
  75. StudentStatus = stu.StudentStatus,
  76. GradeID = gr.GradeID,
  77. StandardID = fa.StandardID,
  78. EducationID = fa.EducationID,
  79. LearningformID = fa.LearningformID,
  80. LearnSystem = fa.LearnSystem,
  81. ClassNum = cl.ClassNum,
  82. ClassmajorID = stu.ClassmajorID,
  83. ClassmajorNo = cl.No,
  84. ClassmajorName = cl.Name,
  85. GrademajorID = cl.GrademajorID,
  86. GrademajorCode = gr.Code,
  87. GrademajorName = gr.Name,
  88. FacultymajorID = gr.FacultymajorID,
  89. FacultymajorCode = fa.Code,
  90. FacultymajorName = fa.Name,
  91. CollegeID = fa.CollegeID,
  92. CollegeNo = col.No,
  93. CollegeName = col.Name,
  94. CampusID = col.CampusID,
  95. CampusCode = cam.No,
  96. CampusName = cam.Name,
  97. ExaminationSubjectID = lvsco.ExaminationSubjectID,
  98. ExaminationSubjectName = exsub.Name,
  99. SchoolyearID = lvsco.SchoolyearID,
  100. SchoolyearValue = sy.Value,
  101. SchoolyearCode = sy.Code,
  102. ExaminationDate = lvsco.ExaminationDate,
  103. ScoreNo = lvsco.ScoreNo,
  104. TotalScore = lvsco.TotalScore,
  105. LevelSettingID = exsubst.LevelSettingID,
  106. LevelName = exsubst.LevelName,
  107. Remark = lvsco.Remark,
  108. ApprovalStatus = lvsco.ApprovalStatus,
  109. RecordStatus = lvsco.RecordStatus,
  110. CreateUserID = lvsco.CreateUserID,
  111. CreateUserName = uscu.Name,
  112. CreateTime = lvsco.CreateTime,
  113. ModifyUserID = lvsco.ModifyUserID,
  114. ModifyUserName = usmu.Name,
  115. ModifyTime = lvsco.ModifyTime
  116. };
  117. return query;
  118. }
  119. /// <summary>
  120. /// 查询对应的等级成绩信息LevelScoreView
  121. /// </summary>
  122. /// <param name="expLevelScore"></param>
  123. /// <param name="expStudent"></param>
  124. /// <returns></returns>
  125. public IQueryable<LevelScoreView> GetLevelScoreViewQueryable(Expression<Func<ER_LevelScore, bool>> expLevelScore, Expression<Func<CF_Student, bool>> expStudent)
  126. {
  127. var query = from lvsco in LevelScoreRepository.GetList(expLevelScore)
  128. join stu in StudentRepository.GetList(expStudent)
  129. on lvsco.UserID equals stu.UserID
  130. join exsub in ExaminationSubjectRepository.Entities
  131. on lvsco.ExaminationSubjectID equals exsub.ExaminationSubjectID
  132. join sy in SchoolyearRepository.Entities
  133. on lvsco.SchoolyearID equals sy.SchoolyearID
  134. join lvst in LevelSettingRepository.Entities
  135. on lvsco.ExaminationSubjectID equals lvst.ExaminationSubjectID into templvst
  136. from lvscost in templvst.DefaultIfEmpty()
  137. join cl in ClassmajorRepository.Entities
  138. on stu.ClassmajorID equals cl.ClassmajorID
  139. join gr in GrademajorRepository.Entities
  140. on cl.GrademajorID equals gr.GrademajorID
  141. join fa in FacultymajorRepository.Entities
  142. on gr.FacultymajorID equals fa.FacultymajorID
  143. join col in CollegeRepository.Entities
  144. on fa.CollegeID equals col.CollegeID
  145. join cam in CampusRepository.Entities
  146. on col.CampusID equals cam.CampusID
  147. join us in UserRepository.Entities
  148. on stu.UserID equals us.UserID
  149. join usc in UserRepository.Entities
  150. on lvsco.CreateUserID equals usc.UserID into tempusc
  151. from uscu in tempusc.DefaultIfEmpty()
  152. join usm in UserRepository.Entities
  153. on lvsco.ModifyUserID equals usm.UserID into tempusm
  154. from usmu in tempusm.DefaultIfEmpty()
  155. where lvscost.LevelSettingID == null || (lvscost.LevelSettingID != null
  156. && ((lvscost.MinScore < lvsco.TotalScore && lvscost.MinScoreOperator == "<" && lvsco.TotalScore < lvscost.MaxScore && lvscost.MaxScoreOperator == "<")
  157. || (lvscost.MinScore < lvsco.TotalScore && lvscost.MinScoreOperator == "<" && lvsco.TotalScore <= lvscost.MaxScore && lvscost.MaxScoreOperator == "<=")
  158. || (lvscost.MinScore <= lvsco.TotalScore && lvscost.MinScoreOperator == "<=" && lvsco.TotalScore < lvscost.MaxScore && lvscost.MaxScoreOperator == "<")
  159. || (lvscost.MinScore <= lvsco.TotalScore && lvscost.MinScoreOperator == "<=" && lvsco.TotalScore <= lvscost.MaxScore && lvscost.MaxScoreOperator == "<=")))
  160. select new LevelScoreView
  161. {
  162. LevelScoreID = lvsco.LevelScoreID,
  163. UserID = lvsco.UserID,
  164. StudentNo = us.LoginID,
  165. Name = us.Name,
  166. SexID = stu.SexID,
  167. BirthDate = stu.BirthDate,
  168. NationID = stu.NationID,
  169. PoliticsID = stu.PoliticsID,
  170. InSchoolStatusID = stu.InSchoolStatusID,
  171. StudentStatus = stu.StudentStatus,
  172. GradeID = gr.GradeID,
  173. StandardID = fa.StandardID,
  174. EducationID = fa.EducationID,
  175. LearningformID = fa.LearningformID,
  176. LearnSystem = fa.LearnSystem,
  177. ClassNum = cl.ClassNum,
  178. ClassmajorID = stu.ClassmajorID,
  179. ClassmajorNo = cl.No,
  180. ClassmajorName = cl.Name,
  181. GrademajorID = cl.GrademajorID,
  182. GrademajorCode = gr.Code,
  183. GrademajorName = gr.Name,
  184. FacultymajorID = gr.FacultymajorID,
  185. FacultymajorCode = fa.Code,
  186. FacultymajorName = fa.Name,
  187. CollegeID = fa.CollegeID,
  188. CollegeNo = col.No,
  189. CollegeName = col.Name,
  190. CampusID = col.CampusID,
  191. CampusCode = cam.No,
  192. CampusName = cam.Name,
  193. ExaminationSubjectID = lvsco.ExaminationSubjectID,
  194. ExaminationSubjectName = exsub.Name,
  195. SchoolyearID = lvsco.SchoolyearID,
  196. SchoolyearValue = sy.Value,
  197. SchoolyearCode = sy.Code,
  198. ExaminationDate = lvsco.ExaminationDate,
  199. ScoreNo = lvsco.ScoreNo,
  200. TotalScore = lvsco.TotalScore,
  201. LevelSettingID = lvscost.LevelSettingID,
  202. LevelName = lvscost.LevelName,
  203. Remark = lvsco.Remark,
  204. ApprovalStatus = lvsco.ApprovalStatus,
  205. RecordStatus = lvsco.RecordStatus,
  206. CreateUserID = lvsco.CreateUserID,
  207. CreateUserName = uscu.Name,
  208. CreateTime = lvsco.CreateTime,
  209. ModifyUserID = lvsco.ModifyUserID,
  210. ModifyUserName = usmu.Name,
  211. ModifyTime = lvsco.ModifyTime
  212. };
  213. return query;
  214. }
  215. }
  216. }