OptionalCoursePlanDAL.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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.SystemView;
  11. using EMIS.ViewModel.Students;
  12. using EMIS.ViewModel.UniversityManage.TeacherManage;
  13. using Bowin.Common.Linq.Entity;
  14. using EMIS.ViewModel.CultureplanManage.PlanManagement;
  15. using EMIS.DataLogic.UniversityManage.SpecialtyClassManage;
  16. namespace EMIS.DataLogic.CultureplanManage.PlanManagement
  17. {
  18. public class OptionalCoursePlanDAL
  19. {
  20. public SchoolyearRepository schoolyearRepository { get; set; }
  21. public OptionalCoursePlanRepository OptionalCoursePlanRepository { get; set; }
  22. public OptionalCoursePlanTeachingModeRepository OptionalCoursePlanTeachingModeRepository { get; set; }
  23. public OptionalCoursePlanTeachingSettingRepository OptionalCoursePlanTeachingSettingRepository { get; set; }
  24. public StaffRepository StaffRepository { get; set; }
  25. public DictionaryItemRepository DictionaryItemRepository { get; set; }
  26. public SpecialtyCourseDAL specialtyCourseDAL { get; set; }
  27. public SpecialtyCourseRepository specialtyCourseRepository { get; set; }
  28. public GrademajorDAL grademajorDAL { get; set; }
  29. public GrademajorRepository grademajorRepository { get; set; }
  30. public SpecialtyRepository specialtyRepository { get; set; }
  31. public DictionaryItemRepository dictionaryItemRepository { get; set; }
  32. public CoursematerialRepository coursematerialRepository { get; set; }
  33. public FacultymajorRepository facultymajorRepository { get; set; }
  34. public ClassmajorRepository classmajorRepository { get; set; }
  35. public DepartmentRepository departmentRepository { get; set; }
  36. public IQueryable<OptionalCoursePlanView> GetOptionalCourseSettingViewQueryable(Expression<Func<EM_OptionalCoursePlan, bool>> exp)
  37. {
  38. var q = from ocp in OptionalCoursePlanRepository.GetList(exp)
  39. join de in departmentRepository.Entities on ocp.DepartmentID equals de.DepartmentID
  40. into tmp1 from de in tmp1.DefaultIfEmpty()
  41. //join g in grademajorRepository.Entities
  42. //on new { SchoolcodeID = ocp.SchoolcodeID, Years = ocp.SchoolyearNumID,ocp.CF_Specialty.StandardID } equals new { SchoolcodeID = g.SchoolcodeID, Years = g.SchoolyearID,g.CF_Facultymajor.StandardID }
  43. //into gsPlan
  44. //from gr in gsPlan.DefaultIfEmpty()
  45. join sp in specialtyRepository.Entities on ocp.SpecialtyID equals sp.SpecialtyID
  46. join dr in dictionaryItemRepository.GetList(x => x.DictionaryCode == DictionaryItem.CF_Standard.ToString())
  47. on sp.StandardID equals dr.Value
  48. into gs
  49. from sr in gs.DefaultIfEmpty()
  50. join co in coursematerialRepository.Entities on ocp.CoursematerialID equals co.CoursematerialID
  51. into tmp from co in tmp.DefaultIfEmpty()
  52. //join sc in specialtyCourseRepository.Entities on new { ocp.CoursematerialID, ocp.SpecialtyID } equals new { sc.CoursematerialID, sc.SpecialtyID }
  53. //into tmp
  54. //from gs in tmp.DefaultIfEmpty()
  55. select new OptionalCoursePlanView
  56. {
  57. TeachingModeID=ocp.EM_OptionalCoursePlanTeachingMode.Select(x=>x.TeachingModeID.Value).ToList(),
  58. OptionalCourseID = ocp.OptionalCourseID,
  59. //StandardID=sp.StandardID,
  60. //GrademajorID = gr.GrademajorID,
  61. //GrademajorCode = gr.Code,
  62. //GrademajorName = gr.Name,
  63. //CampusID = gr.CF_Facultymajor.CF_College.CampusID,
  64. //CollegeID = gr.CF_Facultymajor.CollegeID,
  65. //CollegeName = gr.CF_Facultymajor.CF_College.Name,
  66. DepartmentID = de.DepartmentID,
  67. DepartmentName = de.Name,
  68. //SpecialtyCourseID = sc.SpecialtyCourseID,
  69. SpecialtyID = ocp.SpecialtyID,
  70. //StandardID = ocp.CF_Specialty.StandardID,
  71. StandardID=sr.Value,
  72. StandardCode=sr.Code,
  73. StandardName=sr.Name,
  74. LearnSystem = sp.LearnSystem,
  75. EducationID =sp.EducationID,
  76. LearningformID = sp.LearningformID,
  77. CoursematerialID = ocp.CoursematerialID,
  78. CourseCode = co.CourseCode,
  79. CourseName = co.CourseName,
  80. //Credit = sc.EM_SpecialtyCourseTeachingSetting.Credit,
  81. //EndWeeklyNum = ocp.EM_SpecialtyCourse.EM_SpecialtyCourseTeachingSetting.EndWeeklyNum,
  82. ExaminationModeID = ocp.ExaminationModeID,
  83. TeachinglanguageID = ocp.TeachinglanguageID,
  84. //HandleModeID = ocp.HandleModeID,
  85. //No = ocp.No,
  86. //DefaultClassName = ocp.DefaultClassName,
  87. //SchoolyearID = ocp.SchoolyearID,
  88. //SchoolyearDesc = ocp.CF_Schoolyear.Code,
  89. //IsNeedMaterial = ocp.IsNeedMaterial ?? false,
  90. PeopleNumlower = ocp.PeopleNumlower,
  91. PeopleNumlimit = ocp.PeopleNumlimit,
  92. IsEnable = ocp.IsEnable ?? true,
  93. IsOpened = ocp.IsOpened ?? true,
  94. Remarks = ocp.Remarks,
  95. RecordStatus = ocp.RecordStatus,
  96. CreateUserID = ocp.CreateUserID,
  97. CreateTime = ocp.CreateTime,
  98. ModifyUserID = ocp.ModifyUserID,
  99. ModifyTime = ocp.ModifyTime,
  100. //Schoolyear = gs.SchoolyearID,
  101. //Sys_User = ocp.EM_OptionalCoursePlanStaff.Select(x => x.CF_Staff.Sys_User),
  102. CourseStructureID = ocp.CourseStructureID,
  103. CourseTypeID = ocp.CourseTypeID,
  104. Credit = ocp.EM_OptionalCoursePlanTeachingSetting.Credit ?? 0,
  105. TheoryCourse = ocp.EM_OptionalCoursePlanTeachingSetting.TheoryCourse ?? 0,
  106. Practicehours = ocp.EM_OptionalCoursePlanTeachingSetting.Practicehours ?? 0,
  107. Trialhours = ocp.EM_OptionalCoursePlanTeachingSetting.Trialhours ?? 0,
  108. WeeklyNum = ocp.EM_OptionalCoursePlanTeachingSetting.WeeklyNum ?? 0,
  109. TheoryWeeklyNum = ocp.EM_OptionalCoursePlanTeachingSetting.TheoryWeeklyNum ?? 0,
  110. PracticeWeeklyNum = ocp.EM_OptionalCoursePlanTeachingSetting.PracticeWeeklyNum ?? 0,
  111. TrialWeeklyNum = ocp.EM_OptionalCoursePlanTeachingSetting.TrialWeeklyNum ?? 0,
  112. StartWeeklyNum = ocp.EM_OptionalCoursePlanTeachingSetting.StartWeeklyNum ?? 0,
  113. EndWeeklyNum = ocp.EM_OptionalCoursePlanTeachingSetting.EndWeeklyNum ?? 0,
  114. WeeklyHours = ocp.EM_OptionalCoursePlanTeachingSetting.WeeklyHours ?? 0,
  115. SchoolyearNumID = ocp.SchoolyearNumID,
  116. SchoolcodeID = ocp.SchoolcodeID,
  117. //StarttermID = ((ocp.EM_SpecialtyCourse.SchoolyearNumID - 1) * 2) + (ocp.EM_SpecialtyCourse.SchoolcodeID == ocp.CF_Grademajor.SchoolcodeID ? 0 : 1) + 1,
  118. CourseCategoryID = ocp.CourseCategoryID,
  119. //IsMainCourse = ocp.EM_SpecialtyCourse.IsMainCourse ?? false,
  120. CourseQualityID = ocp.CourseQualityID,
  121. PracticeTypeID=ocp.PracticeTypeID,
  122. ResultTypeID=ocp.ResultTypeID
  123. };
  124. return q;
  125. }
  126. public IQueryable<OptionalCoursePlanView> GetGrademajorOptionalCoursePlanViewQueryable(Expression<Func<EM_OptionalCoursePlan, bool>> exp, Expression<Func<CF_Grademajor, bool>> grExp)
  127. {
  128. var q = from g in grademajorRepository.Entities
  129. join f in facultymajorRepository.Entities on g.FacultymajorID equals f.FacultymajorID
  130. join s in specialtyRepository.Entities on new { f.EducationID, f.LearningformID, f.LearnSystem,f.StandardID } equals new { s.EducationID, s.LearningformID, s.LearnSystem,s.StandardID }
  131. join ocp in OptionalCoursePlanRepository.GetList(exp) on s.SpecialtyID equals ocp.SpecialtyID
  132. join sc in schoolyearRepository.Entities on new { SchoolcodeID = g.SemesterID.Value, Years = g.GradeID.Value } equals new { SchoolcodeID = sc.SchoolcodeID, Years = sc.Years }
  133. join cl in classmajorRepository.Entities on g.GrademajorID equals cl.GrademajorID
  134. join co in coursematerialRepository.Entities on ocp.CoursematerialID equals co.CoursematerialID
  135. select new OptionalCoursePlanView
  136. {
  137. TeachingModeID = ocp.EM_OptionalCoursePlanTeachingMode.Select(x => x.TeachingModeID.Value).ToList(),
  138. OptionalCourseID = ocp.OptionalCourseID,
  139. GrademajorID = g.GrademajorID,
  140. //GrademajorCode = g.Code,
  141. GrademajorName = g.Name,
  142. Years = g.GradeID,
  143. CampusID = g.CF_Facultymajor.CF_College.CampusID,
  144. CollegeID = g.CF_Facultymajor.CollegeID,
  145. //CollegeName = g.CF_Facultymajor.CF_College.Name,
  146. ClassmajorID=cl.ClassmajorID,
  147. DefaultClassName=cl.Name,
  148. DepartmentID = ocp.CF_Department.DepartmentID,
  149. //DepartmentName = ocp.CF_Department.Name,
  150. SpecialtyID = ocp.SpecialtyID,
  151. StandardID = ocp.CF_Specialty.StandardID,
  152. CoursematerialID = ocp.CoursematerialID,
  153. //CourseCode = co.CourseCode,
  154. CourseName = co.CourseName,
  155. ExaminationModeID = ocp.ExaminationModeID,
  156. TeachinglanguageID = ocp.TeachinglanguageID,
  157. PeopleNumlower = ocp.PeopleNumlower,
  158. PeopleNumlimit = ocp.PeopleNumlimit,
  159. //IsEnable = ocp.IsEnable ?? false,
  160. //IsOpened = ocp.IsOpened ?? false,
  161. //Remarks = ocp.Remarks,
  162. //RecordStatus = ocp.RecordStatus,
  163. //CreateUserID = ocp.CreateUserID,
  164. //CreateTime = ocp.CreateTime,
  165. //ModifyUserID = ocp.ModifyUserID,
  166. //ModifyTime = ocp.ModifyTime,
  167. Credit = ocp.EM_OptionalCoursePlanTeachingSetting.Credit ?? 0,
  168. TheoryCourse = ocp.EM_OptionalCoursePlanTeachingSetting.TheoryCourse ?? 0,
  169. Practicehours = ocp.EM_OptionalCoursePlanTeachingSetting.Practicehours ?? 0,
  170. Trialhours = ocp.EM_OptionalCoursePlanTeachingSetting.Trialhours ?? 0,
  171. WeeklyNum = ocp.EM_OptionalCoursePlanTeachingSetting.WeeklyNum ?? 0,
  172. TheoryWeeklyNum = ocp.EM_OptionalCoursePlanTeachingSetting.TheoryWeeklyNum ?? 0,
  173. PracticeWeeklyNum = ocp.EM_OptionalCoursePlanTeachingSetting.PracticeWeeklyNum ?? 0,
  174. TrialWeeklyNum = ocp.EM_OptionalCoursePlanTeachingSetting.TrialWeeklyNum ?? 0,
  175. StartWeeklyNum = ocp.EM_OptionalCoursePlanTeachingSetting.StartWeeklyNum ?? 0,
  176. EndWeeklyNum = ocp.EM_OptionalCoursePlanTeachingSetting.EndWeeklyNum ?? 0,
  177. WeeklyHours = ocp.EM_OptionalCoursePlanTeachingSetting.WeeklyHours ?? 0,
  178. CourseStructureID = ocp.CourseStructureID,
  179. CourseTypeID = ocp.CourseTypeID,
  180. SchoolyearNumID = ocp.SchoolyearNumID,
  181. SchoolcodeID = ocp.SchoolcodeID,
  182. //StarttermID = ((ocp.EM_SpecialtyCourse.SchoolyearNumID - 1) * 2) + (ocp.EM_SpecialtyCourse.SchoolcodeID == ocp.CF_Grademajor.SchoolcodeID ? 0 : 1) + 1,
  183. SchoolValue = sc.Value+((ocp.SchoolyearNumID - 1) * 2) + (ocp.SchoolcodeID == g.SemesterID ? 0 : 1) ,
  184. //(startSchoolyear.Value + ((specialtyCourse.SchoolyearNumID - 1) * 2) + (specialtyCourse.SchoolcodeID == grademajor.SchoolcodeID ? 0 : 1))
  185. CourseCategoryID = ocp.CourseCategoryID,
  186. CourseQualityID = ocp.CourseQualityID,
  187. PracticeTypeID = ocp.PracticeTypeID,
  188. ResultTypeID=ocp.ResultTypeID
  189. };
  190. return q;
  191. }
  192. public List<string> GetTeachingModeTypeQueryble(Guid? OptionalCourseID)
  193. {
  194. var query = from a in OptionalCoursePlanTeachingModeRepository.Entities.Where(x => x.OptionalCourseID == OptionalCourseID)
  195. join b in DictionaryItemRepository.Entities on new { a.TeachingModeID, DictionaryCode = DictionaryItem.CF_TeachingMode.ToString() }
  196. equals new { TeachingModeID = b.Value, b.DictionaryCode }
  197. select b.Value.Value.ToString();
  198. return query.ToList();
  199. }
  200. }
  201. }