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.
 
 
 
 
 
 

175 lines
5.7 KiB

  1. using Dapper;
  2. using Learun.Application.TwoDevelopment.EducationalAdministration;
  3. using Learun.DataBase.Repository;
  4. using Learun.Util;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Data;
  8. using System.Text;
  9. namespace Learun.Application.TwoDevelopment.PersonnelManagement
  10. {
  11. /// <summary>
  12. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  13. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  14. /// 创 建:超级管理员
  15. /// 日 期:2019-03-19 17:02
  16. /// 描 述:教师职称变更
  17. /// </summary>
  18. public class TeacherTitleChangeService : RepositoryFactory
  19. {
  20. #region 获取数据
  21. /// <summary>
  22. /// 获取页面显示列表数据
  23. /// <summary>
  24. /// <param name="queryJson">查询参数</param>
  25. /// <returns></returns>
  26. public IEnumerable<TeacherTitleChangeEntity> GetPageList(Pagination pagination, string queryJson)
  27. {
  28. try
  29. {
  30. var admsdb = this.BaseRepository("CollegeMIS").getDbConnection().Database;
  31. var strSql = new StringBuilder();
  32. strSql.Append("SELECT t.* ");
  33. strSql.Append(" FROM TeacherTitleChange t left join " + admsdb + ".dbo.EmpInfo e on t.EID=e.EmpId ");
  34. strSql.Append(" WHERE 1=1 ");
  35. var queryParam = queryJson.ToJObject();
  36. // 虚拟参数
  37. var dp = new DynamicParameters(new { });
  38. if (!queryParam["EName"].IsEmpty())
  39. {
  40. dp.Add("EName", "%" + queryParam["EName"].ToString() + "%", DbType.String);
  41. strSql.Append(" AND e.EmpName like @EName ");
  42. }
  43. return this.BaseRepository().FindList<TeacherTitleChangeEntity>(strSql.ToString(), dp, pagination);
  44. }
  45. catch (Exception ex)
  46. {
  47. if (ex is ExceptionEx)
  48. {
  49. throw;
  50. }
  51. else
  52. {
  53. throw ExceptionEx.ThrowServiceException(ex);
  54. }
  55. }
  56. }
  57. /// <summary>
  58. /// 获取TeacherTitleChange表实体数据
  59. /// <param name="keyValue">主键</param>
  60. /// <summary>
  61. /// <returns></returns>
  62. public TeacherTitleChangeEntity GetTeacherTitleChangeEntity(string keyValue)
  63. {
  64. try
  65. {
  66. return this.BaseRepository().FindEntity<TeacherTitleChangeEntity>(keyValue);
  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. #endregion
  81. #region 提交数据
  82. /// <summary>
  83. /// 删除实体数据
  84. /// <param name="keyValue">主键</param>
  85. /// <summary>
  86. /// <returns></returns>
  87. public void DeleteEntity(string keyValue)
  88. {
  89. try
  90. {
  91. var entity = this.BaseRepository().FindEntity<TeacherTitleChangeEntity>(keyValue);
  92. if (entity != null)
  93. {
  94. //更新教师信息
  95. var empInfoEntity = this.BaseRepository("CollegeMIS").FindEntity<EmpInfoEntity>(x => x.EmpId == entity.EID);
  96. if (empInfoEntity != null)
  97. {
  98. empInfoEntity.ProfessionalTitle = entity.TCTitlesID;
  99. empInfoEntity.ProfessionalTitleLevel = entity.TCTitlesPostLevel;
  100. empInfoEntity.ProfessionalTitleGetTime = entity.TCTime;
  101. this.BaseRepository("CollegeMIS").Update(empInfoEntity);
  102. }
  103. //删除变更
  104. this.BaseRepository().Delete(entity);
  105. }
  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, TeacherTitleChangeEntity entity)
  125. {
  126. try
  127. {
  128. if (!string.IsNullOrEmpty(keyValue))
  129. {
  130. entity.Modify(keyValue);
  131. this.BaseRepository().Update(entity);
  132. }
  133. else
  134. {
  135. entity.Create();
  136. this.BaseRepository().Insert(entity);
  137. }
  138. //更新教师信息
  139. var empInfoEntity = this.BaseRepository("CollegeMIS").FindEntity<EmpInfoEntity>(x => x.EmpId == entity.EID);
  140. if (empInfoEntity != null)
  141. {
  142. empInfoEntity.ProfessionalTitle = entity.TCTitlesNewID;
  143. empInfoEntity.ProfessionalTitleLevel = entity.TCTitlesPostLevelNew;
  144. empInfoEntity.ProfessionalTitleGetTime = entity.TCChangeTime;
  145. this.BaseRepository("CollegeMIS").Update(empInfoEntity);
  146. }
  147. }
  148. catch (Exception ex)
  149. {
  150. if (ex is ExceptionEx)
  151. {
  152. throw;
  153. }
  154. else
  155. {
  156. throw ExceptionEx.ThrowServiceException(ex);
  157. }
  158. }
  159. }
  160. #endregion
  161. }
  162. }