DegreeOpenControlServices.cs 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Linq.Expressions;
  5. using System.Text;
  6. using Bowin.Common.Linq.Entity;
  7. using Bowin.Common.Linq;
  8. using EMIS.ViewModel;
  9. using EMIS.ViewModel.DegreeManage.DegreeSetting;
  10. using EMIS.Entities;
  11. using EMIS.DataLogic.DegreeManage.DegreeSetting;
  12. namespace EMIS.CommonLogic.DegreeManage.DegreeSetting
  13. {
  14. public class DegreeOpenControlServices : BaseServices, IDegreeOpenControlServices
  15. {
  16. public DegreeOpenControlDAL DegreeOpenControlDAL { get; set; }
  17. /// <summary>
  18. /// 查询对应的学位控制信息View
  19. /// </summary>
  20. /// <param name="configuretView"></param>
  21. /// <param name="graduatingSemesterID"></param>
  22. /// <param name="degreeBatchID"></param>
  23. /// <param name="pageIndex"></param>
  24. /// <param name="pageSize"></param>
  25. /// <returns></returns>
  26. public IGridResultSet<DegreeOpenControlView> GetDegreeOpenControlViewGrid(ConfiguretView configuretView, Guid? graduatingSemesterID, int? degreeBatchID, int pageIndex, int pageSize)
  27. {
  28. //学位控制
  29. Expression<Func<ER_DegreeOpenControl, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  30. if (graduatingSemesterID.HasValue)
  31. {
  32. exp = exp.And(x => x.GraduatingSemesterID == graduatingSemesterID);
  33. }
  34. if (degreeBatchID.HasValue)
  35. {
  36. exp = exp.And(x => x.DegreeBatchID == degreeBatchID);
  37. }
  38. var query = DegreeOpenControlDAL.GetDegreeOpenControlViewQueryable(exp);
  39. //查询条件
  40. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  41. {
  42. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  43. }
  44. return query.OrderByDescending(x => x.GraduatingSemesterValue).ToGridResultSet<DegreeOpenControlView>(pageIndex, pageSize);
  45. }
  46. /// <summary>
  47. /// 查询对应的学位控制信息List
  48. /// </summary>
  49. /// <param name="configuretView"></param>
  50. /// <param name="graduatingSemesterID"></param>
  51. /// <param name="degreeBatchID"></param>
  52. /// <returns></returns>
  53. public IList<DegreeOpenControlView> GetDegreeOpenControlViewList(ConfiguretView configuretView, Guid? graduatingSemesterID, int? degreeBatchID)
  54. {
  55. //学位控制
  56. Expression<Func<ER_DegreeOpenControl, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  57. if (graduatingSemesterID.HasValue)
  58. {
  59. exp = exp.And(x => x.GraduatingSemesterID == graduatingSemesterID);
  60. }
  61. if (degreeBatchID.HasValue)
  62. {
  63. exp = exp.And(x => x.DegreeBatchID == degreeBatchID);
  64. }
  65. var query = DegreeOpenControlDAL.GetDegreeOpenControlViewQueryable(exp);
  66. //查询条件
  67. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  68. {
  69. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  70. }
  71. return query.OrderByDescending(x => x.GraduatingSemesterValue).ToList();
  72. }
  73. /// <summary>
  74. /// 根据学位控制ID查询对应的学位控制信息DegreeOpenControlView
  75. /// </summary>
  76. /// <param name="degreeOpenControlID"></param>
  77. /// <returns></returns>
  78. public DegreeOpenControlView GetDegreeOpenControlView(Guid? degreeOpenControlID)
  79. {
  80. try
  81. {
  82. var query = DegreeOpenControlDAL.GetDegreeOpenControlViewQueryable(x => x.DegreeOpenControlID == degreeOpenControlID).SingleOrDefault();
  83. return query;
  84. }
  85. catch (Exception ex)
  86. {
  87. throw new Exception(ex.Message);
  88. }
  89. }
  90. /// <summary>
  91. /// 编辑(新增、修改)
  92. /// </summary>
  93. /// <param name="degreeOpenControlView"></param>
  94. public void DegreeOpenControlViewEdit(DegreeOpenControlView degreeOpenControlView)
  95. {
  96. try
  97. {
  98. var degreeOpenControlVerify = DegreeOpenControlDAL.DegreeOpenControlRepository.GetList(x => x.DegreeOpenControlID != degreeOpenControlView.DegreeOpenControlID && x.GraduatingSemesterID == degreeOpenControlView.GraduatingSemesterID).SingleOrDefault();
  99. if (degreeOpenControlVerify == null)
  100. {
  101. //数据有误验证
  102. if (degreeOpenControlView.DegreeOpenControlID != Guid.Empty)
  103. {
  104. var degreeOpenControl = DegreeOpenControlDAL.DegreeOpenControlRepository.GetList(x => x.DegreeOpenControlID == degreeOpenControlView.DegreeOpenControlID).SingleOrDefault();
  105. if (degreeOpenControl == null)
  106. {
  107. throw new Exception("数据有误,请核查。");
  108. }
  109. else
  110. {
  111. //表示修改
  112. degreeOpenControl.GraduatingSemesterID = degreeOpenControlView.GraduatingSemesterID;
  113. degreeOpenControl.DegreeBatchID = degreeOpenControlView.DegreeBatchID;
  114. degreeOpenControl.StartDate = degreeOpenControlView.StartDate;
  115. degreeOpenControl.EndDate = degreeOpenControlView.EndDate;
  116. SetModifyStatus(degreeOpenControl);
  117. }
  118. }
  119. else
  120. {
  121. //表示新增
  122. ER_DegreeOpenControl degreeOpenControl = new ER_DegreeOpenControl();
  123. degreeOpenControl.DegreeOpenControlID = Guid.NewGuid();
  124. degreeOpenControl.GraduatingSemesterID = degreeOpenControlView.GraduatingSemesterID;
  125. degreeOpenControl.DegreeBatchID = degreeOpenControlView.DegreeBatchID;
  126. degreeOpenControl.StartDate = degreeOpenControlView.StartDate;
  127. degreeOpenControl.EndDate = degreeOpenControlView.EndDate;
  128. SetNewStatus(degreeOpenControl);
  129. UnitOfWork.Add(degreeOpenControl);
  130. }
  131. }
  132. else
  133. {
  134. throw new Exception("已存在相同的学位控制信息,请核查。");
  135. }
  136. //事务提交
  137. UnitOfWork.Commit();
  138. }
  139. catch (Exception ex)
  140. {
  141. throw new Exception(ex.Message);
  142. }
  143. }
  144. /// <summary>
  145. /// 删除
  146. /// </summary>
  147. /// <param name="degreeOpenControlIDList"></param>
  148. /// <returns></returns>
  149. public bool DegreeOpenControlDelete(IList<Guid?> degreeOpenControlIDList)
  150. {
  151. try
  152. {
  153. UnitOfWork.Delete<ER_DegreeOpenControl>(x => degreeOpenControlIDList.Contains(x.DegreeOpenControlID));
  154. return true;
  155. }
  156. catch (Exception)
  157. {
  158. throw;
  159. }
  160. }
  161. }
  162. }