using System; using System.Collections.Generic; using System.Linq; using System.Text; using EMIS.DataLogic.Repositories; using EMIS.Entities; using Bowin.Common.Linq; using Bowin.Common.Linq.Entity; using EMIS.DataLogic.Common.AdministrativeOrgan; using EMIS.Utility; using System.Linq.Expressions; using EMIS.DataLogic.ExamManage; using EMIS.ViewModel.ExamManage; using EMIS.ViewModel; namespace EMIS.CommonLogic.ExamManage { public class ProjectFeeServices : BaseServices, IProjectFeeServices { public ProjectFeeDAL ProjectFeeDAL { get; set; } public Bowin.Common.Linq.Entity.IGridResultSet GetProjectFeeTypeGrid(ViewModel.ConfiguretView configuretView, int pageIndex, int pageSize) { //校区信息 Expression> expCampus = (x => x.RecordStatus > (int)EMIS.ViewModel.SYS_STATUS.UNUSABLE); var query = ProjectFeeDAL.GetProjectFeeTypeGrid(expCampus); //查询条件 if (!string.IsNullOrEmpty(configuretView.ConditionValue)) { query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); } return query .OrderBy(x => x.ExaminationProjectFeeID) .ToGridResultSet(pageIndex, pageSize); } public IQueryable GetProjectFeeTypeList(Expression> expCampus) { return ProjectFeeDAL.GetProjectFeeTypeGrid(expCampus); } public IGridResultSet GetExaminationTypeList(int pageIndex, int pageSize, params EMIS.ViewModel.ConfiguretView[] configuretViews) { //校区信息 Expression> expCampus = (x => x.RecordStatus > (int)EMIS.ViewModel.SYS_STATUS.UNUSABLE); var query = ProjectFeeDAL.GetExaminationType(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.ExaminationTypeID) .ToGridResultSet(pageIndex, pageSize); } public List GetExaminationTypeList() { //校区信息 Expression> exp = (x => x.RecordStatus > (int)EMIS.ViewModel.SYS_STATUS.UNUSABLE); var query = ProjectFeeDAL.GetExaminationType(exp); return query .OrderBy(x => x.Name) .ToList(); } public IGridResultSet GetProjectSubjectListViewGrid(EMIS.ViewModel.ConfiguretView configuretView, int pageIndex, int pageSize) { Expression> expCampus = (x => x.RecordStatus > (int)EMIS.ViewModel.SYS_STATUS.UNUSABLE); var query = ProjectFeeDAL.GetProjectSubjectList(expCampus); //查询条件 if (!string.IsNullOrEmpty(configuretView.ConditionValue)) { query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); } return query .OrderBy(x => x.ExaminationSubjectID) .ToGridResultSet(pageIndex, pageSize); } public List GetProjectSubjectListViewList(Guid? examinationProjectID) { Expression> exp = (x => x.RecordStatus > (int)EMIS.ViewModel.SYS_STATUS.UNUSABLE); if (examinationProjectID.HasValue) { exp = exp.And(x => x.ExaminationProjectID == examinationProjectID); } var query = ProjectFeeDAL.GetProjectSubjectList(exp).GroupBy(x => x.ExaminationSubjectID).Select(x => x.FirstOrDefault()); return query .OrderBy(x => x.ExaminationSubjectID) .ToList(); } public Bowin.Common.Linq.Entity.IGridResultSet GetProjectFeeGrid(int pageIndex, int pageSize, params ViewModel.ConfiguretView[] configuretViews) { //校区信息 Expression> expCampus = (x => x.RecordStatus > (int)EMIS.ViewModel.SYS_STATUS.UNUSABLE); var query = ProjectFeeDAL.GetProjectFee(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.ExaminationProjectFeeID) .ToGridResultSet(pageIndex, pageSize); } public EMIS.ViewModel.ExaminationProjectFeeView GetProjectFeeView(Expression> expCampus) { var query = ProjectFeeDAL.GetProjectFee(expCampus); return query.FirstOrDefault(); } public IQueryable GetProjectFeeList(params EMIS.ViewModel.ConfiguretView[] configuretViews) { System.Linq.Expressions.Expression> expCampus = (x => true); var query = ProjectFeeDAL.GetProjectFee(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.ExaminationProjectFeeID); } public Bowin.Common.Linq.Entity.IGridResultSet GetProjectListViewGrid(int pageIndex, int pageSize, params ViewModel.ConfiguretView[] configuretViews) { Expression> expCampus = (x => true); var query = ProjectFeeDAL.GetProectListViewGrid(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.ExaminationType).ThenBy(x=>x.Name) .ToGridResultSet(pageIndex, pageSize); result.rows.ForEach(s => { s.ProjectSubjects = s.EX_ExaminationProjectSubject.Select(q => (object)q.ExaminationSubjectID).ToList(); }); return result; } public IQueryable GetProjectList(params ViewModel.ConfiguretView[] configuretViews) { Expression> expCampus = (x => true); var query = ProjectFeeDAL.GetProectListViewGrid(expCampus); //查询条件 foreach (var configuretView in configuretViews) { if (!string.IsNullOrEmpty(configuretView.ConditionValue)) query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); } return query; } public EMIS.ViewModel.ProjectFeeTypeView GetProjectFeeType(Guid? ProjectFeeTypeID) { try { var query = ProjectFeeDAL.GetProjectFeeType(x => x.ExaminationProjectFeeTypeID == ProjectFeeTypeID).SingleOrDefault(); return query; } catch (Exception ex) { throw new Exception(ex.Message); } } public EMIS.ViewModel.ExaminationProjectFeeView GetProjectFee(Guid? ExaminationProjectFeeID) { try { var query = ProjectFeeDAL.GetProjectFee(x => x.ExaminationProjectFeeID == ExaminationProjectFeeID).SingleOrDefault(); return query; } catch (Exception ex) { throw new Exception(ex.Message); } } public EMIS.ViewModel.ExaminationProjectView GetProjectView(Expression> expCampus) { try { var query = ProjectFeeDAL.GetProectListViewGrid(expCampus).FirstOrDefault(); return query; } catch (Exception ex) { throw new Exception(ex.Message); } } public void ProjectFeeTypeEdit(EMIS.ViewModel.ProjectFeeTypeView view) { var entity = ProjectFeeDAL.ProjectFeeTypeRepository.Entities .SingleOrDefault(x => x.ExaminationProjectFeeTypeID == view.ExaminationProjectFeeTypeID); if (entity == null) { entity = new EMIS.Entities.EX_ExaminationProjectFeeType(); entity.ExaminationProjectFeeTypeID = Guid.NewGuid(); this.SetNewStatus(entity); ProjectFeeDAL.ProjectFeeTypeRepository.UnitOfWork.Add(entity); } entity.CreateTime = DateTime.Now; entity.ExaminationProjectFeeID = view.ExaminationProjectFeeID; entity.FeeTypeID = view.FeeTypeID; entity.Fee = view.Fee; entity.IsMaterial = view.IsMaterial; entity.IsRequiredForNew = view.IsRequiredForNew; entity.IsResit = view.IsResit; entity.IsTrainingFee = view.IsTrainingFee; this.SetModifyStatus(entity); ProjectFeeDAL.ProjectFeeTypeRepository.UnitOfWork.Commit(); } public void ProjectFeeEdit(EMIS.ViewModel.ExaminationProjectFeeView view) { var entity = ProjectFeeDAL.ProjectFeeRepository.Entities .SingleOrDefault(x => x.ExaminationProjectFeeID == view.ExaminationProjectFeeID); if (entity == null) { entity = new EX_ExaminationProjectFee(); this.SetNewStatus(entity); ProjectFeeDAL.ProjectFeeTypeRepository.UnitOfWork.Add(entity); } entity.CreateTime = DateTime.Now; entity.ExaminationProjectFeeID = view.ExaminationProjectFeeID; entity.Name = view.Name; entity.RecordStatus = view.RecordStatus; entity.ExaminationProjectID = view.ExaminationProjectID; this.SetModifyStatus(entity); ProjectFeeDAL.ProjectFeeRepository.UnitOfWork.Commit(); } public bool ProjectFeeDelete(List ExaminationProjectFeeIDs) { try { UnitOfWork.Delete(x => ExaminationProjectFeeIDs.Contains(x.ExaminationProjectFeeID)); UnitOfWork.Delete(x => ExaminationProjectFeeIDs.Contains(x.ExaminationProjectFeeID)); UnitOfWork.Commit(); return true; } catch (Exception) { throw; } } public bool ProjectDelete(List ExaminationProjectIDs) { try { UnitOfWork.Delete(x => ExaminationProjectIDs.Contains(x.ExaminationProjectID)); UnitOfWork.Delete(x => ExaminationProjectIDs.Contains(x.ExaminationProjectID)); UnitOfWork.Commit(); return true; } catch (Exception) { throw; } } public bool ProjectFeeTypeDelete(List ExaminationProjectFeeTypeIDs) { try { UnitOfWork.Delete(x => ExaminationProjectFeeTypeIDs.Contains(x.ExaminationProjectFeeTypeID)); UnitOfWork.Commit(); return true; } catch (Exception) { throw; } } public EMIS.ViewModel.ExaminationProjectView GetProject(Guid? ExaminationProjectID) { try { var query = ProjectFeeDAL.GetProectListViewGrid(x => x.ExaminationProjectID == ExaminationProjectID).SingleOrDefault(); query.ProjectSubjects = query.EX_ExaminationProjectSubject.Select(q => (object)q.ExaminationSubjectID).ToList(); return query; } catch (Exception ex) { throw new Exception(ex.Message); } } public void ProjectEdit(EMIS.ViewModel.ExaminationProjectView view, List subjectList) { var entity = ProjectFeeDAL.ProjectRepository.Entities .SingleOrDefault(x => x.ExaminationProjectID == view.ExaminationProjectID); if (entity == null) { entity = new EX_ExaminationProject(); this.SetNewStatus(entity); ProjectFeeDAL.ProjectFeeTypeRepository.UnitOfWork.Add(entity); } else { this.SetModifyStatus(entity); } entity.ExaminationProjectID = view.ExaminationProjectID; entity.Name = view.Name; entity.ExaminationLevelID = view.ExaminationLevelID; entity.ExaminationTypeID = view.ExaminationTypeID; entity.IssuedByID = view.IssuedByID; entity.PreposeProjectID = view.PreposeProjectID; entity.Remark = view.Remark; //修改科目 UnitOfWork.Delete(x => x.ExaminationProjectID == entity.ExaminationProjectID); List projectSubjectList = new List(); if (subjectList != null) { subjectList.ForEach(x => { EX_ExaminationProjectSubject projectSubject = new EX_ExaminationProjectSubject(); projectSubject.ExaminationProjectSubjectID = Guid.NewGuid(); projectSubject.ExaminationProjectID = entity.ExaminationProjectID; projectSubject.ExaminationSubjectID = x.ExaminationSubjectID; projectSubject.ResitCount = x.ResitCount; this.SetNewStatus(projectSubject); projectSubjectList.Add(projectSubject); }); } UnitOfWork.BulkInsert(projectSubjectList); UnitOfWork.Commit(); } public IGridResultSet GetSubjectByProjectIDGrid(ConfiguretView configuretView, Guid? projectID) { Expression> expeps = (x => x.RecordStatus > (int)EMIS.ViewModel.SYS_STATUS.UNUSABLE); expeps = expeps.And(x => x.ExaminationProjectID == projectID); var query = ProjectFeeDAL.GetExamSubjectByProjectID(expeps); //查询条件 if (!string.IsNullOrEmpty(configuretView.ConditionValue)) { query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); } return query.OrderBy(x => x.ExaminationSubjectID) .ToGridResultSet(); } public IGridResultSet GetSubjectListGrid(ConfiguretView configuretView, int pageIndex, int pageSize) { var query = ProjectFeeDAL.GetExamSubject(); return query.OrderBy(x => x.ExaminationSubjectID) .ToGridResultSet(pageIndex, pageSize); } } }