GradePointFormulaServices.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.DataLogic.Repositories;
  6. using EMIS.ViewModel;
  7. using Bowin.Common.Linq.Entity;
  8. using EMIS.Entities;
  9. using EMIS.ViewModel.ScoreManage;
  10. namespace EMIS.CommonLogic.ScoreManage
  11. {
  12. public class GradePointFormulaServices : BaseServices, IGradePointFormulaServices
  13. {
  14. public GradePointFormulaRepository gradePointFormulaRepository { get; set; }
  15. /// <summary>
  16. /// 绩点公式设置查询列表
  17. /// </summary>
  18. /// <param name="name"></param>
  19. /// <param name="pageIndex"></param>
  20. /// <param name="pageSize"></param>
  21. /// <returns></returns>
  22. public Bowin.Common.Linq.Entity.IGridResultSet<Entities.ER_GradePointFormula> GetGradePointFormulaGrid(string name, int pageIndex, int pageSize)
  23. {
  24. var query = gradePointFormulaRepository.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  25. if (!string.IsNullOrEmpty(name))
  26. query = query.Where(x => x.Name.Contains(name));
  27. return query.OrderByDescending(x => x.CreateTime).ToGridResultSet<ER_GradePointFormula>(pageIndex, pageSize);
  28. }
  29. /// <summary>
  30. /// 绩点公式设置查询列表
  31. /// </summary>
  32. /// <param name="name"></param>
  33. /// <returns></returns>
  34. public List<Entities.ER_GradePointFormula> GetGradePointFormulaList(string name)
  35. {
  36. var query = gradePointFormulaRepository.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  37. if (!string.IsNullOrEmpty(name))
  38. query = query.Where(x => x.Name.Contains(name));
  39. return query.OrderByDescending(x => x.CreateTime).ToList();
  40. }
  41. /// <summary>
  42. /// 绩点公式设置
  43. /// </summary>
  44. /// <param name="gradePointFormulaID"></param>
  45. /// <returns></returns>
  46. public Entities.ER_GradePointFormula GetGradePointFormula(Guid? gradePointFormulaID)
  47. {
  48. return gradePointFormulaRepository.GetSingle(x => x.GradePointFormulaID == gradePointFormulaID);
  49. }
  50. /// <summary>
  51. /// 新增、修改绩点公式设置
  52. /// </summary>
  53. /// <param name="gradePointFormulaView"></param>
  54. public void GradePointFormulaAdd(GradePointFormulaView gradePointFormulaView)
  55. {
  56. try
  57. {
  58. ER_GradePointFormula gradePointFormula = null;
  59. if (gradePointFormulaView.GradePointFormulaID == null || gradePointFormulaView.GradePointFormulaID == Guid.Empty)
  60. {
  61. gradePointFormula = new ER_GradePointFormula();
  62. gradePointFormula.GradePointFormulaID = Guid.NewGuid();
  63. gradePointFormula.Name = gradePointFormulaView.Name;
  64. gradePointFormula.GradePointlimit = gradePointFormulaView.GradePointlimit;
  65. gradePointFormula.GradePointFloor = gradePointFormulaView.GradePointFloor;
  66. SetNewStatus(gradePointFormula);
  67. UnitOfWork.Add(gradePointFormula);
  68. }
  69. else
  70. {
  71. gradePointFormula = GetGradePointFormula(gradePointFormulaView.GradePointFormulaID);
  72. if (gradePointFormula == null)
  73. throw new Exception("未找到相对应的成绩绩点公式设置!");
  74. gradePointFormula.Name = gradePointFormulaView.Name;
  75. gradePointFormula.GradePointlimit = gradePointFormulaView.GradePointlimit;
  76. gradePointFormula.GradePointFloor = gradePointFormulaView.GradePointFloor;
  77. SetModifyStatus(gradePointFormula);
  78. }
  79. UnitOfWork.Commit();
  80. }
  81. catch (Exception)
  82. {
  83. throw;
  84. }
  85. }
  86. /// <summary>
  87. /// 删除
  88. /// </summary>
  89. /// <param name="gradePointFormulaIDs"></param>
  90. public void GradePointFormulaDelete(List<Guid> gradePointFormulaIDs)
  91. {
  92. try
  93. {
  94. if (gradePointFormulaIDs.Count > 0)
  95. {
  96. UnitOfWork.Delete<ER_GradePointFormula>(x => gradePointFormulaIDs.Contains(x.GradePointFormulaID));
  97. }
  98. }
  99. catch (Exception)
  100. {
  101. throw;
  102. }
  103. }
  104. }
  105. }