123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- 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;
- namespace EMIS.CommonLogic.ExamManage
- {
- public class ExaminationBatchServices : BaseServices,IExaminationBatchServices
- {
- public ExaminationBatchDAL ExaminationBatchDAL { get; set; }
- public IGridResultSet<EMIS.ViewModel.ExaminationBatchView> GetBatchListGridView(int pageIndex, int pageSize, params EMIS.ViewModel.ConfiguretView[] configuretViews)
- {
- //校区信息
- System.Linq.Expressions.Expression<Func<EX_ExaminationBatch, bool>> expCampus = (x => x.RecordStatus > (int)EMIS.ViewModel.SYS_STATUS.UNUSABLE);
- var query = ExaminationBatchDAL.GetBatchList(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)
- .ToGridResultSet<EMIS.ViewModel.ExaminationBatchView>(pageIndex, pageSize);
- }
- public IQueryable<EMIS.ViewModel.ExaminationBatchView> GetBatchList(params EMIS.ViewModel.ConfiguretView[] configuretViews)
- {
- System.Linq.Expressions.Expression<Func<EX_ExaminationBatch, bool>> expCampus = (x => x.RecordStatus > (int)EMIS.ViewModel.SYS_STATUS.UNUSABLE);
- var query = ExaminationBatchDAL.GetBatchList(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.ExaminationBatchID);
- }
- public EMIS.ViewModel.ExaminationBatchView GetExamBatch(Guid? ExaminationProjectID)
- {
- try
- {
- var query = ExaminationBatchDAL.GetBatchList(x => x.ExaminationBatchID == ExaminationProjectID).SingleOrDefault();
- return query;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- public EMIS.ViewModel.ExaminationBatchView GetExamBatch(Expression<Func<EX_ExaminationBatch, bool>> expCampus)
- {
- try
- {
- var query = ExaminationBatchDAL.GetBatchList(expCampus).SingleOrDefault();
- return query;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- public void Edit(EMIS.ViewModel.ExaminationBatchView view)
- {
- var entity = ExaminationBatchDAL.BatchRepository.Entities
- .SingleOrDefault(x => x.ExaminationBatchID == view.ExaminationBatchID);
- if (entity == null)
- {
- entity = new EX_ExaminationBatch();
- this.SetNewStatus(entity);
- ExaminationBatchDAL.BatchRepository.UnitOfWork.Add(entity);
- }
- entity.CreateTime = DateTime.Now;
- entity.ExaminationBatchID = view.ExaminationBatchID;
- entity.Name = view.Name;
- entity.RecordStatus = view.RecordStatus;
- entity.SchoolyearID = view.SchoolyearID;
- entity.Remark = view.Remark;
- entity.StartDate = view.StartDate;
- entity.EndDate = view.EndDate;
- this.SetModifyStatus(entity);
- ExaminationBatchDAL.BatchRepository.UnitOfWork.Commit();
- }
- public bool DeleteBatch(List<Guid?> ExamBatchIDs)
- {
- try
- {
- UnitOfWork.Delete<EX_ExaminationBatch>(x => ExamBatchIDs.Contains(x.ExaminationBatchID));
- UnitOfWork.Commit();
- return true;
- }
- catch (Exception)
- {
- throw;
- }
- }
- }
- }
|