WorktimeAdditionServices.cs 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Bowin.Common.Linq;
  6. using Bowin.Common.Linq.Entity;
  7. using EMIS.ViewModel.PaymentManage;
  8. using EMIS.ViewModel;
  9. using EMIS.Entities;
  10. using EMIS.DataLogic.PaymentManage;
  11. using System.Linq.Expressions;
  12. namespace EMIS.CommonLogic.PaymentManage
  13. {
  14. public class WorktimeAdditionServices : BaseServices, IWorktimeAdditionServices
  15. {
  16. public WorktimeAdditionDAL WorktimeAdditionDAL { get; set; }
  17. public IGridResultSet<WorktimeAdditionView> GetWorktimeAdditionViewList(ConfiguretView worktimeAdditionConditionView,
  18. Guid? schoolyearID, Guid? collegeID, Guid? teacherUserID, Guid? studentCollegeID, Guid? courseCollegeID, int? year, int? standard,
  19. int? teachingModeID,int? month, int? pageIndex, int? pageSize)
  20. {
  21. Expression<Func<TP_WorktimeAddition, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  22. Expression<Func<CF_Department, bool>> departmentExp = (x => true);
  23. Expression<Func<CF_Grademajor, bool>> gradeExp = (x => true);
  24. Expression<Func<CF_Facultymajor, bool>> facultyExp = (x => true);
  25. if (schoolyearID.HasValue)
  26. {
  27. exp = exp.And(x => x.SchoolyearID == schoolyearID);
  28. }
  29. if (collegeID.HasValue)
  30. {
  31. departmentExp = departmentExp.And(x => x.CollegeID == collegeID);
  32. }
  33. if (teacherUserID.HasValue)
  34. {
  35. exp = exp.And(x => x.UserID == teacherUserID);
  36. }
  37. if (studentCollegeID.HasValue)
  38. {
  39. facultyExp = facultyExp.And(x => x.CollegeID == studentCollegeID);
  40. }
  41. if (courseCollegeID.HasValue)
  42. {
  43. exp = exp.And(x => x.CourseCollegeID == courseCollegeID);
  44. }
  45. if (year.HasValue)
  46. {
  47. gradeExp = gradeExp.And(x => x.GradeID == year);
  48. }
  49. if (standard.HasValue)
  50. {
  51. facultyExp = facultyExp.And(x => x.StandardID == standard);
  52. }
  53. if (teachingModeID.HasValue)
  54. {
  55. exp = exp.And(x => x.TeachingModeID == teachingModeID);
  56. }
  57. if(month.HasValue)
  58. {
  59. exp = exp.And(x => x.Month == month);
  60. }
  61. var query = WorktimeAdditionDAL.GetWorktimeAdditionViewQueryable(exp, departmentExp, gradeExp, facultyExp);
  62. if (!string.IsNullOrEmpty(worktimeAdditionConditionView.ConditionValue) && !string.IsNullOrEmpty(worktimeAdditionConditionView.Attribute))
  63. query = query.DynamicWhere(worktimeAdditionConditionView.Attribute, worktimeAdditionConditionView.Condition, worktimeAdditionConditionView.ConditionValue);
  64. query = query.OrderByDescending(x => x.SchoolyearCode)
  65. .ThenBy(x => x.TeacherName)
  66. .ThenBy(x => x.CourseCode)
  67. .ThenBy(x => x.TeachingModeID);
  68. return query.ToGridResultSet(pageIndex, pageSize);
  69. }
  70. public List<WorktimeAdditionView> GetWorktimeAdditionViewList(ConfiguretView worktimeAdditionConditionView,
  71. Guid? schoolyearID, Guid? collegeID, Guid? teacherUserID, Guid? studentCollegeID, Guid? courseCollegeID, int? year, int? standard,
  72. int? teachingModeID, int? month)
  73. {
  74. Expression<Func<TP_WorktimeAddition, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  75. Expression<Func<CF_Department, bool>> departmentExp = (x => true);
  76. Expression<Func<CF_Grademajor, bool>> gradeExp = (x => true);
  77. Expression<Func<CF_Facultymajor, bool>> facultyExp = (x => true);
  78. if (schoolyearID.HasValue)
  79. {
  80. exp = exp.And(x => x.SchoolyearID == schoolyearID);
  81. }
  82. if (collegeID.HasValue)
  83. {
  84. departmentExp = departmentExp.And(x => x.CollegeID == collegeID);
  85. }
  86. if (teacherUserID.HasValue)
  87. {
  88. exp = exp.And(x => x.UserID == teacherUserID);
  89. }
  90. if (studentCollegeID.HasValue)
  91. {
  92. facultyExp = facultyExp.And(x => x.CollegeID == studentCollegeID);
  93. }
  94. if (courseCollegeID.HasValue)
  95. {
  96. exp = exp.And(x => x.CourseCollegeID == courseCollegeID);
  97. }
  98. if (year.HasValue)
  99. {
  100. gradeExp = gradeExp.And(x => x.GradeID == year);
  101. }
  102. if (standard.HasValue)
  103. {
  104. facultyExp = facultyExp.And(x => x.StandardID == standard);
  105. }
  106. if (teachingModeID.HasValue)
  107. {
  108. exp = exp.And(x => x.TeachingModeID == teachingModeID);
  109. }
  110. if (month.HasValue)
  111. {
  112. exp = exp.And(x => x.Month == month);
  113. }
  114. var query = WorktimeAdditionDAL.GetWorktimeAdditionViewQueryable(exp, departmentExp, gradeExp, facultyExp);
  115. if (!string.IsNullOrEmpty(worktimeAdditionConditionView.ConditionValue) && !string.IsNullOrEmpty(worktimeAdditionConditionView.Attribute))
  116. query = query.DynamicWhere(worktimeAdditionConditionView.Attribute, worktimeAdditionConditionView.Condition, worktimeAdditionConditionView.ConditionValue);
  117. query = query.OrderByDescending(x => x.SchoolyearCode)
  118. .ThenBy(x => x.TeacherName)
  119. .ThenBy(x => x.CourseCode)
  120. .ThenBy(x => x.TeachingModeID);
  121. return query.ToList();
  122. }
  123. public WorktimeAdditionView GetWorktimeAdditionView(Guid? worktimeAdditionID)
  124. {
  125. var query = WorktimeAdditionDAL.GetWorktimeAdditionViewQueryable(x => x.WorktimeAdditionID == worktimeAdditionID,
  126. (x => true), (x => true), (x => true));
  127. return query.FirstOrDefault();
  128. }
  129. public void Save(WorktimeAdditionView worktimeAdditionView)
  130. {
  131. TP_WorktimeAddition worktimeAddition = new TP_WorktimeAddition();
  132. if (worktimeAdditionView.WorktimeAdditionID == null || worktimeAdditionView.WorktimeAdditionID == Guid.Empty)
  133. {
  134. worktimeAddition = new TP_WorktimeAddition();
  135. worktimeAddition.WorktimeAdditionID = Guid.NewGuid();
  136. SetNewStatus(worktimeAddition);
  137. UnitOfWork.Add(worktimeAddition);
  138. }
  139. else
  140. {
  141. worktimeAddition = WorktimeAdditionDAL.WorktimeAdditionRepository.GetSingle(x =>
  142. x.WorktimeAdditionID == worktimeAdditionView.WorktimeAdditionID);
  143. if (worktimeAddition == null)
  144. {
  145. throw new Exception("未能找到需要修改的数据,数据可能已被其他用户更改。");
  146. }
  147. SetModifyStatus(worktimeAddition);
  148. }
  149. worktimeAddition.UserID = worktimeAdditionView.UserID;
  150. worktimeAddition.SchoolyearID = worktimeAdditionView.SchoolyearID;
  151. worktimeAddition.GrademajorID = worktimeAdditionView.GrademajorID;
  152. worktimeAddition.CoursematerialID = worktimeAdditionView.CoursematerialID;
  153. worktimeAddition.CourseCollegeID = worktimeAdditionView.CourseCollegeID;
  154. worktimeAddition.EducationMissionClassName = worktimeAdditionView.EducationMissionClassName;
  155. worktimeAddition.TeachingModeID = worktimeAdditionView.TeachingModeID;
  156. worktimeAddition.TeachType = worktimeAdditionView.TeachType;
  157. worktimeAddition.StudentCount = worktimeAdditionView.StudentCount;
  158. worktimeAddition.CourseTime = worktimeAdditionView.CourseTime;
  159. worktimeAddition.Month = worktimeAdditionView.Month;
  160. worktimeAddition.Remark = worktimeAdditionView.Remark;
  161. UnitOfWork.Commit();
  162. }
  163. public void Delete(IList<Guid?> worktimeAdditionIDList)
  164. {
  165. if (worktimeAdditionIDList.Count > 0)
  166. {
  167. UnitOfWork.Delete<TP_WorktimeAddition>(x => worktimeAdditionIDList.Contains(x.WorktimeAdditionID));
  168. }
  169. }
  170. }
  171. }