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.
 
 
 
 
 
 

184 lines
5.8 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. namespace Learun.Application.TwoDevelopment.EducationalAdministration
  9. {
  10. /// <summary>
  11. /// 版 本 Learun-ADMS V7.0.6 力软敏捷开发框架
  12. /// Copyright (c) 2013-2020 力软信息技术(苏州)有限公司
  13. /// 创 建:超级管理员
  14. /// 日 期:2022-10-26 11:05
  15. /// 描 述:学生选课次数维护
  16. /// </summary>
  17. public class OLPElectiveStuSelectCountService : RepositoryFactory
  18. {
  19. #region 获取数据
  20. /// <summary>
  21. /// 获取页面显示列表数据
  22. /// </summary>
  23. /// <param name="pagination">查询参数</param>
  24. /// <param name="queryJson">查询参数</param>
  25. /// <returns></returns>
  26. public IEnumerable<OLPElectiveStuSelectCountEntity> 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.AcademicYearNo,
  35. t.Semester,
  36. t.DeptNo,
  37. t.SelectMaxCount
  38. ");
  39. strSql.Append(" FROM OLPElectiveStuSelectCount t ");
  40. strSql.Append(" WHERE 1=1 ");
  41. var queryParam = queryJson.ToJObject();
  42. // 虚拟参数
  43. var dp = new DynamicParameters(new { });
  44. if (!queryParam["AcademicYearNo"].IsEmpty())
  45. {
  46. dp.Add("AcademicYearNo", queryParam["AcademicYearNo"].ToString(), DbType.String);
  47. strSql.Append(" AND t.AcademicYearNo = @AcademicYearNo ");
  48. }
  49. if (!queryParam["Semester"].IsEmpty())
  50. {
  51. dp.Add("Semester", queryParam["Semester"].ToString(), DbType.String);
  52. strSql.Append(" AND t.Semester = @Semester ");
  53. }
  54. if (!queryParam["DeptNo"].IsEmpty())
  55. {
  56. dp.Add("DeptNo", queryParam["DeptNo"].ToString(), DbType.String);
  57. strSql.Append(" AND t.DeptNo = @DeptNo ");
  58. }
  59. return this.BaseRepository("CollegeMIS").FindList<OLPElectiveStuSelectCountEntity>(strSql.ToString(), dp, pagination);
  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. /// 获取OLPElectiveStuSelectCount表实体数据
  75. /// </summary>
  76. /// <param name="keyValue">主键</param>
  77. /// <returns></returns>
  78. public OLPElectiveStuSelectCountEntity GetOLPElectiveStuSelectCountEntity(string keyValue)
  79. {
  80. try
  81. {
  82. return this.BaseRepository("CollegeMIS").FindEntity<OLPElectiveStuSelectCountEntity>(keyValue);
  83. }
  84. catch (Exception ex)
  85. {
  86. if (ex is ExceptionEx)
  87. {
  88. throw;
  89. }
  90. else
  91. {
  92. throw ExceptionEx.ThrowServiceException(ex);
  93. }
  94. }
  95. }
  96. public OLPElectiveStuSelectCountEntity GetOLPElectiveStuSelectCountEntity(string AcademicYearNo,
  97. string Semester, string DeptNo)
  98. {
  99. try
  100. {
  101. return this.BaseRepository("CollegeMIS").FindEntity<OLPElectiveStuSelectCountEntity>(x => x.AcademicYearNo == AcademicYearNo && x.Semester == Semester && x.DeptNo == DeptNo);
  102. }
  103. catch (Exception ex)
  104. {
  105. if (ex is ExceptionEx)
  106. {
  107. throw;
  108. }
  109. else
  110. {
  111. throw ExceptionEx.ThrowServiceException(ex);
  112. }
  113. }
  114. }
  115. #endregion
  116. #region 提交数据
  117. /// <summary>
  118. /// 删除实体数据
  119. /// </summary>
  120. /// <param name="keyValue">主键</param>
  121. public void DeleteEntity(string keyValue)
  122. {
  123. try
  124. {
  125. this.BaseRepository("CollegeMIS").Delete<OLPElectiveStuSelectCountEntity>(t => t.Id == keyValue);
  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. /// <summary>
  140. /// 保存实体数据(新增、修改)
  141. /// </summary>
  142. /// <param name="keyValue">主键</param>
  143. /// <param name="entity">实体</param>
  144. public void SaveEntity(string keyValue, OLPElectiveStuSelectCountEntity entity)
  145. {
  146. try
  147. {
  148. if (!string.IsNullOrEmpty(keyValue))
  149. {
  150. entity.Modify(keyValue);
  151. this.BaseRepository("CollegeMIS").Update(entity);
  152. }
  153. else
  154. {
  155. entity.Create();
  156. this.BaseRepository("CollegeMIS").Insert(entity);
  157. }
  158. }
  159. catch (Exception ex)
  160. {
  161. if (ex is ExceptionEx)
  162. {
  163. throw;
  164. }
  165. else
  166. {
  167. throw ExceptionEx.ThrowServiceException(ex);
  168. }
  169. }
  170. }
  171. #endregion
  172. }
  173. }