LevelStandardServices.cs 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Linq.Expressions;
  6. using Bowin.Common.Linq;
  7. using Bowin.Common.Linq.Entity;
  8. using EMIS.ViewModel.PaymentManage;
  9. using EMIS.ViewModel;
  10. using EMIS.DataLogic.PaymentManage;
  11. using EMIS.Entities;
  12. namespace EMIS.CommonLogic.PaymentManage
  13. {
  14. public class LevelStandardServices : BaseServices, ILevelStandardServices
  15. {
  16. public LevelStandardDAL LevelStandardDAL { get; set; }
  17. public IGridResultSet<LevelStandardView> GetLevelStandardViewList(ConfiguretView levelStandardConditionView, int? employmentTypeID,
  18. int? teacherTypeID, int? paymentLevel, int pageIndex, int pageSize)
  19. {
  20. Expression<Func<TP_LevelStandard, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  21. if (teacherTypeID.HasValue)
  22. {
  23. exp = exp.And(x => x.TeacherType == teacherTypeID);
  24. }
  25. if (paymentLevel.HasValue)
  26. {
  27. exp = exp.And(x => x.PaymentLevelID == paymentLevel);
  28. }
  29. var query = LevelStandardDAL.GetLevelStandardViewQueryable(exp);
  30. if (employmentTypeID.HasValue)
  31. {
  32. query = query.Where(x => x.EmploymentTypeID == employmentTypeID);
  33. }
  34. if (!string.IsNullOrEmpty(levelStandardConditionView.ConditionValue) && !string.IsNullOrEmpty(levelStandardConditionView.Attribute))
  35. query = query.DynamicWhere(levelStandardConditionView.Attribute, levelStandardConditionView.Condition, levelStandardConditionView.ConditionValue);
  36. query = query.OrderBy(x => x.EmploymentTypeID).ThenBy(x => x.TeacherType).ThenBy(x => x.PaymentLevelID);
  37. return query.ToGridResultSet<LevelStandardView>(pageIndex, pageSize);
  38. }
  39. public List<LevelStandardView> GetLevelStandardViewList(ConfiguretView levelStandardConditionView, int? employmentTypeID,
  40. int? teacherTypeID, int? paymentLevel)
  41. {
  42. Expression<Func<TP_LevelStandard, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  43. if (teacherTypeID.HasValue)
  44. {
  45. exp = exp.And(x => x.TeacherType == teacherTypeID);
  46. }
  47. if (paymentLevel.HasValue)
  48. {
  49. exp = exp.And(x => x.PaymentLevelID == paymentLevel);
  50. }
  51. var query = LevelStandardDAL.GetLevelStandardViewQueryable(exp);
  52. if (employmentTypeID.HasValue)
  53. {
  54. query = query.Where(x => x.EmploymentTypeID == employmentTypeID);
  55. }
  56. if (!string.IsNullOrEmpty(levelStandardConditionView.ConditionValue) && !string.IsNullOrEmpty(levelStandardConditionView.Attribute))
  57. query = query.DynamicWhere(levelStandardConditionView.Attribute, levelStandardConditionView.Condition, levelStandardConditionView.ConditionValue);
  58. query = query.OrderBy(x => x.EmploymentTypeID).ThenBy(x => x.TeacherType).ThenBy(x => x.PaymentLevelID);
  59. return query.ToList();
  60. }
  61. /// <summary>
  62. /// 获取考试时间信息
  63. /// </summary>
  64. /// <param name="levelStandardID">考试时间ID</param>
  65. /// <returns></returns>
  66. public LevelStandardView GetLevelStandardView(Guid? levelStandardID)
  67. {
  68. var query = LevelStandardDAL.GetLevelStandardViewQueryable(x => x.LevelStandardID == levelStandardID);
  69. return query.FirstOrDefault();
  70. }
  71. /// <summary>
  72. /// 保存
  73. /// </summary>
  74. /// <param name="paymentStandard">实体</param>
  75. /// <returns></returns>
  76. public void Save(LevelStandardView levelStandardView)
  77. {
  78. TP_LevelStandard levelStandard = new TP_LevelStandard();
  79. if (levelStandardView.LevelStandardID == null || levelStandardView.LevelStandardID == Guid.Empty)
  80. {
  81. levelStandard = LevelStandardDAL.LevelStandardRepository.GetSingle(x => x.PaymentLevelID == levelStandardView.PaymentLevelID
  82. && x.TeacherType == levelStandardView.TeacherType);
  83. if (levelStandard != null)
  84. {
  85. throw new Exception("已有相同的标准课酬设置,请勿重复设置。");
  86. }
  87. levelStandard = new TP_LevelStandard();
  88. levelStandard.LevelStandardID = Guid.NewGuid();
  89. SetNewStatus(levelStandard);
  90. UnitOfWork.Add(levelStandard);
  91. }
  92. else
  93. {
  94. levelStandard = LevelStandardDAL.LevelStandardRepository.GetSingle(x => x.LevelStandardID != levelStandardView.LevelStandardID
  95. && x.PaymentLevelID == levelStandardView.PaymentLevelID
  96. && x.TeacherType == levelStandardView.TeacherType);
  97. if (levelStandard != null)
  98. {
  99. throw new Exception("已有相同的标准课酬设置,请勿重复设置。");
  100. }
  101. levelStandard = LevelStandardDAL.LevelStandardRepository.GetSingle(x => x.LevelStandardID == levelStandardView.LevelStandardID);
  102. if (levelStandard == null)
  103. {
  104. throw new Exception("未能找到需要修改的数据,数据可能已被其他用户更改。");
  105. }
  106. SetModifyStatus(levelStandard);
  107. }
  108. levelStandard.PaymentLevelID = levelStandardView.PaymentLevelID;
  109. levelStandard.TeacherType = levelStandardView.TeacherType;
  110. levelStandard.Amount = levelStandardView.Amount;
  111. UnitOfWork.Commit();
  112. }
  113. public void Delete(IList<Guid?> levelStandardIDList)
  114. {
  115. if (levelStandardIDList.Count > 0)
  116. {
  117. UnitOfWork.Delete<TP_LevelStandard>(x => levelStandardIDList.Contains(x.LevelStandardID));
  118. }
  119. }
  120. }
  121. }