123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Bowin.Common.Linq;
- using Bowin.Common.Linq.Entity;
- using EMIS.DataLogic.SelectCourse;
- using System.Linq.Expressions;
- using EMIS.Entities;
- namespace EMIS.CommonLogic.SelectCourse
- {
- public class TypeSettingServices : BaseServices, ITypeSettingServices
- {
- public TypeSettingDAL TypeSettingDAL { get; set; }
- public Bowin.Common.Linq.Entity.IGridResultSet<ViewModel.SelectCourse.SelectCourseTypeSettingView> GetTypeSettingViewList(
- ViewModel.ConfiguretView configuretView, Guid? schoolYearID, int? selectCourseTypeID, int? recordStatus,
- int pageIndex, int pageSize)
- {
- Expression<Func<EM_SelectCourseTypeSetting, bool>> typeSettingExp = (x => true);
- Expression<Func<EMIS.Entities.CF_Schoolyear, bool>> schoolYearExp = (x => true);
- if (schoolYearID.HasValue)
- {
- typeSettingExp = typeSettingExp.And(x => x.SchoolyearID == schoolYearID.Value);
- }
- if (selectCourseTypeID.HasValue)
- {
- typeSettingExp = typeSettingExp.And(x => x.SelectCourseTypeID == selectCourseTypeID.Value);
- }
- if (recordStatus.HasValue)
- {
- typeSettingExp = typeSettingExp.And(x => x.RecordStatus == recordStatus.Value);
- }
- IQueryable<ViewModel.SelectCourse.SelectCourseTypeSettingView> q = TypeSettingDAL.GetTypeSettingView(typeSettingExp, schoolYearExp)
- .OrderByDescending(x => x.SchoolyearCode);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue) && !string.IsNullOrEmpty(configuretView.Attribute))
- q = q.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
- return q.ToGridResultSet(pageIndex, pageSize);
- }
- public IList<ViewModel.SelectCourse.SelectCourseTypeSettingView> GetTypeSettingViewList(ViewModel.ConfiguretView configuretView,
- Guid? schoolYearID, int? selectCourseTypeID, int? recordStatus)
- {
- Expression<Func<EM_SelectCourseTypeSetting, bool>> typeSettingExp = (x => true);
- Expression<Func<EMIS.Entities.CF_Schoolyear, bool>> schoolYearExp = (x => true);
- if (schoolYearID.HasValue)
- {
- typeSettingExp = typeSettingExp.And(x => x.SchoolyearID == schoolYearID.Value);
- }
- if (selectCourseTypeID.HasValue)
- {
- typeSettingExp = typeSettingExp.And(x => x.SelectCourseTypeID == selectCourseTypeID.Value);
- }
- if (recordStatus.HasValue)
- {
- typeSettingExp = typeSettingExp.And(x => x.RecordStatus == recordStatus.Value);
- }
- IQueryable<ViewModel.SelectCourse.SelectCourseTypeSettingView> q = TypeSettingDAL.GetTypeSettingView(typeSettingExp, schoolYearExp)
- .OrderByDescending(x => x.SchoolyearCode);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue) && !string.IsNullOrEmpty(configuretView.Attribute))
- q = q.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
- return q.ToList();
- }
- public ViewModel.SelectCourse.SelectCourseTypeSettingView GetTypeSettingViewInfo(Guid? typeSettingID)
- {
- return TypeSettingDAL.GetTypeSettingView((x => x.SelectCourseTypeSettingID == typeSettingID), (x => true)).FirstOrDefault();
- }
- public void Save(ViewModel.SelectCourse.SelectCourseTypeSettingView typeSetting)
- {
- var dupSettingList = TypeSettingDAL.SelectCourseTypeSettingRepository
- .GetList(x => x.SchoolyearID == typeSetting.SchoolyearID
- && x.SelectCourseTypeID == typeSetting.SelectCourseTypeID
- && x.EndTime >= typeSetting.StartTime && x.StartTime <= typeSetting.EndTime
- && x.SelectCourseTypeSettingID != typeSetting.SelectCourseTypeSettingID).ToList();
- var typeSettingEntity = TypeSettingDAL.SelectCourseTypeSettingRepository
- .GetSingle(x => x.SelectCourseTypeSettingID == typeSetting.SelectCourseTypeSettingID);
- if (typeSettingEntity != null)
- {
- if (dupSettingList.Count > 0)
- {
- throw new Exception("在同一学年学期的有效时间内存在重复的类型设定,不能保存。");
- }
- typeSettingEntity.SchoolyearID = typeSetting.SchoolyearID;
- typeSettingEntity.SelectCourseTypeID = typeSetting.SelectCourseTypeID;
- typeSettingEntity.StartTime = typeSetting.StartTime;
- typeSettingEntity.EndTime = typeSetting.EndTime;
- typeSettingEntity.MaxSelectCount = typeSetting.MaxSelectCount;
- typeSettingEntity.MinSelectCount = typeSetting.MinSelectCount;
- typeSettingEntity.MaxCredit = typeSetting.MaxCredit;
- typeSettingEntity.MinCredit = typeSetting.MinCredit;
- typeSettingEntity.Remark = typeSetting.Remark;
- this.SetModifyStatus(typeSettingEntity);
- }
- else
- {
- if (dupSettingList.Count > 0)
- {
- throw new Exception("在同一学年学期的有效时间内存在重复的类型设定,不能添加。");
- }
- typeSettingEntity = new EM_SelectCourseTypeSetting();
- typeSettingEntity.SelectCourseTypeSettingID = Guid.NewGuid();
- typeSettingEntity.SchoolyearID = typeSetting.SchoolyearID;
- typeSettingEntity.SelectCourseTypeID = typeSetting.SelectCourseTypeID;
- typeSettingEntity.StartTime = typeSetting.StartTime;
- typeSettingEntity.EndTime = typeSetting.EndTime;
- typeSettingEntity.MaxSelectCount = typeSetting.MaxSelectCount;
- typeSettingEntity.MinSelectCount = typeSetting.MinSelectCount;
- typeSettingEntity.MaxCredit = typeSetting.MaxCredit;
- typeSettingEntity.MinCredit = typeSetting.MinCredit;
- typeSettingEntity.Remark = typeSetting.Remark;
- this.SetNewStatus(typeSettingEntity);
- UnitOfWork.Add(typeSettingEntity);
- }
- UnitOfWork.Commit();
- }
- public void Delete(IList<Guid?> typeSettingIDList)
- {
- if (typeSettingIDList.Count > 0)
- {
- UnitOfWork.Delete<EM_SelectCourseTypeSetting>(x => typeSettingIDList.Contains(x.SelectCourseTypeSettingID));
- }
- }
- }
- }
|