MinorPlanApplyDAL.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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.MinorManage.MinorPlanManage;
  7. using System.Linq.Expressions;
  8. using EMIS.Entities;
  9. namespace EMIS.DataLogic.MinorManage.MinorPlanManage
  10. {
  11. public class MinorPlanApplyDAL
  12. {
  13. public GrademinorApplicationRepository GrademinorApplicationRepository { get; set; }
  14. public MinorPlanApplicationRepository MinorPlanApplicationRepository { get; set; }
  15. public MinorPlanApplicationTeachingModeTypeRepository MinorPlanApplicationTeachingModeTypeRepository { get; set; }
  16. public MinorPlanApplicationTeachingPlaceRepository MinorPlanApplicationTeachingPlaceRepository { get; set; }
  17. public MinorPlanApplicationTeachingSettingRepository MinorPlanApplicationTeachingSettingRepository { get; set; }
  18. public MinorCourseRepository MinorCourseRepository { get; set; }
  19. public UserRepository UserRepository { get; set; }
  20. public MinorCourseTeachingSettingRepository MinorCourseTeachingSettingRepository { get; set; }
  21. public MinorCourseTeachingModeTypeRepository MinorCourseTeachingModeTypeRepository { get; set; }
  22. public MinorCourseTeachingPlaceRepository MinorCourseTeachingPlaceRepository { get; set; }
  23. public GrademinorRepository GrademinorRepository { get; set; }
  24. public IQueryable<MinorPlanApplyView> GetMinorPlanApplyViewQueryable(Expression<Func<CF_GrademinorApplication, bool>> exp)
  25. {
  26. var query = from GrademinorApply in GrademinorApplicationRepository.GetList(exp)
  27. join User in UserRepository.Entities on GrademinorApply.CreateUserID equals User.UserID into user
  28. from u in user.DefaultIfEmpty()
  29. select new MinorPlanApplyView
  30. {
  31. GradeMinorApplicationID = GrademinorApply.GradeMinorApplicationID,
  32. YearID = GrademinorApply.YearID,
  33. SchoolyearID=GrademinorApply.SchoolyearID,
  34. SchoolyearCode=GrademinorApply.CF_Schoolyear.Code,
  35. StandardID = GrademinorApply.StandardID,
  36. CollegeID = GrademinorApply.CollegeID,
  37. CollegeName = GrademinorApply.CF_College.Name,
  38. CollegeNo = GrademinorApply.CF_College.No,
  39. StudentLimit = GrademinorApply.StudentLimit,
  40. ApprovalStatus = GrademinorApply.RecordStatus,
  41. CreateUserID = GrademinorApply.CreateUserID,
  42. CreateTime = GrademinorApply.CreateTime,
  43. CreateUserName = u.Name
  44. };
  45. return query;
  46. }
  47. /// <summary>
  48. /// 查询所有年级和专业课程信息
  49. /// </summary>
  50. /// <returns></returns>
  51. public IQueryable<MinorPlanApplyView> StandardAndMinorSpecialtyCourseView(Expression<Func<EM_MinorCourse, bool>> exp,int? YearID)
  52. {
  53. var graduatingSemester = EMIS.Utility.Const.LOCAL_SETTING_ENTRANCESEMESTERID;
  54. if (graduatingSemester == null)
  55. {
  56. throw new Exception("入学学期(春季、上学期、秋季、下学期)未配置,请检查");
  57. }
  58. var SchoolcodeID = Convert.ToInt32(graduatingSemester);
  59. var query = from MinorCourse in MinorCourseRepository.GetList(exp)
  60. join GrademinorApply in
  61. (
  62. from GrademinorApply in GrademinorApplicationRepository.GetList(x => x.YearID == YearID)
  63. join MinorPlanApply in MinorPlanApplicationRepository.Entities on new { GrademinorApply.GradeMinorApplicationID }
  64. equals new { GradeMinorApplicationID = (Guid)MinorPlanApply.GrademinorApplicationID }
  65. select new
  66. {
  67. GradeMinorApplicationID = GrademinorApply.GradeMinorApplicationID,
  68. MinorPlanApplicationID=MinorPlanApply.MinorPlanApplicationID,
  69. CoursematerialID = MinorPlanApply.CoursematerialID,
  70. CollegeID = GrademinorApply.CollegeID,
  71. SchoolyearID = GrademinorApply.SchoolyearID,
  72. StandardID = GrademinorApply.StandardID,
  73. YearID=GrademinorApply.YearID
  74. }
  75. ) on new { MinorCourse.CoursematerialID, MinorCourse.StandardID } equals new { GrademinorApply.CoursematerialID, GrademinorApply.StandardID }
  76. into GrademinorApplication
  77. from GA in GrademinorApplication.DefaultIfEmpty()
  78. where GA.GradeMinorApplicationID == null && GA.MinorPlanApplicationID == null
  79. select new MinorPlanApplyView
  80. {
  81. GradeMinorApplicationID = GA.GradeMinorApplicationID,
  82. MinorPlanApplicationID = GA.MinorPlanApplicationID,
  83. MinorCourseID = MinorCourse.MinorCourseID,
  84. CollegeID = MinorCourse.CF_Department.CollegeID,
  85. CoursematerialID = MinorCourse.CoursematerialID,
  86. CourseCode = MinorCourse.EM_Coursematerial.CourseCode,
  87. CourseName = MinorCourse.EM_Coursematerial.CourseName,
  88. SchoolyearID = GA.SchoolyearID,
  89. YearID = GA.YearID,
  90. StandardID = MinorCourse.StandardID,
  91. CourseCategoryID = MinorCourse.CourseCategoryID,
  92. CourseQualityID = MinorCourse.CourseQualityID,
  93. SchoolcodeID = MinorCourse.SchoolcodeID,
  94. SchoolyearNumID = MinorCourse.SchoolyearNumID,
  95. StarttermID = ((MinorCourse.SchoolyearNumID - 1) * 2) + (MinorCourse.SchoolcodeID == SchoolcodeID ? 0 : 1) + 1,
  96. Credit = MinorCourse.EM_MinorCourseTeachingSetting.Credit ?? 0,
  97. TheoryCourse = MinorCourse.EM_MinorCourseTeachingSetting.TheoryCourse ?? 0,
  98. Practicehours = MinorCourse.EM_MinorCourseTeachingSetting.Practicehours ?? 0,
  99. Trialhours = MinorCourse.EM_MinorCourseTeachingSetting.Trialhours ?? 0,
  100. Totalhours = (MinorCourse.EM_MinorCourseTeachingSetting.TheoryCourse
  101. + MinorCourse.EM_MinorCourseTeachingSetting.Practicehours) ?? 0,
  102. TheoryWeeklyNum = MinorCourse.EM_MinorCourseTeachingSetting.TheoryWeeklyNum ?? 0,
  103. PracticeWeeklyNum = MinorCourse.EM_MinorCourseTeachingSetting.PracticeWeeklyNum ?? 0,
  104. TrialWeeklyNum = MinorCourse.EM_MinorCourseTeachingSetting.TrialWeeklyNum ?? 0,
  105. SchoolweeksNum = (MinorCourse.EM_MinorCourseTeachingSetting.TheoryWeeklyNum
  106. + MinorCourse.EM_MinorCourseTeachingSetting.PracticeWeeklyNum) ?? 0,
  107. StartWeeklyNum = MinorCourse.EM_MinorCourseTeachingSetting.StartWeeklyNum ?? 0,
  108. EndWeeklyNum = MinorCourse.EM_MinorCourseTeachingSetting.EndWeeklyNum ?? 0,
  109. WeeklyNum = MinorCourse.EM_MinorCourseTeachingSetting.WeeklyNum ?? 0,
  110. WeeklyHours = MinorCourse.EM_MinorCourseTeachingSetting.WeeklyHours ?? 0,
  111. DepartmentID = MinorCourse.DepartmentID,
  112. CourseStructureID = MinorCourse.CourseStructureID,
  113. CourseTypeID = MinorCourse.CourseTypeID,
  114. ExaminationModeID = MinorCourse.ExaminationModeID,
  115. TeachinglanguageID = MinorCourse.TeachinglanguageID,
  116. PracticeTypeID = MinorCourse.PracticeTypeID,
  117. CourseFineID = MinorCourse.CourseFineID,
  118. IsSpecialtycore = MinorCourse.IsSpecialtycore ?? false,
  119. IsCooperation = MinorCourse.IsCooperation ?? false,
  120. IsRequired = MinorCourse.IsRequired ?? false,
  121. IsElective = MinorCourse.IsElective ?? false,
  122. IsNetworkCourse = MinorCourse.IsNetworkCourse ?? false,
  123. IsNeedMaterial=true,
  124. HandleModeID=(int)EMIS.ViewModel.CF_HandleMode.MinorCourse,
  125. IsMainCourse = MinorCourse.IsMainCourse ?? false,
  126. IsEnable = MinorCourse.IsEnable ?? false,
  127. ResultTypeID = MinorCourse.ResultTypeID
  128. };
  129. return query;
  130. }
  131. /// <summary>
  132. /// 查询已存在的课程信息
  133. /// </summary>
  134. /// <returns></returns>
  135. public IQueryable<MinorPlanApplyView> existStandardAndMinorSpecialtyCourseView(Expression<Func<CF_GrademinorApplication, bool>> exp)
  136. {
  137. var graduatingSemester = EMIS.Utility.Const.LOCAL_SETTING_ENTRANCESEMESTERID;
  138. if (graduatingSemester == null)
  139. {
  140. throw new Exception("入学学期(春季、上学期、秋季、下学期)未配置,请检查");
  141. }
  142. var SchoolcodeID = Convert.ToInt32(graduatingSemester);
  143. var query = from MinorCourse in MinorCourseRepository.GetList(x=>true)
  144. join GrademinorApply in
  145. (
  146. from GrademinorApply in GrademinorApplicationRepository.GetList(exp)
  147. join MinorPlanApply in MinorPlanApplicationRepository.Entities on new { GrademinorApply.GradeMinorApplicationID }
  148. equals new { GradeMinorApplicationID = (Guid)MinorPlanApply.GrademinorApplicationID }
  149. select new
  150. {
  151. GradeMinorApplicationID = GrademinorApply.GradeMinorApplicationID,
  152. MinorPlanApplicationID = MinorPlanApply.MinorPlanApplicationID,
  153. CoursematerialID = MinorPlanApply.CoursematerialID,
  154. CollegeID = GrademinorApply.CollegeID,
  155. SchoolyearID = GrademinorApply.SchoolyearID,
  156. StandardID = GrademinorApply.StandardID,
  157. YearID = GrademinorApply.YearID,
  158. MinorCourse = MinorPlanApply
  159. }
  160. ) on new { MinorCourse.CoursematerialID, MinorCourse.StandardID } equals new { GrademinorApply.CoursematerialID, GrademinorApply.StandardID }
  161. into GrademinorApplication
  162. from GA in GrademinorApplication.DefaultIfEmpty()
  163. where GA.GradeMinorApplicationID != null && GA.MinorPlanApplicationID != null
  164. select new MinorPlanApplyView
  165. {
  166. GradeMinorApplicationID = GA.GradeMinorApplicationID,
  167. MinorPlanApplicationID = GA.MinorPlanApplicationID,
  168. MinorCourseID = MinorCourse.MinorCourseID,
  169. CollegeID = GA.CollegeID,
  170. CoursematerialID = GA.MinorCourse.CoursematerialID,
  171. CourseCode = MinorCourse.EM_Coursematerial.CourseCode,
  172. CourseName = MinorCourse.EM_Coursematerial.CourseName,
  173. SchoolyearID = GA.SchoolyearID,
  174. YearID = GA.YearID,
  175. StandardID = MinorCourse.StandardID,
  176. CourseCategoryID = GA.MinorCourse.CourseCategoryID,
  177. CourseQualityID = GA.MinorCourse.CourseQualityID,
  178. SchoolcodeID = MinorCourse.SchoolcodeID,
  179. SchoolyearNumID = MinorCourse.SchoolyearNumID,
  180. StarttermID = GA.MinorCourse.StarttermID,
  181. Credit = GA.MinorCourse.EM_MinorPlanApplicationTeachingSetting.Credit ?? 0,
  182. TheoryCourse = GA.MinorCourse.EM_MinorPlanApplicationTeachingSetting.TheoryCourse ?? 0,
  183. Practicehours = GA.MinorCourse.EM_MinorPlanApplicationTeachingSetting.Practicehours ?? 0,
  184. Trialhours = GA.MinorCourse.EM_MinorPlanApplicationTeachingSetting.Trialhours ?? 0,
  185. Totalhours = (GA.MinorCourse.EM_MinorPlanApplicationTeachingSetting.TheoryCourse
  186. + GA.MinorCourse.EM_MinorPlanApplicationTeachingSetting.Practicehours) ?? 0,
  187. TheoryWeeklyNum = GA.MinorCourse.EM_MinorPlanApplicationTeachingSetting.TheoryWeeklyNum ?? 0,
  188. PracticeWeeklyNum = GA.MinorCourse.EM_MinorPlanApplicationTeachingSetting.PracticeWeeklyNum ?? 0,
  189. TrialWeeklyNum = GA.MinorCourse.EM_MinorPlanApplicationTeachingSetting.TrialWeeklyNum ?? 0,
  190. SchoolweeksNum = (GA.MinorCourse.EM_MinorPlanApplicationTeachingSetting.TheoryWeeklyNum
  191. + GA.MinorCourse.EM_MinorPlanApplicationTeachingSetting.PracticeWeeklyNum) ?? 0,
  192. StartWeeklyNum = GA.MinorCourse.EM_MinorPlanApplicationTeachingSetting.StartWeeklyNum ?? 0,
  193. EndWeeklyNum = GA.MinorCourse.EM_MinorPlanApplicationTeachingSetting.EndWeeklyNum ?? 0,
  194. WeeklyNum = GA.MinorCourse.EM_MinorPlanApplicationTeachingSetting.WeeklyNum ?? 0,
  195. WeeklyHours = GA.MinorCourse.EM_MinorPlanApplicationTeachingSetting.WeeklyHours ?? 0,
  196. DepartmentID = MinorCourse.DepartmentID,
  197. CourseStructureID = GA.MinorCourse.CourseStructureID,
  198. CourseTypeID = GA.MinorCourse.CourseTypeID,
  199. ExaminationModeID = GA.MinorCourse.ExaminationModeID,
  200. TeachinglanguageID = GA.MinorCourse.TeachinglanguageID,
  201. PracticeTypeID = GA.MinorCourse.PracticeTypeID,
  202. CourseFineID = GA.MinorCourse.CourseFineID,
  203. IsSpecialtycore = GA.MinorCourse.IsSpecialtycore ?? false,
  204. IsCooperation = GA.MinorCourse.IsCooperation ?? false,
  205. IsRequired = GA.MinorCourse.IsRequired ?? false,
  206. IsElective = GA.MinorCourse.IsElective ?? false,
  207. IsNetworkCourse = GA.MinorCourse.IsNetworkCourse ?? false,
  208. IsMainCourse = GA.MinorCourse.IsMainCourse ?? false,
  209. IsEnable = MinorCourse.IsEnable ?? false,
  210. IsNeedMaterial = GA.MinorCourse.IsNeedMaterial ?? false,
  211. HandleModeID=GA.MinorCourse.HandleModeID,
  212. ResultTypeID = GA.MinorCourse.ResultTypeID
  213. };
  214. return query;
  215. }
  216. public int GetStandardID_MinorPlanApplication_MinorSpecialtyPlan(List<Guid> ids)
  217. {
  218. var query = from GrademinorApplication in GrademinorApplicationRepository.GetList(x => ids.Contains(x.GradeMinorApplicationID))
  219. join Grademinor in GrademinorRepository.Entities on new { GrademinorApplication.YearID, GrademinorApplication.StandardID }
  220. equals new { Grademinor.YearID, Grademinor.StandardID }
  221. select Grademinor;
  222. return query.Count();
  223. }
  224. public IQueryable<MinorPlanApplyView> GetDuplicateSpecialtyPlanApplyView(Expression<Func<CF_GrademinorApplication, bool>> exp)
  225. {
  226. var query = (from GrademinorApplication in GetMinorPlanApplyViewQueryable(exp)
  227. join Grademinor in GrademinorRepository.Entities on new { GrademinorApplication.YearID, GrademinorApplication.StandardID }
  228. equals new { Grademinor.YearID, Grademinor.StandardID }
  229. select GrademinorApplication);
  230. return query;
  231. }
  232. }
  233. }