123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using EMIS.DataLogic.SelectCourse;
- using System.Linq.Expressions;
- using EMIS.Entities;
- using Bowin.Common.Linq.Entity;
- using Bowin.Common.Linq;
- using EMIS.ViewModel.SelectCourse;
- using EMIS.ViewModel;
- namespace EMIS.CommonLogic.SelectCourse
- {
- public class OpenControlSettingServices : BaseServices, IOpenControlSettingServices
- {
- public OpenControlSettingDAL OpenControlSettingDAL { get; set; }
- public Bowin.Common.Linq.Entity.IGridResultSet<ViewModel.SelectCourse.SelectCourseOpenControlSettingView>
- GetOpenControlSettingViewList(ViewModel.ConfiguretView configuretView, Guid? schoolYearID, Guid? campusID, Guid? collegeID,
- int? yearID, int? standardID, int pageIndex, int pageSize)
- {
- Expression<Func<EM_SelectCourseOpenControlSetting, bool>> openControlSettingExp = (x => true);
- Expression<Func<EMIS.Entities.CF_Schoolyear, bool>> schoolYearExp = (x => true);
- Expression<Func<CF_Grademajor, bool>> gradeMajorExp = (x => true);
- if (schoolYearID.HasValue)
- {
- openControlSettingExp = openControlSettingExp.And(x => x.SchoolyearID == schoolYearID.Value);
- }
- if (campusID.HasValue)
- {
- gradeMajorExp = gradeMajorExp.And(x => x.CF_Facultymajor.CF_College.CampusID == campusID.Value);
- }
- if (collegeID.HasValue)
- {
- gradeMajorExp = gradeMajorExp.And(x => x.CF_Facultymajor.CollegeID == collegeID.Value);
- }
- if (yearID.HasValue)
- {
- gradeMajorExp = gradeMajorExp.And(x => x.GradeID == yearID.Value);
- }
- if (standardID.HasValue)
- {
- gradeMajorExp = gradeMajorExp.And(x => x.CF_Facultymajor.StandardID == standardID.Value);
- }
- IQueryable<ViewModel.SelectCourse.SelectCourseOpenControlSettingView> q =
- OpenControlSettingDAL.GetOpenControlSettingView(openControlSettingExp, schoolYearExp, gradeMajorExp)
- .OrderByDescending(x => x.SchoolyearCode);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue) && !string.IsNullOrEmpty(configuretView.Attribute))
- q = q.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
- return this.GetQueryByDataRangeByCollege(q).ToGridResultSet(pageIndex, pageSize);
- }
- public IList<ViewModel.SelectCourse.SelectCourseOpenControlSettingView> GetOpenControlSettingViewList(
- ViewModel.ConfiguretView configuretView, Guid? schoolYearID, Guid? campusID, Guid? collegeID, int? yearID, int? standardID)
- {
- Expression<Func<EM_SelectCourseOpenControlSetting, bool>> openControlSettingExp = (x => true);
- Expression<Func<EMIS.Entities.CF_Schoolyear, bool>> schoolYearExp = (x => true);
- Expression<Func<CF_Grademajor, bool>> gradeMajorExp = (x => true);
- if (schoolYearID.HasValue)
- {
- openControlSettingExp = openControlSettingExp.And(x => x.SchoolyearID == schoolYearID.Value);
- }
- if (campusID.HasValue)
- {
- gradeMajorExp = gradeMajorExp.And(x => x.CF_Facultymajor.CF_College.CampusID == campusID.Value);
- }
- if (collegeID.HasValue)
- {
- gradeMajorExp = gradeMajorExp.And(x => x.CF_Facultymajor.CollegeID == collegeID.Value);
- }
- if (yearID.HasValue)
- {
- gradeMajorExp = gradeMajorExp.And(x => x.GradeID == yearID.Value);
- }
- if (standardID.HasValue)
- {
- gradeMajorExp = gradeMajorExp.And(x => x.CF_Facultymajor.StandardID == standardID.Value);
- }
- IQueryable<ViewModel.SelectCourse.SelectCourseOpenControlSettingView> q =
- OpenControlSettingDAL.GetOpenControlSettingView(openControlSettingExp, schoolYearExp, gradeMajorExp)
- .OrderByDescending(x => x.SchoolyearCode);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue) && !string.IsNullOrEmpty(configuretView.Attribute))
- q = q.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
- return this.GetQueryByDataRangeByCollege(q).ToList();
- }
- public ViewModel.SelectCourse.SelectCourseOpenControlSettingView GetOpenControlSettingViewInfo(Guid? openControlSettingID)
- {
- return OpenControlSettingDAL.GetOpenControlSettingView((x => x.SelectCourseOpenControlSettingID == openControlSettingID),
- (x => true), (x => true)).FirstOrDefault();
- }
- public void Save(ViewModel.SelectCourse.SelectCourseOpenControlSettingView openControlSetting)
- {
- var openControlSettingEntity = OpenControlSettingDAL.SelectCourseOpenControlSettingRepository
- .GetSingle(x => x.SelectCourseOpenControlSettingID == openControlSetting.SelectCourseOpenControlSettingID);
- if (openControlSettingEntity != null)
- {
- openControlSettingEntity.SchoolyearID = openControlSetting.SchoolyearID;
- openControlSettingEntity.GrademajorID = openControlSetting.GrademajorID;
- openControlSettingEntity.StartTime = openControlSetting.StartTime;
- openControlSettingEntity.EndTime = openControlSetting.EndTime;
- openControlSettingEntity.MaxSelectCount = openControlSetting.MaxSelectCount;
- openControlSettingEntity.MinSelectCount = openControlSetting.MinSelectCount;
- openControlSettingEntity.MaxCredit = openControlSetting.MaxCredit;
- openControlSettingEntity.MinCredit = openControlSetting.MinCredit;
- openControlSettingEntity.Remark = openControlSetting.Remark;
- this.SetModifyStatus(openControlSettingEntity);
- }
- else
- {
- openControlSettingEntity = new EM_SelectCourseOpenControlSetting();
- openControlSettingEntity.SelectCourseOpenControlSettingID = Guid.NewGuid();
- openControlSettingEntity.SchoolyearID = openControlSetting.SchoolyearID;
- openControlSettingEntity.GrademajorID = openControlSetting.GrademajorID;
- openControlSettingEntity.StartTime = openControlSetting.StartTime;
- openControlSettingEntity.EndTime = openControlSetting.EndTime;
- openControlSettingEntity.MaxSelectCount = openControlSetting.MaxSelectCount;
- openControlSettingEntity.MinSelectCount = openControlSetting.MinSelectCount;
- openControlSettingEntity.MaxCredit = openControlSetting.MaxCredit;
- openControlSettingEntity.MinCredit = openControlSetting.MinCredit;
- openControlSettingEntity.Remark = openControlSetting.Remark;
- this.SetNewStatus(openControlSettingEntity);
- UnitOfWork.Add(openControlSettingEntity);
- }
- var valid = OpenControlSettingDAL.SelectCourseOpenControlSettingRepository
- .GetSingle(x => x.SchoolyearID == openControlSetting.SchoolyearID &&
- x.GrademajorID == openControlSetting.GrademajorID &&
- x.SelectCourseOpenControlSettingID != openControlSettingEntity.SelectCourseOpenControlSettingID);
- if (valid != null)
- throw new Exception("已存在相同的学年学期和年级专业,请核查。");
- UnitOfWork.Commit();
- }
- public void Delete(IList<Guid?> openControlSettingIDList)
- {
- if (openControlSettingIDList.Count > 0)
- {
- UnitOfWork.Delete<EM_SelectCourseOpenControlSetting>(x => openControlSettingIDList.Contains(x.SelectCourseOpenControlSettingID));
- }
- }
- /// <summary>
- /// 任选控制
- /// </summary>
- /// <param name="openControlView"></param>
- /// <param name="SchoolyearID"></param>
- /// <param name="GradeYear"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<FreeSelectionCouseControlView> GetFreeSelectionCouseControlViewGrid(ViewModel.ConfiguretView openControlView, Guid? SchoolyearID,
- int? GradeYear, int pageIndex, int pageSize)
- {
- Expression<Func<EM_FreeSelectionCourseGradeYearSetting, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (SchoolyearID.HasValue)
- {
- exp = exp.And(x => x.SchoolyearID == SchoolyearID);
- }
- if (GradeYear.HasValue)
- {
- exp = exp.And(x => x.GradeYear == GradeYear);
- }
- var q = OpenControlSettingDAL.GetFreeSelectionCouseControlView(exp);
- if (!string.IsNullOrEmpty(openControlView.ConditionValue) && !string.IsNullOrEmpty(openControlView.Attribute))
- q = q.DynamicWhere(openControlView.Attribute, openControlView.Condition, openControlView.ConditionValue);
- return q.OrderBy(x => x.SchoolyearCode).ThenBy(x => x.GradeYear).ToGridResultSet<FreeSelectionCouseControlView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 任选控制
- /// </summary>
- /// <param name="openControlView"></param>
- /// <param name="SchoolyearID"></param>
- /// <param name="GradeYear"></param>
- /// <returns></returns>
- public IList<FreeSelectionCouseControlView> GetFreeSelectionCouseControlList(ViewModel.ConfiguretView openControlView, Guid? SchoolyearID, int? GradeYear)
- {
- Expression<Func<EM_FreeSelectionCourseGradeYearSetting, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (SchoolyearID.HasValue)
- {
- exp = exp.And(x => x.SchoolyearID == SchoolyearID);
- }
- if (GradeYear.HasValue)
- {
- exp = exp.And(x => x.GradeYear == GradeYear);
- }
- var q = OpenControlSettingDAL.GetFreeSelectionCouseControlView(exp);
- if (!string.IsNullOrEmpty(openControlView.ConditionValue) && !string.IsNullOrEmpty(openControlView.Attribute))
- q = q.DynamicWhere(openControlView.Attribute, openControlView.Condition, openControlView.ConditionValue);
- return q.OrderBy(x => x.SchoolyearCode).ThenBy(x => x.GradeYear).ToList();
- }
- /// <summary>
- /// 任选控制
- /// </summary>
- /// <param name="freeSelectionCouseControlID"></param>
- /// <returns></returns>
- public ViewModel.SelectCourse.FreeSelectionCouseControlView GetFreeSelectionCouseControlSettingViewInfo(Guid? freeSelectionCouseControlID)
- {
- return OpenControlSettingDAL.GetFreeSelectionCouseControlView((x => x.FreeSelectionCourseGradeYearSettingID == freeSelectionCouseControlID)).FirstOrDefault();
- }
- /// <summary>
- /// 任选控制
- /// </summary>
- /// <param name="openControlSetting"></param>
- public void FreeSelectionCouseControlSave(ViewModel.SelectCourse.FreeSelectionCouseControlView openControlSetting)
- {
- var openControlSettingEntity = OpenControlSettingDAL.FreeSelectionCourseGradeYearSettingRepository
- .GetSingle(x => x.FreeSelectionCourseGradeYearSettingID == openControlSetting.FreeSelectionCourseGradeYearSettingID);
- if (openControlSettingEntity != null)
- {
- openControlSettingEntity.SchoolyearID = openControlSetting.SchoolyearID;
- openControlSettingEntity.GradeYear = openControlSetting.GradeYear;
- openControlSettingEntity.StartTime = openControlSetting.StartTime;
- openControlSettingEntity.EndTime = openControlSetting.EndTime;
- openControlSettingEntity.MaxSelectCount = openControlSetting.MaxSelectCount;
- openControlSettingEntity.MinSelectCount = openControlSetting.MinSelectCount;
- openControlSettingEntity.MaxCredit = openControlSetting.MaxCredit;
- openControlSettingEntity.MinCredit = openControlSetting.MinCredit;
- openControlSettingEntity.Remark = openControlSetting.Remark;
- this.SetModifyStatus(openControlSettingEntity);
- }
- else
- {
- openControlSettingEntity = new EM_FreeSelectionCourseGradeYearSetting();
- openControlSettingEntity.FreeSelectionCourseGradeYearSettingID = Guid.NewGuid();
- openControlSettingEntity.SchoolyearID = openControlSetting.SchoolyearID;
- openControlSettingEntity.GradeYear = openControlSetting.GradeYear;
- openControlSettingEntity.StartTime = openControlSetting.StartTime;
- openControlSettingEntity.EndTime = openControlSetting.EndTime;
- openControlSettingEntity.MaxSelectCount = openControlSetting.MaxSelectCount;
- openControlSettingEntity.MinSelectCount = openControlSetting.MinSelectCount;
- openControlSettingEntity.MaxCredit = openControlSetting.MaxCredit;
- openControlSettingEntity.MinCredit = openControlSetting.MinCredit;
- openControlSettingEntity.Remark = openControlSetting.Remark;
- this.SetNewStatus(openControlSettingEntity);
- UnitOfWork.Add(openControlSettingEntity);
- }
- var valid = OpenControlSettingDAL.FreeSelectionCourseGradeYearSettingRepository
- .GetSingle(x => x.SchoolyearID == openControlSetting.SchoolyearID &&
- x.GradeYear == openControlSetting.GradeYear &&
- x.FreeSelectionCourseGradeYearSettingID != openControlSettingEntity.FreeSelectionCourseGradeYearSettingID);
- if (valid != null)
- throw new Exception("已存在相同的学年学期和年级,请核查。");
- UnitOfWork.Commit();
- }
- /// <summary>
- /// 任选控制
- /// </summary>
- /// <param name="openControlSettingIDList"></param>
- public void FreeSelectionCouseControlDelete(IList<Guid?> openControlSettingIDList)
- {
- if (openControlSettingIDList.Count > 0)
- {
- UnitOfWork.Delete<EM_FreeSelectionCourseGradeYearSetting>(x => openControlSettingIDList.Contains(x.FreeSelectionCourseGradeYearSettingID));
- }
- }
- }
- }
|