You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

166 lines
4.9 KiB

  1. using Dapper;
  2. using Learun.DataBase.Repository;
  3. using Learun.Util;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Data;
  7. using System.Text;
  8. namespace Learun.Application.TwoDevelopment.EducationalAdministration
  9. {
  10. /// <summary>
  11. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  12. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  13. /// 创 建:超级管理员
  14. /// 日 期:2019-11-19 11:03
  15. /// 描 述:助学金管理
  16. /// </summary>
  17. public class StuGrantService : RepositoryFactory
  18. {
  19. #region 获取数据
  20. /// <summary>
  21. /// 获取页面显示列表数据
  22. /// <summary>
  23. /// <param name="queryJson">查询参数</param>
  24. /// <returns></returns>
  25. public IEnumerable<StuGrantEntity> GetPageList(Pagination pagination, string queryJson)
  26. {
  27. try
  28. {
  29. var strSql = new StringBuilder();
  30. strSql.Append("SELECT ");
  31. strSql.Append(@"
  32. t.ID,
  33. t.Year,
  34. t.Month,
  35. t.StudentID,
  36. t.Status,
  37. t.Price,
  38. t.ProcessID
  39. ");
  40. strSql.Append(" FROM StuGrant t ");
  41. strSql.Append(" WHERE 1=1 ");
  42. var queryParam = queryJson.ToJObject();
  43. // 虚拟参数
  44. var dp = new DynamicParameters(new { });
  45. if (!queryParam["StudentID"].IsEmpty())
  46. {
  47. dp.Add("StudentID",queryParam["StudentID"].ToString(), DbType.String);
  48. strSql.Append(" AND t.StudentID = @StudentID ");
  49. }
  50. if (!queryParam["Year"].IsEmpty())
  51. {
  52. dp.Add("Year",queryParam["Year"].ToString(), DbType.String);
  53. strSql.Append(" AND t.Year = @Year ");
  54. }
  55. if (!queryParam["Month"].IsEmpty())
  56. {
  57. dp.Add("Month",queryParam["Month"].ToString(), DbType.String);
  58. strSql.Append(" AND t.Month = @Month ");
  59. }
  60. return this.BaseRepository("CollegeMIS").FindList<StuGrantEntity>(strSql.ToString(),dp, pagination);
  61. }
  62. catch (Exception ex)
  63. {
  64. if (ex is ExceptionEx)
  65. {
  66. throw;
  67. }
  68. else
  69. {
  70. throw ExceptionEx.ThrowServiceException(ex);
  71. }
  72. }
  73. }
  74. /// <summary>
  75. /// 获取StuGrant表实体数据
  76. /// <param name="keyValue">主键</param>
  77. /// <summary>
  78. /// <returns></returns>
  79. public StuGrantEntity GetStuGrantEntity(string keyValue)
  80. {
  81. try
  82. {
  83. return this.BaseRepository("CollegeMIS").FindEntity<StuGrantEntity>(keyValue);
  84. }
  85. catch (Exception ex)
  86. {
  87. if (ex is ExceptionEx)
  88. {
  89. throw;
  90. }
  91. else
  92. {
  93. throw ExceptionEx.ThrowServiceException(ex);
  94. }
  95. }
  96. }
  97. #endregion
  98. #region 提交数据
  99. /// <summary>
  100. /// 删除实体数据
  101. /// <param name="keyValue">主键</param>
  102. /// <summary>
  103. /// <returns></returns>
  104. public void DeleteEntity(string keyValue)
  105. {
  106. try
  107. {
  108. this.BaseRepository("CollegeMIS").Delete<StuGrantEntity>(t=>t.ID == keyValue);
  109. }
  110. catch (Exception ex)
  111. {
  112. if (ex is ExceptionEx)
  113. {
  114. throw;
  115. }
  116. else
  117. {
  118. throw ExceptionEx.ThrowServiceException(ex);
  119. }
  120. }
  121. }
  122. /// <summary>
  123. /// 保存实体数据(新增、修改)
  124. /// <param name="keyValue">主键</param>
  125. /// <summary>
  126. /// <returns></returns>
  127. public void SaveEntity(string keyValue, StuGrantEntity entity)
  128. {
  129. try
  130. {
  131. if (!string.IsNullOrEmpty(keyValue))
  132. {
  133. entity.Modify(keyValue);
  134. this.BaseRepository("CollegeMIS").Update(entity);
  135. }
  136. else
  137. {
  138. entity.Create();
  139. this.BaseRepository("CollegeMIS").Insert(entity);
  140. }
  141. }
  142. catch (Exception ex)
  143. {
  144. if (ex is ExceptionEx)
  145. {
  146. throw;
  147. }
  148. else
  149. {
  150. throw ExceptionEx.ThrowServiceException(ex);
  151. }
  152. }
  153. }
  154. #endregion
  155. }
  156. }