您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 
 

181 行
6.0 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. using Learun.Application.TwoDevelopment.EducationalAdministration;
  9. namespace Learun.Application.TwoDevelopment.LogisticsManagement
  10. {
  11. /// <summary>
  12. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  13. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  14. /// 创 建:超级管理员
  15. /// 日 期:2020-05-19 12:01
  16. /// 描 述:兵役登记
  17. /// </summary>
  18. public class MSRMilitaryServiceRegistrationService : RepositoryFactory
  19. {
  20. #region 获取数据
  21. /// <summary>
  22. /// 获取页面显示列表数据
  23. /// <summary>
  24. /// <param name="queryJson">查询参数</param>
  25. /// <returns></returns>
  26. public IEnumerable<MSRMilitaryServiceRegistrationEntity> GetPageList(Pagination pagination, string queryJson)
  27. {
  28. try
  29. {
  30. var strSql = new StringBuilder();
  31. strSql.Append("SELECT ");
  32. strSql.Append(@"
  33. t.ID,
  34. t.MajorNo,
  35. t.ClassNo,
  36. t.StuNo,
  37. t.Screenshot,
  38. t.Remark,
  39. t.YearNo
  40. ");
  41. strSql.Append(" FROM MSRMilitaryServiceRegistration t ");
  42. strSql.Append(" WHERE 1=1 ");
  43. var queryParam = queryJson.ToJObject();
  44. // 虚拟参数
  45. var dp = new DynamicParameters(new { });
  46. if (!queryParam["YearNo"].IsEmpty())
  47. {
  48. dp.Add("YearNo", "%" + queryParam["YearNo"].ToString() + "%", DbType.String);
  49. strSql.Append(" AND t.YearNo Like @YearNo ");
  50. }
  51. if (!queryParam["MajorNo"].IsEmpty())
  52. {
  53. dp.Add("MajorNo",queryParam["MajorNo"].ToString(), DbType.String);
  54. strSql.Append(" AND t.MajorNo = @MajorNo ");
  55. }
  56. if (!queryParam["ClassNo"].IsEmpty())
  57. {
  58. dp.Add("ClassNo",queryParam["ClassNo"].ToString(), DbType.String);
  59. strSql.Append(" AND t.ClassNo = @ClassNo ");
  60. }
  61. if (!queryParam["StuNo"].IsEmpty())
  62. {
  63. dp.Add("StuNo",queryParam["StuNo"].ToString(), DbType.String);
  64. strSql.Append(" AND t.StuNo = @StuNo ");
  65. }
  66. return this.BaseRepository("CollegeMIS").FindList<MSRMilitaryServiceRegistrationEntity>(strSql.ToString(),dp, pagination);
  67. }
  68. catch (Exception ex)
  69. {
  70. if (ex is ExceptionEx)
  71. {
  72. throw;
  73. }
  74. else
  75. {
  76. throw ExceptionEx.ThrowServiceException(ex);
  77. }
  78. }
  79. }
  80. /// <summary>
  81. /// 获取MSRMilitaryServiceRegistration表实体数据
  82. /// <param name="keyValue">主键</param>
  83. /// <summary>
  84. /// <returns></returns>
  85. public MSRMilitaryServiceRegistrationEntity GetMSRMilitaryServiceRegistrationEntity(string keyValue)
  86. {
  87. try
  88. {
  89. return this.BaseRepository("CollegeMIS").FindEntity<MSRMilitaryServiceRegistrationEntity>(keyValue);
  90. }
  91. catch (Exception ex)
  92. {
  93. if (ex is ExceptionEx)
  94. {
  95. throw;
  96. }
  97. else
  98. {
  99. throw ExceptionEx.ThrowServiceException(ex);
  100. }
  101. }
  102. }
  103. #endregion
  104. #region 提交数据
  105. /// <summary>
  106. /// 删除实体数据
  107. /// <param name="keyValue">主键</param>
  108. /// <summary>
  109. /// <returns></returns>
  110. public void DeleteEntity(string keyValue)
  111. {
  112. try
  113. {
  114. this.BaseRepository("CollegeMIS").Delete<MSRMilitaryServiceRegistrationEntity>(t=>t.ID == keyValue);
  115. }
  116. catch (Exception ex)
  117. {
  118. if (ex is ExceptionEx)
  119. {
  120. throw;
  121. }
  122. else
  123. {
  124. throw ExceptionEx.ThrowServiceException(ex);
  125. }
  126. }
  127. }
  128. /// <summary>
  129. /// 保存实体数据(新增、修改)
  130. /// <param name="keyValue">主键</param>
  131. /// <summary>
  132. /// <returns></returns>
  133. public void SaveEntity(string keyValue, MSRMilitaryServiceRegistrationEntity entity)
  134. {
  135. try
  136. {
  137. if (!string.IsNullOrEmpty(keyValue))
  138. {
  139. entity.Modify(keyValue);
  140. this.BaseRepository("CollegeMIS").Update(entity);
  141. }
  142. else
  143. {
  144. //获取当前学生的名字、系、专业、班级
  145. var loginUser = LoginUserInfo.Get();
  146. var userEntity = this.BaseRepository("CollegeMIS")
  147. .FindEntity<StuInfoBasicEntity>(a => a.StuNo == loginUser.account);
  148. var aa = Common.GetSemesterAndYear();
  149. entity.StuNo = userEntity?.StuNo;
  150. entity.MajorNo = userEntity?.MajorNo;
  151. entity.ClassNo = userEntity?.ClassNo;
  152. entity.YearNo = aa.AcademicYearShort;
  153. entity.Create();
  154. this.BaseRepository("CollegeMIS").Insert(entity);
  155. }
  156. }
  157. catch (Exception ex)
  158. {
  159. if (ex is ExceptionEx)
  160. {
  161. throw;
  162. }
  163. else
  164. {
  165. throw ExceptionEx.ThrowServiceException(ex);
  166. }
  167. }
  168. }
  169. #endregion
  170. }
  171. }