ImportScoreDAL.cs 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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.ScoreManage;
  7. using System.Linq.Expressions;
  8. using EMIS.Entities;
  9. using EMIS.ViewModel;
  10. namespace EMIS.DataLogic.ScoreManage
  11. {
  12. public class ImportScoreDAL
  13. {
  14. public ImportScoreRepository ImportScoreRepository { get; set; }
  15. public SchoolyearRepository SchoolyearRepository { get; set; }
  16. public CoursematerialRepository CoursematerialRepository { get; set; }
  17. public UserRepository UserRepository { get; set; }
  18. public StudentRepository StudentRepository { get; set; }
  19. public ClassmajorRepository ClassmajorRepository { get; set; }
  20. public GrademajorRepository GrademajorRepository { get; set; }
  21. public FacultymajorRepository FacultymajorRepository { get; set; }
  22. public CollegeRepository CollegeRepository { get; set; }
  23. public FinalExaminationRepository FinalExaminationRepository { get; set; }
  24. public ScoreRepository ScoreRepository { get; set; }
  25. /// <summary>
  26. /// 查询对应的导入成绩(平时成绩)信息View
  27. /// </summary>
  28. /// <param name="expImportScore"></param>
  29. /// <param name="expStudent"></param>
  30. /// <returns></returns>
  31. public IQueryable<ImportScoreView> GetImportScoreViewQueryable(Expression<Func<ER_ImportScore, bool>> expImportScore,
  32. Expression<Func<CF_Student, bool>> expStudent)
  33. {
  34. var query = from sco in ImportScoreRepository.GetList(expImportScore)
  35. join sy in SchoolyearRepository.Entities
  36. on sco.SchoolyearID equals sy.SchoolyearID
  37. join cou in CoursematerialRepository.Entities
  38. on sco.CoursematerialID equals cou.CoursematerialID
  39. join stu in StudentRepository.GetList(expStudent)
  40. on sco.UserID equals stu.UserID
  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 us in UserRepository.Entities
  50. on stu.UserID equals us.UserID
  51. join mus in UserRepository.Entities
  52. on sco.ModifyUserID equals mus.UserID
  53. into tempmus
  54. from scomus in tempmus.DefaultIfEmpty()
  55. select new ImportScoreView
  56. {
  57. ImportScoreID = sco.ImportScoreID,
  58. SchoolyearID = sco.SchoolyearID,
  59. SchoolyearCode = sy.Code,
  60. UserID = sco.UserID,
  61. StudentNo = us.LoginID,
  62. UserName = us.Name,
  63. Sex = stu.SexID,
  64. InSchoolStatusID = stu.InSchoolStatusID,
  65. StudentStatusID = stu.StudentStatus,
  66. ClassID = stu.ClassmajorID,
  67. ClassNo = cl.No,
  68. ClassName = cl.Name,
  69. GrademajorID = cl.GrademajorID,
  70. GrademajorCode = gr.Code,
  71. GrademajorName = gr.Name,
  72. FacultymajorID = gr.FacultymajorID,
  73. FacultymajorNo = fa.Code,
  74. FacultymajorName = fa.Name,
  75. CollegeID = fa.CollegeID,
  76. CollegeNo = col.No,
  77. CollegeName = col.Name,
  78. GradeID = gr.GradeID,
  79. StandardID = fa.StandardID,
  80. EducationID = fa.EducationID,
  81. LearningformID = fa.LearningformID,
  82. LearnSystem = fa.LearnSystem,
  83. CoursematerialID = sco.CoursematerialID,
  84. CourseCode = cou.CourseCode,
  85. CourseName = cou.CourseName,
  86. Score = sco.Score,
  87. Remark = sco.Remark,
  88. CreateUserID = sco.CreateUserID,
  89. CreateTime = sco.CreateTime,
  90. ModifyUserID = sco.ModifyUserID,
  91. ModifyUserNo = scomus.LoginID,
  92. ModifyUserName = scomus.Name,
  93. ModifyTime = sco.ModifyTime
  94. };
  95. return query;
  96. }
  97. /// <summary>
  98. /// 查询对应的导入成绩(平时成绩)信息View(根据期末设定ID)
  99. /// </summary>
  100. /// <param name="finalExaminationID"></param>
  101. /// <returns></returns>
  102. public IQueryable<ImportScoreView> GetImportScoreViewQueryableByFinalExaminationID(Guid finalExaminationID)
  103. {
  104. var scoreQueryable = this.GetImportScoreViewQueryable(x => true, x => true);
  105. var sql = (from exam in FinalExaminationRepository.GetList(x => x.FinalExaminationID == finalExaminationID)
  106. from student in exam.ER_FinalExaminationStudent
  107. join score in scoreQueryable on new { exam.SchoolyearID, exam.CoursematerialID, student.UserID }
  108. equals new { score.SchoolyearID, score.CoursematerialID, score.UserID }
  109. select score);
  110. return sql;
  111. }
  112. }
  113. }