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.
 
 
 
 
 
 

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