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 GetOpenControlSettingViewList(ViewModel.ConfiguretView configuretView, Guid? schoolYearID, Guid? campusID, Guid? collegeID, int? yearID, int? standardID, int pageIndex, int pageSize) { Expression> openControlSettingExp = (x => true); Expression> schoolYearExp = (x => true); Expression> 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 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 GetOpenControlSettingViewList( ViewModel.ConfiguretView configuretView, Guid? schoolYearID, Guid? campusID, Guid? collegeID, int? yearID, int? standardID) { Expression> openControlSettingExp = (x => true); Expression> schoolYearExp = (x => true); Expression> 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 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 openControlSettingIDList) { if (openControlSettingIDList.Count > 0) { UnitOfWork.Delete(x => openControlSettingIDList.Contains(x.SelectCourseOpenControlSettingID)); } } /// /// 任选控制 /// /// /// /// /// /// /// public IGridResultSet GetFreeSelectionCouseControlViewGrid(ViewModel.ConfiguretView openControlView, Guid? SchoolyearID, int? GradeYear, int pageIndex, int pageSize) { Expression> 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(pageIndex, pageSize); } /// /// 任选控制 /// /// /// /// /// public IList GetFreeSelectionCouseControlList(ViewModel.ConfiguretView openControlView, Guid? SchoolyearID, int? GradeYear) { Expression> 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(); } /// /// 任选控制 /// /// /// public ViewModel.SelectCourse.FreeSelectionCouseControlView GetFreeSelectionCouseControlSettingViewInfo(Guid? freeSelectionCouseControlID) { return OpenControlSettingDAL.GetFreeSelectionCouseControlView((x => x.FreeSelectionCourseGradeYearSettingID == freeSelectionCouseControlID)).FirstOrDefault(); } /// /// 任选控制 /// /// 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(); } /// /// 任选控制 /// /// public void FreeSelectionCouseControlDelete(IList openControlSettingIDList) { if (openControlSettingIDList.Count > 0) { UnitOfWork.Delete(x => openControlSettingIDList.Contains(x.FreeSelectionCourseGradeYearSettingID)); } } } }