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.
 
 
 
 
 
 

203 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:20
  15. /// 描 述:代扣方式管理
  16. /// </summary>
  17. public class FinaReplaceModeService : RepositoryFactory
  18. {
  19. #region 获取数据
  20. /// <summary>
  21. /// 获取页面显示列表数据
  22. /// <summary>
  23. /// <param name="queryJson">查询参数</param>
  24. /// <returns></returns>
  25. public IEnumerable<FinaReplaceModeEntity> GetPageList(Pagination pagination, string queryJson)
  26. {
  27. try
  28. {
  29. var strSql = new StringBuilder();
  30. strSql.Append("SELECT ");
  31. strSql.Append(@"
  32. t.ReplaceModeID,
  33. t.ReplaceModeName,
  34. t.Remark,
  35. t.CreateDate,
  36. t.CreateUserId,
  37. t.CreateUserName
  38. ");
  39. strSql.Append(" FROM FinaReplaceMode t ");
  40. strSql.Append(" WHERE 1=1 ");
  41. var queryParam = queryJson.ToJObject();
  42. // 虚拟参数
  43. var dp = new DynamicParameters(new { });
  44. if (!queryParam["ReplaceModeName"].IsEmpty())
  45. {
  46. dp.Add("ReplaceModeName", "%" + queryParam["ReplaceModeName"].ToString() + "%", DbType.String);
  47. strSql.Append(" AND t.ReplaceModeName Like @ReplaceModeName ");
  48. }
  49. return this.BaseRepository("CollegeMIS").FindList<FinaReplaceModeEntity>(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. /// <returns></returns>
  67. public IEnumerable<FinaReplaceModeEntity> GetList(string keyword)
  68. {
  69. try
  70. {
  71. return this.BaseRepository("CollegeMIS").FindList<FinaReplaceModeEntity>("select * from FinaReplaceMode where 1=1 and ReplaceModeName like '%" + keyword + "%' ");
  72. }
  73. catch (Exception ex)
  74. {
  75. if (ex is ExceptionEx)
  76. {
  77. throw;
  78. }
  79. else
  80. {
  81. throw ExceptionEx.ThrowServiceException(ex);
  82. }
  83. }
  84. }
  85. /// <summary>
  86. /// 获取FinaReplaceMode表实体数据
  87. /// <param name="keyValue">主键</param>
  88. /// <summary>
  89. /// <returns></returns>
  90. public FinaReplaceModeEntity GetFinaReplaceModeEntity(string keyValue)
  91. {
  92. try
  93. {
  94. var keyvalue = Convert.ToInt32(keyValue);
  95. return this.BaseRepository("CollegeMIS").FindEntity<FinaReplaceModeEntity>(keyvalue);
  96. }
  97. catch (Exception ex)
  98. {
  99. if (ex is ExceptionEx)
  100. {
  101. throw;
  102. }
  103. else
  104. {
  105. throw ExceptionEx.ThrowServiceException(ex);
  106. }
  107. }
  108. }
  109. /// <summary>
  110. /// 获取FinaReplaceModeEntity表实体数据
  111. /// <param name="replaceModeName">代扣方式名称</param>
  112. /// <summary>
  113. /// <returns></returns>
  114. public FinaReplaceModeEntity GetFinaReplaceModeEntityByReplaceModeName(string replaceModeName)
  115. {
  116. try
  117. {
  118. return this.BaseRepository("CollegeMIS").FindEntity<FinaReplaceModeEntity>(x => x.ReplaceModeName.Trim() == replaceModeName.Trim());
  119. }
  120. catch (Exception ex)
  121. {
  122. if (ex is ExceptionEx)
  123. {
  124. throw;
  125. }
  126. else
  127. {
  128. throw ExceptionEx.ThrowServiceException(ex);
  129. }
  130. }
  131. }
  132. #endregion
  133. #region 提交数据
  134. /// <summary>
  135. /// 删除实体数据
  136. /// <param name="keyValue">主键</param>
  137. /// <summary>
  138. /// <returns></returns>
  139. public void DeleteEntity(string keyValue)
  140. {
  141. try
  142. {
  143. var keyvalue = Convert.ToInt32(keyValue);
  144. this.BaseRepository("CollegeMIS").Delete<FinaReplaceModeEntity>(t=>t.ReplaceModeID == keyvalue);
  145. }
  146. catch (Exception ex)
  147. {
  148. if (ex is ExceptionEx)
  149. {
  150. throw;
  151. }
  152. else
  153. {
  154. throw ExceptionEx.ThrowServiceException(ex);
  155. }
  156. }
  157. }
  158. /// <summary>
  159. /// 保存实体数据(新增、修改)
  160. /// <param name="keyValue">主键</param>
  161. /// <summary>
  162. /// <returns></returns>
  163. public void SaveEntity(string keyValue, FinaReplaceModeEntity entity)
  164. {
  165. try
  166. {
  167. if (!string.IsNullOrEmpty(keyValue))
  168. {
  169. entity.Modify(keyValue);
  170. this.BaseRepository("CollegeMIS").Update(entity);
  171. }
  172. else
  173. {
  174. entity.Create();
  175. this.BaseRepository("CollegeMIS").Insert(entity);
  176. }
  177. }
  178. catch (Exception ex)
  179. {
  180. if (ex is ExceptionEx)
  181. {
  182. throw;
  183. }
  184. else
  185. {
  186. throw ExceptionEx.ThrowServiceException(ex);
  187. }
  188. }
  189. }
  190. #endregion
  191. }
  192. }