選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

StuPunishmentService.cs 8.6 KiB

4年前
4年前
4年前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  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.Linq;
  8. using System.Text;
  9. namespace Learun.Application.TwoDevelopment.EducationalAdministration
  10. {
  11. /// <summary>
  12. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  13. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  14. /// 创 建:超级管理员
  15. /// 日 期:2019-06-17 14:54
  16. /// 描 述:学生处分管理
  17. /// </summary>
  18. public class StuPunishmentService : RepositoryFactory
  19. {
  20. #region 获取数据
  21. /// <summary>
  22. /// 获取页面显示列表数据
  23. /// <summary>
  24. /// <param name="queryJson">查询参数</param>
  25. /// <returns></returns>
  26. public IEnumerable<StuPunishmentEntity> GetPageList(Pagination pagination, string queryJson)
  27. {
  28. try
  29. {
  30. var strSql = new StringBuilder();
  31. strSql.Append("SELECT t.* ");
  32. strSql.Append(" FROM StuPunishment t ");
  33. strSql.Append(" WHERE 1=1 ");
  34. var queryParam = queryJson.ToJObject();
  35. // 虚拟参数
  36. var dp = new DynamicParameters(new { });
  37. return this.BaseRepository("CollegeMIS").FindList<StuPunishmentEntity>(strSql.ToString(), dp, pagination);
  38. }
  39. catch (Exception ex)
  40. {
  41. if (ex is ExceptionEx)
  42. {
  43. throw;
  44. }
  45. else
  46. {
  47. throw ExceptionEx.ThrowServiceException(ex);
  48. }
  49. }
  50. }
  51. public IEnumerable<StuPunishmentEntity> GetAllList()
  52. {
  53. try
  54. {
  55. return this.BaseRepository("CollegeMIS").FindList<StuPunishmentEntity>();
  56. }
  57. catch (Exception ex)
  58. {
  59. if (ex is ExceptionEx)
  60. {
  61. throw;
  62. }
  63. else
  64. {
  65. throw ExceptionEx.ThrowServiceException(ex);
  66. }
  67. }
  68. }
  69. /// <summary>
  70. /// 获取StuPunishment表实体数据
  71. /// <param name="keyValue">主键</param>
  72. /// <summary>
  73. /// <returns></returns>
  74. public StuPunishmentEntity GetStuPunishmentEntity(string keyValue)
  75. {
  76. try
  77. {
  78. var keyvalue = Convert.ToInt32(keyValue);
  79. return this.BaseRepository("CollegeMIS").FindEntity<StuPunishmentEntity>(keyvalue);
  80. }
  81. catch (Exception ex)
  82. {
  83. if (ex is ExceptionEx)
  84. {
  85. throw;
  86. }
  87. else
  88. {
  89. throw ExceptionEx.ThrowServiceException(ex);
  90. }
  91. }
  92. }
  93. #endregion
  94. #region 提交数据
  95. /// <summary>
  96. /// 删除实体数据
  97. /// <param name="keyValue">主键</param>
  98. /// <summary>
  99. /// <returns></returns>
  100. public void DeleteEntity(string keyValue)
  101. {
  102. try
  103. {
  104. var keyvalue = Convert.ToInt32(keyValue);
  105. this.BaseRepository("CollegeMIS").Delete<StuPunishmentEntity>(t => t.Id == keyvalue);
  106. }
  107. catch (Exception ex)
  108. {
  109. if (ex is ExceptionEx)
  110. {
  111. throw;
  112. }
  113. else
  114. {
  115. throw ExceptionEx.ThrowServiceException(ex);
  116. }
  117. }
  118. }
  119. /// <summary>
  120. /// 保存实体数据(新增、修改)
  121. /// <param name="keyValue">主键</param>
  122. /// <summary>
  123. /// <returns></returns>
  124. public void SaveEntity(string keyValue, StuPunishmentEntity entity)
  125. {
  126. try
  127. {
  128. if (!string.IsNullOrEmpty(keyValue))
  129. {
  130. entity.Modify(keyValue);
  131. this.BaseRepository("CollegeMIS").Update(entity);
  132. }
  133. else
  134. {
  135. entity.Create();
  136. this.BaseRepository("CollegeMIS").Insert(entity);
  137. }
  138. }
  139. catch (Exception ex)
  140. {
  141. if (ex is ExceptionEx)
  142. {
  143. throw;
  144. }
  145. else
  146. {
  147. throw ExceptionEx.ThrowServiceException(ex);
  148. }
  149. }
  150. }
  151. #endregion
  152. #region 扩展数据
  153. /// <summary>
  154. /// 获取学年学期列表
  155. /// </summary>
  156. /// <returns></returns>
  157. public IEnumerable<WebHelper.YearGrade> GetAcademicAndSemesterList()
  158. {
  159. try
  160. {
  161. var aa = this.BaseRepository("CollegeMIS").FindList<StuPunishmentEntity>();
  162. var aaa = aa.GroupBy(x => new { x.AcademicYearNo, x.Semester }).Select(x => new WebHelper.YearGrade()
  163. {
  164. text = string.Format("{0}学年第{1}学期", x.Key.AcademicYearNo, x.Key.Semester),
  165. value = string.Format("{0},{1}", x.Key.AcademicYearNo, x.Key.Semester)
  166. });
  167. return aaa;
  168. }
  169. catch (Exception ex)
  170. {
  171. if (ex is ExceptionEx)
  172. {
  173. throw;
  174. }
  175. else
  176. {
  177. throw ExceptionEx.ThrowServiceException(ex);
  178. }
  179. }
  180. }
  181. /// <summary>
  182. /// 获取页面显示列表数据
  183. /// <summary>
  184. /// <param name="queryJson">查询参数</param>
  185. /// <returns></returns>
  186. public IEnumerable<StuPunishmentEntity> GetPunishmentListByStuNo(string acdemic, string semester, string stuNo)
  187. {
  188. try
  189. {
  190. var result = this.BaseRepository("CollegeMIS").FindList<StuPunishmentEntity>(x => x.AcademicYearNo == acdemic && x.Semester == semester && x.StuNo == stuNo);
  191. return result;
  192. }
  193. catch (Exception ex)
  194. {
  195. if (ex is ExceptionEx)
  196. {
  197. throw;
  198. }
  199. else
  200. {
  201. throw ExceptionEx.ThrowServiceException(ex);
  202. }
  203. }
  204. }
  205. /// <summary>
  206. /// 获取页面显示列表数据
  207. /// <summary>
  208. /// <param name="queryJson">查询参数</param>
  209. /// <returns></returns>
  210. public IEnumerable<StuPunishmentEntity> GetPunishmentListByStuNo(string stuNo)
  211. {
  212. try
  213. {
  214. var result = this.BaseRepository("CollegeMIS").FindList<StuPunishmentEntity>(x => x.StuNo == stuNo);
  215. return result;
  216. }
  217. catch (Exception ex)
  218. {
  219. if (ex is ExceptionEx)
  220. {
  221. throw;
  222. }
  223. else
  224. {
  225. throw ExceptionEx.ThrowServiceException(ex);
  226. }
  227. }
  228. }
  229. /// <summary>
  230. /// 解除处分
  231. /// <param name="keyValue">主键</param>
  232. /// <summary>
  233. /// <returns></returns>
  234. public void DoCancelPunish(string keyValue, bool status, string File, string CancelFileNo)
  235. {
  236. try
  237. {
  238. var userList = LoginUserInfo.Get();
  239. //var keyvalue = Convert.ToInt32(keyValue);
  240. if (status)
  241. {
  242. //解除处分
  243. this.BaseRepository("CollegeMIS").ExecuteBySql("update StuPunishment set IsCancelPunish=1,CancelUser='" + userList.realName + "',CancelPunishDate='" + DateTime.Now + "',CancelFilePatch='" + File + "',CancelFileNo = '" + CancelFileNo + "' where Id= " + keyValue);
  244. }
  245. else
  246. {
  247. //取消解除处分
  248. this.BaseRepository("CollegeMIS").ExecuteBySql("update StuPunishment set IsCancelPunish=0,CancelPunishDate=null,CancelUser=null,CancelFilePatch=null where Id= " + keyValue);
  249. }
  250. }
  251. catch (Exception ex)
  252. {
  253. if (ex is ExceptionEx)
  254. {
  255. throw;
  256. }
  257. else
  258. {
  259. throw ExceptionEx.ThrowServiceException(ex);
  260. }
  261. }
  262. }
  263. #endregion
  264. }
  265. }