PurchasingStatisticsServices.cs 4.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.DataLogic.Common.ProcurementPlan;
  6. using EMIS.ViewModel.TeachingMaterial;
  7. using Bowin.Common.Linq.Entity;
  8. using System.Linq.Expressions;
  9. using EMIS.Entities;
  10. using Bowin.Common.Linq;
  11. using EMIS.CommonLogic.TeachingMaterial;
  12. namespace EMIS.CommonLogic.ProcurementPlan
  13. {
  14. public class PurchasingStatisticsServices : BaseServices, IPurchasingStatisticsServices
  15. {
  16. public PurchasingStatisticsDAL PurchasingStatisticsDAL { get; set; }
  17. public Lazy<ITeachersOrderServices> TeachersOrderServices { get; set; }
  18. public Bowin.Common.Linq.Entity.IGridResultSet<ViewModel.TeachingMaterial.PurchasingStatisticsView> GetPurchasingStatisticsViewGrid(ViewModel.ConfiguretView configuretView, Guid? schoolyearID, Guid? teachingMaterialPoolID, Guid? coursematerialID, Guid? publishID, int pageIndex, int pageSize)
  19. {
  20. var endStatusID = TeachersOrderServices.Value.GetCorrectEndStatus();
  21. Expression<Func<ET_TeachersOrder, bool>> exporder = (x => x.ApprovalStatus == endStatusID);
  22. Expression<Func<ET_StudentsOrder, bool>> stuExporder = (x => true);
  23. if (schoolyearID.HasValue)
  24. {
  25. exporder = exporder.And(x => x.SchoolyearID == schoolyearID);
  26. stuExporder = stuExporder.And(x => x.EM_SpecialtyPlan.SchoolyearID == schoolyearID);
  27. }
  28. if (teachingMaterialPoolID.HasValue)
  29. {
  30. exporder = exporder.And(x => x.TeachingMaterialPoolID == teachingMaterialPoolID);
  31. stuExporder = stuExporder.And(x => x.TeachingMaterialPoolID == teachingMaterialPoolID);
  32. }
  33. if (coursematerialID.HasValue)
  34. {
  35. exporder = exporder.And(x => x.CF_TeachingMaterialPool.EM_Coursematerial.Any(w => w.CoursematerialID == coursematerialID));
  36. stuExporder = stuExporder.And(x => x.CF_TeachingMaterialPool.EM_Coursematerial.Any(w => w.CoursematerialID == coursematerialID));
  37. }
  38. if (publishID.HasValue)
  39. {
  40. exporder = exporder.And(x => x.CF_TeachingMaterialPool.PublishID == publishID);
  41. stuExporder = stuExporder.And(x => x.CF_TeachingMaterialPool.PublishID == publishID);
  42. }
  43. var query = PurchasingStatisticsDAL.GetPurchasingStatisticsGridView(exporder, stuExporder);
  44. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  45. return query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue).OrderBy(x => x.SchoolyearName).ToGridResultSet<PurchasingStatisticsView>(pageIndex, pageSize);
  46. return query.OrderBy(x => x.SchoolyearName).OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToGridResultSet<PurchasingStatisticsView>(pageIndex, pageSize);
  47. }
  48. public IList<ViewModel.TeachingMaterial.PurchasingStatisticsView> GetPurchasingStatisticsList(ViewModel.ConfiguretView configuretView, Guid? schoolyearID, Guid? teachingMaterialPoolID, Guid? coursematerialID, Guid? publishID)
  49. {
  50. var endStatusID = TeachersOrderServices.Value.GetCorrectEndStatus();
  51. Expression<Func<ET_TeachersOrder, bool>> exporder = (x => x.ApprovalStatus == endStatusID);
  52. Expression<Func<ET_StudentsOrder, bool>> stuExporder = (x => true);
  53. if (schoolyearID.HasValue)
  54. {
  55. exporder = exporder.And(x => x.SchoolyearID == schoolyearID);
  56. stuExporder = stuExporder.And(x => x.EM_SpecialtyPlan.SchoolyearID == schoolyearID);
  57. }
  58. if (teachingMaterialPoolID.HasValue)
  59. {
  60. exporder = exporder.And(x => x.TeachingMaterialPoolID == teachingMaterialPoolID);
  61. stuExporder = stuExporder.And(x => x.TeachingMaterialPoolID == teachingMaterialPoolID);
  62. }
  63. if (coursematerialID.HasValue)
  64. {
  65. exporder = exporder.And(x => x.CF_TeachingMaterialPool.EM_Coursematerial.Any(w => w.CoursematerialID == coursematerialID));
  66. stuExporder = stuExporder.And(x => x.CF_TeachingMaterialPool.EM_Coursematerial.Any(w => w.CoursematerialID == coursematerialID));
  67. }
  68. if (publishID.HasValue)
  69. {
  70. exporder = exporder.And(x => x.CF_TeachingMaterialPool.PublishID == publishID);
  71. stuExporder = stuExporder.And(x => x.CF_TeachingMaterialPool.PublishID == publishID);
  72. }
  73. var query = PurchasingStatisticsDAL.GetPurchasingStatisticsGridView(exporder, stuExporder);
  74. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  75. return query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue).OrderBy(x => x.SchoolyearName).ToList();
  76. return query.OrderBy(x => x.SchoolyearName).ToList();
  77. }
  78. }
  79. }