CourseTimeHoursServices.cs 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.DataLogic.SchedulingManage.SchedulingSettings;
  6. using Bowin.Common.Linq.Entity;
  7. using Bowin.Common.Linq;
  8. using EMIS.ViewModel.SchedulingManage.SchedulingSettings;
  9. using System.Linq.Expressions;
  10. using EMIS.Entities;
  11. using EMIS.DataLogic.UniversityManage.ClassroomManage;
  12. using EMIS.ViewModel;
  13. using EMIS.Utility;
  14. namespace EMIS.CommonLogic.SchedulingManage.SchedulingSettings
  15. {
  16. public class CourseTimeHoursServices:BaseServices,ICourseTimeHoursServices
  17. {
  18. public CourseTimeHoursDAL CourseTimeHoursDAL { get; set; }
  19. /// <summary>
  20. /// 查询课程时间信息
  21. /// </summary>
  22. /// <param name="configuretView">查询条件实体</param>
  23. /// <param name="timesSegment">时间段</param>
  24. /// <param name="pageIndex">页码</param>
  25. /// <param name="pageSize">显示页数</param>
  26. /// <returns></returns>
  27. public IGridResultSet<CourseTimeHoursView> GetCoursesTimeViewGrid(ConfiguretView configuretView, int? year, Guid? CoursesTimeID, int pageIndex, int pageSize)
  28. {
  29. Expression<Func<EM_CoursesTime, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  30. Expression<Func<TP_CourseTimeHours, bool>> exps = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  31. if(CoursesTimeID.HasValue){
  32. exp = exp.And(x => x.CoursesTimeID == CoursesTimeID);
  33. }
  34. if(year.HasValue&&year!=-1)
  35. {
  36. exps = exps.And(x => x.Years == year);
  37. }
  38. var query = CourseTimeHoursDAL.GetCoursesTimeQueryable(exp, exps);
  39. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  40. return query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue).ToGridResultSet<CourseTimeHoursView>(pageIndex, pageSize);
  41. return query.OrderByDescending(x => x.Year).ToGridResultSet<CourseTimeHoursView>(pageIndex, pageSize);
  42. }
  43. //查询学时转换
  44. public CourseTimeHoursView GetCourseTimeHoursView(Guid? id) {
  45. Expression<Func<EM_CoursesTime, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  46. Expression<Func<TP_CourseTimeHours, bool>> exps = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE&&x.CourseTimeHoursID==id);
  47. var query=CourseTimeHoursDAL.GetCoursesTimeQueryable(exp, exps).FirstOrDefault();
  48. if(query!=null){
  49. CourseTimeHoursView CourseTimeHoursView=new CourseTimeHoursView();
  50. CourseTimeHoursView.CourseTimeHoursID=query.CourseTimeHoursID;
  51. CourseTimeHoursView.CoursesTimeID=query.CoursesTimeID;
  52. CourseTimeHoursView.Year = query.Year;
  53. CourseTimeHoursView.Hours = query.Hours;
  54. return CourseTimeHoursView;
  55. }
  56. return null;
  57. }
  58. //保存
  59. public void save(CourseTimeHoursView CourseTimeHoursView) {
  60. TP_CourseTimeHours TP_CourseTimeHours;
  61. try
  62. {
  63. Expression<Func<EM_CoursesTime, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  64. Expression<Func<TP_CourseTimeHours, bool>> exps = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE && x.CoursesTimeID == CourseTimeHoursView.CoursesTimeID&&x.Years==CourseTimeHoursView.Year&&x.CourseTimeHoursID!=CourseTimeHoursView.CourseTimeHoursID);
  65. var query = CourseTimeHoursDAL.GetCoursesTimeQueryable(exp, exps).ToList();
  66. if(query.Count()>0)
  67. {
  68. throw new Exception(CourseTimeHoursView.Year+"级在改时间段已存在请重新输入!");
  69. }
  70. if (CourseTimeHoursView.CourseTimeHoursID != null)
  71. {
  72. TP_CourseTimeHours = new Entities.TP_CourseTimeHours();
  73. TP_CourseTimeHours.CourseTimeHoursID = (Guid)CourseTimeHoursView.CourseTimeHoursID;
  74. TP_CourseTimeHours.CoursesTimeID = CourseTimeHoursView.CoursesTimeID;
  75. TP_CourseTimeHours.Hours = CourseTimeHoursView.Hours;
  76. TP_CourseTimeHours.Years = CourseTimeHoursView.Year;
  77. TP_CourseTimeHours.RecordStatus = (int)SYS_STATUS.USABLE;
  78. UnitOfWork.Update(TP_CourseTimeHours);
  79. SetNewStatus(TP_CourseTimeHours);
  80. }
  81. else
  82. {
  83. TP_CourseTimeHours = new Entities.TP_CourseTimeHours();
  84. TP_CourseTimeHours.CourseTimeHoursID = Guid.NewGuid();
  85. TP_CourseTimeHours.CoursesTimeID = CourseTimeHoursView.CoursesTimeID;
  86. TP_CourseTimeHours.Hours = CourseTimeHoursView.Hours;
  87. TP_CourseTimeHours.Years = CourseTimeHoursView.Year;
  88. TP_CourseTimeHours.RecordStatus = (int)SYS_STATUS.USABLE;
  89. UnitOfWork.Add(TP_CourseTimeHours);
  90. SetNewStatus(TP_CourseTimeHours);
  91. }
  92. }
  93. catch (Exception)
  94. {
  95. throw;
  96. }
  97. this.UnitOfWork.Commit();
  98. }
  99. //删除
  100. public void Delete(List<Guid> id) {
  101. UnitOfWork.Remove<TP_CourseTimeHours>(x => id.Contains(x.CourseTimeHoursID));
  102. UnitOfWork.Commit();
  103. }
  104. }
  105. }