Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 
 

179 linhas
6.1 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 MSRMilitaryServiceRegistrationTranService : RepositoryFactory
  19. {
  20. #region 获取数据
  21. /// <summary>
  22. /// 获取页面显示列表数据
  23. /// <summary>
  24. /// <param name="queryJson">查询参数</param>
  25. /// <returns></returns>
  26. public IEnumerable<MSRMilitaryServiceRegistrationTranEntity> GetPageList(Pagination pagination, string queryJson)
  27. {
  28. try
  29. {
  30. var strSql = new StringBuilder();
  31. strSql.Append("SELECT ");
  32. strSql.Append(@" t.* ");
  33. strSql.Append(" FROM MSRMilitaryServiceRegistrationTran t ");
  34. strSql.Append(" WHERE 1=1 ");
  35. var queryParam = queryJson.ToJObject();
  36. // 虚拟参数
  37. var dp = new DynamicParameters(new { });
  38. if (!queryParam["YearNo"].IsEmpty())
  39. {
  40. dp.Add("YearNo", "%" + queryParam["YearNo"].ToString() + "%", DbType.String);
  41. strSql.Append(" AND t.YearNo Like @YearNo ");
  42. }
  43. if (!queryParam["DeptNo"].IsEmpty())
  44. {
  45. dp.Add("DeptNo",queryParam["DeptNo"].ToString(), DbType.String);
  46. strSql.Append(" AND t.DeptNo = @DeptNo ");
  47. }
  48. if (!queryParam["MajorNo"].IsEmpty())
  49. {
  50. dp.Add("MajorNo",queryParam["MajorNo"].ToString(), DbType.String);
  51. strSql.Append(" AND t.MajorNo = @MajorNo ");
  52. }
  53. if (!queryParam["ClassNo"].IsEmpty())
  54. {
  55. dp.Add("ClassNo",queryParam["ClassNo"].ToString(), DbType.String);
  56. strSql.Append(" AND t.ClassNo = @ClassNo ");
  57. }
  58. if (!queryParam["StuNo"].IsEmpty())
  59. {
  60. dp.Add("StuNo",queryParam["StuNo"].ToString(), DbType.String);
  61. strSql.Append(" AND t.StuNo = @StuNo ");
  62. }
  63. return this.BaseRepository("CollegeMIS").FindList<MSRMilitaryServiceRegistrationTranEntity>(strSql.ToString(),dp, pagination);
  64. }
  65. catch (Exception ex)
  66. {
  67. if (ex is ExceptionEx)
  68. {
  69. throw;
  70. }
  71. else
  72. {
  73. throw ExceptionEx.ThrowServiceException(ex);
  74. }
  75. }
  76. }
  77. /// <summary>
  78. /// 获取MSRMilitaryServiceRegistrationTran表实体数据
  79. /// <param name="keyValue">主键</param>
  80. /// <summary>
  81. /// <returns></returns>
  82. public MSRMilitaryServiceRegistrationTranEntity GetMSRMilitaryServiceRegistrationEntity(string keyValue)
  83. {
  84. try
  85. {
  86. return this.BaseRepository("CollegeMIS").FindEntity<MSRMilitaryServiceRegistrationTranEntity>(keyValue);
  87. }
  88. catch (Exception ex)
  89. {
  90. if (ex is ExceptionEx)
  91. {
  92. throw;
  93. }
  94. else
  95. {
  96. throw ExceptionEx.ThrowServiceException(ex);
  97. }
  98. }
  99. }
  100. #endregion
  101. #region 提交数据
  102. /// <summary>
  103. /// 删除实体数据
  104. /// <param name="keyValue">主键</param>
  105. /// <summary>
  106. /// <returns></returns>
  107. public void DeleteEntity(string keyValue)
  108. {
  109. try
  110. {
  111. this.BaseRepository("CollegeMIS").Delete<MSRMilitaryServiceRegistrationTranEntity>(t=>t.ID == keyValue);
  112. }
  113. catch (Exception ex)
  114. {
  115. if (ex is ExceptionEx)
  116. {
  117. throw;
  118. }
  119. else
  120. {
  121. throw ExceptionEx.ThrowServiceException(ex);
  122. }
  123. }
  124. }
  125. /// <summary>
  126. /// 保存实体数据(新增、修改)
  127. /// <param name="keyValue">主键</param>
  128. /// <summary>
  129. /// <returns></returns>
  130. public void SaveEntity(string keyValue, MSRMilitaryServiceRegistrationTranEntity entity)
  131. {
  132. try
  133. {
  134. if (!string.IsNullOrEmpty(keyValue))
  135. {
  136. entity.Modify(keyValue);
  137. this.BaseRepository("CollegeMIS").Update(entity);
  138. }
  139. else
  140. {
  141. //获取当前学生的名字、系、专业、班级
  142. var loginUser = LoginUserInfo.Get();
  143. var userEntity = this.BaseRepository("CollegeMIS")
  144. .FindEntity<StuInfoBasicEntity>(a => a.StuNo == loginUser.account);
  145. var aa = Common.GetSemesterAndYear();
  146. entity.StuNo = userEntity?.StuNo;
  147. entity.DeptNo = userEntity?.DeptNo;
  148. entity.MajorNo = userEntity?.MajorNo;
  149. entity.ClassNo = userEntity?.ClassNo;
  150. entity.YearNo = aa.AcademicYearShort;
  151. entity.Create();
  152. this.BaseRepository("CollegeMIS").Insert(entity);
  153. }
  154. }
  155. catch (Exception ex)
  156. {
  157. if (ex is ExceptionEx)
  158. {
  159. throw;
  160. }
  161. else
  162. {
  163. throw ExceptionEx.ThrowServiceException(ex);
  164. }
  165. }
  166. }
  167. #endregion
  168. }
  169. }