123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Transactions;
- using Bowin.Common.Utility;
- using EMIS.Entities;
- using EMIS.DataLogic.CultureplanManage.PlanManagement;
- using EMIS.ViewModel.CultureplanManage;
- namespace EMIS.ExtensionLogic.ServiceLogic.CultureplanManage.PlanManagement
- {
- public class SpecialtyCourseServices : EMIS.CommonLogic.CultureplanManage.PlanManagement.SpecialtyCourseServices
- {
- /// <summary>
- /// 编辑(新增、修改,业务主键:专业信息ID、开课学期、课程信息ID、开课教研室(2020.11.17梁剑提出))
- /// </summary>
- /// <param name="specialtyCourseView"></param>
- public override void SpecialtyCourseEdit(SpecialtyCourseView specialtyCourseView)
- {
- try
- {
- //查询数据库进行验证
- var specialtyCourseVerify = SpecialtyCourseDAL.SpecialtyCourseRepository
- .GetList(x => x.SpecialtyCourseID != specialtyCourseView.SpecialtyCourseID
- && x.SpecialtyID == specialtyCourseView.SpecialtyID
- && x.StarttermID == specialtyCourseView.StarttermID
- && x.CoursematerialID == specialtyCourseView.CoursematerialID
- && x.DepartmentID == specialtyCourseView.DepartmentID).SingleOrDefault();
- if (specialtyCourseVerify == null)
- {
- //查询对应的专业信息
- var specialty = SpecialtyCourseDAL.SpecialtyRepository
- .GetList(x => x.SpecialtyID == specialtyCourseView.SpecialtyID).SingleOrDefault();
- if (specialty == null)
- {
- throw new Exception("专业信息不存在,请检查。");
- }
- //对学制和开课学期进行判断
- var maxStartterm = Convert.ToInt32(Math.Ceiling(specialty.LearnSystem.Value * 2 - 1)) + 1;
- if (specialtyCourseView.StarttermID > maxStartterm)
- {
- throw new Exception("开课学期超出学制范围,请检查。");
- }
- List<EM_SpecialtyCourse> newSpecialtyCourseInList = new List<EM_SpecialtyCourse>();
- List<EM_SpecialtyCourse> newSpecialtyCourseUpList = new List<EM_SpecialtyCourse>();
- List<EM_SpecialtyCourseTeachingSetting> newTeachingSettingInList = new List<EM_SpecialtyCourseTeachingSetting>();
- List<EM_SpecialtyCourseTeachingSetting> newTeachingSettingUpList = new List<EM_SpecialtyCourseTeachingSetting>();
- List<EM_TeachingModeType> newTeachingModeTypeInList = new List<EM_TeachingModeType>();
- List<EMIS.Entities.EM_TeachingPlace> newTeachingPlaceInList = new List<EMIS.Entities.EM_TeachingPlace>();
- List<Guid?> specialtyCourseTMDelList = new List<Guid?>();
- List<Guid?> specialtyCourseTPDelList = new List<Guid?>();
- //数据有误验证
- if (specialtyCourseView.SpecialtyCourseID != Guid.Empty)
- {
- var specialtyCourse = SpecialtyCourseDAL.SpecialtyCourseRepository
- .GetList(x => x.SpecialtyCourseID == specialtyCourseView.SpecialtyCourseID,
- (x => x.EM_SpecialtyCourseTeachingSetting)).SingleOrDefault();
- if (specialtyCourse == null)
- {
- throw new Exception("数据有误,请核查。");
- }
- else
- {
- //表示修改
- specialtyCourse.SpecialtyID = specialtyCourseView.SpecialtyID;
- specialtyCourse.StarttermID = specialtyCourseView.StarttermID;
- specialtyCourse.CoursematerialID = specialtyCourseView.CoursematerialID;
- specialtyCourse.CourseStructureID = specialtyCourseView.CourseStructureID;
- specialtyCourse.CourseCategoryID = specialtyCourseView.CourseCategoryID;
- specialtyCourse.CourseTypeID = specialtyCourseView.CourseTypeID;
- specialtyCourse.CourseQualityID = specialtyCourseView.CourseQualityID;
- specialtyCourse.DepartmentID = specialtyCourseView.DepartmentID;
- specialtyCourse.IsSpecialtycore = specialtyCourseView.IsSpecialtycore;
- specialtyCourse.IsCooperation = specialtyCourseView.IsCooperation;
- specialtyCourse.IsRequired = specialtyCourseView.IsRequired;
- specialtyCourse.IsElective = specialtyCourseView.IsElective;
- specialtyCourse.IsNetworkCourse = specialtyCourseView.IsNetworkCourse;
- specialtyCourse.IsMainCourse = specialtyCourseView.IsMainCourse;
- specialtyCourse.IsNeedMaterial = specialtyCourseView.IsNeedMaterial;
- specialtyCourse.CourseFineID = specialtyCourseView.CourseFineID;
- specialtyCourse.PracticeTypeID = specialtyCourseView.PracticeTypeID;
- specialtyCourse.TeachinglanguageID = specialtyCourseView.TeachinglanguageID;
- specialtyCourse.ExaminationModeID = specialtyCourseView.ExaminationModeID;
- specialtyCourse.ResultTypeID = specialtyCourseView.ResultTypeID;
- specialtyCourse.HandleModeID = specialtyCourseView.HandleModeID;
- specialtyCourse.IsEnable = specialtyCourseView.IsEnable;
- specialtyCourse.Remark = specialtyCourseView.Remark;
- SetModifyStatus(specialtyCourse);
- newSpecialtyCourseUpList.Add(specialtyCourse);
- if (specialtyCourse.EM_SpecialtyCourseTeachingSetting == null)
- {
- var newTeachingSetting = new EM_SpecialtyCourseTeachingSetting();
- newTeachingSetting.SpecialtyCourseID = specialtyCourse.SpecialtyCourseID;
- 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);
- }
- else
- {
- specialtyCourse.EM_SpecialtyCourseTeachingSetting.Credit = specialtyCourseView.Credit;
- specialtyCourse.EM_SpecialtyCourseTeachingSetting.TheoryCourse = specialtyCourseView.TheoryCourse;
- specialtyCourse.EM_SpecialtyCourseTeachingSetting.Practicehours = specialtyCourseView.Practicehours;
- specialtyCourse.EM_SpecialtyCourseTeachingSetting.Trialhours = specialtyCourseView.Trialhours;
- specialtyCourse.EM_SpecialtyCourseTeachingSetting.TheoryWeeklyNum = specialtyCourseView.TheoryWeeklyNum;
- specialtyCourse.EM_SpecialtyCourseTeachingSetting.PracticeWeeklyNum = specialtyCourseView.PracticeWeeklyNum;
- specialtyCourse.EM_SpecialtyCourseTeachingSetting.TrialWeeklyNum = specialtyCourseView.TrialWeeklyNum;
- specialtyCourse.EM_SpecialtyCourseTeachingSetting.WeeklyHours = specialtyCourseView.WeeklyHours;
- specialtyCourse.EM_SpecialtyCourseTeachingSetting.WeeklyNum = specialtyCourseView.WeeklyNum;
- specialtyCourse.EM_SpecialtyCourseTeachingSetting.StartWeeklyNum = specialtyCourseView.StartWeeklyNum;
- specialtyCourse.EM_SpecialtyCourseTeachingSetting.EndWeeklyNum = specialtyCourseView.EndWeeklyNum;
- newTeachingSettingUpList.Add(specialtyCourse.EM_SpecialtyCourseTeachingSetting);
- }
- if (specialtyCourseView.TeachingModeIDList != null && specialtyCourseView.TeachingModeIDList.Count() > 0)
- {
- specialtyCourseTMDelList.Add(specialtyCourse.SpecialtyCourseID);
- foreach (var teachingModeID in specialtyCourseView.TeachingModeIDList)
- {
- var newTeachingMode = new EM_TeachingModeType();
- newTeachingMode.TeachingModeTypeID = Guid.NewGuid();
- newTeachingMode.SpecialtyCourseID = specialtyCourse.SpecialtyCourseID;
- newTeachingMode.TeachingModeID = teachingModeID;
- SetNewStatus(newTeachingMode);
- newTeachingModeTypeInList.Add(newTeachingMode);
- }
- }
- else
- {
- specialtyCourseTMDelList.Add(specialtyCourse.SpecialtyCourseID);
- }
- if (specialtyCourseView.TeachingPlaceIDList != null && specialtyCourseView.TeachingPlaceIDList.Count() > 0)
- {
- specialtyCourseTPDelList.Add(specialtyCourse.SpecialtyCourseID);
- foreach (var teachingPlaceID in specialtyCourseView.TeachingPlaceIDList)
- {
- var newTeachingPlace = new EMIS.Entities.EM_TeachingPlace();
- newTeachingPlace.TeachingPlaceID = Guid.NewGuid();
- newTeachingPlace.SpecialtyCourseID = specialtyCourse.SpecialtyCourseID;
- newTeachingPlace.TeachingPlace = teachingPlaceID;
- SetNewStatus(newTeachingPlace);
- newTeachingPlaceInList.Add(newTeachingPlace);
- }
- }
- else
- {
- specialtyCourseTPDelList.Add(specialtyCourse.SpecialtyCourseID);
- }
- }
- }
- else
- {
- //表示新增
- var newSpecialtyCourse = new EM_SpecialtyCourse();
- newSpecialtyCourse.SpecialtyCourseID = Guid.NewGuid();
- newSpecialtyCourse.SpecialtyID = specialtyCourseView.SpecialtyID;
- newSpecialtyCourse.StarttermID = specialtyCourseView.StarttermID;
- newSpecialtyCourse.CoursematerialID = specialtyCourseView.CoursematerialID;
- newSpecialtyCourse.CourseStructureID = specialtyCourseView.CourseStructureID;
- newSpecialtyCourse.CourseCategoryID = specialtyCourseView.CourseCategoryID;
- newSpecialtyCourse.CourseTypeID = specialtyCourseView.CourseTypeID;
- newSpecialtyCourse.CourseQualityID = specialtyCourseView.CourseQualityID;
- newSpecialtyCourse.DepartmentID = specialtyCourseView.DepartmentID;
- newSpecialtyCourse.IsSpecialtycore = specialtyCourseView.IsSpecialtycore;
- newSpecialtyCourse.IsCooperation = specialtyCourseView.IsCooperation;
- newSpecialtyCourse.IsRequired = specialtyCourseView.IsRequired;
- newSpecialtyCourse.IsElective = specialtyCourseView.IsElective;
- newSpecialtyCourse.IsNetworkCourse = specialtyCourseView.IsNetworkCourse;
- newSpecialtyCourse.IsMainCourse = specialtyCourseView.IsMainCourse;
- newSpecialtyCourse.IsNeedMaterial = specialtyCourseView.IsNeedMaterial;
- newSpecialtyCourse.CourseFineID = specialtyCourseView.CourseFineID;
- newSpecialtyCourse.PracticeTypeID = specialtyCourseView.PracticeTypeID;
- newSpecialtyCourse.TeachinglanguageID = specialtyCourseView.TeachinglanguageID;
- newSpecialtyCourse.ExaminationModeID = specialtyCourseView.ExaminationModeID;
- newSpecialtyCourse.ResultTypeID = specialtyCourseView.ResultTypeID;
- newSpecialtyCourse.HandleModeID = specialtyCourseView.HandleModeID;
- newSpecialtyCourse.IsEnable = specialtyCourseView.IsEnable;
- newSpecialtyCourse.Remark = specialtyCourseView.Remark;
- SetNewStatus(newSpecialtyCourse);
- newSpecialtyCourseInList.Add(newSpecialtyCourse);
- var newTeachingSetting = new EM_SpecialtyCourseTeachingSetting();
- newTeachingSetting.SpecialtyCourseID = newSpecialtyCourse.SpecialtyCourseID;
- 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_TeachingModeType();
- newTeachingMode.TeachingModeTypeID = Guid.NewGuid();
- newTeachingMode.SpecialtyCourseID = newSpecialtyCourse.SpecialtyCourseID;
- 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 EMIS.Entities.EM_TeachingPlace();
- newTeachingPlace.TeachingPlaceID = Guid.NewGuid();
- newTeachingPlace.SpecialtyCourseID = newSpecialtyCourse.SpecialtyCourseID;
- newTeachingPlace.TeachingPlace = teachingPlaceID;
- SetNewStatus(newTeachingPlace);
- newTeachingPlaceInList.Add(newTeachingPlace);
- }
- }
- }
- //事务提交
- //UnitOfWork.Commit();
- using (TransactionScope ts = new TransactionScope())
- {
- //删除
- UnitOfWork.Delete<EMIS.Entities.EM_TeachingPlace>(x => specialtyCourseTPDelList.Contains(x.SpecialtyCourseID));
- UnitOfWork.Delete<EM_TeachingModeType>(x => specialtyCourseTMDelList.Contains(x.SpecialtyCourseID));
- //批量插入
- UnitOfWork.BulkInsert(newSpecialtyCourseInList);
- UnitOfWork.BulkInsert(newTeachingSettingInList);
- UnitOfWork.BulkInsert(newTeachingModeTypeInList);
- UnitOfWork.BulkInsert(newTeachingPlaceInList);
- //批量统一提交更新
- if (newSpecialtyCourseUpList != null && newSpecialtyCourseUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(newSpecialtyCourseUpList);
- }
- //批量统一提交更新
- if (newTeachingSettingUpList != null && newTeachingSettingUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(newTeachingSettingUpList);
- }
- ts.Complete();
- }
- }
- else
- {
- throw new Exception("已存在相同的专业课程信息(专业信息、开课学期、课程信息唯一),请核查。");
- }
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- }
- }
|