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.

StuInfoFreshSusService.cs 6.1 KiB

4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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. /// 日 期:2020-08-12 14:37
  15. /// 描 述:校服补订管理
  16. /// </summary>
  17. public class StuInfoFreshSusService : RepositoryFactory
  18. {
  19. #region 获取数据
  20. /// <summary>
  21. /// 获取页面显示列表数据
  22. /// <summary>
  23. /// <param name="queryJson">查询参数</param>
  24. /// <returns></returns>
  25. public IEnumerable<StuInfoFreshSusEntity> 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.HighWeight,
  34. t.CSize,
  35. t.ApplyTime,
  36. t.IsGet,
  37. t.StuID,
  38. t.IsPay
  39. ");
  40. strSql.Append(" FROM StuInfoFreshSus t ");
  41. strSql.Append(" WHERE 1=1 ");
  42. var queryParam = queryJson.ToJObject();
  43. // 虚拟参数
  44. var dp = new DynamicParameters(new { });
  45. if (!queryParam["StuID"].IsEmpty())
  46. {
  47. strSql.Append(" and t.StuID = @StuID ");
  48. dp.Add("StuID", queryParam["StuID"].ToString(), DbType.String);
  49. }
  50. return this.BaseRepository("CollegeMIS").FindList<StuInfoFreshSusEntity>(strSql.ToString(), dp, pagination);
  51. }
  52. catch (Exception ex)
  53. {
  54. if (ex is ExceptionEx)
  55. {
  56. throw;
  57. }
  58. else
  59. {
  60. throw ExceptionEx.ThrowServiceException(ex);
  61. }
  62. }
  63. }
  64. /// <summary>
  65. /// 获取StuInfoFreshSus表实体数据
  66. /// <param name="keyValue">主键</param>
  67. /// <summary>
  68. /// <returns></returns>
  69. public StuInfoFreshSusEntity GetStuInfoFreshSusEntity(string keyValue)
  70. {
  71. try
  72. {
  73. return this.BaseRepository("CollegeMIS").FindEntity<StuInfoFreshSusEntity>(keyValue);
  74. }
  75. catch (Exception ex)
  76. {
  77. if (ex is ExceptionEx)
  78. {
  79. throw;
  80. }
  81. else
  82. {
  83. throw ExceptionEx.ThrowServiceException(ex);
  84. }
  85. }
  86. }
  87. #endregion
  88. #region 提交数据
  89. /// <summary>
  90. /// 删除实体数据
  91. /// <param name="keyValue">主键</param>
  92. /// <summary>
  93. /// <returns></returns>
  94. public void DeleteEntity(string keyValue)
  95. {
  96. try
  97. {
  98. this.BaseRepository("CollegeMIS").Delete<StuInfoFreshSusEntity>(t => t.ID == 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. public void GetUniform(string keyValue, bool status)
  113. {
  114. try
  115. {
  116. var sql = "";
  117. if (status)
  118. {
  119. sql = $"UPDATE dbo.StuInfoFreshSus SET IsGet=1 WHERE ID='{keyValue}'";
  120. }
  121. else
  122. {
  123. sql = $"UPDATE dbo.StuInfoFreshSus SET IsGet=0 WHERE ID='{keyValue}'";
  124. }
  125. this.BaseRepository("CollegeMIS").ExecuteBySql(sql);
  126. }
  127. catch (Exception ex)
  128. {
  129. if (ex is ExceptionEx)
  130. {
  131. throw;
  132. }
  133. else
  134. {
  135. throw ExceptionEx.ThrowServiceException(ex);
  136. }
  137. }
  138. }
  139. public void PayUniform(string keyValue, bool status)
  140. {
  141. try
  142. {
  143. var sql = "";
  144. if (status)
  145. {
  146. sql = $"UPDATE dbo.StuInfoFreshSus SET IsPay=1 WHERE ID='{keyValue}'";
  147. }
  148. else
  149. {
  150. sql = $"UPDATE dbo.StuInfoFreshSus SET IsPay=0 WHERE ID='{keyValue}'";
  151. }
  152. this.BaseRepository("CollegeMIS").ExecuteBySql(sql);
  153. }
  154. catch (Exception ex)
  155. {
  156. if (ex is ExceptionEx)
  157. {
  158. throw;
  159. }
  160. else
  161. {
  162. throw ExceptionEx.ThrowServiceException(ex);
  163. }
  164. }
  165. }
  166. /// <summary>
  167. /// 保存实体数据(新增、修改)
  168. /// <param name="keyValue">主键</param>
  169. /// <summary>
  170. /// <returns></returns>
  171. public void SaveEntity(string keyValue, StuInfoFreshSusEntity entity)
  172. {
  173. try
  174. {
  175. if (!string.IsNullOrEmpty(keyValue))
  176. {
  177. entity.Modify(keyValue);
  178. this.BaseRepository("CollegeMIS").Update(entity);
  179. }
  180. else
  181. {
  182. entity.Create();
  183. this.BaseRepository("CollegeMIS").Insert(entity);
  184. }
  185. }
  186. catch (Exception ex)
  187. {
  188. if (ex is ExceptionEx)
  189. {
  190. throw;
  191. }
  192. else
  193. {
  194. throw ExceptionEx.ThrowServiceException(ex);
  195. }
  196. }
  197. }
  198. #endregion
  199. }
  200. }