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.
 
 
 
 
 
 

204 lines
6.2 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.ReceiveSendFeeManagement
  9. {
  10. /// <summary>
  11. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  12. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  13. /// 创 建:超级管理员
  14. /// 日 期:2019-06-05 16:52
  15. /// 描 述:收退费类别管理
  16. /// </summary>
  17. public class FinaRefundItemService : RepositoryFactory
  18. {
  19. #region 获取数据
  20. /// <summary>
  21. /// 获取页面显示列表数据
  22. /// <summary>
  23. /// <param name="queryJson">查询参数</param>
  24. /// <returns></returns>
  25. public IEnumerable<FinaRefundItemEntity> GetPageList(Pagination pagination, string queryJson)
  26. {
  27. try
  28. {
  29. var strSql = new StringBuilder();
  30. strSql.Append("SELECT ");
  31. strSql.Append(@"
  32. t.RefundItemId,
  33. t.RefundItemName,
  34. t.Remark,
  35. t.CreateDate,
  36. t.CreateUserId,
  37. t.CreateUserName
  38. ");
  39. strSql.Append(" FROM FinaRefundItem t ");
  40. strSql.Append(" WHERE 1=1 ");
  41. var queryParam = queryJson.ToJObject();
  42. // 虚拟参数
  43. var dp = new DynamicParameters(new { });
  44. if (!queryParam["RefundItemName"].IsEmpty())
  45. {
  46. dp.Add("RefundItemName", "%" + queryParam["RefundItemName"].ToString() + "%", DbType.String);
  47. strSql.Append(" AND t.RefundItemName Like @RefundItemName ");
  48. }
  49. return this.BaseRepository("CollegeMIS").FindList<FinaRefundItemEntity>(strSql.ToString(),dp, pagination);
  50. }
  51. catch (Exception ex)
  52. {
  53. if (ex is ExceptionEx)
  54. {
  55. throw;
  56. }
  57. else
  58. {
  59. throw ExceptionEx.ThrowServiceException(ex);
  60. }
  61. }
  62. }
  63. /// <summary>
  64. /// 获取页面显示列表数据
  65. /// <summary>
  66. /// <param name="keyword">搜索关键字</param>
  67. /// <returns></returns>
  68. public IEnumerable<FinaRefundItemEntity> GetList(string keyword)
  69. {
  70. try
  71. {
  72. return this.BaseRepository("CollegeMIS").FindList<FinaRefundItemEntity>("select * from FinaRefundItem where 1=1 and RefundItemName like '%" + keyword + "%' ");
  73. }
  74. catch (Exception ex)
  75. {
  76. if (ex is ExceptionEx)
  77. {
  78. throw;
  79. }
  80. else
  81. {
  82. throw ExceptionEx.ThrowServiceException(ex);
  83. }
  84. }
  85. }
  86. /// <summary>
  87. /// 获取FinaRefundItem表实体数据
  88. /// <param name="keyValue">主键</param>
  89. /// <summary>
  90. /// <returns></returns>
  91. public FinaRefundItemEntity GetFinaRefundItemEntity(string keyValue)
  92. {
  93. try
  94. {
  95. var keyvalue = Convert.ToInt32(keyValue);
  96. return this.BaseRepository("CollegeMIS").FindEntity<FinaRefundItemEntity>(keyvalue);
  97. }
  98. catch (Exception ex)
  99. {
  100. if (ex is ExceptionEx)
  101. {
  102. throw;
  103. }
  104. else
  105. {
  106. throw ExceptionEx.ThrowServiceException(ex);
  107. }
  108. }
  109. }
  110. /// <summary>
  111. /// 获取FinaRefundItemEntity表实体数据
  112. /// <param name="refundItemName">费用类别名称</param>
  113. /// <summary>
  114. /// <returns></returns>
  115. public FinaRefundItemEntity GetFinaRefundItemEntityByRefundItemName(string refundItemName)
  116. {
  117. try
  118. {
  119. return this.BaseRepository("CollegeMIS").FindEntity<FinaRefundItemEntity>(x => x.RefundItemName.Trim() == refundItemName.Trim());
  120. }
  121. catch (Exception ex)
  122. {
  123. if (ex is ExceptionEx)
  124. {
  125. throw;
  126. }
  127. else
  128. {
  129. throw ExceptionEx.ThrowServiceException(ex);
  130. }
  131. }
  132. }
  133. #endregion
  134. #region 提交数据
  135. /// <summary>
  136. /// 删除实体数据
  137. /// <param name="keyValue">主键</param>
  138. /// <summary>
  139. /// <returns></returns>
  140. public void DeleteEntity(string keyValue)
  141. {
  142. try
  143. {
  144. var keyvalue = Convert.ToInt32(keyValue);
  145. this.BaseRepository("CollegeMIS").Delete<FinaRefundItemEntity>(t=>t.RefundItemId == keyvalue);
  146. }
  147. catch (Exception ex)
  148. {
  149. if (ex is ExceptionEx)
  150. {
  151. throw;
  152. }
  153. else
  154. {
  155. throw ExceptionEx.ThrowServiceException(ex);
  156. }
  157. }
  158. }
  159. /// <summary>
  160. /// 保存实体数据(新增、修改)
  161. /// <param name="keyValue">主键</param>
  162. /// <summary>
  163. /// <returns></returns>
  164. public void SaveEntity(string keyValue, FinaRefundItemEntity entity)
  165. {
  166. try
  167. {
  168. if (!string.IsNullOrEmpty(keyValue))
  169. {
  170. entity.Modify(keyValue);
  171. this.BaseRepository("CollegeMIS").Update(entity);
  172. }
  173. else
  174. {
  175. entity.Create();
  176. this.BaseRepository("CollegeMIS").Insert(entity);
  177. }
  178. }
  179. catch (Exception ex)
  180. {
  181. if (ex is ExceptionEx)
  182. {
  183. throw;
  184. }
  185. else
  186. {
  187. throw ExceptionEx.ThrowServiceException(ex);
  188. }
  189. }
  190. }
  191. #endregion
  192. }
  193. }