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.
 
 
 
 
 
 

249 lines
7.4 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.Linq;
  8. using System.Text;
  9. namespace Learun.Application.TwoDevelopment.EducationalAdministration
  10. {
  11. /// <summary>
  12. /// 版 本 Learun-ADMS V7.0.6 力软敏捷开发框架
  13. /// Copyright (c) 2013-2020 力软信息技术(苏州)有限公司
  14. /// 创 建:超级管理员
  15. /// 日 期:2021-09-17 11:30
  16. /// 描 述:学生学期注册
  17. /// </summary>
  18. public class StuInfoSemsterService : RepositoryFactory
  19. {
  20. #region 构造函数和属性
  21. private string fieldSql;
  22. /// <summary>
  23. /// 构造方法
  24. /// </summary>
  25. public StuInfoSemsterService()
  26. {
  27. fieldSql = @"
  28. t.StuId,
  29. t.StuNo,
  30. t.StuName,
  31. t.MajorNo,
  32. t.ClassNo,
  33. t.AcademicYearNo,
  34. t.Semester,
  35. t.Status,
  36. t.TIME
  37. ";
  38. }
  39. #endregion
  40. #region 获取数据
  41. /// <summary>
  42. /// 获取列表数据
  43. /// </summary>
  44. /// <param name="queryJson">条件参数</param>
  45. /// <returns></returns>
  46. public IEnumerable<StuInfoSemsterEntity> GetList(string queryJson)
  47. {
  48. try
  49. {
  50. //参考写法
  51. //var queryParam = queryJson.ToJObject();
  52. // 虚拟参数
  53. //var dp = new DynamicParameters(new { });
  54. //dp.Add("startTime", queryParam["StartTime"].ToDate(), DbType.DateTime);
  55. var strSql = new StringBuilder();
  56. strSql.Append("SELECT ");
  57. strSql.Append(fieldSql);
  58. strSql.Append(" FROM StuInfoSemster t ");
  59. return this.BaseRepository("CollegeMIS").FindList<StuInfoSemsterEntity>(strSql.ToString());
  60. }
  61. catch (Exception ex)
  62. {
  63. if (ex is ExceptionEx)
  64. {
  65. throw;
  66. }
  67. else
  68. {
  69. throw ExceptionEx.ThrowServiceException(ex);
  70. }
  71. }
  72. }
  73. /// <summary>
  74. /// 获取列表分页数据
  75. /// </summary>
  76. /// <param name="pagination">分页参数</param>
  77. /// <param name="queryJson">条件参数</param>
  78. /// <returns></returns>
  79. public IEnumerable<StuInfoSemsterEntity> GetPageList(Pagination pagination, string queryJson)
  80. {
  81. try
  82. {
  83. var strSql = new StringBuilder();
  84. strSql.Append("SELECT ");
  85. strSql.Append(fieldSql);
  86. strSql.Append(" FROM StuInfoSemster t ");
  87. return this.BaseRepository("CollegeMIS").FindList<StuInfoSemsterEntity>(strSql.ToString(), pagination);
  88. }
  89. catch (Exception ex)
  90. {
  91. if (ex is ExceptionEx)
  92. {
  93. throw;
  94. }
  95. else
  96. {
  97. throw ExceptionEx.ThrowServiceException(ex);
  98. }
  99. }
  100. }
  101. /// <summary>
  102. /// 获取实体数据
  103. /// </summary>
  104. /// <param name="keyValue">主键</param>
  105. /// <returns></returns>
  106. public StuInfoSemsterEntity GetEntity(string keyValue)
  107. {
  108. try
  109. {
  110. return this.BaseRepository("CollegeMIS").FindEntity<StuInfoSemsterEntity>(keyValue);
  111. }
  112. catch (Exception ex)
  113. {
  114. if (ex is ExceptionEx)
  115. {
  116. throw;
  117. }
  118. else
  119. {
  120. throw ExceptionEx.ThrowServiceException(ex);
  121. }
  122. }
  123. }
  124. #endregion
  125. #region 提交数据
  126. /// <summary>
  127. /// 删除实体数据
  128. /// </summary>
  129. /// <param name="keyValue">主键</param>
  130. public void DeleteEntity(string keyValue)
  131. {
  132. try
  133. {
  134. this.BaseRepository("CollegeMIS").Delete<StuInfoSemsterEntity>(t => t.StuId == keyValue);
  135. }
  136. catch (Exception ex)
  137. {
  138. if (ex is ExceptionEx)
  139. {
  140. throw;
  141. }
  142. else
  143. {
  144. throw ExceptionEx.ThrowServiceException(ex);
  145. }
  146. }
  147. }
  148. /// <summary>
  149. /// 保存实体数据(新增、修改)
  150. /// <param name="keyValue">主键</param>
  151. /// <param name="entity">实体</param>
  152. /// </summary>
  153. public void SaveEntity(string keyValue, StuInfoSemsterEntity entity)
  154. {
  155. try
  156. {
  157. if (!string.IsNullOrEmpty(keyValue))
  158. {
  159. entity.Modify(keyValue);
  160. this.BaseRepository("CollegeMIS").Update(entity);
  161. }
  162. else
  163. {
  164. entity.Create();
  165. this.BaseRepository("CollegeMIS").Insert(entity);
  166. }
  167. }
  168. catch (Exception ex)
  169. {
  170. if (ex is ExceptionEx)
  171. {
  172. throw;
  173. }
  174. else
  175. {
  176. throw ExceptionEx.ThrowServiceException(ex);
  177. }
  178. }
  179. }
  180. #endregion
  181. #region 扩展数据
  182. /// 注册
  183. /// </summary>
  184. /// <param name="keyValue">主键</param>
  185. public void ZhuCe(string keyValue, string status)
  186. {
  187. var db = BaseRepository("CollegeMIS").BeginTrans();
  188. try
  189. {
  190. List<string> Ids = keyValue.Split(',').ToList();
  191. List<StuInfoSemsterEntity> StuInfoEntity = new List<StuInfoSemsterEntity>();
  192. if (status == "1")
  193. {
  194. foreach (var item in Ids)
  195. {
  196. var list = this.BaseRepository("CollegeMIS").FindEntity<StuInfoSemsterEntity>(x => x.StuId == item);
  197. if (list != null)
  198. {
  199. list.Status = "1";
  200. list.TIME = DateTime.Now;
  201. StuInfoEntity.Add(list);
  202. }
  203. }
  204. }
  205. else
  206. {
  207. foreach (var item in Ids)
  208. {
  209. var list = this.BaseRepository("CollegeMIS").FindEntity<StuInfoSemsterEntity>(x => x.StuId == item);
  210. if (list != null)
  211. {
  212. list.Status = "0";
  213. list.TIME = null;
  214. StuInfoEntity.Add(list);
  215. }
  216. }
  217. }
  218. db.Update(StuInfoEntity);
  219. db.Commit();
  220. }
  221. catch (Exception ex)
  222. {
  223. if (ex is ExceptionEx)
  224. {
  225. throw;
  226. }
  227. else
  228. {
  229. throw ExceptionEx.ThrowServiceException(ex);
  230. }
  231. }
  232. }
  233. #endregion
  234. }
  235. }