using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Text.RegularExpressions; using System.Linq.Expressions; using System.Transactions; using Bowin.Common.Utility; using Bowin.Common.Linq; using Bowin.Common.Linq.Entity; using EMIS.Utility; using EMIS.Entities; using EMIS.ViewModel; using EMIS.ViewModel.CacheManage; using EMIS.ViewModel.CultureplanManage; using EMIS.ViewModel.CultureplanManage.PlanManagement; using EMIS.ViewModel.UniversityManage.SpecialtyClassManage; using EMIS.ViewModel.Students; using EMIS.DataLogic.CultureplanManage.PlanManagement; using EMIS.DataLogic.EducationManage; using EMIS.CommonLogic.StudentManage.StudentStatistics; namespace EMIS.CommonLogic.CultureplanManage.PlanManagement { public class AdultSpecialtyPlanServices : BaseServices, IAdultSpecialtyPlanServices { public SpecialtyPlanDAL SpecialtyPlanDAL { get; set; } public ExecutablePlanDAL ExecutablePlanDAL { get; set; } public Lazy InSchoolSettingServices { get; set; } /// /// 查询对应的专业计划信息SpecialtyPlanView /// 注:成教版本(入学学年学期、专业信息) /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// public IGridResultSet GetAdultSpecialtyPlanViewGrid(ConfiguretView configuretView, Guid? schoolyearID, Guid? departmentID, int? yearID, int? standardID, int? educationID, int? learningformID, string learnSystem, Guid? coursematerialID, int? courseTypeID, int? isMainCourse, int? teachingModeID, int? handleModeID, int pageIndex, int pageSize) { //专业计划 Expression> expSpecialtyPlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (schoolyearID.HasValue) { expSpecialtyPlan = expSpecialtyPlan.And(x => x.SchoolyearID == schoolyearID); } if (departmentID.HasValue) { expSpecialtyPlan = expSpecialtyPlan.And(x => x.DepartmentID == departmentID); } if (coursematerialID.HasValue) { expSpecialtyPlan = expSpecialtyPlan.And(x => x.CoursematerialID == coursematerialID); } if (courseTypeID.HasValue) { expSpecialtyPlan = expSpecialtyPlan.And(x => x.CourseTypeID == courseTypeID); } if (isMainCourse.HasValue) { //是否学位课程 if (isMainCourse == (int)CF_GeneralPurpose.IsYes) { expSpecialtyPlan = expSpecialtyPlan.And(x => x.IsMainCourse == true); } if (isMainCourse == (int)CF_GeneralPurpose.IsNo) { expSpecialtyPlan = expSpecialtyPlan.And(x => x.IsMainCourse != true); } } if (handleModeID.HasValue) { expSpecialtyPlan = expSpecialtyPlan.And(x => x.HandleModeID == handleModeID); } //学生信息 Expression> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); var query = SpecialtyPlanDAL.GetAdultSpecialtyPlanViewQueryable(expSpecialtyPlan, expStudent); if (yearID.HasValue) { query = query.Where(x => x.GradeID == yearID); } if (standardID.HasValue) { query = query.Where(x => x.StandardID == standardID); } if (educationID.HasValue) { query = query.Where(x => x.EducationID == educationID); } if (learningformID.HasValue) { query = query.Where(x => x.LearningformID == learningformID); } if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1") { var LearnSystems = Convert.ToDecimal(learnSystem); query = query.Where(x => x.LearnSystem == LearnSystems); } if (teachingModeID.HasValue) { //授课方式 query = query.Where(x => x.TeachingModeIDList.Contains(teachingModeID)); } //查询条件 if (!string.IsNullOrEmpty(configuretView.ConditionValue)) { query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); } return this.GetQueryByDataRangeByCollege(query) .OrderBy(x => x.GradeID).ThenBy(x => x.StandardID) .ThenBy(x => x.EducationID).ThenBy(x => x.LearningformID) .ThenBy(x => x.LearnSystem).ThenBy(x => x.Value) .ThenBy(x => x.CourseTypeID).ThenBy(x => x.CourseCode.Length) .ThenBy(x => x.CourseCode) .ToGridResultSet(pageIndex, pageSize); } /// /// 查询对应的专业计划信息List /// 注:成教版本(入学学年学期、专业信息) /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// public IList GetAdultSpecialtyPlanViewList(ConfiguretView configuretView, Guid? schoolyearID, Guid? departmentID, int? yearID, int? standardID, int? educationID, int? learningformID, string learnSystem, Guid? coursematerialID, int? courseTypeID, int? isMainCourse, int? teachingModeID, int? handleModeID) { //专业计划 Expression> expSpecialtyPlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (schoolyearID.HasValue) { expSpecialtyPlan = expSpecialtyPlan.And(x => x.SchoolyearID == schoolyearID); } if (departmentID.HasValue) { expSpecialtyPlan = expSpecialtyPlan.And(x => x.DepartmentID == departmentID); } if (coursematerialID.HasValue) { expSpecialtyPlan = expSpecialtyPlan.And(x => x.CoursematerialID == coursematerialID); } if (courseTypeID.HasValue) { expSpecialtyPlan = expSpecialtyPlan.And(x => x.CourseTypeID == courseTypeID); } if (isMainCourse.HasValue) { //是否学位课程 if (isMainCourse == (int)CF_GeneralPurpose.IsYes) { expSpecialtyPlan = expSpecialtyPlan.And(x => x.IsMainCourse == true); } if (isMainCourse == (int)CF_GeneralPurpose.IsNo) { expSpecialtyPlan = expSpecialtyPlan.And(x => x.IsMainCourse != true); } } if (handleModeID.HasValue) { expSpecialtyPlan = expSpecialtyPlan.And(x => x.HandleModeID == handleModeID); } //学生信息 Expression> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); var query = SpecialtyPlanDAL.GetAdultSpecialtyPlanViewQueryable(expSpecialtyPlan, expStudent); if (yearID.HasValue) { query = query.Where(x => x.GradeID == yearID); } if (standardID.HasValue) { query = query.Where(x => x.StandardID == standardID); } if (educationID.HasValue) { query = query.Where(x => x.EducationID == educationID); } if (learningformID.HasValue) { query = query.Where(x => x.LearningformID == learningformID); } if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1") { var LearnSystems = Convert.ToDecimal(learnSystem); query = query.Where(x => x.LearnSystem == LearnSystems); } if (teachingModeID.HasValue) { //授课方式 query = query.Where(x => x.TeachingModeIDList.Contains(teachingModeID)); } //查询条件 if (!string.IsNullOrEmpty(configuretView.ConditionValue)) { query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); } return this.GetQueryByDataRangeByCollege(query) .OrderBy(x => x.GradeID).ThenBy(x => x.StandardID) .ThenBy(x => x.EducationID).ThenBy(x => x.LearningformID) .ThenBy(x => x.LearnSystem).ThenBy(x => x.Value) .ThenBy(x => x.CourseTypeID).ThenBy(x => x.CourseCode.Length) .ThenBy(x => x.CourseCode).ToList(); } /// /// 查询对应的专业计划信息SpecialtyPlanView(根据专业计划ID) /// /// /// public SpecialtyPlanView GetAdultSpecialtyPlanView(Guid? specialtyPlanID) { try { var specialtyPlanView = SpecialtyPlanDAL.GetAdultSpecialtyPlanViewQueryable(x => x.SpecialtyPlanID == specialtyPlanID).SingleOrDefault(); return specialtyPlanView; } catch (Exception ex) { throw new Exception(ex.Message); } } /// /// 编辑(新增、修改,业务主键:学年学期ID、入学学年学期ID、专业信息ID、课程信息ID) /// 注:刷新相关的执行计划信息 /// /// public void AdultSpecialtyPlanEdit(SpecialtyPlanView specialtyPlanView) { try { //查询对应的专业信息 var specialty = SpecialtyPlanDAL.SpecialtyRepository .GetList(x => x.SpecialtyID == specialtyPlanView.SpecialtyID).SingleOrDefault(); if (specialty == null) { throw new Exception("专业信息不存在,请检查。"); } //查询学年学期信息schoolyearList var schoolyearList = SpecialtyPlanDAL.SchoolyearRepository .GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE).ToList(); //查询对应的入学学年学期信息 var startSchoolyear = schoolyearList.Where(x => x.Years == specialtyPlanView.GradeID && x.SchoolcodeID == specialtyPlanView.StartSchoolcodeID).SingleOrDefault(); if (startSchoolyear == null) { throw new Exception("入学学期、年级对应的入学学年学期信息不存在,请检查。"); } //查询对应的毕业学年学期信息(根据入学学期、年级和专业信息对应的学制计算) var graduateSchoolyearValue = (specialtyPlanView.GradeID.Value * 2) - 1 + (specialtyPlanView.StartSchoolcodeID.Value - 1); graduateSchoolyearValue += Convert.ToInt32(Math.Ceiling(specialty.LearnSystem.Value * 2 - 1)); var graduatingSemester = schoolyearList.Where(x => x.Value == graduateSchoolyearValue).SingleOrDefault(); if (graduatingSemester == null) { throw new Exception("入学学期、年级和专业信息对应的毕业学年学期信息不存在,请检查。"); } //查询对应的学年学期信息 var schoolyear = schoolyearList.Where(x => x.SchoolyearID == specialtyPlanView.SchoolyearID).SingleOrDefault(); if (schoolyear == null) { throw new Exception("学年学期信息不存在,请检查。"); } if (schoolyear.Value < startSchoolyear.Value) { throw new Exception("学年学期小于入学学年学期,请检查。"); } if (schoolyear.Value > graduatingSemester.Value) { throw new Exception("学年学期大于毕业学年学期,请检查。"); } //查询数据库进行验证 var specialtyPlanVerify = SpecialtyPlanDAL.SpecialtyPlanRepository .GetList(x => x.SpecialtyPlanID != specialtyPlanView.SpecialtyPlanID && x.SchoolyearID == specialtyPlanView.SchoolyearID && x.StartSchoolyearID == startSchoolyear.SchoolyearID && x.SpecialtyID == specialty.SpecialtyID && x.CoursematerialID == specialtyPlanView.CoursematerialID).SingleOrDefault(); if (specialtyPlanVerify == null) { //学年学期 Expression> expSchoolyear = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); expSchoolyear = expSchoolyear.And(x => x.Years == specialtyPlanView.GradeID); expSchoolyear = expSchoolyear.And(x => x.SchoolcodeID == specialtyPlanView.StartSchoolcodeID); //专业信息 Expression> expSpecialty = (x => x.RecordStatus >= (int)SYS_STATUS.UNUSABLE); expSpecialty = expSpecialty.And(x => x.SpecialtyID == specialtyPlanView.SpecialtyID); //查询对应的年级专业信息grademajorViewList var grademajorViewList = SpecialtyPlanDAL.GetAdultGrademajorViewQueryable(expSchoolyear, expSpecialty).ToList(); List newSpecialtyPlanInList = new List(); List newSpecialtyPlanUpList = new List(); List newSPTeachingSettingInList = new List(); List newSPTeachingSettingUpList = new List(); List newSPTeachingModeTypeInList = new List(); List newSPTeachingPlaceInList = new List(); List specialtyPlanTMDelList = new List(); List specialtyPlanTPDelList = new List(); List newExecutablePlanUpList = new List(); List newProfileInList = new List(); List newProfileUpList = new List(); List newEPTeachingSettingInList = new List(); List newEPTeachingSettingUpList = new List(); List newEPTeachingModeTypeInList = new List(); List newEPTeachingPlaceInList = new List(); List executablePlanTMDelList = new List(); List executablePlanTPDelList = new List(); List executablePlanIDList = new List(); //数据有误验证 if (specialtyPlanView.SpecialtyPlanID != Guid.Empty) { var specialtyPlan = SpecialtyPlanDAL.SpecialtyPlanRepository .GetList(x => x.SpecialtyPlanID == specialtyPlanView.SpecialtyPlanID, (x => x.EM_SpecialtyPlanTeachingSetting)).SingleOrDefault(); if (specialtyPlan == null) { throw new Exception("数据有误,请核查。"); } else { //表示修改 specialtyPlan.SchoolyearID = specialtyPlanView.SchoolyearID; specialtyPlan.StartSchoolyearID = startSchoolyear.SchoolyearID; specialtyPlan.SpecialtyID = specialty.SpecialtyID; specialtyPlan.CoursematerialID = specialtyPlanView.CoursematerialID; specialtyPlan.CourseStructureID = specialtyPlanView.CourseStructureID; specialtyPlan.CourseCategoryID = specialtyPlanView.CourseCategoryID; specialtyPlan.CourseTypeID = specialtyPlanView.CourseTypeID; specialtyPlan.CourseQualityID = specialtyPlanView.CourseQualityID; specialtyPlan.DepartmentID = specialtyPlanView.DepartmentID; specialtyPlan.IsSpecialtycore = specialtyPlanView.IsSpecialtycore; specialtyPlan.IsCooperation = specialtyPlanView.IsCooperation; specialtyPlan.IsRequired = specialtyPlanView.IsRequired; specialtyPlan.IsElective = specialtyPlanView.IsElective; specialtyPlan.IsNetworkCourse = specialtyPlanView.IsNetworkCourse; specialtyPlan.IsMainCourse = specialtyPlanView.IsMainCourse; specialtyPlan.IsNeedMaterial = specialtyPlanView.IsNeedMaterial; specialtyPlan.CourseFineID = specialtyPlanView.CourseFineID; specialtyPlan.PracticeTypeID = specialtyPlanView.PracticeTypeID; specialtyPlan.TeachinglanguageID = specialtyPlanView.TeachinglanguageID; specialtyPlan.ExaminationModeID = specialtyPlanView.ExaminationModeID; specialtyPlan.ResultTypeID = specialtyPlanView.ResultTypeID; specialtyPlan.HandleModeID = specialtyPlanView.HandleModeID; specialtyPlan.Remark = specialtyPlanView.Remark; SetModifyStatus(specialtyPlan); newSpecialtyPlanUpList.Add(specialtyPlan); if (specialtyPlan.EM_SpecialtyPlanTeachingSetting == null) { var newSPTeachingSetting = new EM_SpecialtyPlanTeachingSetting(); newSPTeachingSetting.SpecialtyPlanID = specialtyPlan.SpecialtyPlanID; newSPTeachingSetting.Credit = specialtyPlanView.Credit; newSPTeachingSetting.TheoryCourse = specialtyPlanView.TheoryCourse; newSPTeachingSetting.Practicehours = specialtyPlanView.Practicehours; newSPTeachingSetting.Trialhours = specialtyPlanView.Trialhours; newSPTeachingSetting.TheoryWeeklyNum = specialtyPlanView.TheoryWeeklyNum; newSPTeachingSetting.PracticeWeeklyNum = specialtyPlanView.PracticeWeeklyNum; newSPTeachingSetting.TrialWeeklyNum = specialtyPlanView.TrialWeeklyNum; newSPTeachingSetting.WeeklyHours = specialtyPlanView.WeeklyHours; newSPTeachingSetting.WeeklyNum = specialtyPlanView.WeeklyNum; newSPTeachingSetting.StartWeeklyNum = specialtyPlanView.StartWeeklyNum; newSPTeachingSetting.EndWeeklyNum = specialtyPlanView.EndWeeklyNum; newSPTeachingSettingInList.Add(newSPTeachingSetting); } else { specialtyPlan.EM_SpecialtyPlanTeachingSetting.Credit = specialtyPlanView.Credit; specialtyPlan.EM_SpecialtyPlanTeachingSetting.TheoryCourse = specialtyPlanView.TheoryCourse; specialtyPlan.EM_SpecialtyPlanTeachingSetting.Practicehours = specialtyPlanView.Practicehours; specialtyPlan.EM_SpecialtyPlanTeachingSetting.Trialhours = specialtyPlanView.Trialhours; specialtyPlan.EM_SpecialtyPlanTeachingSetting.TheoryWeeklyNum = specialtyPlanView.TheoryWeeklyNum; specialtyPlan.EM_SpecialtyPlanTeachingSetting.PracticeWeeklyNum = specialtyPlanView.PracticeWeeklyNum; specialtyPlan.EM_SpecialtyPlanTeachingSetting.TrialWeeklyNum = specialtyPlanView.TrialWeeklyNum; specialtyPlan.EM_SpecialtyPlanTeachingSetting.WeeklyHours = specialtyPlanView.WeeklyHours; specialtyPlan.EM_SpecialtyPlanTeachingSetting.WeeklyNum = specialtyPlanView.WeeklyNum; specialtyPlan.EM_SpecialtyPlanTeachingSetting.StartWeeklyNum = specialtyPlanView.StartWeeklyNum; specialtyPlan.EM_SpecialtyPlanTeachingSetting.EndWeeklyNum = specialtyPlanView.EndWeeklyNum; newSPTeachingSettingUpList.Add(specialtyPlan.EM_SpecialtyPlanTeachingSetting); } if (specialtyPlanView.TeachingModeIDList != null && specialtyPlanView.TeachingModeIDList.Count() > 0) { specialtyPlanTMDelList.Add(specialtyPlan.SpecialtyPlanID); foreach (var teachingModeID in specialtyPlanView.TeachingModeIDList) { var newSPTeachingMode = new EM_SpecialtyPlanTeachingModeType(); newSPTeachingMode.SpecialtyPlanTeachingModeTypeID = Guid.NewGuid(); newSPTeachingMode.SpecialtyPlanID = specialtyPlan.SpecialtyPlanID; newSPTeachingMode.TeachingModeID = teachingModeID; SetNewStatus(newSPTeachingMode); newSPTeachingModeTypeInList.Add(newSPTeachingMode); } } else { specialtyPlanTMDelList.Add(specialtyPlan.SpecialtyPlanID); } if (specialtyPlanView.TeachingPlaceIDList != null && specialtyPlanView.TeachingPlaceIDList.Count() > 0) { specialtyPlanTPDelList.Add(specialtyPlan.SpecialtyPlanID); foreach (var teachingPlaceID in specialtyPlanView.TeachingPlaceIDList) { var newSPTeachingPlace = new EM_SpecialtyPlanTeachingPlace(); newSPTeachingPlace.SpecialtyPlanTeachingPlaceID = Guid.NewGuid(); newSPTeachingPlace.SpecialtyPlanID = specialtyPlan.SpecialtyPlanID; newSPTeachingPlace.TeachingPlace = teachingPlaceID; SetNewStatus(newSPTeachingPlace); newSPTeachingPlaceInList.Add(newSPTeachingPlace); } } else { specialtyPlanTPDelList.Add(specialtyPlan.SpecialtyPlanID); } //对应的执行计划信息更新(根据业务主键:学年学期ID、年级专业ID、课程信息ID) //注:由于相关业务主键冗余且同时存在主外键关联,目前不允许修改相关业务主键 foreach (var grademajorView in grademajorViewList) { //判断年级专业对应的学生人数 if (grademajorView.StudentCount <= 0) { //表示年级专业对应的学生人数小于等于0(暂不做考虑) } else { //查询对应的执行计划信息(业务主键:学年学期ID、年级专业ID、课程信息ID) var executablePlan = SpecialtyPlanDAL.ExecutablePlanRepository.GetList(x => x.SchoolyearID == specialtyPlanView.SchoolyearID && x.GrademajorID == grademajorView.GrademajorID && x.CoursematerialID == specialtyPlanView.CoursematerialID, (x => x.EM_ExecutablePlanProfile), (x => x.EM_ExecutablePlanTeachingSetting)).SingleOrDefault(); if (executablePlan == null) { //表示不存在对应的执行计划信息(暂不新增) } else { //表示存在对应的执行计划信息(修改) executablePlan.SourceTypeID = (int)EM_SourceType.RequiredCourse; //暂不考虑 //executablePlan.DefaultClassName = specialtyPlanView.CourseName + "-" + grademajorView.Name; executablePlan.SpecialtyPlanID = specialtyPlan.SpecialtyPlanID; executablePlan.SchoolyearID = specialtyPlanView.SchoolyearID; executablePlan.GrademajorID = grademajorView.GrademajorID; executablePlan.CoursematerialID = specialtyPlanView.CoursematerialID; executablePlan.CourseStructureID = specialtyPlanView.CourseStructureID; executablePlan.CourseCategoryID = specialtyPlanView.CourseCategoryID; executablePlan.CourseTypeID = specialtyPlanView.CourseTypeID; executablePlan.CourseQualityID = specialtyPlanView.CourseQualityID; executablePlan.DepartmentID = specialtyPlanView.DepartmentID; executablePlan.IsNeedMaterial = specialtyPlanView.IsNeedMaterial; executablePlan.ResultTypeID = specialtyPlanView.ResultTypeID; executablePlan.HandleModeID = specialtyPlanView.HandleModeID; SetModifyStatus(executablePlan); newExecutablePlanUpList.Add(executablePlan); if (executablePlan.EM_ExecutablePlanProfile == null) { var newProfile = new EM_ExecutablePlanProfile(); newProfile.ExecutablePlanID = executablePlan.ExecutablePlanID; newProfile.IsSpecialtycore = specialtyPlanView.IsSpecialtycore; newProfile.IsCooperation = specialtyPlanView.IsCooperation; newProfile.IsRequired = specialtyPlanView.IsRequired; newProfile.IsElective = specialtyPlanView.IsElective; newProfile.IsNetworkCourse = specialtyPlanView.IsNetworkCourse; newProfile.IsMainCourse = specialtyPlanView.IsMainCourse; newProfile.CourseFineID = specialtyPlanView.CourseFineID; newProfile.PracticeTypeID = specialtyPlanView.PracticeTypeID; newProfile.TeachinglanguageID = specialtyPlanView.TeachinglanguageID; newProfile.ExaminationModeID = specialtyPlanView.ExaminationModeID; SetNewStatus(newProfile); newProfileInList.Add(newProfile); } else { executablePlan.EM_ExecutablePlanProfile.IsSpecialtycore = specialtyPlanView.IsSpecialtycore; executablePlan.EM_ExecutablePlanProfile.IsCooperation = specialtyPlanView.IsCooperation; executablePlan.EM_ExecutablePlanProfile.IsRequired = specialtyPlanView.IsRequired; executablePlan.EM_ExecutablePlanProfile.IsElective = specialtyPlanView.IsElective; executablePlan.EM_ExecutablePlanProfile.IsNetworkCourse = specialtyPlanView.IsNetworkCourse; executablePlan.EM_ExecutablePlanProfile.IsMainCourse = specialtyPlanView.IsMainCourse; executablePlan.EM_ExecutablePlanProfile.CourseFineID = specialtyPlanView.CourseFineID; executablePlan.EM_ExecutablePlanProfile.PracticeTypeID = specialtyPlanView.PracticeTypeID; executablePlan.EM_ExecutablePlanProfile.TeachinglanguageID = specialtyPlanView.TeachinglanguageID; executablePlan.EM_ExecutablePlanProfile.ExaminationModeID = specialtyPlanView.ExaminationModeID; SetModifyStatus(executablePlan.EM_ExecutablePlanProfile); newProfileUpList.Add(executablePlan.EM_ExecutablePlanProfile); } if (executablePlan.EM_ExecutablePlanTeachingSetting == null) { var newEPTeachingSetting = new EM_ExecutablePlanTeachingSetting(); newEPTeachingSetting.ExecutablePlanID = executablePlan.ExecutablePlanID; newEPTeachingSetting.Credit = specialtyPlanView.Credit; newEPTeachingSetting.TheoryCourse = specialtyPlanView.TheoryCourse; newEPTeachingSetting.Practicehours = specialtyPlanView.Practicehours; newEPTeachingSetting.Trialhours = specialtyPlanView.Trialhours; newEPTeachingSetting.TheoryWeeklyNum = specialtyPlanView.TheoryWeeklyNum; newEPTeachingSetting.PracticeWeeklyNum = specialtyPlanView.PracticeWeeklyNum; newEPTeachingSetting.TrialWeeklyNum = specialtyPlanView.TrialWeeklyNum; newEPTeachingSetting.WeeklyHours = specialtyPlanView.WeeklyHours; newEPTeachingSetting.WeeklyNum = specialtyPlanView.WeeklyNum; newEPTeachingSetting.StartWeeklyNum = specialtyPlanView.StartWeeklyNum; newEPTeachingSetting.EndWeeklyNum = specialtyPlanView.EndWeeklyNum; newEPTeachingSettingInList.Add(newEPTeachingSetting); } else { //可更新的相关信息 executablePlan.EM_ExecutablePlanTeachingSetting.Credit = specialtyPlanView.Credit; executablePlan.EM_ExecutablePlanTeachingSetting.TheoryCourse = specialtyPlanView.TheoryCourse; executablePlan.EM_ExecutablePlanTeachingSetting.Practicehours = specialtyPlanView.Practicehours; executablePlan.EM_ExecutablePlanTeachingSetting.Trialhours = specialtyPlanView.Trialhours; if (executablePlan.RecordStatus == (int)EM_ExecuteStatus.NotSubmited) { executablePlan.EM_ExecutablePlanTeachingSetting.TheoryWeeklyNum = specialtyPlanView.TheoryWeeklyNum; executablePlan.EM_ExecutablePlanTeachingSetting.PracticeWeeklyNum = specialtyPlanView.PracticeWeeklyNum; executablePlan.EM_ExecutablePlanTeachingSetting.TrialWeeklyNum = specialtyPlanView.TrialWeeklyNum; executablePlan.EM_ExecutablePlanTeachingSetting.WeeklyHours = specialtyPlanView.WeeklyHours; executablePlan.EM_ExecutablePlanTeachingSetting.WeeklyNum = specialtyPlanView.WeeklyNum; executablePlan.EM_ExecutablePlanTeachingSetting.StartWeeklyNum = specialtyPlanView.StartWeeklyNum; executablePlan.EM_ExecutablePlanTeachingSetting.EndWeeklyNum = specialtyPlanView.EndWeeklyNum; } newEPTeachingSettingUpList.Add(executablePlan.EM_ExecutablePlanTeachingSetting); } if (executablePlan.RecordStatus == (int)EM_ExecuteStatus.NotSubmited) { //可更新的相关信息 if (specialtyPlanView.TeachingModeIDList != null && specialtyPlanView.TeachingModeIDList.Count() > 0) { executablePlanTMDelList.Add(executablePlan.ExecutablePlanID); foreach (var newModeType in specialtyPlanView.TeachingModeIDList.ToList()) { var newEPTeachingModeType = new EM_ExecutablePlanTeachingModeType(); newEPTeachingModeType.ExecutablePlanTeachingModeTypeID = Guid.NewGuid(); newEPTeachingModeType.ExecutablePlanID = executablePlan.ExecutablePlanID; newEPTeachingModeType.TeachingModeID = newModeType; this.SetNewStatus(newEPTeachingModeType); newEPTeachingModeTypeInList.Add(newEPTeachingModeType); } } else { executablePlanTMDelList.Add(executablePlan.ExecutablePlanID); } } if (specialtyPlanView.TeachingPlaceIDList != null && specialtyPlanView.TeachingPlaceIDList.Count() > 0) { executablePlanTPDelList.Add(executablePlan.ExecutablePlanID); foreach (var newPlace in specialtyPlanView.TeachingPlaceIDList.ToList()) { var newEPTeachingPlace = new EM_ExecutablePlanTeachingPlace(); newEPTeachingPlace.ExecutablePlanTeachingPlaceID = Guid.NewGuid(); newEPTeachingPlace.ExecutablePlanID = executablePlan.ExecutablePlanID; newEPTeachingPlace.TeachingPlace = newPlace; this.SetNewStatus(newEPTeachingPlace); newEPTeachingPlaceInList.Add(newEPTeachingPlace); } } else { executablePlanTPDelList.Add(executablePlan.ExecutablePlanID); } executablePlanIDList.Add(executablePlan.ExecutablePlanID); } } } //存在对应的主外键关联 if (specialtyPlan.EM_ExecutablePlan.Count() > 0) { //根据专业计划主键ID查询对应的执行计划信息List var newExecutablePlanList = SpecialtyPlanDAL.ExecutablePlanRepository .GetList(x => x.SpecialtyPlanID == specialtyPlan.SpecialtyPlanID, (x => x.EM_ExecutablePlanProfile), (x => x.EM_ExecutablePlanTeachingSetting)).ToList(); foreach (var newExecutablePlan in newExecutablePlanList) { if (!executablePlanIDList.Contains(newExecutablePlan.ExecutablePlanID)) { //查询对应的执行计划信息View var newExecutablePlanView = ExecutablePlanDAL.GetExecutablePlanViewQueryable(x => x.ExecutablePlanID == newExecutablePlan.ExecutablePlanID).SingleOrDefault(); //查询对应的专业计划信息(业务主键:学年学期ID、入学学年学期ID、专业信息ID、课程信息ID) var newSpecialtyPlanView = SpecialtyPlanDAL.GetAdultSpecialtyPlanViewQueryable(x => x.SpecialtyPlanID != specialtyPlan.SpecialtyPlanID && x.SchoolyearID == newExecutablePlanView.SchoolyearID && x.StartSchoolyearID == newExecutablePlanView.StartSchoolyearID && x.SpecialtyID == newExecutablePlanView.SpecialtyID && x.CoursematerialID == newExecutablePlanView.CoursematerialID).SingleOrDefault(); if (newSpecialtyPlanView == null) { newExecutablePlan.SpecialtyPlanID = null; SetModifyStatus(newExecutablePlan); newExecutablePlanUpList.Add(newExecutablePlan); } else { //来源专业计划默认为必修课 newExecutablePlan.SourceTypeID = (int)EM_SourceType.RequiredCourse; newExecutablePlan.DefaultClassName = newExecutablePlanView.CourseName + "-" + newExecutablePlanView.GrademajorName; newExecutablePlan.SpecialtyPlanID = newSpecialtyPlanView.SpecialtyPlanID; newExecutablePlan.SchoolyearID = newSpecialtyPlanView.SchoolyearID; newExecutablePlan.GrademajorID = newExecutablePlanView.GrademajorID; newExecutablePlan.CoursematerialID = newSpecialtyPlanView.CoursematerialID; newExecutablePlan.CourseStructureID = newSpecialtyPlanView.CourseStructureID; newExecutablePlan.CourseCategoryID = newSpecialtyPlanView.CourseCategoryID; newExecutablePlan.CourseTypeID = newSpecialtyPlanView.CourseTypeID; newExecutablePlan.CourseQualityID = newSpecialtyPlanView.CourseQualityID; newExecutablePlan.DepartmentID = newSpecialtyPlanView.DepartmentID; newExecutablePlan.IsNeedMaterial = newSpecialtyPlanView.IsNeedMaterial; newExecutablePlan.ResultTypeID = newSpecialtyPlanView.ResultTypeID; newExecutablePlan.HandleModeID = newSpecialtyPlanView.HandleModeID; SetModifyStatus(newExecutablePlan); newExecutablePlanUpList.Add(newExecutablePlan); if (newExecutablePlan.EM_ExecutablePlanProfile == null) { var newProfile = new EM_ExecutablePlanProfile(); newProfile.ExecutablePlanID = newExecutablePlan.ExecutablePlanID; newProfile.IsSpecialtycore = newSpecialtyPlanView.IsSpecialtycore; newProfile.IsCooperation = newSpecialtyPlanView.IsCooperation; newProfile.IsRequired = newSpecialtyPlanView.IsRequired; newProfile.IsElective = newSpecialtyPlanView.IsElective; newProfile.IsNetworkCourse = newSpecialtyPlanView.IsNetworkCourse; newProfile.IsMainCourse = newSpecialtyPlanView.IsMainCourse; newProfile.CourseFineID = newSpecialtyPlanView.CourseFineID; newProfile.PracticeTypeID = newSpecialtyPlanView.PracticeTypeID; newProfile.TeachinglanguageID = newSpecialtyPlanView.TeachinglanguageID; newProfile.ExaminationModeID = newSpecialtyPlanView.ExaminationModeID; SetNewStatus(newProfile); newProfileInList.Add(newProfile); } else { newExecutablePlan.EM_ExecutablePlanProfile.IsSpecialtycore = newSpecialtyPlanView.IsSpecialtycore; newExecutablePlan.EM_ExecutablePlanProfile.IsCooperation = newSpecialtyPlanView.IsCooperation; newExecutablePlan.EM_ExecutablePlanProfile.IsRequired = newSpecialtyPlanView.IsRequired; newExecutablePlan.EM_ExecutablePlanProfile.IsElective = newSpecialtyPlanView.IsElective; newExecutablePlan.EM_ExecutablePlanProfile.IsNetworkCourse = newSpecialtyPlanView.IsNetworkCourse; newExecutablePlan.EM_ExecutablePlanProfile.IsMainCourse = newSpecialtyPlanView.IsMainCourse; newExecutablePlan.EM_ExecutablePlanProfile.CourseFineID = newSpecialtyPlanView.CourseFineID; newExecutablePlan.EM_ExecutablePlanProfile.PracticeTypeID = newSpecialtyPlanView.PracticeTypeID; newExecutablePlan.EM_ExecutablePlanProfile.TeachinglanguageID = newSpecialtyPlanView.TeachinglanguageID; newExecutablePlan.EM_ExecutablePlanProfile.ExaminationModeID = newSpecialtyPlanView.ExaminationModeID; SetModifyStatus(newExecutablePlan.EM_ExecutablePlanProfile); newProfileUpList.Add(newExecutablePlan.EM_ExecutablePlanProfile); } if (newExecutablePlan.EM_ExecutablePlanTeachingSetting == null) { var newEPTeachingSetting = new EM_ExecutablePlanTeachingSetting(); newEPTeachingSetting.ExecutablePlanID = newExecutablePlan.ExecutablePlanID; newEPTeachingSetting.Credit = newSpecialtyPlanView.Credit; newEPTeachingSetting.TheoryCourse = newSpecialtyPlanView.TheoryCourse; newEPTeachingSetting.Practicehours = newSpecialtyPlanView.Practicehours; newEPTeachingSetting.Trialhours = newSpecialtyPlanView.Trialhours; newEPTeachingSetting.TheoryWeeklyNum = newSpecialtyPlanView.TheoryWeeklyNum; newEPTeachingSetting.PracticeWeeklyNum = newSpecialtyPlanView.PracticeWeeklyNum; newEPTeachingSetting.TrialWeeklyNum = newSpecialtyPlanView.TrialWeeklyNum; newEPTeachingSetting.WeeklyHours = newSpecialtyPlanView.WeeklyHours; newEPTeachingSetting.WeeklyNum = newSpecialtyPlanView.WeeklyNum; newEPTeachingSetting.StartWeeklyNum = newSpecialtyPlanView.StartWeeklyNum; newEPTeachingSetting.EndWeeklyNum = newSpecialtyPlanView.EndWeeklyNum; newEPTeachingSettingInList.Add(newEPTeachingSetting); } else { //可更新的相关信息 newExecutablePlan.EM_ExecutablePlanTeachingSetting.Credit = newSpecialtyPlanView.Credit; newExecutablePlan.EM_ExecutablePlanTeachingSetting.TheoryCourse = newSpecialtyPlanView.TheoryCourse; newExecutablePlan.EM_ExecutablePlanTeachingSetting.Practicehours = newSpecialtyPlanView.Practicehours; newExecutablePlan.EM_ExecutablePlanTeachingSetting.Trialhours = newSpecialtyPlanView.Trialhours; if (newExecutablePlan.RecordStatus == (int)EM_ExecuteStatus.NotSubmited) { newExecutablePlan.EM_ExecutablePlanTeachingSetting.TheoryWeeklyNum = newSpecialtyPlanView.TheoryWeeklyNum; newExecutablePlan.EM_ExecutablePlanTeachingSetting.PracticeWeeklyNum = newSpecialtyPlanView.PracticeWeeklyNum; newExecutablePlan.EM_ExecutablePlanTeachingSetting.TrialWeeklyNum = newSpecialtyPlanView.TrialWeeklyNum; newExecutablePlan.EM_ExecutablePlanTeachingSetting.WeeklyHours = newSpecialtyPlanView.WeeklyHours; newExecutablePlan.EM_ExecutablePlanTeachingSetting.WeeklyNum = newSpecialtyPlanView.WeeklyNum; newExecutablePlan.EM_ExecutablePlanTeachingSetting.StartWeeklyNum = newSpecialtyPlanView.StartWeeklyNum; newExecutablePlan.EM_ExecutablePlanTeachingSetting.EndWeeklyNum = newSpecialtyPlanView.EndWeeklyNum; } newEPTeachingSettingUpList.Add(newExecutablePlan.EM_ExecutablePlanTeachingSetting); } if (newExecutablePlan.RecordStatus == (int)EM_ExecuteStatus.NotSubmited) { //可更新的相关信息 if (newSpecialtyPlanView.TeachingModeIDList != null && newSpecialtyPlanView.TeachingModeIDList.Count() > 0) { executablePlanTMDelList.Add(newExecutablePlan.ExecutablePlanID); foreach (var newModeType in newSpecialtyPlanView.TeachingModeIDList.ToList()) { var newEPTeachingModeType = new EM_ExecutablePlanTeachingModeType(); newEPTeachingModeType.ExecutablePlanTeachingModeTypeID = Guid.NewGuid(); newEPTeachingModeType.ExecutablePlanID = newExecutablePlan.ExecutablePlanID; newEPTeachingModeType.TeachingModeID = newModeType; this.SetNewStatus(newEPTeachingModeType); newEPTeachingModeTypeInList.Add(newEPTeachingModeType); } } else { executablePlanTMDelList.Add(newExecutablePlan.ExecutablePlanID); } } if (newSpecialtyPlanView.TeachingPlaceIDList != null && newSpecialtyPlanView.TeachingPlaceIDList.Count() > 0) { executablePlanTPDelList.Add(newExecutablePlan.ExecutablePlanID); foreach (var newPlace in newSpecialtyPlanView.TeachingPlaceIDList.ToList()) { var newEPTeachingPlace = new EM_ExecutablePlanTeachingPlace(); newEPTeachingPlace.ExecutablePlanTeachingPlaceID = Guid.NewGuid(); newEPTeachingPlace.ExecutablePlanID = newExecutablePlan.ExecutablePlanID; newEPTeachingPlace.TeachingPlace = newPlace; this.SetNewStatus(newEPTeachingPlace); newEPTeachingPlaceInList.Add(newEPTeachingPlace); } } else { executablePlanTPDelList.Add(newExecutablePlan.ExecutablePlanID); } } executablePlanIDList.Add(newExecutablePlan.ExecutablePlanID); } } } } } else { //表示新增 var newSpecialtyPlan = new EM_SpecialtyPlan(); newSpecialtyPlan.SpecialtyPlanID = Guid.NewGuid(); newSpecialtyPlan.PlanApplicationID = null; newSpecialtyPlan.SchoolyearID = specialtyPlanView.SchoolyearID; newSpecialtyPlan.StartSchoolyearID = startSchoolyear.SchoolyearID; newSpecialtyPlan.SpecialtyID = specialty.SpecialtyID; newSpecialtyPlan.CoursematerialID = specialtyPlanView.CoursematerialID; newSpecialtyPlan.CourseStructureID = specialtyPlanView.CourseStructureID; newSpecialtyPlan.CourseCategoryID = specialtyPlanView.CourseCategoryID; newSpecialtyPlan.CourseTypeID = specialtyPlanView.CourseTypeID; newSpecialtyPlan.CourseQualityID = specialtyPlanView.CourseQualityID; newSpecialtyPlan.DepartmentID = specialtyPlanView.DepartmentID; newSpecialtyPlan.IsSpecialtycore = specialtyPlanView.IsSpecialtycore; newSpecialtyPlan.IsCooperation = specialtyPlanView.IsCooperation; newSpecialtyPlan.IsRequired = specialtyPlanView.IsRequired; newSpecialtyPlan.IsElective = specialtyPlanView.IsElective; newSpecialtyPlan.IsNetworkCourse = specialtyPlanView.IsNetworkCourse; newSpecialtyPlan.IsMainCourse = specialtyPlanView.IsMainCourse; newSpecialtyPlan.IsNeedMaterial = specialtyPlanView.IsNeedMaterial; newSpecialtyPlan.CourseFineID = specialtyPlanView.CourseFineID; newSpecialtyPlan.PracticeTypeID = specialtyPlanView.PracticeTypeID; newSpecialtyPlan.TeachinglanguageID = specialtyPlanView.TeachinglanguageID; newSpecialtyPlan.ExaminationModeID = specialtyPlanView.ExaminationModeID; newSpecialtyPlan.ResultTypeID = specialtyPlanView.ResultTypeID; newSpecialtyPlan.HandleModeID = specialtyPlanView.HandleModeID; newSpecialtyPlan.Remark = specialtyPlanView.Remark; SetNewStatus(newSpecialtyPlan); newSpecialtyPlanInList.Add(newSpecialtyPlan); var newSPTeachingSetting = new EM_SpecialtyPlanTeachingSetting(); newSPTeachingSetting.SpecialtyPlanID = newSpecialtyPlan.SpecialtyPlanID; newSPTeachingSetting.Credit = specialtyPlanView.Credit; newSPTeachingSetting.TheoryCourse = specialtyPlanView.TheoryCourse; newSPTeachingSetting.Practicehours = specialtyPlanView.Practicehours; newSPTeachingSetting.Trialhours = specialtyPlanView.Trialhours; newSPTeachingSetting.TheoryWeeklyNum = specialtyPlanView.TheoryWeeklyNum; newSPTeachingSetting.PracticeWeeklyNum = specialtyPlanView.PracticeWeeklyNum; newSPTeachingSetting.TrialWeeklyNum = specialtyPlanView.TrialWeeklyNum; newSPTeachingSetting.WeeklyHours = specialtyPlanView.WeeklyHours; newSPTeachingSetting.WeeklyNum = specialtyPlanView.WeeklyNum; newSPTeachingSetting.StartWeeklyNum = specialtyPlanView.StartWeeklyNum; newSPTeachingSetting.EndWeeklyNum = specialtyPlanView.EndWeeklyNum; newSPTeachingSettingInList.Add(newSPTeachingSetting); if (specialtyPlanView.TeachingModeIDList != null && specialtyPlanView.TeachingModeIDList.Count() > 0) { foreach (var teachingModeID in specialtyPlanView.TeachingModeIDList) { var newSPTeachingMode = new EM_SpecialtyPlanTeachingModeType(); newSPTeachingMode.SpecialtyPlanTeachingModeTypeID = Guid.NewGuid(); newSPTeachingMode.SpecialtyPlanID = newSpecialtyPlan.SpecialtyPlanID; newSPTeachingMode.TeachingModeID = teachingModeID; SetNewStatus(newSPTeachingMode); newSPTeachingModeTypeInList.Add(newSPTeachingMode); } } if (specialtyPlanView.TeachingPlaceIDList != null && specialtyPlanView.TeachingPlaceIDList.Count() > 0) { foreach (var teachingPlaceID in specialtyPlanView.TeachingPlaceIDList) { var newSPTeachingPlace = new EM_SpecialtyPlanTeachingPlace(); newSPTeachingPlace.SpecialtyPlanTeachingPlaceID = Guid.NewGuid(); newSPTeachingPlace.SpecialtyPlanID = newSpecialtyPlan.SpecialtyPlanID; newSPTeachingPlace.TeachingPlace = teachingPlaceID; SetNewStatus(newSPTeachingPlace); newSPTeachingPlaceInList.Add(newSPTeachingPlace); } } //对应的执行计划信息更新(根据业务主键:学年学期ID、年级专业ID、课程信息ID) //注:由于相关业务主键冗余且同时存在主外键关联,目前不允许修改相关业务主键 foreach (var grademajorView in grademajorViewList) { //查询对应的执行计划信息(业务主键:学年学期ID、年级专业ID、课程信息ID) var executablePlan = SpecialtyPlanDAL.ExecutablePlanRepository.GetList(x => x.SchoolyearID == specialtyPlanView.SchoolyearID && x.GrademajorID == grademajorView.GrademajorID && x.CoursematerialID == specialtyPlanView.CoursematerialID, (x => x.EM_ExecutablePlanProfile), (x => x.EM_ExecutablePlanTeachingSetting)).SingleOrDefault(); if (executablePlan == null) { //表示不存在对应的执行计划信息(暂不新增) } else { //表示存在对应的执行计划信息(修改) executablePlan.SourceTypeID = (int)EM_SourceType.RequiredCourse; //暂不考虑 //executablePlan.DefaultClassName = specialtyPlanView.CourseName + "-" + grademajorView.Name; executablePlan.SpecialtyPlanID = newSpecialtyPlan.SpecialtyPlanID; executablePlan.SchoolyearID = specialtyPlanView.SchoolyearID; executablePlan.GrademajorID = grademajorView.GrademajorID; executablePlan.CoursematerialID = specialtyPlanView.CoursematerialID; executablePlan.CourseStructureID = specialtyPlanView.CourseStructureID; executablePlan.CourseCategoryID = specialtyPlanView.CourseCategoryID; executablePlan.CourseTypeID = specialtyPlanView.CourseTypeID; executablePlan.CourseQualityID = specialtyPlanView.CourseQualityID; executablePlan.DepartmentID = specialtyPlanView.DepartmentID; executablePlan.IsNeedMaterial = specialtyPlanView.IsNeedMaterial; executablePlan.ResultTypeID = specialtyPlanView.ResultTypeID; executablePlan.HandleModeID = specialtyPlanView.HandleModeID; SetModifyStatus(executablePlan); newExecutablePlanUpList.Add(executablePlan); if (executablePlan.EM_ExecutablePlanProfile == null) { var newProfile = new EM_ExecutablePlanProfile(); newProfile.ExecutablePlanID = executablePlan.ExecutablePlanID; newProfile.IsSpecialtycore = specialtyPlanView.IsSpecialtycore; newProfile.IsCooperation = specialtyPlanView.IsCooperation; newProfile.IsRequired = specialtyPlanView.IsRequired; newProfile.IsElective = specialtyPlanView.IsElective; newProfile.IsNetworkCourse = specialtyPlanView.IsNetworkCourse; newProfile.IsMainCourse = specialtyPlanView.IsMainCourse; newProfile.CourseFineID = specialtyPlanView.CourseFineID; newProfile.PracticeTypeID = specialtyPlanView.PracticeTypeID; newProfile.TeachinglanguageID = specialtyPlanView.TeachinglanguageID; newProfile.ExaminationModeID = specialtyPlanView.ExaminationModeID; SetNewStatus(newProfile); newProfileInList.Add(newProfile); } else { executablePlan.EM_ExecutablePlanProfile.IsSpecialtycore = specialtyPlanView.IsSpecialtycore; executablePlan.EM_ExecutablePlanProfile.IsCooperation = specialtyPlanView.IsCooperation; executablePlan.EM_ExecutablePlanProfile.IsRequired = specialtyPlanView.IsRequired; executablePlan.EM_ExecutablePlanProfile.IsElective = specialtyPlanView.IsElective; executablePlan.EM_ExecutablePlanProfile.IsNetworkCourse = specialtyPlanView.IsNetworkCourse; executablePlan.EM_ExecutablePlanProfile.IsMainCourse = specialtyPlanView.IsMainCourse; executablePlan.EM_ExecutablePlanProfile.CourseFineID = specialtyPlanView.CourseFineID; executablePlan.EM_ExecutablePlanProfile.PracticeTypeID = specialtyPlanView.PracticeTypeID; executablePlan.EM_ExecutablePlanProfile.TeachinglanguageID = specialtyPlanView.TeachinglanguageID; executablePlan.EM_ExecutablePlanProfile.ExaminationModeID = specialtyPlanView.ExaminationModeID; SetModifyStatus(executablePlan.EM_ExecutablePlanProfile); newProfileUpList.Add(executablePlan.EM_ExecutablePlanProfile); } if (executablePlan.EM_ExecutablePlanTeachingSetting == null) { var newEPTeachingSetting = new EM_ExecutablePlanTeachingSetting(); newEPTeachingSetting.ExecutablePlanID = executablePlan.ExecutablePlanID; newEPTeachingSetting.Credit = specialtyPlanView.Credit; newEPTeachingSetting.TheoryCourse = specialtyPlanView.TheoryCourse; newEPTeachingSetting.Practicehours = specialtyPlanView.Practicehours; newEPTeachingSetting.Trialhours = specialtyPlanView.Trialhours; newEPTeachingSetting.TheoryWeeklyNum = specialtyPlanView.TheoryWeeklyNum; newEPTeachingSetting.PracticeWeeklyNum = specialtyPlanView.PracticeWeeklyNum; newEPTeachingSetting.TrialWeeklyNum = specialtyPlanView.TrialWeeklyNum; newEPTeachingSetting.WeeklyHours = specialtyPlanView.WeeklyHours; newEPTeachingSetting.WeeklyNum = specialtyPlanView.WeeklyNum; newEPTeachingSetting.StartWeeklyNum = specialtyPlanView.StartWeeklyNum; newEPTeachingSetting.EndWeeklyNum = specialtyPlanView.EndWeeklyNum; newEPTeachingSettingInList.Add(newEPTeachingSetting); } else { //可更新的相关信息 executablePlan.EM_ExecutablePlanTeachingSetting.Credit = specialtyPlanView.Credit; executablePlan.EM_ExecutablePlanTeachingSetting.TheoryCourse = specialtyPlanView.TheoryCourse; executablePlan.EM_ExecutablePlanTeachingSetting.Practicehours = specialtyPlanView.Practicehours; executablePlan.EM_ExecutablePlanTeachingSetting.Trialhours = specialtyPlanView.Trialhours; if (executablePlan.RecordStatus == (int)EM_ExecuteStatus.NotSubmited) { executablePlan.EM_ExecutablePlanTeachingSetting.TheoryWeeklyNum = specialtyPlanView.TheoryWeeklyNum; executablePlan.EM_ExecutablePlanTeachingSetting.PracticeWeeklyNum = specialtyPlanView.PracticeWeeklyNum; executablePlan.EM_ExecutablePlanTeachingSetting.TrialWeeklyNum = specialtyPlanView.TrialWeeklyNum; executablePlan.EM_ExecutablePlanTeachingSetting.WeeklyHours = specialtyPlanView.WeeklyHours; executablePlan.EM_ExecutablePlanTeachingSetting.WeeklyNum = specialtyPlanView.WeeklyNum; executablePlan.EM_ExecutablePlanTeachingSetting.StartWeeklyNum = specialtyPlanView.StartWeeklyNum; executablePlan.EM_ExecutablePlanTeachingSetting.EndWeeklyNum = specialtyPlanView.EndWeeklyNum; } newEPTeachingSettingUpList.Add(executablePlan.EM_ExecutablePlanTeachingSetting); } if (executablePlan.RecordStatus == (int)EM_ExecuteStatus.NotSubmited) { //可更新的相关信息 if (specialtyPlanView.TeachingModeIDList != null && specialtyPlanView.TeachingModeIDList.Count() > 0) { executablePlanTMDelList.Add(executablePlan.ExecutablePlanID); foreach (var newModeType in specialtyPlanView.TeachingModeIDList.ToList()) { var newEPTeachingModeType = new EM_ExecutablePlanTeachingModeType(); newEPTeachingModeType.ExecutablePlanTeachingModeTypeID = Guid.NewGuid(); newEPTeachingModeType.ExecutablePlanID = executablePlan.ExecutablePlanID; newEPTeachingModeType.TeachingModeID = newModeType; this.SetNewStatus(newEPTeachingModeType); newEPTeachingModeTypeInList.Add(newEPTeachingModeType); } } else { executablePlanTMDelList.Add(executablePlan.ExecutablePlanID); } } if (specialtyPlanView.TeachingPlaceIDList != null && specialtyPlanView.TeachingPlaceIDList.Count() > 0) { executablePlanTPDelList.Add(executablePlan.ExecutablePlanID); foreach (var newPlace in specialtyPlanView.TeachingPlaceIDList.ToList()) { var newEPTeachingPlace = new EM_ExecutablePlanTeachingPlace(); newEPTeachingPlace.ExecutablePlanTeachingPlaceID = Guid.NewGuid(); newEPTeachingPlace.ExecutablePlanID = executablePlan.ExecutablePlanID; newEPTeachingPlace.TeachingPlace = newPlace; this.SetNewStatus(newEPTeachingPlace); newEPTeachingPlaceInList.Add(newEPTeachingPlace); } } else { executablePlanTPDelList.Add(executablePlan.ExecutablePlanID); } executablePlanIDList.Add(executablePlan.ExecutablePlanID); } } } //事务提交 //UnitOfWork.Commit(); using (TransactionScope ts = new TransactionScope()) { //删除 UnitOfWork.Delete(x => specialtyPlanTPDelList.Contains(x.SpecialtyPlanID)); UnitOfWork.Delete(x => specialtyPlanTMDelList.Contains(x.SpecialtyPlanID)); //批量插入 UnitOfWork.BulkInsert(newSpecialtyPlanInList); UnitOfWork.BulkInsert(newSPTeachingSettingInList); UnitOfWork.BulkInsert(newSPTeachingModeTypeInList); UnitOfWork.BulkInsert(newSPTeachingPlaceInList); //批量统一提交更新 if (newSpecialtyPlanUpList != null && newSpecialtyPlanUpList.Count() > 0) { UnitOfWork.BatchUpdate(newSpecialtyPlanUpList); } //批量统一提交更新 if (newSPTeachingSettingUpList != null && newSPTeachingSettingUpList.Count() > 0) { UnitOfWork.BatchUpdate(newSPTeachingSettingUpList); } //删除 UnitOfWork.Delete(x => executablePlanTPDelList.Contains(x.ExecutablePlanID)); UnitOfWork.Delete(x => executablePlanTMDelList.Contains(x.ExecutablePlanID)); //批量插入 UnitOfWork.BulkInsert(newProfileInList); UnitOfWork.BulkInsert(newEPTeachingSettingInList); UnitOfWork.BulkInsert(newEPTeachingModeTypeInList); UnitOfWork.BulkInsert(newEPTeachingPlaceInList); //批量统一提交更新 if (newExecutablePlanUpList != null && newExecutablePlanUpList.Count() > 0) { UnitOfWork.BatchUpdate(newExecutablePlanUpList); } //批量统一提交更新 if (newProfileUpList != null && newProfileUpList.Count() > 0) { UnitOfWork.BatchUpdate(newProfileUpList); } //批量统一提交更新 if (newEPTeachingSettingUpList != null && newEPTeachingSettingUpList.Count() > 0) { UnitOfWork.BatchUpdate(newEPTeachingSettingUpList); } ts.Complete(); } } else { throw new Exception("已存在相同的专业计划信息(学年学期、入学学期、年级、专业信息、课程信息唯一),请核查。"); } } catch (Exception ex) { throw new Exception(ex.Message); } } /// /// 专业课程模版批量新增 /// /// /// /// public string AdultSpecialtyPlanBatchAdd(List specialtyCourseViewList, SpecialtyPlanView specialtyPlanView) { try { //查询对应的专业信息 var specialty = SpecialtyPlanDAL.SpecialtyRepository .GetList(x => x.SpecialtyID == specialtyPlanView.SpecialtyID).SingleOrDefault(); if (specialty == null) { throw new Exception("选择新增的专业信息不存在,请检查。"); } //查询学年学期信息schoolyearList var schoolyearList = SpecialtyPlanDAL.SchoolyearRepository .GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE).ToList(); //查询对应的入学学年学期信息 var startSchoolyear = schoolyearList.Where(x => x.Years == specialtyPlanView.GradeID && x.SchoolcodeID == specialtyPlanView.StartSchoolcodeID).SingleOrDefault(); if (startSchoolyear == null) { throw new Exception("选择新增的入学学期、年级对应的入学学年学期不存在,请检查。"); } //查询对应的毕业学年学期信息(根据入学学期、年级和专业信息对应的学制计算) var graduateSchoolyearValue = (specialtyPlanView.GradeID.Value * 2) - 1 + (specialtyPlanView.StartSchoolcodeID.Value - 1); graduateSchoolyearValue += Convert.ToInt32(Math.Ceiling(specialty.LearnSystem.Value * 2 - 1)); var graduatingSemester = schoolyearList.Where(x => x.Value == graduateSchoolyearValue).SingleOrDefault(); if (graduatingSemester == null) { throw new Exception("选择新增的入学学期、年级和专业信息对应的毕业学年学期信息不存在,请检查。"); } //查询专业计划信息specialtyPlanList var specialtyPlanList = SpecialtyPlanDAL.SpecialtyPlanRepository.GetList(x => x.SpecialtyID == specialty.SpecialtyID && x.StartSchoolyearID == startSchoolyear.SchoolyearID, (x => x.EM_SpecialtyPlanTeachingSetting)).ToList(); int success = 0; //成功 int fail = 0; //失败 string tipMessage = null; //提示消息 List newSpecialtyPlanInList = new List(); List newTeachingSettingInList = new List(); List newTeachingModeTypeInList = new List(); List newTeachingPlaceInList = new List(); foreach (var specialtyCourseView in specialtyCourseViewList) { //判断对应的学年学期信息 var value = startSchoolyear.Value + specialtyCourseView.StarttermID - 1; if (value < startSchoolyear.Value) { //表示学年学期小于入学学年学期 fail++; } else { if (value > graduatingSemester.Value) { //表示学年学期大于毕业学年学期 fail++; } else { var schoolyear = schoolyearList.Where(x => x.Value == value).SingleOrDefault(); if (schoolyear == null) { //表示对应的学年学期信息不存在 fail++; } else { //查询对应的专业计划信息(根据业务主键:学年学期ID、入学学年学期ID、专业信息ID、课程信息ID) var specialtyPlan = specialtyPlanList.Where(x => x.SchoolyearID == schoolyear.SchoolyearID && x.StartSchoolyearID == startSchoolyear.SchoolyearID && x.SpecialtyID == specialty.SpecialtyID && x.CoursematerialID == specialtyCourseView.CoursematerialID).SingleOrDefault(); if (specialtyPlan == null) { //表示新增 var newSpecialtyPlan = new EM_SpecialtyPlan(); newSpecialtyPlan.SpecialtyPlanID = Guid.NewGuid(); newSpecialtyPlan.PlanApplicationID = null; newSpecialtyPlan.SchoolyearID = schoolyear.SchoolyearID; newSpecialtyPlan.StartSchoolyearID = startSchoolyear.SchoolyearID; newSpecialtyPlan.SpecialtyID = specialty.SpecialtyID; newSpecialtyPlan.CoursematerialID = specialtyCourseView.CoursematerialID; newSpecialtyPlan.CourseStructureID = specialtyCourseView.CourseStructureID; newSpecialtyPlan.CourseCategoryID = specialtyCourseView.CourseCategoryID; newSpecialtyPlan.CourseTypeID = specialtyCourseView.CourseTypeID; newSpecialtyPlan.CourseQualityID = specialtyCourseView.CourseQualityID; newSpecialtyPlan.DepartmentID = specialtyCourseView.DepartmentID; newSpecialtyPlan.IsSpecialtycore = specialtyCourseView.IsSpecialtycore; newSpecialtyPlan.IsCooperation = specialtyCourseView.IsCooperation; newSpecialtyPlan.IsRequired = specialtyCourseView.IsRequired; newSpecialtyPlan.IsElective = specialtyCourseView.IsElective; newSpecialtyPlan.IsNetworkCourse = specialtyCourseView.IsNetworkCourse; newSpecialtyPlan.IsMainCourse = specialtyCourseView.IsMainCourse; newSpecialtyPlan.IsNeedMaterial = specialtyCourseView.IsNeedMaterial; newSpecialtyPlan.CourseFineID = specialtyCourseView.CourseFineID; newSpecialtyPlan.PracticeTypeID = specialtyCourseView.PracticeTypeID; newSpecialtyPlan.TeachinglanguageID = specialtyCourseView.TeachinglanguageID; newSpecialtyPlan.ExaminationModeID = specialtyCourseView.ExaminationModeID; newSpecialtyPlan.ResultTypeID = specialtyCourseView.ResultTypeID; newSpecialtyPlan.HandleModeID = specialtyCourseView.HandleModeID; newSpecialtyPlan.Remark = specialtyPlanView.Remark; SetNewStatus(newSpecialtyPlan); newSpecialtyPlanInList.Add(newSpecialtyPlan); var newTeachingSetting = new EM_SpecialtyPlanTeachingSetting(); newTeachingSetting.SpecialtyPlanID = newSpecialtyPlan.SpecialtyPlanID; newTeachingSetting.Credit = specialtyCourseView.Credit; newTeachingSetting.TheoryCourse = specialtyCourseView.TheoryCourse; newTeachingSetting.Practicehours = specialtyCourseView.Practicehours; newTeachingSetting.Trialhours = specialtyCourseView.Trialhours; newTeachingSetting.TheoryWeeklyNum = specialtyCourseView.TheoryWeeklyNum; newTeachingSetting.PracticeWeeklyNum = specialtyCourseView.PracticeWeeklyNum; newTeachingSetting.TrialWeeklyNum = specialtyCourseView.TrialWeeklyNum; newTeachingSetting.WeeklyHours = specialtyCourseView.WeeklyHours; newTeachingSetting.WeeklyNum = specialtyCourseView.WeeklyNum; newTeachingSetting.StartWeeklyNum = specialtyCourseView.StartWeeklyNum; newTeachingSetting.EndWeeklyNum = specialtyCourseView.EndWeeklyNum; newTeachingSettingInList.Add(newTeachingSetting); if (specialtyCourseView.TeachingModeIDList != null && specialtyCourseView.TeachingModeIDList.Count() > 0) { foreach (var teachingModeID in specialtyCourseView.TeachingModeIDList) { var newTeachingMode = new EM_SpecialtyPlanTeachingModeType(); newTeachingMode.SpecialtyPlanTeachingModeTypeID = Guid.NewGuid(); newTeachingMode.SpecialtyPlanID = newSpecialtyPlan.SpecialtyPlanID; newTeachingMode.TeachingModeID = teachingModeID; SetNewStatus(newTeachingMode); newTeachingModeTypeInList.Add(newTeachingMode); } } if (specialtyCourseView.TeachingPlaceIDList != null && specialtyCourseView.TeachingPlaceIDList.Count() > 0) { foreach (var teachingPlaceID in specialtyCourseView.TeachingPlaceIDList) { var newTeachingPlace = new EM_SpecialtyPlanTeachingPlace(); newTeachingPlace.SpecialtyPlanTeachingPlaceID = Guid.NewGuid(); newTeachingPlace.SpecialtyPlanID = newSpecialtyPlan.SpecialtyPlanID; newTeachingPlace.TeachingPlace = teachingPlaceID; SetNewStatus(newTeachingPlace); newTeachingPlaceInList.Add(newTeachingPlace); } } success++; } else { //表示已存在相同的计划申请信息 fail++; } } } } } //事务提交 using (TransactionScope ts = new TransactionScope()) { //批量插入 UnitOfWork.BulkInsert(newSpecialtyPlanInList); UnitOfWork.BulkInsert(newTeachingSettingInList); UnitOfWork.BulkInsert(newTeachingModeTypeInList); UnitOfWork.BulkInsert(newTeachingPlaceInList); ts.Complete(); } if (success > 0 && fail <= 0) { tipMessage = success + "条"; } else { tipMessage = success + "条,失败" + fail + "条,原因:学年学期小于入学学年学期、学年学期大于毕业学年学期、对应的学年学期不存在或已存在相同的专业计划信息,请检查"; } return tipMessage; } catch (Exception ex) { throw new Exception(ex.Message); } } /// /// 查询对应的未新增专业课程信息SpecialtyCourseView /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// public IGridResultSet GetAdultSpecialtyCourseViewNoAddGrid(ConfiguretView configuretView, Guid? departmentID, int? educationID, int? learningformID, string learnSystem, Guid? coursematerialID, int? starttermID, int? handleModeID, int? startSchoolcodeID, int? yearID, Guid? specialtyID, int pageIndex, int pageSize) { //专业课程 Expression> expSpecialtyCourse = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); expSpecialtyCourse = expSpecialtyCourse.And(x => x.IsEnable == true); expSpecialtyCourse = expSpecialtyCourse.And(x => x.SpecialtyID == specialtyID); if (departmentID.HasValue) { expSpecialtyCourse = expSpecialtyCourse.And(x => x.DepartmentID == departmentID); } if (coursematerialID.HasValue) { expSpecialtyCourse = expSpecialtyCourse.And(x => x.CoursematerialID == coursematerialID); } if (starttermID.HasValue) { expSpecialtyCourse = expSpecialtyCourse.And(x => x.StarttermID == starttermID); } if (handleModeID.HasValue) { expSpecialtyCourse = expSpecialtyCourse.And(x => x.HandleModeID == handleModeID); } //学年学期 Expression> expSchoolyear = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); expSchoolyear = expSchoolyear.And(x => x.SchoolcodeID == startSchoolcodeID); expSchoolyear = expSchoolyear.And(x => x.Years == yearID); //专业信息 Expression> expSpecialty = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); expSpecialty = expSpecialty.And(x => x.SpecialtyID == specialtyID); if (educationID.HasValue) { expSpecialty = expSpecialty.And(x => x.EducationID == educationID); } if (learningformID.HasValue) { expSpecialty = expSpecialty.And(x => x.LearningformID == learningformID); } if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1") { var LearnSystems = Convert.ToDecimal(learnSystem); expSpecialty = expSpecialty.And(x => x.LearnSystem == LearnSystems); } //专业计划 Expression> expSpecialtyPlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (coursematerialID.HasValue) { expSpecialtyPlan = expSpecialtyPlan.And(x => x.CoursematerialID == coursematerialID); } if (specialtyID.HasValue) { expSpecialtyPlan = expSpecialtyPlan.And(x => x.SpecialtyID == specialtyID); } var query = SpecialtyPlanDAL.GetAdultSpecialtyCourseViewNoAddQueryable(expSpecialtyCourse, expSchoolyear, expSpecialty, expSpecialtyPlan); //查询条件 if (!string.IsNullOrEmpty(configuretView.ConditionValue)) { query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); } return this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.StandardID).ThenBy(x => x.EducationID) .ThenBy(x => x.LearningformID).ThenBy(x => x.LearnSystem) .ThenBy(x => x.StarttermID).ThenBy(x => x.CourseTypeID) .ThenBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode) .ToGridResultSet(pageIndex, pageSize); } /// /// 查询对应的未新增专业课程信息List /// /// /// /// /// /// /// /// /// /// /// /// /// public IList GetAdultSpecialtyCourseViewNoAddList(ConfiguretView configuretView, Guid? departmentID, int? educationID, int? learningformID, string learnSystem, Guid? coursematerialID, int? starttermID, int? handleModeID, int? startSchoolcodeID, int? yearID, Guid? specialtyID) { //专业课程 Expression> expSpecialtyCourse = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); expSpecialtyCourse = expSpecialtyCourse.And(x => x.IsEnable == true); expSpecialtyCourse = expSpecialtyCourse.And(x => x.SpecialtyID == specialtyID); if (departmentID.HasValue) { expSpecialtyCourse = expSpecialtyCourse.And(x => x.DepartmentID == departmentID); } if (coursematerialID.HasValue) { expSpecialtyCourse = expSpecialtyCourse.And(x => x.CoursematerialID == coursematerialID); } if (starttermID.HasValue) { expSpecialtyCourse = expSpecialtyCourse.And(x => x.StarttermID == starttermID); } if (handleModeID.HasValue) { expSpecialtyCourse = expSpecialtyCourse.And(x => x.HandleModeID == handleModeID); } //学年学期 Expression> expSchoolyear = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); expSchoolyear = expSchoolyear.And(x => x.SchoolcodeID == startSchoolcodeID); expSchoolyear = expSchoolyear.And(x => x.Years == yearID); //专业信息 Expression> expSpecialty = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); expSpecialty = expSpecialty.And(x => x.SpecialtyID == specialtyID); if (educationID.HasValue) { expSpecialty = expSpecialty.And(x => x.EducationID == educationID); } if (learningformID.HasValue) { expSpecialty = expSpecialty.And(x => x.LearningformID == learningformID); } if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1") { var LearnSystems = Convert.ToDecimal(learnSystem); expSpecialty = expSpecialty.And(x => x.LearnSystem == LearnSystems); } //专业计划 Expression> expSpecialtyPlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (coursematerialID.HasValue) { expSpecialtyPlan = expSpecialtyPlan.And(x => x.CoursematerialID == coursematerialID); } if (specialtyID.HasValue) { expSpecialtyPlan = expSpecialtyPlan.And(x => x.SpecialtyID == specialtyID); } var query = SpecialtyPlanDAL.GetAdultSpecialtyCourseViewNoAddQueryable(expSpecialtyCourse, expSchoolyear, expSpecialty, expSpecialtyPlan); //查询条件 if (!string.IsNullOrEmpty(configuretView.ConditionValue)) { query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); } return this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.StandardID).ThenBy(x => x.EducationID) .ThenBy(x => x.LearningformID).ThenBy(x => x.LearnSystem) .ThenBy(x => x.StarttermID).ThenBy(x => x.CourseTypeID) .ThenBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode) .ToList(); } /// /// 删除 /// /// /// public bool AdultSpecialtyPlanDelete(List specialtyPlanIDs) { try { using (TransactionScope ts = new TransactionScope()) { UnitOfWork.Delete(x => specialtyPlanIDs.Contains(x.SpecialtyPlanID)); UnitOfWork.Delete(x => specialtyPlanIDs.Contains(x.SpecialtyPlanID)); UnitOfWork.Delete(x => specialtyPlanIDs.Contains(x.SpecialtyPlanID)); UnitOfWork.Delete(x => specialtyPlanIDs.Contains(x.SpecialtyPlanID)); ts.Complete(); return true; } } catch (Exception) { throw; } } /// /// 专业计划执行 /// 注:成教版本(入学学年学期、专业信息) /// 注:年级专业对应的学生人数小于等于0时,不可执行 /// /// /// public string AdultSpecialtyPlanExecute(List specialtyPlanIDList) { try { //查询对应的专业计划信息specialtyPlanViewList var specialtyPlanViewList = SpecialtyPlanDAL.GetAdultSpecialtyPlanViewQueryable(x => specialtyPlanIDList.Contains(x.SpecialtyPlanID)).ToList(); //查询对应的入学学年学期IDList var startSchoolyearIDList = specialtyPlanViewList.Select(x => x.StartSchoolyearID).Distinct().ToList(); //查询对应的专业信息IDList var specialtyIDList = specialtyPlanViewList.Select(x => x.SpecialtyID).Distinct().ToList(); //学年学期 Expression> expSchoolyear = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); expSchoolyear = expSchoolyear.And(x => startSchoolyearIDList.Contains(x.SchoolyearID)); //专业信息 Expression> expSpecialty = (x => x.RecordStatus >= (int)SYS_STATUS.UNUSABLE); expSpecialty = expSpecialty.And(x => specialtyIDList.Contains(x.SpecialtyID)); //查询对应的年级专业信息grademajorViewList var grademajorViewList = SpecialtyPlanDAL.GetAdultGrademajorViewQueryable(expSchoolyear, expSpecialty).ToList(); //查询对应的年级专业IDList var grademajorIDList = grademajorViewList.Select(x => x.GrademajorID).Distinct().ToList(); //查询对比后的执行计划信息List(暂时只对比年级专业ID) var executablePlanList = SpecialtyPlanDAL.ExecutablePlanRepository .GetList(x => grademajorIDList.Contains(x.GrademajorID.Value), (x => x.EM_ExecutablePlanProfile), (x => x.EM_ExecutablePlanTeachingSetting)).ToList(); int insert = 0; //成功 int update = 0; //更新 int fail = 0; //失败 string tipMessage = null; //提示消息 List newExecutablePlanInList = new List(); List newExecutablePlanUpList = new List(); List newProfileInList = new List(); List newProfileUpList = new List(); List newTeachingSettingInList = new List(); List newTeachingSettingUpList = new List(); List newTeachingModeTypeInList = new List(); List newTeachingPlaceInList = new List(); List executablePlanTMDelList = new List(); List executablePlanTPDelList = new List(); List executablePlanIDList = new List(); foreach (var specialtyPlanView in specialtyPlanViewList) { if (specialtyPlanView.Value < specialtyPlanView.StartValue) { //表示学年学期小于入学学年学期 fail++; } else { if (specialtyPlanView.Value > specialtyPlanView.GraduatingSemesterValue) { //表示学年学期大于毕业学年学期 fail++; } else { //查询对应的年级专业信息List var newGrademajorViewList = grademajorViewList.Where(x => x.StartSchoolyearID == specialtyPlanView.StartSchoolyearID && x.SpecialtyID == specialtyPlanView.SpecialtyID).ToList(); //根据业务主键查询对应的执行计划信息(业务主键:学年学期ID、年级专业ID、课程信息ID) //注:由于相关业务主键冗余且同时存在主外键关联,目前不允许修改相关业务主键 foreach (var newGrademajorView in newGrademajorViewList) { //判断年级专业对应的学生人数 if (newGrademajorView.StudentCount <= 0) { //表示年级专业对应的学生人数小于等于0 fail++; } else { var executablePlan = executablePlanList.Where(x => x.SchoolyearID == specialtyPlanView.SchoolyearID && x.GrademajorID == newGrademajorView.GrademajorID && x.CoursematerialID == specialtyPlanView.CoursematerialID).SingleOrDefault(); if (executablePlan == null) { //表示不存在对应的执行计划信息(新增) var newExecutablePlan = new EM_ExecutablePlan(); newExecutablePlan.ExecutablePlanID = Guid.NewGuid(); //来源专业计划默认为必修课 newExecutablePlan.SourceTypeID = (int)EM_SourceType.RequiredCourse; newExecutablePlan.DefaultClassName = specialtyPlanView.CourseName + "-" + newGrademajorView.Name; newExecutablePlan.SpecialtyPlanID = specialtyPlanView.SpecialtyPlanID; newExecutablePlan.SchoolyearID = specialtyPlanView.SchoolyearID; newExecutablePlan.GrademajorID = newGrademajorView.GrademajorID; newExecutablePlan.CoursematerialID = specialtyPlanView.CoursematerialID; newExecutablePlan.CourseStructureID = specialtyPlanView.CourseStructureID; newExecutablePlan.CourseCategoryID = specialtyPlanView.CourseCategoryID; newExecutablePlan.CourseTypeID = specialtyPlanView.CourseTypeID; newExecutablePlan.CourseQualityID = specialtyPlanView.CourseQualityID; newExecutablePlan.DepartmentID = specialtyPlanView.DepartmentID; newExecutablePlan.IsNeedMaterial = specialtyPlanView.IsNeedMaterial; newExecutablePlan.ResultTypeID = specialtyPlanView.ResultTypeID; newExecutablePlan.HandleModeID = specialtyPlanView.HandleModeID; newExecutablePlan.Remark = specialtyPlanView.Remark; SetNewStatus(newExecutablePlan, (int)EM_ExecuteStatus.NotSubmited); newExecutablePlanInList.Add(newExecutablePlan); var newProfile = new EM_ExecutablePlanProfile(); newProfile.ExecutablePlanID = newExecutablePlan.ExecutablePlanID; newProfile.IsSpecialtycore = specialtyPlanView.IsSpecialtycore; newProfile.IsCooperation = specialtyPlanView.IsCooperation; newProfile.IsRequired = specialtyPlanView.IsRequired; newProfile.IsElective = specialtyPlanView.IsElective; newProfile.IsNetworkCourse = specialtyPlanView.IsNetworkCourse; newProfile.IsMainCourse = specialtyPlanView.IsMainCourse; newProfile.CourseFineID = specialtyPlanView.CourseFineID; newProfile.PracticeTypeID = specialtyPlanView.PracticeTypeID; newProfile.TeachinglanguageID = specialtyPlanView.TeachinglanguageID; newProfile.ExaminationModeID = specialtyPlanView.ExaminationModeID; SetNewStatus(newProfile); newProfileInList.Add(newProfile); var newTeachingSetting = new EM_ExecutablePlanTeachingSetting(); newTeachingSetting.ExecutablePlanID = newExecutablePlan.ExecutablePlanID; newTeachingSetting.Credit = specialtyPlanView.Credit; newTeachingSetting.TheoryCourse = specialtyPlanView.TheoryCourse; newTeachingSetting.Practicehours = specialtyPlanView.Practicehours; newTeachingSetting.Trialhours = specialtyPlanView.Trialhours; newTeachingSetting.TheoryWeeklyNum = specialtyPlanView.TheoryWeeklyNum; newTeachingSetting.PracticeWeeklyNum = specialtyPlanView.PracticeWeeklyNum; newTeachingSetting.TrialWeeklyNum = specialtyPlanView.TrialWeeklyNum; newTeachingSetting.WeeklyHours = specialtyPlanView.WeeklyHours; newTeachingSetting.WeeklyNum = specialtyPlanView.WeeklyNum; newTeachingSetting.StartWeeklyNum = specialtyPlanView.StartWeeklyNum; newTeachingSetting.EndWeeklyNum = specialtyPlanView.EndWeeklyNum; newTeachingSettingInList.Add(newTeachingSetting); if (specialtyPlanView.TeachingModeIDList != null && specialtyPlanView.TeachingModeIDList.Count() > 0) { foreach (var newModeType in specialtyPlanView.TeachingModeIDList.ToList()) { var newTeachingModeType = new EM_ExecutablePlanTeachingModeType(); newTeachingModeType.ExecutablePlanTeachingModeTypeID = Guid.NewGuid(); newTeachingModeType.ExecutablePlanID = newExecutablePlan.ExecutablePlanID; newTeachingModeType.TeachingModeID = newModeType; this.SetNewStatus(newTeachingModeType); newTeachingModeTypeInList.Add(newTeachingModeType); } } if (specialtyPlanView.TeachingPlaceIDList != null && specialtyPlanView.TeachingPlaceIDList.Count() > 0) { foreach (var newPlace in specialtyPlanView.TeachingPlaceIDList.ToList()) { var newTeachingPlace = new EM_ExecutablePlanTeachingPlace(); newTeachingPlace.ExecutablePlanTeachingPlaceID = Guid.NewGuid(); newTeachingPlace.ExecutablePlanID = newExecutablePlan.ExecutablePlanID; newTeachingPlace.TeachingPlace = newPlace; this.SetNewStatus(newTeachingPlace); newTeachingPlaceInList.Add(newTeachingPlace); } } insert++; } else { if (!executablePlanIDList.Contains(executablePlan.ExecutablePlanID)) { //表示存在对应的执行计划信息(修改) executablePlan.SourceTypeID = (int)EM_SourceType.RequiredCourse; executablePlan.DefaultClassName = specialtyPlanView.CourseName + "-" + newGrademajorView.Name; executablePlan.SpecialtyPlanID = specialtyPlanView.SpecialtyPlanID; executablePlan.SchoolyearID = specialtyPlanView.SchoolyearID; executablePlan.GrademajorID = newGrademajorView.GrademajorID; executablePlan.CoursematerialID = specialtyPlanView.CoursematerialID; executablePlan.CourseStructureID = specialtyPlanView.CourseStructureID; executablePlan.CourseCategoryID = specialtyPlanView.CourseCategoryID; executablePlan.CourseTypeID = specialtyPlanView.CourseTypeID; executablePlan.CourseQualityID = specialtyPlanView.CourseQualityID; executablePlan.DepartmentID = specialtyPlanView.DepartmentID; executablePlan.IsNeedMaterial = specialtyPlanView.IsNeedMaterial; executablePlan.ResultTypeID = specialtyPlanView.ResultTypeID; executablePlan.HandleModeID = specialtyPlanView.HandleModeID; SetModifyStatus(executablePlan); newExecutablePlanUpList.Add(executablePlan); if (executablePlan.EM_ExecutablePlanProfile == null) { var newProfile = new EM_ExecutablePlanProfile(); newProfile.ExecutablePlanID = executablePlan.ExecutablePlanID; newProfile.IsSpecialtycore = specialtyPlanView.IsSpecialtycore; newProfile.IsCooperation = specialtyPlanView.IsCooperation; newProfile.IsRequired = specialtyPlanView.IsRequired; newProfile.IsElective = specialtyPlanView.IsElective; newProfile.IsNetworkCourse = specialtyPlanView.IsNetworkCourse; newProfile.IsMainCourse = specialtyPlanView.IsMainCourse; newProfile.CourseFineID = specialtyPlanView.CourseFineID; newProfile.PracticeTypeID = specialtyPlanView.PracticeTypeID; newProfile.TeachinglanguageID = specialtyPlanView.TeachinglanguageID; newProfile.ExaminationModeID = specialtyPlanView.ExaminationModeID; SetNewStatus(newProfile); newProfileInList.Add(newProfile); } else { executablePlan.EM_ExecutablePlanProfile.IsSpecialtycore = specialtyPlanView.IsSpecialtycore; executablePlan.EM_ExecutablePlanProfile.IsCooperation = specialtyPlanView.IsCooperation; executablePlan.EM_ExecutablePlanProfile.IsRequired = specialtyPlanView.IsRequired; executablePlan.EM_ExecutablePlanProfile.IsElective = specialtyPlanView.IsElective; executablePlan.EM_ExecutablePlanProfile.IsNetworkCourse = specialtyPlanView.IsNetworkCourse; executablePlan.EM_ExecutablePlanProfile.IsMainCourse = specialtyPlanView.IsMainCourse; executablePlan.EM_ExecutablePlanProfile.CourseFineID = specialtyPlanView.CourseFineID; executablePlan.EM_ExecutablePlanProfile.PracticeTypeID = specialtyPlanView.PracticeTypeID; executablePlan.EM_ExecutablePlanProfile.TeachinglanguageID = specialtyPlanView.TeachinglanguageID; executablePlan.EM_ExecutablePlanProfile.ExaminationModeID = specialtyPlanView.ExaminationModeID; SetModifyStatus(executablePlan.EM_ExecutablePlanProfile); newProfileUpList.Add(executablePlan.EM_ExecutablePlanProfile); } if (executablePlan.EM_ExecutablePlanTeachingSetting == null) { var newTeachingSetting = new EM_ExecutablePlanTeachingSetting(); newTeachingSetting.ExecutablePlanID = executablePlan.ExecutablePlanID; newTeachingSetting.Credit = specialtyPlanView.Credit; newTeachingSetting.TheoryCourse = specialtyPlanView.TheoryCourse; newTeachingSetting.Practicehours = specialtyPlanView.Practicehours; newTeachingSetting.Trialhours = specialtyPlanView.Trialhours; newTeachingSetting.TheoryWeeklyNum = specialtyPlanView.TheoryWeeklyNum; newTeachingSetting.PracticeWeeklyNum = specialtyPlanView.PracticeWeeklyNum; newTeachingSetting.TrialWeeklyNum = specialtyPlanView.TrialWeeklyNum; newTeachingSetting.WeeklyHours = specialtyPlanView.WeeklyHours; newTeachingSetting.WeeklyNum = specialtyPlanView.WeeklyNum; newTeachingSetting.StartWeeklyNum = specialtyPlanView.StartWeeklyNum; newTeachingSetting.EndWeeklyNum = specialtyPlanView.EndWeeklyNum; newTeachingSettingInList.Add(newTeachingSetting); } else { //可更新的相关信息 executablePlan.EM_ExecutablePlanTeachingSetting.Credit = specialtyPlanView.Credit; executablePlan.EM_ExecutablePlanTeachingSetting.TheoryCourse = specialtyPlanView.TheoryCourse; executablePlan.EM_ExecutablePlanTeachingSetting.Practicehours = specialtyPlanView.Practicehours; executablePlan.EM_ExecutablePlanTeachingSetting.Trialhours = specialtyPlanView.Trialhours; if (executablePlan.RecordStatus == (int)EM_ExecuteStatus.NotSubmited) { executablePlan.EM_ExecutablePlanTeachingSetting.TheoryWeeklyNum = specialtyPlanView.TheoryWeeklyNum; executablePlan.EM_ExecutablePlanTeachingSetting.PracticeWeeklyNum = specialtyPlanView.PracticeWeeklyNum; executablePlan.EM_ExecutablePlanTeachingSetting.TrialWeeklyNum = specialtyPlanView.TrialWeeklyNum; executablePlan.EM_ExecutablePlanTeachingSetting.WeeklyHours = specialtyPlanView.WeeklyHours; executablePlan.EM_ExecutablePlanTeachingSetting.WeeklyNum = specialtyPlanView.WeeklyNum; executablePlan.EM_ExecutablePlanTeachingSetting.StartWeeklyNum = specialtyPlanView.StartWeeklyNum; executablePlan.EM_ExecutablePlanTeachingSetting.EndWeeklyNum = specialtyPlanView.EndWeeklyNum; } newTeachingSettingUpList.Add(executablePlan.EM_ExecutablePlanTeachingSetting); } if (executablePlan.RecordStatus == (int)EM_ExecuteStatus.NotSubmited) { //可更新的相关信息 if (specialtyPlanView.TeachingModeIDList != null && specialtyPlanView.TeachingModeIDList.Count() > 0) { executablePlanTMDelList.Add(executablePlan.ExecutablePlanID); foreach (var newModeType in specialtyPlanView.TeachingModeIDList.ToList()) { var newTeachingModeType = new EM_ExecutablePlanTeachingModeType(); newTeachingModeType.ExecutablePlanTeachingModeTypeID = Guid.NewGuid(); newTeachingModeType.ExecutablePlanID = executablePlan.ExecutablePlanID; newTeachingModeType.TeachingModeID = newModeType; this.SetNewStatus(newTeachingModeType); newTeachingModeTypeInList.Add(newTeachingModeType); } } else { executablePlanTMDelList.Add(executablePlan.ExecutablePlanID); } } if (specialtyPlanView.TeachingPlaceIDList != null && specialtyPlanView.TeachingPlaceIDList.Count() > 0) { executablePlanTPDelList.Add(executablePlan.ExecutablePlanID); foreach (var newPlace in specialtyPlanView.TeachingPlaceIDList.ToList()) { var newTeachingPlace = new EM_ExecutablePlanTeachingPlace(); newTeachingPlace.ExecutablePlanTeachingPlaceID = Guid.NewGuid(); newTeachingPlace.ExecutablePlanID = executablePlan.ExecutablePlanID; newTeachingPlace.TeachingPlace = newPlace; this.SetNewStatus(newTeachingPlace); newTeachingPlaceInList.Add(newTeachingPlace); } } else { executablePlanTPDelList.Add(executablePlan.ExecutablePlanID); } executablePlanIDList.Add(executablePlan.ExecutablePlanID); } update++; } } } //表示存在对应的主外键关联 if (specialtyPlanView.PlanStatus == (int)EM_PlanStatus.Execute) { //根据专业计划主键ID查询对应的执行计划信息List var newExecutablePlanList = SpecialtyPlanDAL.ExecutablePlanRepository .GetList(x => x.SpecialtyPlanID == specialtyPlanView.SpecialtyPlanID, (x => x.EM_ExecutablePlanProfile), (x => x.EM_ExecutablePlanTeachingSetting)).ToList(); foreach (var newExecutablePlan in newExecutablePlanList) { if (!executablePlanIDList.Contains(newExecutablePlan.ExecutablePlanID)) { //查询对应的执行计划信息View var newExecutablePlanView = ExecutablePlanDAL.GetExecutablePlanViewQueryable(x => x.ExecutablePlanID == newExecutablePlan.ExecutablePlanID).SingleOrDefault(); //查询对应的专业计划信息(业务主键:学年学期ID、入学学年学期ID、专业信息ID、课程信息ID) var newSpecialtyPlanView = SpecialtyPlanDAL.GetAdultSpecialtyPlanViewQueryable(x => x.SpecialtyPlanID != specialtyPlanView.SpecialtyPlanID && x.SchoolyearID == newExecutablePlanView.SchoolyearID && x.StartSchoolyearID == newExecutablePlanView.StartSchoolyearID && x.SpecialtyID == newExecutablePlanView.SpecialtyID && x.CoursematerialID == newExecutablePlanView.CoursematerialID).SingleOrDefault(); if (newSpecialtyPlanView == null) { newExecutablePlan.SpecialtyPlanID = null; SetModifyStatus(newExecutablePlan); newExecutablePlanUpList.Add(newExecutablePlan); } else { //来源专业计划默认为必修课 newExecutablePlan.SourceTypeID = (int)EM_SourceType.RequiredCourse; newExecutablePlan.DefaultClassName = newExecutablePlanView.CourseName + "-" + newExecutablePlanView.GrademajorName; newExecutablePlan.SpecialtyPlanID = newSpecialtyPlanView.SpecialtyPlanID; newExecutablePlan.SchoolyearID = newSpecialtyPlanView.SchoolyearID; newExecutablePlan.GrademajorID = newExecutablePlanView.GrademajorID; newExecutablePlan.CoursematerialID = newSpecialtyPlanView.CoursematerialID; newExecutablePlan.CourseStructureID = newSpecialtyPlanView.CourseStructureID; newExecutablePlan.CourseCategoryID = newSpecialtyPlanView.CourseCategoryID; newExecutablePlan.CourseTypeID = newSpecialtyPlanView.CourseTypeID; newExecutablePlan.CourseQualityID = newSpecialtyPlanView.CourseQualityID; newExecutablePlan.DepartmentID = newSpecialtyPlanView.DepartmentID; newExecutablePlan.IsNeedMaterial = newSpecialtyPlanView.IsNeedMaterial; newExecutablePlan.ResultTypeID = newSpecialtyPlanView.ResultTypeID; newExecutablePlan.HandleModeID = newSpecialtyPlanView.HandleModeID; SetModifyStatus(newExecutablePlan); newExecutablePlanUpList.Add(newExecutablePlan); if (newExecutablePlan.EM_ExecutablePlanProfile == null) { var newProfile = new EM_ExecutablePlanProfile(); newProfile.ExecutablePlanID = newExecutablePlan.ExecutablePlanID; newProfile.IsSpecialtycore = newSpecialtyPlanView.IsSpecialtycore; newProfile.IsCooperation = newSpecialtyPlanView.IsCooperation; newProfile.IsRequired = newSpecialtyPlanView.IsRequired; newProfile.IsElective = newSpecialtyPlanView.IsElective; newProfile.IsNetworkCourse = newSpecialtyPlanView.IsNetworkCourse; newProfile.IsMainCourse = newSpecialtyPlanView.IsMainCourse; newProfile.CourseFineID = newSpecialtyPlanView.CourseFineID; newProfile.PracticeTypeID = newSpecialtyPlanView.PracticeTypeID; newProfile.TeachinglanguageID = newSpecialtyPlanView.TeachinglanguageID; newProfile.ExaminationModeID = newSpecialtyPlanView.ExaminationModeID; SetNewStatus(newProfile); newProfileInList.Add(newProfile); } else { newExecutablePlan.EM_ExecutablePlanProfile.IsSpecialtycore = newSpecialtyPlanView.IsSpecialtycore; newExecutablePlan.EM_ExecutablePlanProfile.IsCooperation = newSpecialtyPlanView.IsCooperation; newExecutablePlan.EM_ExecutablePlanProfile.IsRequired = newSpecialtyPlanView.IsRequired; newExecutablePlan.EM_ExecutablePlanProfile.IsElective = newSpecialtyPlanView.IsElective; newExecutablePlan.EM_ExecutablePlanProfile.IsNetworkCourse = newSpecialtyPlanView.IsNetworkCourse; newExecutablePlan.EM_ExecutablePlanProfile.IsMainCourse = newSpecialtyPlanView.IsMainCourse; newExecutablePlan.EM_ExecutablePlanProfile.CourseFineID = newSpecialtyPlanView.CourseFineID; newExecutablePlan.EM_ExecutablePlanProfile.PracticeTypeID = newSpecialtyPlanView.PracticeTypeID; newExecutablePlan.EM_ExecutablePlanProfile.TeachinglanguageID = newSpecialtyPlanView.TeachinglanguageID; newExecutablePlan.EM_ExecutablePlanProfile.ExaminationModeID = newSpecialtyPlanView.ExaminationModeID; SetModifyStatus(newExecutablePlan.EM_ExecutablePlanProfile); newProfileUpList.Add(newExecutablePlan.EM_ExecutablePlanProfile); } if (newExecutablePlan.EM_ExecutablePlanTeachingSetting == null) { var newTeachingSetting = new EM_ExecutablePlanTeachingSetting(); newTeachingSetting.ExecutablePlanID = newExecutablePlan.ExecutablePlanID; newTeachingSetting.Credit = newSpecialtyPlanView.Credit; newTeachingSetting.TheoryCourse = newSpecialtyPlanView.TheoryCourse; newTeachingSetting.Practicehours = newSpecialtyPlanView.Practicehours; newTeachingSetting.Trialhours = newSpecialtyPlanView.Trialhours; newTeachingSetting.TheoryWeeklyNum = newSpecialtyPlanView.TheoryWeeklyNum; newTeachingSetting.PracticeWeeklyNum = newSpecialtyPlanView.PracticeWeeklyNum; newTeachingSetting.TrialWeeklyNum = newSpecialtyPlanView.TrialWeeklyNum; newTeachingSetting.WeeklyHours = newSpecialtyPlanView.WeeklyHours; newTeachingSetting.WeeklyNum = newSpecialtyPlanView.WeeklyNum; newTeachingSetting.StartWeeklyNum = newSpecialtyPlanView.StartWeeklyNum; newTeachingSetting.EndWeeklyNum = newSpecialtyPlanView.EndWeeklyNum; newTeachingSettingInList.Add(newTeachingSetting); } else { //可更新的相关信息 newExecutablePlan.EM_ExecutablePlanTeachingSetting.Credit = newSpecialtyPlanView.Credit; newExecutablePlan.EM_ExecutablePlanTeachingSetting.TheoryCourse = newSpecialtyPlanView.TheoryCourse; newExecutablePlan.EM_ExecutablePlanTeachingSetting.Practicehours = newSpecialtyPlanView.Practicehours; newExecutablePlan.EM_ExecutablePlanTeachingSetting.Trialhours = newSpecialtyPlanView.Trialhours; if (newExecutablePlan.RecordStatus == (int)EM_ExecuteStatus.NotSubmited) { newExecutablePlan.EM_ExecutablePlanTeachingSetting.TheoryWeeklyNum = newSpecialtyPlanView.TheoryWeeklyNum; newExecutablePlan.EM_ExecutablePlanTeachingSetting.PracticeWeeklyNum = newSpecialtyPlanView.PracticeWeeklyNum; newExecutablePlan.EM_ExecutablePlanTeachingSetting.TrialWeeklyNum = newSpecialtyPlanView.TrialWeeklyNum; newExecutablePlan.EM_ExecutablePlanTeachingSetting.WeeklyHours = newSpecialtyPlanView.WeeklyHours; newExecutablePlan.EM_ExecutablePlanTeachingSetting.WeeklyNum = newSpecialtyPlanView.WeeklyNum; newExecutablePlan.EM_ExecutablePlanTeachingSetting.StartWeeklyNum = newSpecialtyPlanView.StartWeeklyNum; newExecutablePlan.EM_ExecutablePlanTeachingSetting.EndWeeklyNum = newSpecialtyPlanView.EndWeeklyNum; } newTeachingSettingUpList.Add(newExecutablePlan.EM_ExecutablePlanTeachingSetting); } if (newExecutablePlan.RecordStatus == (int)EM_ExecuteStatus.NotSubmited) { //可更新的相关信息 if (newSpecialtyPlanView.TeachingModeIDList != null && newSpecialtyPlanView.TeachingModeIDList.Count() > 0) { executablePlanTMDelList.Add(newExecutablePlan.ExecutablePlanID); foreach (var newModeType in newSpecialtyPlanView.TeachingModeIDList.ToList()) { var newTeachingModeType = new EM_ExecutablePlanTeachingModeType(); newTeachingModeType.ExecutablePlanTeachingModeTypeID = Guid.NewGuid(); newTeachingModeType.ExecutablePlanID = newExecutablePlan.ExecutablePlanID; newTeachingModeType.TeachingModeID = newModeType; this.SetNewStatus(newTeachingModeType); newTeachingModeTypeInList.Add(newTeachingModeType); } } else { executablePlanTMDelList.Add(newExecutablePlan.ExecutablePlanID); } } if (newSpecialtyPlanView.TeachingPlaceIDList != null && newSpecialtyPlanView.TeachingPlaceIDList.Count() > 0) { executablePlanTPDelList.Add(newExecutablePlan.ExecutablePlanID); foreach (var newPlace in newSpecialtyPlanView.TeachingPlaceIDList.ToList()) { var newTeachingPlace = new EM_ExecutablePlanTeachingPlace(); newTeachingPlace.ExecutablePlanTeachingPlaceID = Guid.NewGuid(); newTeachingPlace.ExecutablePlanID = newExecutablePlan.ExecutablePlanID; newTeachingPlace.TeachingPlace = newPlace; this.SetNewStatus(newTeachingPlace); newTeachingPlaceInList.Add(newTeachingPlace); } } else { executablePlanTPDelList.Add(newExecutablePlan.ExecutablePlanID); } } executablePlanIDList.Add(newExecutablePlan.ExecutablePlanID); } } } } } } using (TransactionScope ts = new TransactionScope()) { //删除 UnitOfWork.Delete(x => executablePlanTPDelList.Contains(x.ExecutablePlanID)); UnitOfWork.Delete(x => executablePlanTMDelList.Contains(x.ExecutablePlanID)); //批量插入 UnitOfWork.BulkInsert(newExecutablePlanInList); UnitOfWork.BulkInsert(newProfileInList); UnitOfWork.BulkInsert(newTeachingSettingInList); UnitOfWork.BulkInsert(newTeachingModeTypeInList); UnitOfWork.BulkInsert(newTeachingPlaceInList); //批量统一提交更新 if (newExecutablePlanUpList != null && newExecutablePlanUpList.Count() > 0) { UnitOfWork.BatchUpdate(newExecutablePlanUpList); } //批量统一提交更新 if (newProfileUpList != null && newProfileUpList.Count() > 0) { UnitOfWork.BatchUpdate(newProfileUpList); } //批量统一提交更新 if (newTeachingSettingUpList != null && newTeachingSettingUpList.Count() > 0) { UnitOfWork.BatchUpdate(newTeachingSettingUpList); } ts.Complete(); } if (fail > 0) { tipMessage = insert + "条,刷新成功" + update + "条,失败" + fail + "条,原因:年级专业对应的学生人数为0、学年学期小于入学学年学期或学年学期大于毕业学年学期,请检查"; } else if (insert > 0 && update <= 0) { tipMessage = insert + "条"; } else { tipMessage = insert + "条,刷新成功" + update + "条"; } return tipMessage; } catch (Exception) { throw; } } /// /// 查询专业计划对应的授课方式List /// /// /// public List GetTeachingModeTypeList(Guid? specialtyPlanID) { //专业计划 Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); exp = exp.And(x => x.SpecialtyPlanID == specialtyPlanID); var query = SpecialtyPlanDAL.GetTeachingModeTypeQueryble(exp); return query.OrderBy(x => x.Value).Select(x => x.ToString()).ToList(); } /// /// 查询专业计划对应的授课地点List /// /// /// public List GetTeachingPlaceList(Guid? specialtyPlanID) { //专业计划 Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); exp = exp.And(x => x.SpecialtyPlanID == specialtyPlanID); var query = SpecialtyPlanDAL.GetTeachingPlaceQueryble(exp); return query.OrderBy(x => x.Value).Select(x => x.ToString()).ToList(); } /// /// 查询对应的计划范围信息GrademajorView(根据专业计划信息,统计各年级专业对应的班级数、学生人数) /// 注:成教版本(入学学年学期、专业信息) /// /// /// /// /// /// /// /// /// public IGridResultSet GetAdultPlanRangeViewGrid(ConfiguretView configuretView, Guid? specialtyPlanID, Guid? collegeID, Guid? grademajorID, int? inSchoolStatus, int pageIndex, int pageSize) { //专业计划 Expression> expSpecialtyPlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); expSpecialtyPlan = expSpecialtyPlan.And(x => x.SpecialtyPlanID == specialtyPlanID); //学生信息 Expression> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (inSchoolStatus != null && inSchoolStatus > -1) { var inschoolStatusList = InSchoolSettingServices.Value.GetInschoolStatusList(true); if (inSchoolStatus == 1) { //表示在校 expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID)); } if (inSchoolStatus == 0) { //不在校 expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID)); } } var query = SpecialtyPlanDAL.GetAdultPlanRangeViewQueryable(expSpecialtyPlan, expStudent); if (collegeID.HasValue) { query = query.Where(x => x.CollegeID == collegeID); } if (grademajorID.HasValue) { query = query.Where(x => x.GrademajorID == grademajorID); } //查询条件 if (!string.IsNullOrEmpty(configuretView.ConditionValue)) { query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); } return query.OrderBy(x => x.CollegeCode.Length).ThenBy(x => x.CollegeCode) .ThenBy(x => x.StandardID).ThenBy(x => x.Code.Length).ThenBy(x => x.Code) .ToGridResultSet(pageIndex, pageSize); } /// /// 查询对应的计划范围信息List(根据专业计划信息,统计各年级专业对应的班级数、学生人数) /// 注:成教版本(入学学年学期、专业信息) /// /// /// /// /// /// /// public IList GetAdultPlanRangeViewList(ConfiguretView configuretView, Guid? specialtyPlanID, Guid? collegeID, Guid? grademajorID, int? inSchoolStatus) { //专业计划 Expression> expSpecialtyPlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); expSpecialtyPlan = expSpecialtyPlan.And(x => x.SpecialtyPlanID == specialtyPlanID); //学生信息 Expression> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (inSchoolStatus != null && inSchoolStatus > -1) { var inschoolStatusList = InSchoolSettingServices.Value.GetInschoolStatusList(true); if (inSchoolStatus == 1) { //表示在校 expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID)); } if (inSchoolStatus == 0) { //不在校 expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID)); } } var query = SpecialtyPlanDAL.GetAdultPlanRangeViewQueryable(expSpecialtyPlan, expStudent); if (collegeID.HasValue) { query = query.Where(x => x.CollegeID == collegeID); } if (grademajorID.HasValue) { query = query.Where(x => x.GrademajorID == grademajorID); } //查询条件 if (!string.IsNullOrEmpty(configuretView.ConditionValue)) { query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); } return query.OrderBy(x => x.CollegeCode.Length).ThenBy(x => x.CollegeCode) .ThenBy(x => x.StandardID).ThenBy(x => x.Code.Length).ThenBy(x => x.Code) .ToList(); } /// /// 查询专业计划对应的学生信息BaseStudentView /// 注:成教版本(入学学年学期、专业信息) /// /// /// /// /// /// /// /// /// public IGridResultSet GetAdultBaseStudentViewGrid(ConfiguretView configuretView, Guid? specialtyPlanID, Guid? collegeID, Guid? classmajorID, int? inSchoolStatus, int pageIndex, int pageSize) { //专业计划 Expression> expSpecialtyPlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); expSpecialtyPlan = expSpecialtyPlan.And(x => x.SpecialtyPlanID == specialtyPlanID); //学生信息 Expression> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (inSchoolStatus != null && inSchoolStatus > -1) { var inschoolStatusList = InSchoolSettingServices.Value.GetInschoolStatusList(true); if (inSchoolStatus == 1) { //表示在校 expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID)); } if (inSchoolStatus == 0) { //不在校 expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID)); } } var query = SpecialtyPlanDAL.GetAdultBaseStudentViewQueryable(expSpecialtyPlan, expStudent); if (collegeID.HasValue) { query = query.Where(x => x.CollegeID == collegeID); } if (classmajorID.HasValue) { query = query.Where(x => x.ClassmajorID == classmajorID); } //查询条件 if (!string.IsNullOrEmpty(configuretView.ConditionValue)) { query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); } return query.OrderBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo) .ThenBy(x => x.ClassmajorCode.Length) .ThenBy(x => x.ClassmajorCode).ThenBy(x => x.LoginID) .ToGridResultSet(pageIndex, pageSize); } /// /// 查询专业计划对应的学生信息List /// 注:成教版本(入学学年学期、专业信息) /// /// /// /// /// /// /// public IList GetAdultBaseStudentViewList(ConfiguretView configuretView, Guid? specialtyPlanID, Guid? collegeID, Guid? classmajorID, int? inSchoolStatus) { //专业计划 Expression> expSpecialtyPlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); expSpecialtyPlan = expSpecialtyPlan.And(x => x.SpecialtyPlanID == specialtyPlanID); //学生信息 Expression> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (inSchoolStatus != null && inSchoolStatus > -1) { var inschoolStatusList = InSchoolSettingServices.Value.GetInschoolStatusList(true); if (inSchoolStatus == 1) { //表示在校 expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID)); } if (inSchoolStatus == 0) { //不在校 expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID)); } } var query = SpecialtyPlanDAL.GetAdultBaseStudentViewQueryable(expSpecialtyPlan, expStudent); if (collegeID.HasValue) { query = query.Where(x => x.CollegeID == collegeID); } if (classmajorID.HasValue) { query = query.Where(x => x.ClassmajorID == classmajorID); } //查询条件 if (!string.IsNullOrEmpty(configuretView.ConditionValue)) { query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); } return query.OrderBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo) .ThenBy(x => x.ClassmajorCode.Length) .ThenBy(x => x.ClassmajorCode).ThenBy(x => x.LoginID) .ToList(); } /// /// 新增(数据库表,用于报表) /// /// /// public void CreateIDTempTable(string tempTableName, List ids) { try { UnitOfWork.CreateIDTempTable(tempTableName, ids); } catch (Exception) { throw; } } /// /// 删除(数据库表,用于报表) /// /// /// public bool DeleteTempTable(string tempTableName) { try { UnitOfWork.DeleteTempTable(tempTableName); return true; } catch (Exception) { throw; } } /// /// 专业计划信息Excel导入 /// /// /// /// /// /// /// public void AdultSpecialtyPlanImport(Dictionary cellheader, out int? inCount, out int? upCount, out List errdataList, out int? errCount, string sourcePhysicalPath) { try { StringBuilder errorMsg = new StringBuilder(); // 错误信息 List errList = new List(); // 1.1解析文件,存放到一个List集合里 cellheader.Remove("ErrorMessage");//移除“未导入原因”列(ErrorMessage) List enlist = NpoiExcelHelper.ExcelToEntityList(cellheader, sourcePhysicalPath, out errorMsg, out errList); cellheader.Add("ErrorMessage", "未导入原因"); //对List集合进行有效性校验 if (enlist.Count() <= 0) { throw new Exception("Excel文件数据为空,请检查。"); } Regex reg = null; //正则表达式 //DateTime result; //用于返回判断日期字段格式 bool isListPass = true; //List判断标识 inCount = 0; //导入个数 upCount = 0; //更新个数 errCount = 0; //失败个数 string errorMsgStr = ""; //错误信息 List newSpecialtyPlanInList = new List(); List newSpecialtyPlanUpList = new List(); List newTeachingSettingInList = new List(); List newTeachingSettingUpList = new List(); List newTeachingModeTypeInList = new List(); List newTeachingPlaceInList = new List(); List specialtyPlanTMDelList = new List(); List specialtyPlanTPDelList = new List(); //将循环中相关数据库查询统一查询出来进行匹配(尽量避免在循环中进行数据库查询) //年级 var gradeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Grade).ToList(); //开课学年 var schoolyearNumList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_SchoolyearNum).ToList(); //学期 var schoolcodeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Semester).ToList(); //专业代码、专业名称、专业ID(Value) var standardList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Standard).ToList(); //培养层次(所修学历) var educationList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Education).ToList(); //学习形式 var learningFormList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Learningform).ToList(); //专业信息 var specialtyList = SpecialtyPlanDAL.SpecialtyRepository.GetList(x => true).ToList(); //学年学期 var schoolyearList = SpecialtyPlanDAL.SchoolyearRepository.GetList(x => true).ToList(); //课程信息 var courseList = SpecialtyPlanDAL.CoursematerialRepository.GetList(x => true).ToList(); //课程代码 var courseCodeList = enlist.Where(x => !string.IsNullOrEmpty(x.CourseCode)).Select(x => x.CourseCode.Trim()).ToList(); //对比后的newCourseList var newCourseList = courseList.Where(x => courseCodeList.Contains(x.CourseCode)).ToList(); //对比后的coursematerialIDList var coursematerialIDList = newCourseList.Select(x => (Guid?)x.CoursematerialID).ToList(); //课程结构 var courseStructureList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_CourseStructure).ToList(); //课程属性 var courseCategoryList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_CourseCategory).ToList(); //课程类型 var courseTypeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_CourseType).ToList(); //课程性质 var courseQualityList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_CourseQuality).ToList(); //教研室信息 var departmentList = SpecialtyPlanDAL.DepartmentRepository.GetList(x => true).ToList(); //开课教研室 var departmentNameList = enlist.Where(x => !string.IsNullOrEmpty(x.DepartmentName)).Select(x => x.DepartmentName.Trim()).ToList(); //对比后的newDepartmentList var newDepartmentList = departmentList.Where(x => departmentNameList.Contains(x.Name)).ToList(); //是否启用 var generalPurposeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_GeneralPurpose).ToList(); //精品课程 var courseFineList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_CourseFine).ToList(); //实践类型 var practiceTypeList = IdNameExt.GetDictionaryItem(DictionaryItem.EM_PracticeType).ToList(); //授课语言 var teachinglanguageList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Teachinglanguage).ToList(); //考试方式 var examinationModeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_ExaminationMode).ToList(); //成绩类型 var resultTypeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_ResultType).ToList(); //处理方式 var handleModeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_HandleMode).ToList(); //授课方式 var teachingModeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_TeachingMode).ToList(); //授课地点 var teachingPlaceList = IdNameExt.GetDictionaryItem(DictionaryItem.EM_TeachingPlace).ToList(); //专业计划 var specialtyPlanList = SpecialtyPlanDAL.SpecialtyPlanRepository .GetList(x => true, (x => x.EM_SpecialtyPlanTeachingSetting)).ToList(); //对比后的newSpecialtyPlanList(暂时只对比课程信息ID) var newSpecialtyPlanList = specialtyPlanList.Where(x => coursematerialIDList.Contains(x.CoursematerialID)).ToList(); //循环检测数据列,对各数据列进行验证(必填、字典项验证、数据格式等) for (int i = 0; i < enlist.Count; i++) { SpecialtyPlanView en = enlist[i]; //Excel表数据视图 EM_SpecialtyPlan newSpecialtyPlan = new EM_SpecialtyPlan(); EM_SpecialtyPlanTeachingSetting newTeachingSetting = new EM_SpecialtyPlanTeachingSetting(); List newModeTypeList = new List(); List newPlaceList = new List(); //年级 if (string.IsNullOrWhiteSpace(en.GradeStr)) { errCount++; errorMsgStr = "年级不能为空"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { var grade = gradeList.Where(x => x.Name == en.GradeStr.Trim()).SingleOrDefault(); if (grade == null) { errCount++; errorMsgStr = "年级不存在,请检查"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { //年级 en.GradeID = grade.Value; } } //入学学期 if (string.IsNullOrWhiteSpace(en.StartSchoolcodeStr)) { errCount++; errorMsgStr = "入学学期不能为空"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { var startSchoolcode = schoolcodeList.Where(x => x.Name == en.StartSchoolcodeStr.Trim()).SingleOrDefault(); if (startSchoolcode == null) { errCount++; errorMsgStr = "入学学期不存在,请检查"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { //入学学期 en.StartSchoolcodeID = startSchoolcode.Value; } } //查询对应的入学学年学期ID if (en.GradeID.HasValue && en.StartSchoolcodeID.HasValue) { //查询对应的学年学期信息 var startSchoolyear = schoolyearList.Where(x => x.Years == en.GradeID && x.SchoolcodeID == en.StartSchoolcodeID).SingleOrDefault(); if (startSchoolyear == null) { errCount++; errorMsgStr = "无法计算出对应的入学学年学期信息(以年级、入学学期计算),请检查"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { //入学学年学期ID newSpecialtyPlan.StartSchoolyearID = startSchoolyear.SchoolyearID; //入学学年学期对应的Value值 en.StartValue = startSchoolyear.Value; } } else { errCount++; errorMsgStr = "数据有误,请检查(年级或入学学期不能为空)"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } //专业代码 if (string.IsNullOrWhiteSpace(en.StandardCodeStr)) { errCount++; errorMsgStr = "专业代码不能为空"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { var standard = standardList.Where(x => x.Code == en.StandardCodeStr.Trim()).FirstOrDefault(); if (standard == null) { errCount++; errorMsgStr = "专业代码不存在,请检查"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { //专业代码 } } //专业名称 if (string.IsNullOrWhiteSpace(en.StandardNameStr)) { errCount++; errorMsgStr = "专业名称不能为空"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { var standard = standardList.Where(x => x.Name == en.StandardNameStr.Trim()).FirstOrDefault(); if (standard == null) { errCount++; errorMsgStr = "专业名称不存在,请检查"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { //专业名称 } } //专业代码与专业名称查询专业ID(Value) if (string.IsNullOrWhiteSpace(en.StandardCodeStr) || string.IsNullOrWhiteSpace(en.StandardNameStr)) { errCount++; errorMsgStr = "专业代码或专业名称不能为空"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { var standard = standardList.Where(x => x.Code == en.StandardCodeStr.Trim() && x.Name == en.StandardNameStr.Trim()).SingleOrDefault(); if (standard == null) { errCount++; errorMsgStr = "专业代码与专业名称对应的元素值不存在,请检查"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { //专业ID(Value) en.StandardID = standard.Value; } } //培养层次 if (string.IsNullOrWhiteSpace(en.EducationStr)) { errCount++; errorMsgStr = RSL.Get("EducationID") + "不能为空"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { var education = educationList.Where(x => x.Name == en.EducationStr.Trim()).SingleOrDefault(); if (education == null) { errCount++; errorMsgStr = RSL.Get("EducationID") + "不存在,请检查"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { //培养层次 en.EducationID = education.Value; } } //学习形式 if (string.IsNullOrWhiteSpace(en.LearningformStr)) { errCount++; errorMsgStr = "学习形式不能为空"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { var learningForm = learningFormList.Where(x => x.Name == en.LearningformStr.Trim()).SingleOrDefault(); if (learningForm == null) { errCount++; errorMsgStr = "学习形式不存在,请检查"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { //学习形式 en.LearningformID = learningForm.Value; } } //学制 if (string.IsNullOrWhiteSpace(en.LearnSystemStr)) { errCount++; errorMsgStr = "学制不能为空"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { reg = new Regex(@"^[0-9]+([.]{1}[0-9]+){0,1}$"); //学制字段正则表达式() if (!reg.IsMatch(en.LearnSystemStr.Trim())) { errCount++; errorMsgStr = "学制格式不正确,请检查"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { //学制 en.LearnSystem = Convert.ToDecimal(en.LearnSystemStr.Trim()); } } //查询对应的专业信息ID if (en.StandardID.HasValue && en.EducationID.HasValue && en.LearningformID.HasValue && en.LearnSystem.HasValue) { //查询对应的专业信息 var specialty = specialtyList.Where(x => x.StandardID == en.StandardID && x.EducationID == en.EducationID && x.LearningformID == en.LearningformID && x.LearnSystem == en.LearnSystem).SingleOrDefault(); if (specialty == null) { errCount++; errorMsgStr = "对应的专业信息不存在(以专业代码、专业名称、" + RSL.Get("EducationID") + "、学习形式、学制查询),请检查"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { //判断对应的专业信息状态(启用、禁用状态) if (specialty.RecordStatus > (int)SYS_STATUS.UNUSABLE) { newSpecialtyPlan.SpecialtyID = specialty.SpecialtyID; } else { newSpecialtyPlan.SpecialtyID = specialty.SpecialtyID; errCount++; errorMsgStr = "对应的专业信息为禁用状态,请检查"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } } } else { errCount++; errorMsgStr = "数据有误,请检查(专业ID(Value)、" + RSL.Get("EducationID") + "、学习形式或学制不能为空)"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } //开课学年 if (string.IsNullOrWhiteSpace(en.SchoolyearNumStr)) { errCount++; errorMsgStr = "开课学年不能为空"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { var schoolyearNum = schoolyearNumList.Where(x => x.Name == en.SchoolyearNumStr.Trim()).SingleOrDefault(); if (schoolyearNum == null) { errCount++; errorMsgStr = "开课学年不存在,请检查"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { //开课学年 en.SchoolyearNumID = schoolyearNum.Value; } } //学期 if (string.IsNullOrWhiteSpace(en.SchoolcodeStr)) { errCount++; errorMsgStr = "学期不能为空"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { var schoolcode = schoolcodeList.Where(x => x.Name == en.SchoolcodeStr.Trim()).SingleOrDefault(); if (schoolcode == null) { errCount++; errorMsgStr = "学期不存在,请检查"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { //学期 en.SchoolcodeID = schoolcode.Value; } } //查询对应的学年学期ID且匹配对应的学年学期(学年学期不为空时) if (en.GradeID.HasValue && en.StartSchoolcodeID.HasValue && en.SchoolyearNumID.HasValue && en.SchoolcodeID.HasValue && en.LearnSystem.HasValue) { //查询对应的毕业学年学期信息 var graduateSchoolyearValue = (en.GradeID.Value * 2) - 1 + (en.StartSchoolcodeID.Value - 1); graduateSchoolyearValue += Convert.ToInt32(Math.Ceiling(en.LearnSystem.Value * 2 - 1)); var graduatingSemester = schoolyearList.Where(x => x.Value == graduateSchoolyearValue).SingleOrDefault(); if (graduatingSemester == null) { errCount++; errorMsgStr = "年级、入学学期和学制对应的毕业学年学期信息不存在,请检查"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { //查询对应的学年学期信息 var yearID = Convert.ToInt32(en.GradeID + en.SchoolyearNumID - 1); var schoolyear = schoolyearList.Where(x => x.Years == yearID && x.SchoolcodeID == en.SchoolcodeID).SingleOrDefault(); if (schoolyear == null) { errCount++; errorMsgStr = "无法计算出对应的学年学期信息(以开课学年、学期、年级计算),请检查"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { //判断学年学期(以计算出的学年学期为准) if (string.IsNullOrWhiteSpace(en.SchoolyearCode)) { //暂不考虑 } else { //学年学期与计算出的学年学期不对应 if (schoolyear.Code.Trim() != en.SchoolyearCode.Trim()) { errCount++; errorMsgStr = "学年学期与计算出的学年学期不对应(以计算出的学年学期为准),请检查"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } } //学年学期小于入学学年学期 if (schoolyear.Value < en.StartValue) { errCount++; errorMsgStr = "学年学期小于对应的入学学年学期(以计算出的学年学期为准),请检查"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } //学年学期大于毕业学年学期 if (schoolyear.Value > graduatingSemester.Value) { errCount++; errorMsgStr = "学年学期大于对应的毕业学年学期(以计算出的学年学期为准),请检查"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } //学年学期ID newSpecialtyPlan.SchoolyearID = schoolyear.SchoolyearID; } } } else { errCount++; errorMsgStr = "数据有误,请检查(年级、入学学期、学制、开课学年或学期不能为空)"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } //学年学期 if (string.IsNullOrWhiteSpace(en.SchoolyearCode)) { //暂不考虑 } else { //暂不考虑 } //课程代码 if (string.IsNullOrWhiteSpace(en.CourseCode)) { errCount++; errorMsgStr = "课程代码不能为空"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { reg = new Regex(@"^[0-9a-zA-Z\s?]+$"); //正则表达式(请输入数字或英文字母) if (!reg.IsMatch(en.CourseCode.Trim())) { errCount++; errorMsgStr = "课程代码格式不正确,请检查(数字或英文字母)"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { var course = newCourseList.Where(x => x.CourseCode == en.CourseCode.Trim()).SingleOrDefault(); if (course == null) { errCount++; errorMsgStr = "课程代码不存在,请检查"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { //判断课程代码与课程名称(以课程代码为准) if (string.IsNullOrWhiteSpace(en.CourseName)) { //暂不考虑 } else { //课程代码与课程名称不对应 if (course.CourseName.Trim() != en.CourseName.Trim()) { errCount++; errorMsgStr = "课程代码与课程名称不对应(以课程代码为准),请检查"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } } //判断对应的课程信息状态(启用、禁用状态) if (course.IsEnable == true) { //课程信息ID newSpecialtyPlan.CoursematerialID = course.CoursematerialID; } else { newSpecialtyPlan.CoursematerialID = course.CoursematerialID; errCount++; errorMsgStr = "对应的课程信息为禁用状态,请检查"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } } } } //课程名称 if (string.IsNullOrWhiteSpace(en.CourseName)) { //暂不考虑 } else { //暂不考虑 } //课程结构 if (string.IsNullOrWhiteSpace(en.CourseStructureStr)) { newSpecialtyPlan.CourseStructureID = (int)CF_CourseStructure.ClassroomTeaching; } else { var courseStructure = courseStructureList.Where(x => x.Name == en.CourseStructureStr.Trim()).SingleOrDefault(); if (courseStructure == null) { errCount++; errorMsgStr = "课程结构不存在,请检查"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { //课程结构 newSpecialtyPlan.CourseStructureID = courseStructure.Value; } } //课程属性 if (string.IsNullOrWhiteSpace(en.CourseCategoryStr)) { newSpecialtyPlan.CourseCategoryID = (int)CF_CourseCategory.Publiccourse; } else { var courseCategory = courseCategoryList.Where(x => x.Name == en.CourseCategoryStr.Trim()).SingleOrDefault(); if (courseCategory == null) { errCount++; errorMsgStr = "课程属性不存在,请检查"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { //课程属性 newSpecialtyPlan.CourseCategoryID = courseCategory.Value; } } //课程类型 if (string.IsNullOrWhiteSpace(en.CourseTypeStr)) { errCount++; errorMsgStr = "课程类型不能为空"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { var courseType = courseTypeList.Where(x => x.Name == en.CourseTypeStr.Trim()).SingleOrDefault(); if (courseType == null) { errCount++; errorMsgStr = "课程类型不存在,请检查"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { //课程类型 newSpecialtyPlan.CourseTypeID = courseType.Value; } } //课程性质 if (string.IsNullOrWhiteSpace(en.CourseQualityStr)) { newSpecialtyPlan.CourseQualityID = (int)CF_CourseQuality.Required; } else { var courseQuality = courseQualityList.Where(x => x.Name == en.CourseQualityStr.Trim()).SingleOrDefault(); if (courseQuality == null) { errCount++; errorMsgStr = "课程性质不存在,请检查"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { //课程性质 newSpecialtyPlan.CourseQualityID = courseQuality.Value; } } //课程学分 if (string.IsNullOrWhiteSpace(en.CreditStr)) { errCount++; errorMsgStr = "课程学分不能为空"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { reg = new Regex(@"^[0-9]+([.]{1}[0-9]+){0,1}$"); //课程学分字段正则表达式() if (!reg.IsMatch(en.CreditStr.Trim())) { errCount++; errorMsgStr = "课程学分格式不正确,请检查"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { //课程学分 newTeachingSetting.Credit = Convert.ToDecimal(en.CreditStr.Trim()); } } //理论学时 if (string.IsNullOrWhiteSpace(en.TheoryCourseStr)) { errCount++; errorMsgStr = "理论学时不能为空"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { reg = new Regex(@"^\d+$"); //正则表达式(非负整数) if (!reg.IsMatch(en.TheoryCourseStr.Trim())) { errCount++; errorMsgStr = "理论学时格式不正确,请检查"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { //理论学时 newTeachingSetting.TheoryCourse = Convert.ToInt32(en.TheoryCourseStr.Trim()); } } //实践学时 if (string.IsNullOrWhiteSpace(en.PracticehoursStr)) { errCount++; errorMsgStr = "实践学时不能为空"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { reg = new Regex(@"^\d+$"); //正则表达式(非负整数) if (!reg.IsMatch(en.PracticehoursStr.Trim())) { errCount++; errorMsgStr = "实践学时格式不正确,请检查"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { //实践学时 newTeachingSetting.Practicehours = Convert.ToInt32(en.PracticehoursStr.Trim()); } } //实验学时 if (string.IsNullOrWhiteSpace(en.TrialhoursStr)) { newTeachingSetting.Trialhours = 0; } else { reg = new Regex(@"^\d+$"); //正则表达式(非负整数) if (!reg.IsMatch(en.TrialhoursStr.Trim())) { errCount++; errorMsgStr = "实验学时格式不正确,请检查"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { //实验学时 newTeachingSetting.Trialhours = Convert.ToInt32(en.TrialhoursStr.Trim()); } } //理论周次 if (string.IsNullOrWhiteSpace(en.TheoryWeeklyNumStr)) { newTeachingSetting.TheoryWeeklyNum = 0; } else { reg = new Regex(@"^\d+$"); //正则表达式(非负整数) if (!reg.IsMatch(en.TheoryWeeklyNumStr.Trim())) { errCount++; errorMsgStr = "理论周次格式不正确,请检查"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { //理论周次 newTeachingSetting.TheoryWeeklyNum = Convert.ToInt32(en.TheoryWeeklyNumStr.Trim()); } } //实践周次 if (string.IsNullOrWhiteSpace(en.PracticeWeeklyNumStr)) { newTeachingSetting.PracticeWeeklyNum = 0; } else { reg = new Regex(@"^\d+$"); //正则表达式(非负整数) if (!reg.IsMatch(en.PracticeWeeklyNumStr.Trim())) { errCount++; errorMsgStr = "实践周次格式不正确,请检查"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { //实践周次 newTeachingSetting.PracticeWeeklyNum = Convert.ToInt32(en.PracticeWeeklyNumStr.Trim()); } } //实验周次 if (string.IsNullOrWhiteSpace(en.TrialWeeklyNumStr)) { newTeachingSetting.TrialWeeklyNum = 0; } else { reg = new Regex(@"^\d+$"); //正则表达式(非负整数) if (!reg.IsMatch(en.TrialWeeklyNumStr.Trim())) { errCount++; errorMsgStr = "实验周次格式不正确,请检查"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { //实践周次 newTeachingSetting.TrialWeeklyNum = Convert.ToInt32(en.TrialWeeklyNumStr.Trim()); } } //开课教研室 if (string.IsNullOrWhiteSpace(en.DepartmentName)) { errCount++; errorMsgStr = "开课教研室不能为空"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { var department = newDepartmentList.Where(x => x.Name == en.DepartmentName.Trim()).SingleOrDefault(); if (department == null) { errCount++; errorMsgStr = "开课教研室不存在,请检查"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { //教研室信息ID newSpecialtyPlan.DepartmentID = department.DepartmentID; } } //是否专业核心 if (string.IsNullOrWhiteSpace(en.IsSpecialtycoreStr)) { //是否专业核心(默认为否) newSpecialtyPlan.IsSpecialtycore = false; } else { var generalPurpose = generalPurposeList.Where(x => x.Name == en.IsSpecialtycoreStr.Trim()).SingleOrDefault(); if (generalPurpose == null) { errCount++; errorMsgStr = "是否专业核心不存在,请检查"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { //是否专业核心 newSpecialtyPlan.IsSpecialtycore = generalPurpose.Value == (int)CF_GeneralPurpose.IsYes ? true : false; } } //是否合作开发 if (string.IsNullOrWhiteSpace(en.IsCooperationStr)) { //是否合作开发(默认为否) newSpecialtyPlan.IsCooperation = false; } else { var generalPurpose = generalPurposeList.Where(x => x.Name == en.IsCooperationStr.Trim()).SingleOrDefault(); if (generalPurpose == null) { errCount++; errorMsgStr = "是否合作开发不存在,请检查"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { //是否合作开发 newSpecialtyPlan.IsCooperation = generalPurpose.Value == (int)CF_GeneralPurpose.IsYes ? true : false; } } //是否必修课 if (string.IsNullOrWhiteSpace(en.IsRequiredStr)) { //是否必修课(默认为否) newSpecialtyPlan.IsRequired = false; } else { var generalPurpose = generalPurposeList.Where(x => x.Name == en.IsRequiredStr.Trim()).SingleOrDefault(); if (generalPurpose == null) { errCount++; errorMsgStr = RSL.Get("IsRequired") + "不存在,请检查"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { //是否必修课 newSpecialtyPlan.IsRequired = generalPurpose.Value == (int)CF_GeneralPurpose.IsYes ? true : false; } } //是否网上选修 if (string.IsNullOrWhiteSpace(en.IsElectiveStr)) { //是否网上选修(默认为否) newSpecialtyPlan.IsElective = false; } else { var generalPurpose = generalPurposeList.Where(x => x.Name == en.IsElectiveStr.Trim()).SingleOrDefault(); if (generalPurpose == null) { errCount++; errorMsgStr = "是否网上选修不存在,请检查"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { //是否网上选修 newSpecialtyPlan.IsElective = generalPurpose.Value == (int)CF_GeneralPurpose.IsYes ? true : false; } } //是否网络课程 if (string.IsNullOrWhiteSpace(en.IsNetworkCourseStr)) { //是否网络课程(默认为否) newSpecialtyPlan.IsNetworkCourse = false; } else { var generalPurpose = generalPurposeList.Where(x => x.Name == en.IsNetworkCourseStr.Trim()).SingleOrDefault(); if (generalPurpose == null) { errCount++; errorMsgStr = "是否网络课程不存在,请检查"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { //是否网络课程 newSpecialtyPlan.IsNetworkCourse = generalPurpose.Value == (int)CF_GeneralPurpose.IsYes ? true : false; } } //是否学位课程 if (string.IsNullOrWhiteSpace(en.IsMainCourseStr)) { //是否学位课程(默认为否) newSpecialtyPlan.IsMainCourse = false; } else { var generalPurpose = generalPurposeList.Where(x => x.Name == en.IsMainCourseStr.Trim()).SingleOrDefault(); if (generalPurpose == null) { errCount++; errorMsgStr = "是否学位课程不存在,请检查"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { //是否学位课程 newSpecialtyPlan.IsMainCourse = generalPurpose.Value == (int)CF_GeneralPurpose.IsYes ? true : false; } } //是否需要教材 if (string.IsNullOrWhiteSpace(en.IsNeedMaterialStr)) { //是否需要教材(默认为否) newSpecialtyPlan.IsNeedMaterial = false; } else { var generalPurpose = generalPurposeList.Where(x => x.Name == en.IsNeedMaterialStr.Trim()).SingleOrDefault(); if (generalPurpose == null) { errCount++; errorMsgStr = "是否需要教材不存在,请检查"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { //是否需要教材 newSpecialtyPlan.IsNeedMaterial = generalPurpose.Value == (int)CF_GeneralPurpose.IsYes ? true : false; } } //精品课程 if (string.IsNullOrWhiteSpace(en.CourseFineStr)) { newSpecialtyPlan.CourseFineID = (int)CF_CourseFine.No; } else { var courseFine = courseFineList.Where(x => x.Name == en.CourseFineStr.Trim()).SingleOrDefault(); if (courseFine == null) { errCount++; errorMsgStr = "精品课程不存在,请检查"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { //精品课程 newSpecialtyPlan.CourseFineID = courseFine.Value; } } //实践类型 if (string.IsNullOrWhiteSpace(en.PracticeTypeStr)) { //不考虑 } else { var practiceType = practiceTypeList.Where(x => x.Name == en.PracticeTypeStr.Trim()).SingleOrDefault(); if (practiceType == null) { errCount++; errorMsgStr = "实践类型不存在,请检查"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { //实践类型 newSpecialtyPlan.PracticeTypeID = practiceType.Value; } } //授课语言 if (string.IsNullOrWhiteSpace(en.TeachinglanguageStr)) { newSpecialtyPlan.TeachinglanguageID = (int)CF_Teachinglanguage.Chinese; } else { var teachinglanguage = teachinglanguageList.Where(x => x.Name == en.TeachinglanguageStr.Trim()).SingleOrDefault(); if (teachinglanguage == null) { errCount++; errorMsgStr = "授课语言不存在,请检查"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { //授课语言 newSpecialtyPlan.TeachinglanguageID = teachinglanguage.Value; } } //考试方式 if (string.IsNullOrWhiteSpace(en.ExaminationModeStr)) { newSpecialtyPlan.ExaminationModeID = (int)CF_ExaminationMode.WrittenExam; } else { var examinationMode = examinationModeList.Where(x => x.Name == en.ExaminationModeStr.Trim()).SingleOrDefault(); if (examinationMode == null) { errCount++; errorMsgStr = "考试方式不存在,请检查"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { //考试方式 newSpecialtyPlan.ExaminationModeID = examinationMode.Value; } } //成绩类型 if (string.IsNullOrWhiteSpace(en.ResultTypeStr)) { newSpecialtyPlan.ResultTypeID = (int)CF_ResultType.Percentage; } else { var resultType = resultTypeList.Where(x => x.Name == en.ResultTypeStr.Trim()).SingleOrDefault(); if (resultType == null) { errCount++; errorMsgStr = "成绩类型不存在,请检查"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { //成绩类型 newSpecialtyPlan.ResultTypeID = resultType.Value; } } //处理方式 if (string.IsNullOrWhiteSpace(en.HandleModeStr)) { newSpecialtyPlan.HandleModeID = (int)CF_HandleMode.RequiredCourse; } else { var handleMode = handleModeList.Where(x => x.Name == en.HandleModeStr.Trim()).SingleOrDefault(); if (handleMode == null) { errCount++; errorMsgStr = "处理方式不存在,请检查"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { //处理方式 newSpecialtyPlan.HandleModeID = handleMode.Value; } } //授课方式 if (string.IsNullOrWhiteSpace(en.TeachingModeIDListStr)) { newModeTypeList.Add((int)CF_TeachingMode.Theory); } else { //授课方式可为多个(可用顿号隔开) List list = en.TeachingModeIDListStr.Split('、').Where(x => !string.IsNullOrEmpty(x)) .Select(x => x.Trim()).Distinct().ToList(); foreach (var item in list) { var teachingMode = teachingModeList.Where(x => x.Name == item.Trim()).SingleOrDefault(); if (teachingMode == null) { errCount++; errorMsgStr = "授课方式(" + item.Trim() + ")不存在,请检查(存在多个授课方式时,可用顿号隔开)"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); isListPass = false; break; } } if (isListPass) { newModeTypeList = teachingModeList.Where(x => list.Contains(x.Name)) .Select(x => x.Value.Value).ToList(); } else { isListPass = true; continue; } } //授课地点 if (string.IsNullOrWhiteSpace(en.TeachingPlaceIDListStr)) { newPlaceList.Add((int)EMIS.ViewModel.EM_TeachingPlace.Multimedia); } else { //授课地点可为多个(可用顿号隔开) List list = en.TeachingPlaceIDListStr.Split('、').Where(x => !string.IsNullOrEmpty(x)) .Select(x => x.Trim()).Distinct().ToList(); foreach (var item in list) { var teachingPlace = teachingPlaceList.Where(x => x.Name == item.Trim()).SingleOrDefault(); if (teachingPlace == null) { errCount++; errorMsgStr = "授课地点(" + item.Trim() + ")不存在,请检查(存在多个授课地点时,可用顿号隔开)"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); isListPass = false; break; } } if (isListPass) { newPlaceList = teachingPlaceList.Where(x => list.Contains(x.Name)) .Select(x => x.Value.Value).ToList(); } else { isListPass = true; continue; } } //备注 if (string.IsNullOrWhiteSpace(en.Remark)) { //不考虑 } else { newSpecialtyPlan.Remark = en.Remark; } ////Excel表重复性验证(注:当数据表中没有此记录,但是Excel中有重复数据时的去掉) //for (int j = i + 1; j < enlist.Count; j++) //{ // SpecialtyPlanView enA = enlist[j]; // //根据Excel表中的业务主键进行去重(学年学期ID、入学学年学期ID、专业信息ID、课程信息ID唯一) // if (en.No == enA.No && en.Name == enA.Name) // { // //用于标识Excel表中的重复记录(由于是批量进行插入数据表) // } //} //数据表重复性验证(学年学期ID、入学学年学期ID、专业信息ID、课程信息ID唯一) var specialtyPlanVerification = newSpecialtyPlanList.Where(x => x.SchoolyearID == newSpecialtyPlan.SchoolyearID && x.StartSchoolyearID == newSpecialtyPlan.StartSchoolyearID && x.SpecialtyID == newSpecialtyPlan.SpecialtyID && x.CoursematerialID == newSpecialtyPlan.CoursematerialID).SingleOrDefault(); if (specialtyPlanVerification == null) { //新增 if (!newSpecialtyPlanInList.Any(x => x.SchoolyearID == newSpecialtyPlan.SchoolyearID && x.StartSchoolyearID == newSpecialtyPlan.StartSchoolyearID && x.SpecialtyID == newSpecialtyPlan.SpecialtyID && x.CoursematerialID == newSpecialtyPlan.CoursematerialID)) { newSpecialtyPlan.SpecialtyPlanID = Guid.NewGuid(); SetNewStatus(newSpecialtyPlan); newSpecialtyPlanInList.Add(newSpecialtyPlan); newTeachingSetting.SpecialtyPlanID = newSpecialtyPlan.SpecialtyPlanID; //newTeachingSetting.TheoryWeeklyNum = 0; //newTeachingSetting.PracticeWeeklyNum = 0; //newTeachingSetting.TrialWeeklyNum = 0; newTeachingSetting.WeeklyHours = 0; newTeachingSetting.WeeklyNum = 0; newTeachingSetting.StartWeeklyNum = 1; newTeachingSetting.EndWeeklyNum = 16; newTeachingSettingInList.Add(newTeachingSetting); if (newModeTypeList != null && newModeTypeList.Count() > 0) { foreach (var newModeType in newModeTypeList) { var newTeachingModeType = new EM_SpecialtyPlanTeachingModeType(); newTeachingModeType.SpecialtyPlanTeachingModeTypeID = Guid.NewGuid(); newTeachingModeType.SpecialtyPlanID = newSpecialtyPlan.SpecialtyPlanID; newTeachingModeType.TeachingModeID = newModeType; this.SetNewStatus(newTeachingModeType); newTeachingModeTypeInList.Add(newTeachingModeType); } } if (newPlaceList != null && newPlaceList.Count() > 0) { foreach (var newPlace in newPlaceList) { var newTeachingPlace = new EM_SpecialtyPlanTeachingPlace(); newTeachingPlace.SpecialtyPlanTeachingPlaceID = Guid.NewGuid(); newTeachingPlace.SpecialtyPlanID = newSpecialtyPlan.SpecialtyPlanID; newTeachingPlace.TeachingPlace = newPlace; this.SetNewStatus(newTeachingPlace); newTeachingPlaceInList.Add(newTeachingPlace); } } inCount++; } else { //Excel表重复性验证 //(注:当数据表中没有此记录,但是Excel中有重复数据,可在此处进行抛出到失败数据文件中,目前暂不考虑) inCount++; } } else { //更新(Excel有重复时,以最后一条记录的更新为准) specialtyPlanVerification.CourseStructureID = newSpecialtyPlan.CourseStructureID; specialtyPlanVerification.CourseCategoryID = newSpecialtyPlan.CourseCategoryID; specialtyPlanVerification.CourseTypeID = newSpecialtyPlan.CourseTypeID; specialtyPlanVerification.CourseQualityID = newSpecialtyPlan.CourseQualityID; specialtyPlanVerification.DepartmentID = newSpecialtyPlan.DepartmentID; specialtyPlanVerification.IsSpecialtycore = newSpecialtyPlan.IsSpecialtycore; specialtyPlanVerification.IsCooperation = newSpecialtyPlan.IsCooperation; specialtyPlanVerification.IsRequired = newSpecialtyPlan.IsRequired; specialtyPlanVerification.IsElective = newSpecialtyPlan.IsElective; specialtyPlanVerification.IsNetworkCourse = newSpecialtyPlan.IsNetworkCourse; specialtyPlanVerification.IsMainCourse = newSpecialtyPlan.IsMainCourse; specialtyPlanVerification.IsNeedMaterial = newSpecialtyPlan.IsNeedMaterial; specialtyPlanVerification.CourseFineID = newSpecialtyPlan.CourseFineID; specialtyPlanVerification.PracticeTypeID = newSpecialtyPlan.PracticeTypeID; specialtyPlanVerification.TeachinglanguageID = newSpecialtyPlan.TeachinglanguageID; specialtyPlanVerification.ExaminationModeID = newSpecialtyPlan.ExaminationModeID; specialtyPlanVerification.ResultTypeID = newSpecialtyPlan.ResultTypeID; specialtyPlanVerification.HandleModeID = newSpecialtyPlan.HandleModeID; SetModifyStatus(specialtyPlanVerification); newSpecialtyPlanUpList.Add(specialtyPlanVerification); if (specialtyPlanVerification.EM_SpecialtyPlanTeachingSetting == null) { if (newTeachingSettingInList.Any(x => x.SpecialtyPlanID == specialtyPlanVerification.SpecialtyPlanID)) { newTeachingSettingInList.RemoveAll(x => x.SpecialtyPlanID == specialtyPlanVerification.SpecialtyPlanID); } newTeachingSetting.SpecialtyPlanID = specialtyPlanVerification.SpecialtyPlanID; //newTeachingSetting.TheoryWeeklyNum = 0; //newTeachingSetting.PracticeWeeklyNum = 0; //newTeachingSetting.TrialWeeklyNum = 0; newTeachingSetting.WeeklyHours = 0; newTeachingSetting.WeeklyNum = 0; newTeachingSetting.StartWeeklyNum = 1; newTeachingSetting.EndWeeklyNum = 16; newTeachingSettingInList.Add(newTeachingSetting); } else { specialtyPlanVerification.EM_SpecialtyPlanTeachingSetting.Credit = newTeachingSetting.Credit; specialtyPlanVerification.EM_SpecialtyPlanTeachingSetting.TheoryCourse = newTeachingSetting.TheoryCourse; specialtyPlanVerification.EM_SpecialtyPlanTeachingSetting.Practicehours = newTeachingSetting.Practicehours; specialtyPlanVerification.EM_SpecialtyPlanTeachingSetting.Trialhours = newTeachingSetting.Trialhours; specialtyPlanVerification.EM_SpecialtyPlanTeachingSetting.TheoryWeeklyNum = newTeachingSetting.TheoryWeeklyNum; specialtyPlanVerification.EM_SpecialtyPlanTeachingSetting.PracticeWeeklyNum = newTeachingSetting.PracticeWeeklyNum; specialtyPlanVerification.EM_SpecialtyPlanTeachingSetting.TrialWeeklyNum = newTeachingSetting.TrialWeeklyNum; newTeachingSettingUpList.Add(specialtyPlanVerification.EM_SpecialtyPlanTeachingSetting); } if (newModeTypeList != null && newModeTypeList.Count() > 0) { if (newTeachingModeTypeInList.Any(x => x.SpecialtyPlanID == specialtyPlanVerification.SpecialtyPlanID)) { newTeachingModeTypeInList.RemoveAll(x => x.SpecialtyPlanID == specialtyPlanVerification.SpecialtyPlanID); } specialtyPlanTMDelList.Add(specialtyPlanVerification.SpecialtyPlanID); foreach (var newModeType in newModeTypeList) { var newTeachingModeType = new EM_SpecialtyPlanTeachingModeType(); newTeachingModeType.SpecialtyPlanTeachingModeTypeID = Guid.NewGuid(); newTeachingModeType.SpecialtyPlanID = specialtyPlanVerification.SpecialtyPlanID; newTeachingModeType.TeachingModeID = newModeType; this.SetNewStatus(newTeachingModeType); newTeachingModeTypeInList.Add(newTeachingModeType); } } else { specialtyPlanTMDelList.Add(specialtyPlanVerification.SpecialtyPlanID); } if (newPlaceList != null && newPlaceList.Count() > 0) { if (newTeachingPlaceInList.Any(x => x.SpecialtyPlanID == specialtyPlanVerification.SpecialtyPlanID)) { newTeachingPlaceInList.RemoveAll(x => x.SpecialtyPlanID == specialtyPlanVerification.SpecialtyPlanID); } specialtyPlanTPDelList.Add(specialtyPlanVerification.SpecialtyPlanID); foreach (var newPlace in newPlaceList) { var newTeachingPlace = new EM_SpecialtyPlanTeachingPlace(); newTeachingPlace.SpecialtyPlanTeachingPlaceID = Guid.NewGuid(); newTeachingPlace.SpecialtyPlanID = specialtyPlanVerification.SpecialtyPlanID; newTeachingPlace.TeachingPlace = newPlace; this.SetNewStatus(newTeachingPlace); newTeachingPlaceInList.Add(newTeachingPlace); } } else { specialtyPlanTPDelList.Add(specialtyPlanVerification.SpecialtyPlanID); } upCount++; } } using (TransactionScope ts = new TransactionScope()) { //删除 UnitOfWork.Delete(x => specialtyPlanTPDelList.Contains(x.SpecialtyPlanID)); UnitOfWork.Delete(x => specialtyPlanTMDelList.Contains(x.SpecialtyPlanID)); //批量插入 UnitOfWork.BulkInsert(newSpecialtyPlanInList); UnitOfWork.BulkInsert(newTeachingSettingInList); UnitOfWork.BulkInsert(newTeachingModeTypeInList); UnitOfWork.BulkInsert(newTeachingPlaceInList); //批量统一提交更新 if (newSpecialtyPlanUpList != null && newSpecialtyPlanUpList.Count() > 0) { UnitOfWork.BatchUpdate(newSpecialtyPlanUpList); } //批量统一提交更新 if (newTeachingSettingUpList != null && newTeachingSettingUpList.Count() > 0) { UnitOfWork.BatchUpdate(newTeachingSettingUpList); } ts.Complete(); } errdataList = errList.Distinct().ToList(); //错误列表List } catch (Exception) { throw; } } } }