using System; using System.Collections.Generic; using System.Linq; using System.Text; using EMIS.CommonLogic; using EMIS.CommonLogic.CultureplanManage.PlanManagement; using EMIS.DataLogic.CultureplanManage.PlanManagement; using EMIS.CommonLogic.Students; using Bowin.Common.Utility; using Bowin.Common.Linq; using Bowin.Common.Linq.Entity; using EMIS.ViewModel.CultureplanManage.PlanManagement; using EMIS.ViewModel; using System.Linq.Expressions; using EMIS.Entities; using System.Transactions; using EMIS.ViewModel.CultureplanManage; using EMIS.ViewModel.Students; using System.Text.RegularExpressions; using EMIS.Utility; namespace EMIS.ExtensionLogic.ServiceLogic.CultureplanManage.PlanManagement { public class SpecialtyPlanServices : EMIS.CommonLogic.CultureplanManage.PlanManagement.SpecialtyPlanServices { /// /// 编辑(新增、修改,业务主键:学年学期ID、年级专业ID、课程信息ID、开课教研室(2020.11.17梁剑提出)) /// 注:刷新相关的执行计划信息 /// /// public override void SpecialtyPlanEdit(SpecialtyPlanView specialtyPlanView) { try { //查询对应的年级专业信息 var grademajor = SpecialtyPlanDAL.GrademajorRepository .GetList(x => x.GrademajorID == specialtyPlanView.GrademajorID).SingleOrDefault(); if (grademajor == null) { throw new Exception("年级专业信息不存在,请检查。"); } //查询年级专业对应的入学学年学期信息 var startSchoolyear = SpecialtyPlanDAL.SchoolyearRepository.GetList(x => x.Years == grademajor.GradeID && x.SchoolcodeID == grademajor.SemesterID).SingleOrDefault(); if (startSchoolyear == null) { throw new Exception("年级专业对应的入学学年学期信息不存在,请检查。"); } //查询年级专业对应的毕业学年学期信息 var graduatingSemester = SpecialtyPlanDAL.SchoolyearRepository .GetList(x => x.SchoolyearID == grademajor.GraduateSchoolyearID).SingleOrDefault(); if (graduatingSemester == null) { throw new Exception("年级专业对应的毕业学年学期信息不存在,请检查。"); } //查询对应的学年学期信息 var schoolyear = SpecialtyPlanDAL.SchoolyearRepository .GetList(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.GrademajorID == specialtyPlanView.GrademajorID && x.CoursematerialID == specialtyPlanView.CoursematerialID && x.DepartmentID == specialtyPlanView.DepartmentID).SingleOrDefault(); if (specialtyPlanVerify == null) { 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), (x => x.EM_ExecutablePlan)).SingleOrDefault(); if (specialtyPlan == null) { throw new Exception("数据有误,请核查。"); } else { //表示修改 specialtyPlan.SchoolyearID = specialtyPlanView.SchoolyearID; specialtyPlan.GrademajorID = specialtyPlanView.GrademajorID; 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) //注:由于相关业务主键冗余且同时存在主外键关联,目前不允许修改相关业务主键 var executablePlan = SpecialtyPlanDAL.ExecutablePlanRepository.GetList(x => x.SchoolyearID == specialtyPlanView.SchoolyearID && x.GrademajorID == specialtyPlanView.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 + "-" + specialtyPlanView.GrademajorName; executablePlan.SpecialtyPlanID = specialtyPlan.SpecialtyPlanID; executablePlan.SchoolyearID = specialtyPlanView.SchoolyearID; executablePlan.GrademajorID = specialtyPlanView.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)) { //查询对应的专业计划信息(业务主键:学年学期ID、年级专业ID、课程信息ID) var newSpecialtyPlanView = SpecialtyPlanDAL.GetSpecialtyPlanViewQueryable(x => x.SpecialtyPlanID != specialtyPlan.SpecialtyPlanID && x.SchoolyearID == newExecutablePlan.SchoolyearID && x.GrademajorID == newExecutablePlan.GrademajorID && x.CoursematerialID == newExecutablePlan.CoursematerialID).SingleOrDefault(); if (newSpecialtyPlanView == null) { newExecutablePlan.SpecialtyPlanID = null; SetModifyStatus(newExecutablePlan); newExecutablePlanUpList.Add(newExecutablePlan); } else { //来源专业计划默认为必修课 newExecutablePlan.SourceTypeID = (int)EM_SourceType.RequiredCourse; newExecutablePlan.DefaultClassName = newSpecialtyPlanView.CourseName + "-" + newSpecialtyPlanView.GrademajorName; newExecutablePlan.SpecialtyPlanID = newSpecialtyPlanView.SpecialtyPlanID; newExecutablePlan.SchoolyearID = newSpecialtyPlanView.SchoolyearID; newExecutablePlan.GrademajorID = newSpecialtyPlanView.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.GrademajorID = specialtyPlanView.GrademajorID; 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) //注:由于相关业务主键冗余且同时存在主外键关联,目前不允许修改相关业务主键 var executablePlan = SpecialtyPlanDAL.ExecutablePlanRepository.GetList(x => x.SchoolyearID == specialtyPlanView.SchoolyearID && x.GrademajorID == specialtyPlanView.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 + "-" + specialtyPlanView.GrademajorName; executablePlan.SpecialtyPlanID = newSpecialtyPlan.SpecialtyPlanID; executablePlan.SchoolyearID = specialtyPlanView.SchoolyearID; executablePlan.GrademajorID = specialtyPlanView.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(TransactionScopeOption.RequiresNew, new TransactionOptions { IsolationLevel = IsolationLevel.Serializable })) { //删除 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); } } } }