CreditFormulaServices.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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 CreditFormulaServices : BaseServices, ICreditFormulaServices
  13. {
  14. public CreditFormulaRepository creditFormulaRepository { 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_CreditFormula> GetCreditFormulaGrid(string name, int pageIndex, int pageSize)
  23. {
  24. var query = creditFormulaRepository.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_CreditFormula>(pageIndex, pageSize);
  28. }
  29. /// <summary>
  30. /// 成绩学分公式设置
  31. /// </summary>
  32. /// <param name="name"></param>
  33. /// <returns></returns>
  34. public List<Entities.ER_CreditFormula> GetCreditFormulaList(string name)
  35. {
  36. var query = creditFormulaRepository.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="creditFormulaID"></param>
  45. /// <returns></returns>
  46. public Entities.ER_CreditFormula GetCreditFormula(Guid? creditFormulaID)
  47. {
  48. return creditFormulaRepository.GetSingle(x => x.CreditFormulaID == creditFormulaID);
  49. }
  50. /// <summary>
  51. /// 添加
  52. /// </summary>
  53. /// <param name="scoreFormulaView"></param>
  54. public void CreditFormulaAdd(CreditFormulaView creditFormulaView)
  55. {
  56. try
  57. {
  58. ER_CreditFormula creditFormula = null;
  59. if (creditFormulaView.CreditFormulaID == null || creditFormulaView.CreditFormulaID == Guid.Empty)
  60. {
  61. creditFormula = new ER_CreditFormula();
  62. creditFormula.CreditFormulaID = Guid.NewGuid();
  63. creditFormula.Name = creditFormulaView.Name;
  64. creditFormula.Scores = creditFormulaView.Scores;
  65. SetNewStatus(creditFormula);
  66. UnitOfWork.Add(creditFormula);
  67. }
  68. else
  69. {
  70. creditFormula = GetCreditFormula(creditFormulaView.CreditFormulaID);
  71. if(creditFormula == null)
  72. throw new Exception("未找到相对应的成绩学分公式设置!");
  73. creditFormula.Name = creditFormulaView.Name;
  74. creditFormula.Scores = creditFormulaView.Scores;
  75. SetModifyStatus(creditFormula);
  76. }
  77. UnitOfWork.Commit();
  78. }
  79. catch (Exception)
  80. {
  81. throw;
  82. }
  83. }
  84. /// <summary>
  85. /// 根据成绩公式设置ID查询明细
  86. /// </summary>
  87. /// <param name="scoreFormulaID"></param>
  88. /// <returns></returns>
  89. public void CreditFormulaDelete(List<Guid> creditFormulaIDs)
  90. {
  91. try
  92. {
  93. if (creditFormulaIDs.Count > 0)
  94. {
  95. UnitOfWork.Delete<ER_CreditFormula>(x => creditFormulaIDs.Contains(x.CreditFormulaID));
  96. }
  97. }
  98. catch (Exception)
  99. {
  100. throw;
  101. }
  102. }
  103. }
  104. }