ExamSubjectLimitServices.cs 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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 ExamSubjectLimitServices : BaseServices, IExamSubjectLimitServices
  13. {
  14. public ExamSubjectLimitDAL ExamSubjectLimitDAL { get; set; }
  15. public Bowin.Common.Linq.Entity.IGridResultSet<ViewModel.ExamSubjectLimitView> GetListGridView(int pageIndex, int pageSize, params ViewModel.ConfiguretView[] configuretViews)
  16. {
  17. System.Linq.Expressions.Expression<Func<EX_ExaminationProjectCountLimit, bool>> expCampus = (x => true);
  18. var query = ExamSubjectLimitDAL.GetList(expCampus);
  19. //查询条件
  20. foreach (var configuretView in configuretViews)
  21. {
  22. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  23. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  24. }
  25. return query
  26. .OrderBy(x => x.ExaminationTypeName).ThenBy(x => x.StandardName)
  27. .ToGridResultSet<EMIS.ViewModel.ExamSubjectLimitView>(pageIndex, pageSize);
  28. }
  29. public ViewModel.ExamSubjectLimitView GetView(Guid? ViewID)
  30. {
  31. var query = ExamSubjectLimitDAL.GetList(x => x.ExaminationSubjectCountLimitID == ViewID).SingleOrDefault();
  32. return query;
  33. }
  34. public void Edit(ViewModel.ExamSubjectLimitView view, List<EMIS.ViewModel.ExamSubjectLimitView> StandardList)
  35. {
  36. foreach (var stand in StandardList)
  37. {
  38. var entity = ExamSubjectLimitDAL.CountLimitRepository.Entities
  39. .SingleOrDefault(x => x.ExaminationTypeID == view.ExaminationTypeID && x.SchoolyearNumID == view.SchoolyearNumID && x.StandardID == stand.StandardID);
  40. if (entity == null)
  41. {
  42. entity = new EX_ExaminationProjectCountLimit() { ExaminationSubjectCountLimitID = Guid.NewGuid() };
  43. this.SetNewStatus(entity);
  44. ExamSubjectLimitDAL.CountLimitRepository.UnitOfWork.Add(entity);
  45. }
  46. entity.ExaminationTypeID = view.ExaminationTypeID;
  47. entity.SchoolyearNumID = view.SchoolyearNumID;
  48. entity.StandardID = stand.StandardID;
  49. entity.SubjectCountLimit = view.SubjectCountLimit;
  50. this.SetModifyStatus(entity);
  51. // entity.ExaminationSubjectCountLimitID = view.ExaminationSubjectCountLimitID;
  52. }
  53. ExamSubjectLimitDAL.CountLimitRepository.UnitOfWork.Commit();
  54. }
  55. public ViewModel.ExamSubjectLimitView GetView(System.Linq.Expressions.Expression<Func<Entities.EX_ExaminationProjectCountLimit, bool>> expCampus)
  56. {
  57. var query = ExamSubjectLimitDAL.GetList(expCampus).SingleOrDefault();
  58. return query;
  59. }
  60. public IQueryable<ViewModel.ExamSubjectLimitView> GetList(params ViewModel.ConfiguretView[] configuretViews)
  61. {
  62. System.Linq.Expressions.Expression<Func<EX_ExaminationProjectCountLimit, bool>> expCampus = (x => true);
  63. var query = ExamSubjectLimitDAL.GetList(expCampus);
  64. //查询条件
  65. foreach (var configuretView in configuretViews)
  66. {
  67. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  68. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  69. }
  70. return query
  71. .OrderBy(x => x.ExaminationSubjectCountLimitID);
  72. }
  73. public bool Delete(List<Guid?> IDs)
  74. {
  75. UnitOfWork.Delete<EX_ExaminationProjectCountLimit>(x => IDs.Contains(x.ExaminationSubjectCountLimitID));
  76. UnitOfWork.Commit();
  77. return true;
  78. }
  79. }
  80. }