ElectiveCourseEnterDAL.cs 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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.SelectCourse;
  7. using System.Linq.Expressions;
  8. using EMIS.Entities;
  9. using EMIS.ViewModel;
  10. using EMIS.ViewModel.CultureplanManage.PlanManagement;
  11. namespace EMIS.DataLogic.ElectiveEnter
  12. {
  13. public class ElectiveCourseEnterDAL
  14. {
  15. public SelectCourseOpenControlSettingRepository SelectCourseOpenControlSettingRepository { get; set; }
  16. public ExecutableOptionalCourseRepository executableOptionalCourseRepository { get; set; }
  17. public SchoolyearRepository schoolyearRepository { get; set; }
  18. public GrademajorRepository grademajorRepository { get; set; }
  19. public DictionaryItemRepository DictionaryItemRepository { get; set; }
  20. public OptionalCoursePlanRepository OptionalCoursePlanRepository { get; set; }
  21. public SpecialtyCourseRepository specialtyCourseRepository { get; set; }
  22. public CoursematerialRepository coursematerialRepository { get; set; }
  23. public DepartmentRepository departmentRepository { get; set; }
  24. public ClassmajorRepository classmajorRepository { get; set; }
  25. public ExecutableOptionalCourseTeachingSettingRepository executableOptionalCourseTeachingSettingRepository { get; set; }
  26. public ExecutableOptionalCourseTeacherRepository executableOptionalCourseTeacherRepository { get; set; }
  27. public ExecutableOptionalCourseTeachingModeRepository executableOptionalCourseTeachingModeRepository { get; set; }
  28. public IQueryable<OptionalCourseSettingView> GetOpenControlSettingView(
  29. Expression<Func<EM_ExecutableOptionalCourse, bool>> openCourseSettingExp,
  30. Expression<Func<EM_OptionalCoursePlan, bool>> exp,
  31. Expression<Func<EMIS.Entities.CF_Schoolyear, bool>> schoolYearExp,
  32. Expression<Func<CF_Grademajor, bool>> gradeMajorExp)
  33. {
  34. var q = from ocps in executableOptionalCourseRepository.GetList(openCourseSettingExp)
  35. join ocp in OptionalCoursePlanRepository.Entities on ocps.OptionalCourseID equals ocp.OptionalCourseID
  36. into tmp1
  37. from ocpss in tmp1.DefaultIfEmpty()
  38. join gr in grademajorRepository.Entities on ocps.GrademajorID equals gr.GrademajorID
  39. from cl in ocps.CF_Classmajor.DefaultIfEmpty()
  40. //join cl in classmajorRepository.Entities on gr.GrademajorID equals cl.GrademajorID
  41. join sc in schoolyearRepository.Entities on new { Years = gr.GradeID.Value, SchoolcodeID = gr.SemesterID.Value } equals new { Years = sc.Years, SchoolcodeID = sc.SchoolcodeID }
  42. join sc1 in schoolyearRepository.Entities on ocps.SchoolyearID equals sc1.SchoolyearID
  43. //from gr in gsPlan.DefaultIfEmpty()
  44. //join sp in specialtyRepository.Entities on ocp.SpecialtyID equals sp.SpecialtyID
  45. //join dr in dictionaryItemRepository.GetList(x => x.DictionaryCode == DictionaryItem.CF_Standard.ToString())
  46. // on sp.StandardID equals dr.Value
  47. // into gs
  48. //from sr in gs.DefaultIfEmpty()
  49. join co in coursematerialRepository.Entities on ocpss.CoursematerialID equals co.CoursematerialID
  50. join sc2 in specialtyCourseRepository.Entities on new { ocpss.CoursematerialID, ocpss.SpecialtyID } equals new { sc2.CoursematerialID, sc2.SpecialtyID }
  51. into tmp
  52. from gs in tmp.DefaultIfEmpty()
  53. join de in departmentRepository.Entities on ocps.DepartmentID equals de.DepartmentID
  54. select new OptionalCourseSettingView
  55. {
  56. ExecutableOptionalCourseID = ocps.ExecutableOptionalCourseID,
  57. OptionalCourseID = ocpss.OptionalCourseID,
  58. SchoolyearID = sc.SchoolyearID,
  59. DefaultClassName = ocps.DefaultClassName,
  60. ClassmajorID = cl.ClassmajorID,
  61. //StandardID=sp.StandardID,
  62. SchoolYearCode = sc1.Code,
  63. GSchoolYearCode = sc.Code,
  64. GrademajorID = gr.GrademajorID,
  65. GrademajorCode = gr.Code,
  66. GrademajorName = gr.Name,
  67. CampusID = gr.CF_Facultymajor.CF_College.CampusID,
  68. CollegeID = gr.CF_Facultymajor.CollegeID,
  69. CollegeName = gr.CF_Facultymajor.CF_College.Name,
  70. DepartmentID = ocps.DepartmentID,
  71. DepartmentName = de.Name,
  72. //SpecialtyCourseID = sc.SpecialtyCourseID,
  73. SpecialtyID = ocpss.SpecialtyID,
  74. StandardID = ocpss.CF_Specialty.StandardID,
  75. CoursematerialID = ocpss.CoursematerialID,
  76. CourseCode = co.CourseCode,
  77. CourseName = co.CourseName,
  78. //Credit = sc.EM_SpecialtyCourseTeachingSetting.Credit,
  79. //EndWeeklyNum = ocp.EM_SpecialtyCourse.EM_SpecialtyCourseTeachingSetting.EndWeeklyNum,
  80. ExaminationModeID = ocps.ExaminationModeID,
  81. TeachinglanguageID = ocps.TeachinglanguageID,
  82. //HandleModeID = ocp.HandleModeID,
  83. //No = ocp.No,
  84. //DefaultClassName = ocp.DefaultClassName,
  85. //SchoolyearID = ocp.SchoolyearID,
  86. //SchoolyearDesc = ocp.CF_Schoolyear.Code,
  87. //IsNeedMaterial = ocp.IsNeedMaterial ?? false,
  88. PeopleNumlower = ocps.PeopleNumlower,
  89. PeopleNumlimit = ocps.PeopleNumlimit,
  90. IsEnable = ocps.IsEnable ?? false,
  91. IsOpened = ocps.IsOpened ?? false,
  92. Remarks = ocps.Remarks,
  93. RecordStatus = ocps.RecordStatus,
  94. CreateUserID = ocps.CreateUserID,
  95. CreateTime = ocps.CreateTime,
  96. ModifyUserID = ocps.ModifyUserID,
  97. ModifyTime = ocps.ModifyTime,
  98. //Schoolyear = gs.SchoolyearID,
  99. //Sys_User = ocp.EM_OptionalCoursePlanStaff.Select(x => x.CF_Staff.Sys_User),
  100. CourseStructureID = ocps.CourseStructureID,
  101. CourseTypeID = ocps.CourseTypeID,
  102. Credit = gs.EM_SpecialtyCourseTeachingSetting.Credit,
  103. TheoryCourse = gs.EM_SpecialtyCourseTeachingSetting.TheoryCourse,
  104. Practicehours = gs.EM_SpecialtyCourseTeachingSetting.Practicehours,
  105. Trialhours = gs.EM_SpecialtyCourseTeachingSetting.Trialhours,
  106. SchoolyearNumID = ocpss.SchoolyearNumID,
  107. SchoolcodeID = ocpss.SchoolcodeID,
  108. //StarttermID = ((ocp.EM_SpecialtyCourse.SchoolyearNumID - 1) * 2) + (ocp.EM_SpecialtyCourse.SchoolcodeID == ocp.CF_Grademajor.SchoolcodeID ? 0 : 1) + 1,
  109. CourseCategoryID = ocps.CourseCategoryID,
  110. //IsMainCourse = ocp.EM_SpecialtyCourse.IsMainCourse ?? false,
  111. CourseQualityID = ocps.CourseQualityID,
  112. PracticeTypeID = ocps.PracticeTypeID
  113. };
  114. //var q = (from scocs in SelectCourseOpenControlSettingRepository.GetList(openControlSettingExp)
  115. // join sy in SchoolyearRepository.GetList(schoolYearExp) on scocs.SchoolyearID equals sy.SchoolyearID
  116. // join gm in GrademajorRepository.GetList(gradeMajorExp) on scocs.GrademajorID equals gm.GrademajorID
  117. // join dis in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(CF_Standard).Name) on gm.CF_Facultymajor.StandardID equals dis.Value into ddis
  118. // from edis in ddis.DefaultIfEmpty()
  119. // join disy in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(EMIS.ViewModel.CF_Schoolyear).Name) on gm.SchoolyearID equals disy.Value into ddisy
  120. // from edisy in ddisy.DefaultIfEmpty()
  121. // select new SelectCourseOpenControlSettingView
  122. // {
  123. // SelectCourseOpenControlSettingID = scocs.SelectCourseOpenControlSettingID,
  124. // SchoolyearID = scocs.SchoolyearID,
  125. // SchoolyearCode = sy.Code,
  126. // GrademajorID = scocs.GrademajorID,
  127. // GrademajorName = gm.Name,
  128. // YearID = gm.SchoolyearID,
  129. // YearName = edisy.Name,
  130. // StandardID = gm.CF_Facultymajor.StandardID,
  131. // StandardDesc = edis.Name,
  132. // CollegeID = gm.CF_Facultymajor.CollegeID,
  133. // CollegeName = gm.CF_Facultymajor.CF_College.Name,
  134. // StartTime = scocs.StartTime,
  135. // EndTime = scocs.EndTime,
  136. // MaxSelectCount = scocs.MaxSelectCount,
  137. // MinSelectCount = scocs.MinSelectCount,
  138. // MaxCredit = scocs.MaxCredit,
  139. // MinCredit = scocs.MinCredit,
  140. // Remark = scocs.Remark,
  141. // RecordStatus = scocs.RecordStatus,
  142. // CreateUserID = scocs.CreateUserID,
  143. // CreateTime = scocs.CreateTime,
  144. // ModifyUserID = scocs.ModifyUserID,
  145. // ModifyTime = scocs.ModifyTime
  146. // });
  147. return q;
  148. }
  149. }
  150. }