Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 
 
 
 

200 Zeilen
6.4 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 16:42
  16. /// 描 述:离职教职工
  17. /// </summary>
  18. public class TeacherDimissionService : RepositoryFactory
  19. {
  20. #region 获取数据
  21. /// <summary>
  22. /// 获取页面显示列表数据
  23. /// <summary>
  24. /// <param name="queryJson">查询参数</param>
  25. /// <returns></returns>
  26. public IEnumerable<TeacherDimissionEntity> 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 TeacherDimission 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<TeacherDimissionEntity>(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. /// 获取TeacherDimission表实体数据
  59. /// <param name="keyValue">主键</param>
  60. /// <summary>
  61. /// <returns></returns>
  62. public TeacherDimissionEntity GetTeacherDimissionEntity(string keyValue)
  63. {
  64. try
  65. {
  66. return this.BaseRepository().FindEntity<TeacherDimissionEntity>(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. var db = this.BaseRepository();
  90. db.BeginTrans();
  91. try
  92. {
  93. var entity = db.FindEntity<TeacherDimissionEntity>(keyValue);
  94. if (entity != null)
  95. {
  96. //更新教师信息
  97. var empInfoEntity = this.BaseRepository("CollegeMIS").FindEntity<EmpInfoEntity>(x => x.EmpId == entity.EID);
  98. if (empInfoEntity != null)
  99. {
  100. empInfoEntity.IsInActiveStatus = entity.EStatus;
  101. this.BaseRepository("CollegeMIS").Update(empInfoEntity);
  102. }
  103. //人事异动
  104. db.Delete<TeacherChangeEntity>(x => x.EmpId == entity.EID && x.ChangeType == "02");
  105. db.Delete(entity);
  106. }
  107. db.Commit();
  108. }
  109. catch (Exception ex)
  110. {
  111. db.Rollback();
  112. if (ex is ExceptionEx)
  113. {
  114. throw;
  115. }
  116. else
  117. {
  118. throw ExceptionEx.ThrowServiceException(ex);
  119. }
  120. }
  121. }
  122. /// <summary>
  123. /// 保存实体数据(新增、修改)
  124. /// <param name="keyValue">主键</param>
  125. /// <summary>
  126. /// <returns></returns>
  127. public void SaveEntity(string keyValue, TeacherDimissionEntity entity)
  128. {
  129. var db = this.BaseRepository();
  130. db.BeginTrans();
  131. try
  132. {
  133. if (!string.IsNullOrEmpty(keyValue))
  134. {
  135. entity.Modify(keyValue);
  136. db.Update(entity);
  137. }
  138. else
  139. {
  140. entity.Create();
  141. db.Insert(entity);
  142. }
  143. //人事异动
  144. var tcEntity = db.FindEntity<TeacherChangeEntity>(x => x.EmpId == entity.EID && x.ChangeType == "02");
  145. if (tcEntity == null)
  146. {
  147. var tcModel = new TeacherChangeEntity()
  148. {
  149. EmpId = entity.EID,
  150. ChangeTime = DateTime.Now,
  151. ChangeType = "02"
  152. };
  153. tcModel.Create();
  154. db.Insert(tcModel);
  155. }
  156. else
  157. {
  158. tcEntity.ChangeTime = DateTime.Now;
  159. tcEntity.Modify(tcEntity.Id);
  160. db.Update(tcEntity);
  161. }
  162. db.Commit();
  163. //更新教师信息
  164. var empInfoEntity = this.BaseRepository("CollegeMIS").FindEntity<EmpInfoEntity>(x => x.EmpId == entity.EID);
  165. if (empInfoEntity != null)
  166. {
  167. empInfoEntity.IsInActiveStatus = "0";
  168. this.BaseRepository("CollegeMIS").Update(empInfoEntity);
  169. }
  170. }
  171. catch (Exception ex)
  172. {
  173. db.Rollback();
  174. if (ex is ExceptionEx)
  175. {
  176. throw;
  177. }
  178. else
  179. {
  180. throw ExceptionEx.ThrowServiceException(ex);
  181. }
  182. }
  183. }
  184. #endregion
  185. }
  186. }