using System; using System.Collections.Generic; using System.Linq; using System.Text; using EMIS.DataLogic.Common.ProcurementPlan; using EMIS.ViewModel.TeachingMaterial; using Bowin.Common.Linq.Entity; using System.Linq.Expressions; using EMIS.Entities; using Bowin.Common.Linq; using EMIS.CommonLogic.TeachingMaterial; namespace EMIS.CommonLogic.ProcurementPlan { public class PurchasingStatisticsServices : BaseServices, IPurchasingStatisticsServices { public PurchasingStatisticsDAL PurchasingStatisticsDAL { get; set; } public Lazy TeachersOrderServices { get; set; } public Bowin.Common.Linq.Entity.IGridResultSet GetPurchasingStatisticsViewGrid(ViewModel.ConfiguretView configuretView, Guid? schoolyearID, Guid? teachingMaterialPoolID, Guid? coursematerialID, Guid? publishID, int pageIndex, int pageSize) { var endStatusID = TeachersOrderServices.Value.GetCorrectEndStatus(); Expression> exporder = (x => x.ApprovalStatus == endStatusID); Expression> stuExporder = (x => true); if (schoolyearID.HasValue) { exporder = exporder.And(x => x.SchoolyearID == schoolyearID); stuExporder = stuExporder.And(x => x.EM_SpecialtyPlan.SchoolyearID == schoolyearID); } if (teachingMaterialPoolID.HasValue) { exporder = exporder.And(x => x.TeachingMaterialPoolID == teachingMaterialPoolID); stuExporder = stuExporder.And(x => x.TeachingMaterialPoolID == teachingMaterialPoolID); } if (coursematerialID.HasValue) { exporder = exporder.And(x => x.CF_TeachingMaterialPool.EM_Coursematerial.Any(w => w.CoursematerialID == coursematerialID)); stuExporder = stuExporder.And(x => x.CF_TeachingMaterialPool.EM_Coursematerial.Any(w => w.CoursematerialID == coursematerialID)); } if (publishID.HasValue) { exporder = exporder.And(x => x.CF_TeachingMaterialPool.PublishID == publishID); stuExporder = stuExporder.And(x => x.CF_TeachingMaterialPool.PublishID == publishID); } var query = PurchasingStatisticsDAL.GetPurchasingStatisticsGridView(exporder, stuExporder); if (!string.IsNullOrEmpty(configuretView.ConditionValue)) return query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue).OrderBy(x => x.SchoolyearName).ToGridResultSet(pageIndex, pageSize); return query.OrderBy(x => x.SchoolyearName).OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToGridResultSet(pageIndex, pageSize); } public IList GetPurchasingStatisticsList(ViewModel.ConfiguretView configuretView, Guid? schoolyearID, Guid? teachingMaterialPoolID, Guid? coursematerialID, Guid? publishID) { var endStatusID = TeachersOrderServices.Value.GetCorrectEndStatus(); Expression> exporder = (x => x.ApprovalStatus == endStatusID); Expression> stuExporder = (x => true); if (schoolyearID.HasValue) { exporder = exporder.And(x => x.SchoolyearID == schoolyearID); stuExporder = stuExporder.And(x => x.EM_SpecialtyPlan.SchoolyearID == schoolyearID); } if (teachingMaterialPoolID.HasValue) { exporder = exporder.And(x => x.TeachingMaterialPoolID == teachingMaterialPoolID); stuExporder = stuExporder.And(x => x.TeachingMaterialPoolID == teachingMaterialPoolID); } if (coursematerialID.HasValue) { exporder = exporder.And(x => x.CF_TeachingMaterialPool.EM_Coursematerial.Any(w => w.CoursematerialID == coursematerialID)); stuExporder = stuExporder.And(x => x.CF_TeachingMaterialPool.EM_Coursematerial.Any(w => w.CoursematerialID == coursematerialID)); } if (publishID.HasValue) { exporder = exporder.And(x => x.CF_TeachingMaterialPool.PublishID == publishID); stuExporder = stuExporder.And(x => x.CF_TeachingMaterialPool.PublishID == publishID); } var query = PurchasingStatisticsDAL.GetPurchasingStatisticsGridView(exporder, stuExporder); if (!string.IsNullOrEmpty(configuretView.ConditionValue)) return query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue).OrderBy(x => x.SchoolyearName).ToList(); return query.OrderBy(x => x.SchoolyearName).ToList(); } } }