ExamProjectControlServices.cs 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Bowin.Common.Linq.Entity;
  6. using EMIS.Entities;
  7. using EMIS.DataLogic.ExamManage;
  8. using System.Linq.Expressions;
  9. using EMIS.DataLogic;
  10. namespace EMIS.CommonLogic.ExamManage
  11. {
  12. public class ExamProjectControlServices : BaseServices, IExamProjectControlServices
  13. {
  14. public ExamProjectControlDAL ExamProjectControlDAL { get; set; }
  15. public ProjectFeeDAL ProjectFeeDAL { get; set; }
  16. public Bowin.Common.Linq.Entity.IGridResultSet<ViewModel.ExamProjectControlView> GetListGridView(int pageIndex, int pageSize, params ViewModel.ConfiguretView[] configuretViews)
  17. {
  18. System.Linq.Expressions.Expression<Func<EX_ExaminationBatchProjectControl, bool>> expCampus = (x => true);
  19. var query = ExamProjectControlDAL.GetList(expCampus);
  20. //查询条件
  21. foreach (var configuretView in configuretViews)
  22. {
  23. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  24. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  25. }
  26. //排序:按学年学期(倒序)、考试批次、项目名称、年级、院系、专业
  27. return query.OrderByDescending(x=>x.Schoolyear)
  28. .ThenBy(x => x.ExaminationBatchID).ThenBy(x => x.ProjectName).ThenBy(x => x.SchoolyearID)
  29. .ThenBy(x => x.CollegeID).ThenBy(x => x.StandardID)
  30. .ToGridResultSet<EMIS.ViewModel.ExamProjectControlView>(pageIndex, pageSize);
  31. }
  32. public IGridResultSet<EMIS.ViewModel.ExaminationApply.ExaminationTypeView> GetControlExamTypeListViewGrid(int pageIndex, int pageSize, params EMIS.ViewModel.ConfiguretView[] configuretViews)
  33. {
  34. System.Linq.Expressions.Expression<Func<EX_ExaminationBatchProjectControl, bool>> expCampus = (x => true);
  35. var query = ExamProjectControlDAL.GetList(expCampus);
  36. //查询条件
  37. foreach (var configuretView in configuretViews)
  38. {
  39. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  40. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  41. }
  42. var result = query.OrderBy(x => x.ExaminationBatchProjectID).GroupBy(x => new
  43. {
  44. x.ExaminationBatchID,
  45. x.ExaminationTypeID,
  46. x.ExaminationType
  47. }).Select(x => new EMIS.ViewModel.ExaminationApply.ExaminationTypeView()
  48. {
  49. ExaminationBatchID = x.Key.ExaminationBatchID.Value,
  50. ExaminationTypeID = x.Key.ExaminationTypeID.Value,
  51. Name = x.Key.ExaminationType
  52. });
  53. return result
  54. .OrderBy(x => x.ExaminationBatchID)
  55. .ToGridResultSet<EMIS.ViewModel.ExaminationApply.ExaminationTypeView>(pageIndex, pageSize);
  56. }
  57. public IGridResultSet<EMIS.ViewModel.ExamBatchProjectView> GetControlProjectListViewGrid(int pageIndex, int pageSize, params EMIS.ViewModel.ConfiguretView[] configuretViews)
  58. {
  59. System.Linq.Expressions.Expression<Func<EX_ExaminationBatchProjectControl, bool>> expCampus = (x => true);
  60. var query = ExamProjectControlDAL.GetList(expCampus);
  61. //查询条件
  62. foreach (var configuretView in configuretViews)
  63. {
  64. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  65. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  66. }
  67. var result = query.OrderBy(x => x.ExaminationBatchProjectID).GroupBy(x => new
  68. {
  69. x.ExaminationBatchID,
  70. x.ExaminationTypeID,
  71. x.ExaminationBatchProjectID,
  72. x.ExaminationProjectID,
  73. x.ProjectName
  74. }).Select(x => new EMIS.ViewModel.ExamBatchProjectView()
  75. {
  76. ExaminationBatchID = x.Key.ExaminationBatchID.Value,
  77. ExaminationTypeID = x.Key.ExaminationTypeID.Value,
  78. Name = x.Key.ProjectName,
  79. ExaminationProjectID = x.Key.ExaminationProjectID,
  80. ExaminationBatchProjectID = x.Key.ExaminationBatchProjectID.Value,
  81. });
  82. return result
  83. .OrderBy(x => x.ExaminationBatchID)
  84. .ToGridResultSet<EMIS.ViewModel.ExamBatchProjectView>(pageIndex, pageSize);
  85. }
  86. public ViewModel.ExamProjectControlView GetView(Guid? ViewID)
  87. {
  88. var query = ExamProjectControlDAL.GetList(x => x.ExaminationBatchProjectControlID == ViewID).SingleOrDefault();
  89. return query;
  90. }
  91. public void Edit(ViewModel.ExamProjectControlView view, List<EMIS.ViewModel.ExamProjectControlView> standardList)
  92. {
  93. var examinationBatchProject = ProjectFeeDAL.BatchProjectRepository.Entities.Where(x => x.ExaminationBatchID == view.ExaminationBatchID && x.ExaminationProjectID == view.ExaminationProjectID).FirstOrDefault();
  94. foreach (var stand in standardList)
  95. {
  96. var entity = ExamProjectControlDAL.ProjectControlRepository.Entities
  97. .SingleOrDefault(x => x.ExaminationBatchProjectID == examinationBatchProject.ExaminationBatchProjectID && x.StandardID == stand.StandardID && x.CollegeID == stand.CollegeID && x.SchoolyearID == stand.SchoolyearID);
  98. if (entity == null)
  99. {
  100. entity = new EX_ExaminationBatchProjectControl();
  101. entity.ExaminationBatchProjectControlID = Guid.NewGuid();
  102. this.SetNewStatus(entity);
  103. ExamProjectControlDAL.ProjectControlRepository.UnitOfWork.Add(entity);
  104. }
  105. entity.CollegeID = stand.CollegeID;
  106. entity.SchoolyearID = stand.SchoolyearID;
  107. entity.StandardID = stand.StandardID;
  108. entity.ExaminationBatchProjectID = examinationBatchProject.ExaminationBatchProjectID;
  109. entity.IsOnlinePay = view.IsOnlinePay;
  110. entity.ExaminationProjectFeeID = view.ExaminationProjectFeeID;
  111. this.SetModifyStatus<EX_ExaminationBatchProjectControl>(entity);
  112. }
  113. ExamProjectControlDAL.ProjectControlRepository.UnitOfWork.Commit();
  114. }
  115. public void Edit(ViewModel.ExamProjectControlView view)
  116. {
  117. var examinationBatchProject = ProjectFeeDAL.BatchProjectRepository.Entities.Where(x => x.ExaminationBatchID == view.ExaminationBatchID && x.ExaminationProjectID == view.ExaminationProjectID).FirstOrDefault();
  118. var entity = ExamProjectControlDAL.ProjectControlRepository.Entities
  119. .SingleOrDefault(x => x.ExaminationBatchProjectControlID == view.ExaminationBatchProjectControlID);
  120. if (entity == null)
  121. {
  122. entity = new EX_ExaminationBatchProjectControl();
  123. this.SetNewStatus(entity);
  124. ExamProjectControlDAL.ProjectControlRepository.UnitOfWork.Add(entity);
  125. }
  126. entity.ExaminationBatchProjectControlID = view.ExaminationBatchProjectControlID;
  127. entity.CollegeID = view.CollegeID;
  128. entity.SchoolyearID = view.SchoolyearID == -1 ? null : view.SchoolyearID;
  129. entity.StandardID = view.StandardID == -1 ? null : view.StandardID;
  130. entity.ExaminationBatchProjectID = examinationBatchProject.ExaminationBatchProjectID;
  131. entity.IsOnlinePay = view.IsOnlinePay;
  132. entity.ExaminationProjectFeeID = view.ExaminationProjectFeeID;
  133. this.SetModifyStatus<EX_ExaminationBatchProjectControl>(entity);
  134. ExamProjectControlDAL.ProjectControlRepository.UnitOfWork.Commit();
  135. }
  136. public ViewModel.ExamProjectControlView GetView(System.Linq.Expressions.Expression<Func<Entities.EX_ExaminationBatchProjectControl, bool>> expCampus)
  137. {
  138. var query = ExamProjectControlDAL.GetList(expCampus).SingleOrDefault();
  139. return query;
  140. }
  141. public IQueryable<ViewModel.ExamProjectControlView> GetList(params ViewModel.ConfiguretView[] configuretViews)
  142. {
  143. System.Linq.Expressions.Expression<Func<EX_ExaminationBatchProjectControl, bool>> expCampus = (x => true);
  144. var query = ExamProjectControlDAL.GetList(expCampus);
  145. //查询条件
  146. foreach (var configuretView in configuretViews)
  147. {
  148. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  149. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  150. }
  151. return query
  152. .OrderBy(x => x.ExaminationBatchProjectControlID);
  153. }
  154. public bool Delete(List<Guid?> IDs)
  155. {
  156. UnitOfWork.Delete<EX_ExaminationBatchProjectControl>(x => IDs.Contains(x.ExaminationBatchProjectControlID));
  157. UnitOfWork.Commit();
  158. return true;
  159. }
  160. }
  161. }