PaymentStandardServices.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.DataLogic.PaymentManage;
  6. using Bowin.Common.Linq.Entity;
  7. using EMIS.ViewModel.PaymentManage;
  8. using EMIS.ViewModel;
  9. using System.Linq.Expressions;
  10. using EMIS.Entities;
  11. namespace EMIS.CommonLogic.PaymentManage
  12. {
  13. public class PaymentStandardServices : BaseServices, IPaymentStandardServices
  14. {
  15. public PaymentStandardDAL PaymentStandardDAL { get; set; }
  16. public IGridResultSet<PaymentStandardView> GetPaymentStandardViewList(ConfiguretView paymentStandardConditionView, int pageIndex, int pageSize)
  17. {
  18. Expression<Func<TP_PaymentStandard, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  19. var query = PaymentStandardDAL.GetPaymentStandardViewQueryable(exp);
  20. if (!string.IsNullOrEmpty(paymentStandardConditionView.ConditionValue) && !string.IsNullOrEmpty(paymentStandardConditionView.Attribute))
  21. query = query.DynamicWhere(paymentStandardConditionView.Attribute, paymentStandardConditionView.Condition, paymentStandardConditionView.ConditionValue);
  22. query = query.OrderBy(x => x.TitleID).ThenBy(x => x.TeacherType);
  23. return query.ToGridResultSet<PaymentStandardView>(pageIndex, pageSize);
  24. }
  25. public List<PaymentStandardView> GetPaymentStandardViewList()
  26. {
  27. Expression<Func<TP_PaymentStandard, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  28. var query = PaymentStandardDAL.GetPaymentStandardViewQueryable(exp);
  29. query = query.OrderBy(x => x.TitleID).ThenBy(x => x.TeacherType);
  30. return query.ToList();
  31. }
  32. /// <summary>
  33. /// 获取考试时间信息
  34. /// </summary>
  35. /// <param name="paymentStandardID">考试时间ID</param>
  36. /// <returns></returns>
  37. public PaymentStandardView GetPaymentStandardView(Guid? paymentStandardID)
  38. {
  39. var query = PaymentStandardDAL.GetPaymentStandardViewQueryable(x => x.PaymentStandardID == paymentStandardID);
  40. return query.FirstOrDefault();
  41. }
  42. /// <summary>
  43. /// 保存
  44. /// </summary>
  45. /// <param name="paymentStandard">实体</param>
  46. /// <returns></returns>
  47. public void Save(PaymentStandardView paymentStandardView)
  48. {
  49. TP_PaymentStandard paymentStandard = new TP_PaymentStandard();
  50. if (paymentStandardView.PaymentStandardID == null || paymentStandardView.PaymentStandardID == Guid.Empty)
  51. {
  52. paymentStandard = PaymentStandardDAL.PaymentStandardRepository.GetSingle(x => x.Title == paymentStandardView.TitleID
  53. && x.TeacherType == paymentStandardView.TeacherType);
  54. if (paymentStandard != null)
  55. {
  56. throw new Exception("已有相同的标准课酬设置,请勿重复设置。");
  57. }
  58. paymentStandard = new TP_PaymentStandard();
  59. paymentStandard.PaymentStandardID = Guid.NewGuid();
  60. SetNewStatus(paymentStandard);
  61. UnitOfWork.Add(paymentStandard);
  62. }
  63. else
  64. {
  65. paymentStandard = PaymentStandardDAL.PaymentStandardRepository.GetSingle(x => x.PaymentStandardID != paymentStandardView.PaymentStandardID
  66. && x.Title == paymentStandardView.TitleID
  67. && x.TeacherType == paymentStandardView.TeacherType);
  68. if (paymentStandard != null)
  69. {
  70. throw new Exception("已有相同的标准课酬设置,请勿重复设置。");
  71. }
  72. paymentStandard = PaymentStandardDAL.PaymentStandardRepository.GetSingle(x => x.PaymentStandardID == paymentStandardView.PaymentStandardID);
  73. if (paymentStandard == null)
  74. {
  75. throw new Exception("未能找到需要修改的数据,数据可能已被其他用户更改。");
  76. }
  77. SetModifyStatus(paymentStandard);
  78. }
  79. paymentStandard.Title = paymentStandardView.TitleID;
  80. paymentStandard.TeacherType = paymentStandardView.TeacherType;
  81. paymentStandard.Amount = paymentStandardView.Amount;
  82. UnitOfWork.Commit();
  83. }
  84. public void Delete(IList<Guid?> paymentStandardIDList)
  85. {
  86. if (paymentStandardIDList.Count > 0)
  87. {
  88. UnitOfWork.Delete<TP_PaymentStandard>(x => paymentStandardIDList.Contains(x.PaymentStandardID));
  89. }
  90. }
  91. }
  92. }