OpenControlSettingDAL.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. namespace EMIS.DataLogic.SelectCourse
  11. {
  12. public class OpenControlSettingDAL
  13. {
  14. public SelectCourseOpenControlSettingRepository SelectCourseOpenControlSettingRepository { get; set; }
  15. public SchoolyearRepository SchoolyearRepository { get; set; }
  16. public GrademajorRepository GrademajorRepository { get; set; }
  17. public DictionaryItemRepository DictionaryItemRepository { get; set; }
  18. public FreeSelectionCourseGradeYearSettingRepository FreeSelectionCourseGradeYearSettingRepository { get; set; }
  19. public IQueryable<SelectCourseOpenControlSettingView> GetOpenControlSettingView(
  20. Expression<Func<EM_SelectCourseOpenControlSetting, bool>> openControlSettingExp,
  21. Expression<Func<EMIS.Entities.CF_Schoolyear, bool>> schoolYearExp,
  22. Expression<Func<CF_Grademajor, bool>> gradeMajorExp)
  23. {
  24. var q = (from scocs in SelectCourseOpenControlSettingRepository.GetList(openControlSettingExp)
  25. join sy in SchoolyearRepository.GetList(schoolYearExp) on scocs.SchoolyearID equals sy.SchoolyearID
  26. join gm in GrademajorRepository.GetList(gradeMajorExp) on scocs.GrademajorID equals gm.GrademajorID
  27. join dis in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(CF_Standard).Name) on gm.CF_Facultymajor.StandardID equals dis.Value into ddis
  28. from edis in ddis.DefaultIfEmpty()
  29. join disy in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(EMIS.ViewModel.CF_Year).Name) on gm.GradeID equals disy.Value into ddisy
  30. from edisy in ddisy.DefaultIfEmpty()
  31. select new SelectCourseOpenControlSettingView
  32. {
  33. SelectCourseOpenControlSettingID = scocs.SelectCourseOpenControlSettingID,
  34. SchoolyearID = scocs.SchoolyearID,
  35. SchoolyearCode = sy.Code,
  36. GrademajorID = scocs.GrademajorID,
  37. GrademajorName = gm.Name,
  38. GrademajorCode=gm.Code,
  39. YearID = gm.GradeID,
  40. YearName = edisy.Name,
  41. StandardID = gm.CF_Facultymajor.StandardID,
  42. StandardDesc = edis.Name,
  43. LearnSystem = gm.CF_Facultymajor.LearnSystem,
  44. EducationID = gm.CF_Facultymajor.EducationID,
  45. LearningformID = gm.CF_Facultymajor.LearningformID,
  46. CollegeID = gm.CF_Facultymajor.CollegeID,
  47. CollegeName = gm.CF_Facultymajor.CF_College.Name,
  48. StartTime = scocs.StartTime,
  49. EndTime = scocs.EndTime,
  50. MaxSelectCount = scocs.MaxSelectCount,
  51. MinSelectCount = scocs.MinSelectCount,
  52. MaxCredit = scocs.MaxCredit,
  53. MinCredit = scocs.MinCredit,
  54. Remark = scocs.Remark,
  55. RecordStatus = scocs.RecordStatus,
  56. CreateUserID = scocs.CreateUserID,
  57. CreateTime = scocs.CreateTime,
  58. ModifyUserID = scocs.ModifyUserID,
  59. ModifyTime = scocs.ModifyTime
  60. });
  61. return q;
  62. }
  63. public IQueryable<FreeSelectionCouseControlView> GetFreeSelectionCouseControlView(
  64. Expression<Func<EM_FreeSelectionCourseGradeYearSetting, bool>> openControlSettingExp)
  65. {
  66. var q = (from fr in FreeSelectionCourseGradeYearSettingRepository.GetList(openControlSettingExp)
  67. join sy in SchoolyearRepository.Entities on fr.SchoolyearID equals sy.SchoolyearID
  68. select new FreeSelectionCouseControlView
  69. {
  70. FreeSelectionCourseGradeYearSettingID = fr.FreeSelectionCourseGradeYearSettingID,
  71. SchoolyearID = fr.SchoolyearID,
  72. SchoolyearCode = sy.Code,
  73. GradeYear = fr.GradeYear,
  74. StartTime = fr.StartTime,
  75. EndTime = fr.EndTime,
  76. MaxSelectCount = fr.MaxSelectCount??0,
  77. MinSelectCount = fr.MinSelectCount??0,
  78. MaxCredit = fr.MaxCredit??0,
  79. MinCredit = fr.MinCredit??0,
  80. Remark = fr.Remark,
  81. });
  82. return q;
  83. }
  84. }
  85. }