ExaminationSubjectCollegeControlServices.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Bowin.Common.Linq;
  6. using Bowin.Common.Linq.Entity;
  7. using EMIS.ViewModel.SelectCourse;
  8. using EMIS.ViewModel;
  9. using System.Linq.Expressions;
  10. using EMIS.Entities;
  11. using EMIS.DataLogic.SelectCourse;
  12. namespace EMIS.CommonLogic.SelectCourse
  13. {
  14. public class ExaminationSubjectCollegeControlServices : BaseServices, IExaminationSubjectCollegeControlServices
  15. {
  16. public ExaminationSubjectCollegeControlDAL examinationSubjectCollegeControlDAL { get; set; }
  17. /// <summary>
  18. /// 列表查询
  19. /// </summary>
  20. /// <param name="configuretView"></param>
  21. /// <param name="examinationTypeID"></param>
  22. /// <param name="examinationSubjectID"></param>
  23. /// <param name="collegeID"></param>
  24. /// <param name="facultymajorID"></param>
  25. /// <param name="schoolyearNumID"></param>
  26. /// <param name="pageIndex"></param>
  27. /// <param name="pageSize"></param>
  28. /// <returns></returns>
  29. public IGridResultSet<ExaminationSubjectCollegeControlView> GetExaminationSubjectCollegeControlViewGrid(ConfiguretView configuretView, Guid? examinationTypeID, Guid? examinationSubjectID, Guid? collegeID, Guid? facultymajorID, int? schoolyearNumID, int pageIndex, int pageSize)
  30. {
  31. Expression<Func<EX_ExaminationSubjectCollegeControl, bool>> esccexp = x => true;
  32. Expression<Func<EX_ExaminationSubject, bool>> esexp= x => true;
  33. Expression<Func<CF_Facultymajor, bool>> fexp = x => true;
  34. if (examinationTypeID.HasValue)
  35. {
  36. esexp = esexp.And(x => x.ExaminationTypeID == examinationTypeID);
  37. }
  38. if (examinationSubjectID.HasValue)
  39. {
  40. esccexp = esccexp.And(x => x.ExaminationSubjectID == examinationSubjectID);
  41. }
  42. if (collegeID.HasValue)
  43. {
  44. fexp = fexp.And(x => x.CollegeID == collegeID);
  45. }
  46. if (facultymajorID.HasValue)
  47. {
  48. esccexp = esccexp.And(x => x.FacultymajorID == facultymajorID);
  49. }
  50. if (schoolyearNumID.HasValue)
  51. {
  52. esccexp = esccexp.And(x => x.SchoolyearNumID == schoolyearNumID);
  53. }
  54. var query = examinationSubjectCollegeControlDAL.GetExaminationSubjectCollegeControlView(esccexp, esexp, fexp);
  55. if (!string.IsNullOrEmpty(configuretView.ConditionValue) && !string.IsNullOrEmpty(configuretView.Attribute))
  56. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
  57. var result = GetQueryByDataRangeByCollege(query);
  58. return result.OrderBy(x => x.ExaminationSubjectName.Length).ThenBy(x => x.ExaminationSubjectName).ThenBy(x => x.CollegeName.Length).ThenBy(x => x.CollegeName).ThenBy(x => x.SchoolyearNumID).ToGridResultSet<ExaminationSubjectCollegeControlView>(pageIndex, pageSize);
  59. }
  60. /// <summary>
  61. /// excel导出
  62. /// </summary>
  63. /// <param name="configuretView"></param>
  64. /// <param name="examinationTypeID"></param>
  65. /// <param name="examinationSubjectID"></param>
  66. /// <param name="collegeID"></param>
  67. /// <param name="facultymajorID"></param>
  68. /// <param name="schoolyearNumID"></param>
  69. /// <param name="idList"></param>
  70. /// <returns></returns>
  71. public List<ExaminationSubjectCollegeControlView> GetExaminationSubjectCollegeControlViewList(ConfiguretView configuretView, Guid? examinationTypeID, Guid? examinationSubjectID, Guid? collegeID, Guid? facultymajorID, int? schoolyearNumID, List<Guid?> idList)
  72. {
  73. Expression<Func<EX_ExaminationSubjectCollegeControl, bool>> esccexp = x => true;
  74. Expression<Func<EX_ExaminationSubject, bool>> esexp = x => true;
  75. Expression<Func<CF_Facultymajor, bool>> fexp = x => true;
  76. if (examinationTypeID.HasValue)
  77. {
  78. esexp = esexp.And(x => x.ExaminationTypeID == examinationTypeID);
  79. }
  80. if (examinationSubjectID.HasValue)
  81. {
  82. esccexp = esccexp.And(x => x.ExaminationSubjectID == examinationSubjectID);
  83. }
  84. if (collegeID.HasValue)
  85. {
  86. fexp = fexp.And(x => x.CollegeID == collegeID);
  87. }
  88. if (facultymajorID.HasValue)
  89. {
  90. esccexp = esccexp.And(x => x.FacultymajorID == facultymajorID);
  91. }
  92. if (schoolyearNumID.HasValue)
  93. {
  94. esccexp = esccexp.And(x => x.SchoolyearNumID == schoolyearNumID);
  95. }
  96. if (idList.Count > 0)
  97. {
  98. esccexp = esccexp.And(x => idList.Contains(x.ExaminationSubjectCollegeControlID));
  99. }
  100. var query = examinationSubjectCollegeControlDAL.GetExaminationSubjectCollegeControlView(esccexp, esexp, fexp);
  101. if (!string.IsNullOrEmpty(configuretView.ConditionValue) && !string.IsNullOrEmpty(configuretView.Attribute))
  102. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
  103. var result = GetQueryByDataRangeByCollege(query);
  104. return result.OrderBy(x => x.ExaminationSubjectName.Length).ThenBy(x => x.ExaminationSubjectName).ThenBy(x => x.CollegeName.Length).ThenBy(x => x.CollegeName).ThenBy(x => x.SchoolyearNumID).ToList();
  105. }
  106. public ExaminationSubjectCollegeControlView GetExaminationSubjectCollegeControlView(Guid? examinationSubjectCollegeControlID)
  107. {
  108. Expression<Func<EX_ExaminationSubjectCollegeControl, bool>> esccexp = x => x.ExaminationSubjectCollegeControlID == examinationSubjectCollegeControlID;
  109. var query = examinationSubjectCollegeControlDAL.GetExaminationSubjectCollegeControlView(esccexp, x => true, x => true).FirstOrDefault();
  110. return query;
  111. }
  112. /// <summary>
  113. /// 新增
  114. /// </summary>
  115. /// <param name="examinationSubjectCollegeControlView"></param>
  116. /// <param name="facultymajorIDList"></param>
  117. public void ExaminationSubjectCollegeControlAdd(ExaminationSubjectCollegeControlView examinationSubjectCollegeControlView, List<Guid> facultymajorIDList)
  118. {
  119. try
  120. {
  121. if (facultymajorIDList.Count > 0)
  122. {
  123. List<EX_ExaminationSubjectCollegeControl> examinationSubjectCollegeControlList = new List<EX_ExaminationSubjectCollegeControl>();
  124. foreach (Guid facultymajorID in facultymajorIDList)
  125. {
  126. EX_ExaminationSubjectCollegeControl examinationSubjectCollegeControl = new EX_ExaminationSubjectCollegeControl();
  127. //新增
  128. examinationSubjectCollegeControl = examinationSubjectCollegeControlDAL.examinationSubjectCollegeControlRepository
  129. .GetSingle(x => x.ExaminationSubjectID == examinationSubjectCollegeControlView.ExaminationSubjectID && x.FacultymajorID == examinationSubjectCollegeControlView.FacultymajorID
  130. && x.SchoolyearNumID == examinationSubjectCollegeControlView.SchoolyearNumID);
  131. if (examinationSubjectCollegeControl != null)
  132. {
  133. throw new Exception("已存在相同的专业报考限制信息。");
  134. }
  135. examinationSubjectCollegeControl = new EX_ExaminationSubjectCollegeControl();
  136. examinationSubjectCollegeControl.ExaminationSubjectCollegeControlID = Guid.NewGuid();
  137. examinationSubjectCollegeControl.ExaminationSubjectID = examinationSubjectCollegeControlView.ExaminationSubjectID;
  138. examinationSubjectCollegeControl.FacultymajorID = facultymajorID;
  139. examinationSubjectCollegeControl.SchoolyearNumID = examinationSubjectCollegeControlView.SchoolyearNumID == -1 ? null : examinationSubjectCollegeControlView.SchoolyearNumID;
  140. SetNewStatus(examinationSubjectCollegeControl);
  141. examinationSubjectCollegeControlList.Add(examinationSubjectCollegeControl);
  142. }
  143. UnitOfWork.BulkInsert(examinationSubjectCollegeControlList);
  144. }
  145. }
  146. catch (Exception ex)
  147. {
  148. throw new Exception(ex.Message);
  149. }
  150. }
  151. /// <summary>
  152. /// 修改
  153. /// </summary>
  154. /// <param name="examinationSubjectCollegeControlView"></param>
  155. public void ExaminationSubjectCollegeControlEdit(ExaminationSubjectCollegeControlView examinationSubjectCollegeControlView)
  156. {
  157. try
  158. {
  159. EX_ExaminationSubjectCollegeControl examinationSubjectCollegeControl = new EX_ExaminationSubjectCollegeControl();
  160. //修改
  161. examinationSubjectCollegeControl = examinationSubjectCollegeControlDAL.examinationSubjectCollegeControlRepository
  162. .GetSingle(x => x.ExaminationSubjectCollegeControlID != examinationSubjectCollegeControlView.ExaminationSubjectCollegeControlID
  163. && x.ExaminationSubjectID == examinationSubjectCollegeControlView.ExaminationSubjectID && x.FacultymajorID == examinationSubjectCollegeControlView.FacultymajorID
  164. && x.SchoolyearNumID == examinationSubjectCollegeControlView.SchoolyearNumID);
  165. if (examinationSubjectCollegeControl != null)
  166. {
  167. throw new Exception("已存在相同的专业报考限制信息。");
  168. }
  169. examinationSubjectCollegeControl = examinationSubjectCollegeControlDAL.examinationSubjectCollegeControlRepository
  170. .GetSingle(x => x.ExaminationSubjectCollegeControlID == examinationSubjectCollegeControlView.ExaminationSubjectCollegeControlID);
  171. if (examinationSubjectCollegeControl == null)
  172. {
  173. throw new Exception("数据有误,请核查。");
  174. }
  175. examinationSubjectCollegeControl.ExaminationSubjectID = examinationSubjectCollegeControlView.ExaminationSubjectID;
  176. examinationSubjectCollegeControl.FacultymajorID = examinationSubjectCollegeControlView.FacultymajorID;
  177. examinationSubjectCollegeControl.SchoolyearNumID = examinationSubjectCollegeControlView.SchoolyearNumID == -1 ? null : examinationSubjectCollegeControlView.SchoolyearNumID;
  178. SetModifyStatus(examinationSubjectCollegeControl);
  179. UnitOfWork.Commit();
  180. }
  181. catch (Exception ex)
  182. {
  183. throw new Exception(ex.Message);
  184. }
  185. }
  186. /// <summary>
  187. /// 删除
  188. /// </summary>
  189. /// <param name="examinationSubjectCollegeControlIDList"></param>
  190. public void ExaminationSubjectCollegeControlDelete(IList<Guid?> examinationSubjectCollegeControlIDList)
  191. {
  192. try
  193. {
  194. if (examinationSubjectCollegeControlIDList.Count > 0)
  195. {
  196. UnitOfWork.Delete<EX_ExaminationSubjectCollegeControl>(x => examinationSubjectCollegeControlIDList.Contains(x.ExaminationSubjectCollegeControlID));
  197. }
  198. }
  199. catch (Exception ex)
  200. {
  201. throw new Exception(ex.Message);
  202. }
  203. }
  204. }
  205. }