using System; using System.Collections.Generic; using System.Linq; using System.Text; using Bowin.Common.Linq.Entity; using EMIS.Entities; using EMIS.DataLogic.ExamManage; using System.Linq.Expressions; using EMIS.DataLogic; namespace EMIS.CommonLogic.ExamManage { public class ExamProjectControlServices : BaseServices, IExamProjectControlServices { public ExamProjectControlDAL ExamProjectControlDAL { get; set; } public ProjectFeeDAL ProjectFeeDAL { get; set; } public Bowin.Common.Linq.Entity.IGridResultSet GetListGridView(int pageIndex, int pageSize, params ViewModel.ConfiguretView[] configuretViews) { System.Linq.Expressions.Expression> expCampus = (x => true); var query = ExamProjectControlDAL.GetList(expCampus); //查询条件 foreach (var configuretView in configuretViews) { if (!string.IsNullOrEmpty(configuretView.ConditionValue)) query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); } //排序:按学年学期(倒序)、考试批次、项目名称、年级、院系、专业 return query.OrderByDescending(x=>x.Schoolyear) .ThenBy(x => x.ExaminationBatchID).ThenBy(x => x.ProjectName).ThenBy(x => x.SchoolyearID) .ThenBy(x => x.CollegeID).ThenBy(x => x.StandardID) .ToGridResultSet(pageIndex, pageSize); } public IGridResultSet GetControlExamTypeListViewGrid(int pageIndex, int pageSize, params EMIS.ViewModel.ConfiguretView[] configuretViews) { System.Linq.Expressions.Expression> expCampus = (x => true); var query = ExamProjectControlDAL.GetList(expCampus); //查询条件 foreach (var configuretView in configuretViews) { if (!string.IsNullOrEmpty(configuretView.ConditionValue)) query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); } var result = query.OrderBy(x => x.ExaminationBatchProjectID).GroupBy(x => new { x.ExaminationBatchID, x.ExaminationTypeID, x.ExaminationType }).Select(x => new EMIS.ViewModel.ExaminationApply.ExaminationTypeView() { ExaminationBatchID = x.Key.ExaminationBatchID.Value, ExaminationTypeID = x.Key.ExaminationTypeID.Value, Name = x.Key.ExaminationType }); return result .OrderBy(x => x.ExaminationBatchID) .ToGridResultSet(pageIndex, pageSize); } public IGridResultSet GetControlProjectListViewGrid(int pageIndex, int pageSize, params EMIS.ViewModel.ConfiguretView[] configuretViews) { System.Linq.Expressions.Expression> expCampus = (x => true); var query = ExamProjectControlDAL.GetList(expCampus); //查询条件 foreach (var configuretView in configuretViews) { if (!string.IsNullOrEmpty(configuretView.ConditionValue)) query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); } var result = query.OrderBy(x => x.ExaminationBatchProjectID).GroupBy(x => new { x.ExaminationBatchID, x.ExaminationTypeID, x.ExaminationBatchProjectID, x.ExaminationProjectID, x.ProjectName }).Select(x => new EMIS.ViewModel.ExamBatchProjectView() { ExaminationBatchID = x.Key.ExaminationBatchID.Value, ExaminationTypeID = x.Key.ExaminationTypeID.Value, Name = x.Key.ProjectName, ExaminationProjectID = x.Key.ExaminationProjectID, ExaminationBatchProjectID = x.Key.ExaminationBatchProjectID.Value, }); return result .OrderBy(x => x.ExaminationBatchID) .ToGridResultSet(pageIndex, pageSize); } public ViewModel.ExamProjectControlView GetView(Guid? ViewID) { var query = ExamProjectControlDAL.GetList(x => x.ExaminationBatchProjectControlID == ViewID).SingleOrDefault(); return query; } public void Edit(ViewModel.ExamProjectControlView view, List standardList) { var examinationBatchProject = ProjectFeeDAL.BatchProjectRepository.Entities.Where(x => x.ExaminationBatchID == view.ExaminationBatchID && x.ExaminationProjectID == view.ExaminationProjectID).FirstOrDefault(); foreach (var stand in standardList) { var entity = ExamProjectControlDAL.ProjectControlRepository.Entities .SingleOrDefault(x => x.ExaminationBatchProjectID == examinationBatchProject.ExaminationBatchProjectID && x.StandardID == stand.StandardID && x.CollegeID == stand.CollegeID && x.SchoolyearID == stand.SchoolyearID); if (entity == null) { entity = new EX_ExaminationBatchProjectControl(); entity.ExaminationBatchProjectControlID = Guid.NewGuid(); this.SetNewStatus(entity); ExamProjectControlDAL.ProjectControlRepository.UnitOfWork.Add(entity); } entity.CollegeID = stand.CollegeID; entity.SchoolyearID = stand.SchoolyearID; entity.StandardID = stand.StandardID; entity.ExaminationBatchProjectID = examinationBatchProject.ExaminationBatchProjectID; entity.IsOnlinePay = view.IsOnlinePay; entity.ExaminationProjectFeeID = view.ExaminationProjectFeeID; this.SetModifyStatus(entity); } ExamProjectControlDAL.ProjectControlRepository.UnitOfWork.Commit(); } public void Edit(ViewModel.ExamProjectControlView view) { var examinationBatchProject = ProjectFeeDAL.BatchProjectRepository.Entities.Where(x => x.ExaminationBatchID == view.ExaminationBatchID && x.ExaminationProjectID == view.ExaminationProjectID).FirstOrDefault(); var entity = ExamProjectControlDAL.ProjectControlRepository.Entities .SingleOrDefault(x => x.ExaminationBatchProjectControlID == view.ExaminationBatchProjectControlID); if (entity == null) { entity = new EX_ExaminationBatchProjectControl(); this.SetNewStatus(entity); ExamProjectControlDAL.ProjectControlRepository.UnitOfWork.Add(entity); } entity.ExaminationBatchProjectControlID = view.ExaminationBatchProjectControlID; entity.CollegeID = view.CollegeID; entity.SchoolyearID = view.SchoolyearID == -1 ? null : view.SchoolyearID; entity.StandardID = view.StandardID == -1 ? null : view.StandardID; entity.ExaminationBatchProjectID = examinationBatchProject.ExaminationBatchProjectID; entity.IsOnlinePay = view.IsOnlinePay; entity.ExaminationProjectFeeID = view.ExaminationProjectFeeID; this.SetModifyStatus(entity); ExamProjectControlDAL.ProjectControlRepository.UnitOfWork.Commit(); } public ViewModel.ExamProjectControlView GetView(System.Linq.Expressions.Expression> expCampus) { var query = ExamProjectControlDAL.GetList(expCampus).SingleOrDefault(); return query; } public IQueryable GetList(params ViewModel.ConfiguretView[] configuretViews) { System.Linq.Expressions.Expression> expCampus = (x => true); var query = ExamProjectControlDAL.GetList(expCampus); //查询条件 foreach (var configuretView in configuretViews) { if (!string.IsNullOrEmpty(configuretView.ConditionValue)) query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); } return query .OrderBy(x => x.ExaminationBatchProjectControlID); } public bool Delete(List IDs) { UnitOfWork.Delete(x => IDs.Contains(x.ExaminationBatchProjectControlID)); UnitOfWork.Commit(); return true; } } }