StaffStandardServices.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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 StaffStandardServices : BaseServices, IStaffStandardServices
  15. {
  16. public StaffStandardDAL StaffStandardDAL { get; set; }
  17. public IGridResultSet<StaffStandardView> GetStaffStandardViewList(ConfiguretView staffStandardConditionView,
  18. Guid? collegeID, Guid? departmentID, Guid? userID, int? pageIndex, int? pageSize)
  19. {
  20. Expression<Func<TP_StaffStandard, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  21. Expression<Func<CF_College, bool>> collegeExp = (x => true);
  22. Expression<Func<CF_Department, bool>> departmentExp = (x => true);
  23. if (collegeID.HasValue)
  24. {
  25. collegeExp = collegeExp.And(x => x.CollegeID == collegeID);
  26. }
  27. if (departmentID.HasValue)
  28. {
  29. departmentExp = departmentExp.And(x => x.DepartmentID == departmentID);
  30. }
  31. if (userID.HasValue)
  32. {
  33. exp = exp.And(x => x.UserID == userID);
  34. }
  35. var query = StaffStandardDAL.GetStaffStandardViewQueryable(exp, departmentExp, collegeExp);
  36. if (!string.IsNullOrEmpty(staffStandardConditionView.ConditionValue) && !string.IsNullOrEmpty(staffStandardConditionView.Attribute))
  37. query = query.DynamicWhere(staffStandardConditionView.Attribute, staffStandardConditionView.Condition, staffStandardConditionView.ConditionValue);
  38. query = query.OrderBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo)
  39. .ThenBy(x => x.DepartmentName)
  40. .ThenBy(x => x.LoginID);
  41. return query.ToGridResultSet<StaffStandardView>(pageIndex, pageSize);
  42. }
  43. public List<StaffStandardView> GetStaffStandardViewList(ConfiguretView staffStandardConditionView,
  44. Guid? collegeID, Guid? departmentID, Guid? userID)
  45. {
  46. Expression<Func<TP_StaffStandard, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  47. Expression<Func<CF_College, bool>> collegeExp = (x => true);
  48. Expression<Func<CF_Department, bool>> departmentExp = (x => true);
  49. if (collegeID.HasValue)
  50. {
  51. collegeExp = collegeExp.And(x => x.CollegeID == collegeID);
  52. }
  53. if (departmentID.HasValue)
  54. {
  55. departmentExp = departmentExp.And(x => x.DepartmentID == departmentID);
  56. }
  57. if (userID.HasValue)
  58. {
  59. exp = exp.And(x => x.UserID == userID);
  60. }
  61. var query = StaffStandardDAL.GetStaffStandardViewQueryable(exp, departmentExp, collegeExp);
  62. if (!string.IsNullOrEmpty(staffStandardConditionView.ConditionValue) && !string.IsNullOrEmpty(staffStandardConditionView.Attribute))
  63. query = query.DynamicWhere(staffStandardConditionView.Attribute, staffStandardConditionView.Condition, staffStandardConditionView.ConditionValue);
  64. query = query.OrderBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo)
  65. .ThenBy(x => x.DepartmentName)
  66. .ThenBy(x => x.LoginID);
  67. return query.ToList();
  68. }
  69. public StaffStandardView GetStaffStandardView(Guid? staffStandardID)
  70. {
  71. var query = StaffStandardDAL.GetStaffStandardViewQueryable(x => x.StaffStandardID == staffStandardID, (x => true), (x => true));
  72. return query.FirstOrDefault();
  73. }
  74. public void Save(StaffStandardView staffStandardView)
  75. {
  76. TP_StaffStandard staffStandard = new TP_StaffStandard();
  77. staffStandard = StaffStandardDAL.StaffStandardRepository.GetSingle(x => x.UserID == staffStandardView.UserID
  78. && x.StaffStandardID != staffStandardView.StaffStandardID);
  79. if (staffStandard != null)
  80. {
  81. throw new Exception("已有相同的标准课酬设置,请勿重复设置。");
  82. }
  83. if (staffStandardView.StaffStandardID == null || staffStandardView.StaffStandardID == Guid.Empty)
  84. {
  85. staffStandard = new TP_StaffStandard();
  86. staffStandard.StaffStandardID = Guid.NewGuid();
  87. SetNewStatus(staffStandard);
  88. UnitOfWork.Add(staffStandard);
  89. }
  90. else
  91. {
  92. staffStandard = StaffStandardDAL.StaffStandardRepository.GetSingle(x => x.StaffStandardID == staffStandardView.StaffStandardID);
  93. if (staffStandard == null)
  94. {
  95. throw new Exception("未能找到需要修改的数据,数据可能已被其他用户更改。");
  96. }
  97. SetModifyStatus(staffStandard);
  98. }
  99. staffStandard.UserID = staffStandardView.UserID;
  100. staffStandard.Amount = staffStandardView.Amount;
  101. UnitOfWork.Commit();
  102. }
  103. public void Delete(IList<Guid?> staffStandardIDList)
  104. {
  105. if (staffStandardIDList.Count > 0)
  106. {
  107. UnitOfWork.Delete<TP_StaffStandard>(x => staffStandardIDList.Contains(x.StaffStandardID));
  108. }
  109. }
  110. }
  111. }