SpecialtyPlanServices.cs 61 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.CommonLogic;
  6. using EMIS.CommonLogic.CultureplanManage.PlanManagement;
  7. using EMIS.DataLogic.CultureplanManage.PlanManagement;
  8. using EMIS.CommonLogic.Students;
  9. using Bowin.Common.Utility;
  10. using Bowin.Common.Linq;
  11. using Bowin.Common.Linq.Entity;
  12. using EMIS.ViewModel.CultureplanManage.PlanManagement;
  13. using EMIS.ViewModel;
  14. using System.Linq.Expressions;
  15. using EMIS.Entities;
  16. using System.Transactions;
  17. using EMIS.ViewModel.CultureplanManage;
  18. using EMIS.ViewModel.Students;
  19. using System.Text.RegularExpressions;
  20. using EMIS.Utility;
  21. namespace EMIS.ExtensionLogic.ServiceLogic.CultureplanManage.PlanManagement
  22. {
  23. public class SpecialtyPlanServices : EMIS.CommonLogic.CultureplanManage.PlanManagement.SpecialtyPlanServices
  24. {
  25. /// <summary>
  26. /// 编辑(新增、修改,业务主键:学年学期ID、年级专业ID、课程信息ID、开课教研室(2020.11.17梁剑提出))
  27. /// 注:刷新相关的执行计划信息
  28. /// </summary>
  29. /// <param name="specialtyPlanView"></param>
  30. public override void SpecialtyPlanEdit(SpecialtyPlanView specialtyPlanView)
  31. {
  32. try
  33. {
  34. //查询对应的年级专业信息
  35. var grademajor = SpecialtyPlanDAL.GrademajorRepository
  36. .GetList(x => x.GrademajorID == specialtyPlanView.GrademajorID).SingleOrDefault();
  37. if (grademajor == null)
  38. {
  39. throw new Exception("年级专业信息不存在,请检查。");
  40. }
  41. //查询年级专业对应的入学学年学期信息
  42. var startSchoolyear = SpecialtyPlanDAL.SchoolyearRepository.GetList(x => x.Years == grademajor.GradeID
  43. && x.SchoolcodeID == grademajor.SemesterID).SingleOrDefault();
  44. if (startSchoolyear == null)
  45. {
  46. throw new Exception("年级专业对应的入学学年学期信息不存在,请检查。");
  47. }
  48. //查询年级专业对应的毕业学年学期信息
  49. var graduatingSemester = SpecialtyPlanDAL.SchoolyearRepository
  50. .GetList(x => x.SchoolyearID == grademajor.GraduateSchoolyearID).SingleOrDefault();
  51. if (graduatingSemester == null)
  52. {
  53. throw new Exception("年级专业对应的毕业学年学期信息不存在,请检查。");
  54. }
  55. //查询对应的学年学期信息
  56. var schoolyear = SpecialtyPlanDAL.SchoolyearRepository
  57. .GetList(x => x.SchoolyearID == specialtyPlanView.SchoolyearID).SingleOrDefault();
  58. if (schoolyear == null)
  59. {
  60. throw new Exception("学年学期信息不存在,请检查。");
  61. }
  62. if (schoolyear.Value < startSchoolyear.Value)
  63. {
  64. throw new Exception("学年学期小于入学学年学期,请检查。");
  65. }
  66. if (schoolyear.Value > graduatingSemester.Value)
  67. {
  68. throw new Exception("学年学期大于毕业学年学期,请检查。");
  69. }
  70. //查询数据库进行验证
  71. var specialtyPlanVerify = SpecialtyPlanDAL.SpecialtyPlanRepository
  72. .GetList(x => x.SpecialtyPlanID != specialtyPlanView.SpecialtyPlanID
  73. && x.SchoolyearID == specialtyPlanView.SchoolyearID
  74. && x.GrademajorID == specialtyPlanView.GrademajorID
  75. && x.CoursematerialID == specialtyPlanView.CoursematerialID
  76. && x.DepartmentID == specialtyPlanView.DepartmentID).SingleOrDefault();
  77. if (specialtyPlanVerify == null)
  78. {
  79. List<EM_SpecialtyPlan> newSpecialtyPlanInList = new List<EM_SpecialtyPlan>();
  80. List<EM_SpecialtyPlan> newSpecialtyPlanUpList = new List<EM_SpecialtyPlan>();
  81. List<EM_SpecialtyPlanTeachingSetting> newSPTeachingSettingInList = new List<EM_SpecialtyPlanTeachingSetting>();
  82. List<EM_SpecialtyPlanTeachingSetting> newSPTeachingSettingUpList = new List<EM_SpecialtyPlanTeachingSetting>();
  83. List<EM_SpecialtyPlanTeachingModeType> newSPTeachingModeTypeInList = new List<EM_SpecialtyPlanTeachingModeType>();
  84. List<EM_SpecialtyPlanTeachingPlace> newSPTeachingPlaceInList = new List<EM_SpecialtyPlanTeachingPlace>();
  85. List<Guid?> specialtyPlanTMDelList = new List<Guid?>();
  86. List<Guid?> specialtyPlanTPDelList = new List<Guid?>();
  87. List<EM_ExecutablePlan> newExecutablePlanUpList = new List<EM_ExecutablePlan>();
  88. List<EM_ExecutablePlanProfile> newProfileInList = new List<EM_ExecutablePlanProfile>();
  89. List<EM_ExecutablePlanProfile> newProfileUpList = new List<EM_ExecutablePlanProfile>();
  90. List<EM_ExecutablePlanTeachingSetting> newEPTeachingSettingInList = new List<EM_ExecutablePlanTeachingSetting>();
  91. List<EM_ExecutablePlanTeachingSetting> newEPTeachingSettingUpList = new List<EM_ExecutablePlanTeachingSetting>();
  92. List<EM_ExecutablePlanTeachingModeType> newEPTeachingModeTypeInList = new List<EM_ExecutablePlanTeachingModeType>();
  93. List<EM_ExecutablePlanTeachingPlace> newEPTeachingPlaceInList = new List<EM_ExecutablePlanTeachingPlace>();
  94. List<Guid?> executablePlanTMDelList = new List<Guid?>();
  95. List<Guid?> executablePlanTPDelList = new List<Guid?>();
  96. List<Guid> executablePlanIDList = new List<Guid>();
  97. //数据有误验证
  98. if (specialtyPlanView.SpecialtyPlanID != Guid.Empty)
  99. {
  100. var specialtyPlan = SpecialtyPlanDAL.SpecialtyPlanRepository
  101. .GetList(x => x.SpecialtyPlanID == specialtyPlanView.SpecialtyPlanID,
  102. (x => x.EM_SpecialtyPlanTeachingSetting), (x => x.EM_ExecutablePlan)).SingleOrDefault();
  103. if (specialtyPlan == null)
  104. {
  105. throw new Exception("数据有误,请核查。");
  106. }
  107. else
  108. {
  109. //表示修改
  110. specialtyPlan.SchoolyearID = specialtyPlanView.SchoolyearID;
  111. specialtyPlan.GrademajorID = specialtyPlanView.GrademajorID;
  112. specialtyPlan.CoursematerialID = specialtyPlanView.CoursematerialID;
  113. specialtyPlan.CourseStructureID = specialtyPlanView.CourseStructureID;
  114. specialtyPlan.CourseCategoryID = specialtyPlanView.CourseCategoryID;
  115. specialtyPlan.CourseTypeID = specialtyPlanView.CourseTypeID;
  116. specialtyPlan.CourseQualityID = specialtyPlanView.CourseQualityID;
  117. specialtyPlan.DepartmentID = specialtyPlanView.DepartmentID;
  118. specialtyPlan.IsSpecialtycore = specialtyPlanView.IsSpecialtycore;
  119. specialtyPlan.IsCooperation = specialtyPlanView.IsCooperation;
  120. specialtyPlan.IsRequired = specialtyPlanView.IsRequired;
  121. specialtyPlan.IsElective = specialtyPlanView.IsElective;
  122. specialtyPlan.IsNetworkCourse = specialtyPlanView.IsNetworkCourse;
  123. specialtyPlan.IsMainCourse = specialtyPlanView.IsMainCourse;
  124. specialtyPlan.IsNeedMaterial = specialtyPlanView.IsNeedMaterial;
  125. specialtyPlan.CourseFineID = specialtyPlanView.CourseFineID;
  126. specialtyPlan.PracticeTypeID = specialtyPlanView.PracticeTypeID;
  127. specialtyPlan.TeachinglanguageID = specialtyPlanView.TeachinglanguageID;
  128. specialtyPlan.ExaminationModeID = specialtyPlanView.ExaminationModeID;
  129. specialtyPlan.ResultTypeID = specialtyPlanView.ResultTypeID;
  130. specialtyPlan.HandleModeID = specialtyPlanView.HandleModeID;
  131. specialtyPlan.Remark = specialtyPlanView.Remark;
  132. SetModifyStatus(specialtyPlan);
  133. newSpecialtyPlanUpList.Add(specialtyPlan);
  134. if (specialtyPlan.EM_SpecialtyPlanTeachingSetting == null)
  135. {
  136. var newSPTeachingSetting = new EM_SpecialtyPlanTeachingSetting();
  137. newSPTeachingSetting.SpecialtyPlanID = specialtyPlan.SpecialtyPlanID;
  138. newSPTeachingSetting.Credit = specialtyPlanView.Credit;
  139. newSPTeachingSetting.TheoryCourse = specialtyPlanView.TheoryCourse;
  140. newSPTeachingSetting.Practicehours = specialtyPlanView.Practicehours;
  141. newSPTeachingSetting.Trialhours = specialtyPlanView.Trialhours;
  142. newSPTeachingSetting.TheoryWeeklyNum = specialtyPlanView.TheoryWeeklyNum;
  143. newSPTeachingSetting.PracticeWeeklyNum = specialtyPlanView.PracticeWeeklyNum;
  144. newSPTeachingSetting.TrialWeeklyNum = specialtyPlanView.TrialWeeklyNum;
  145. newSPTeachingSetting.WeeklyHours = specialtyPlanView.WeeklyHours;
  146. newSPTeachingSetting.WeeklyNum = specialtyPlanView.WeeklyNum;
  147. newSPTeachingSetting.StartWeeklyNum = specialtyPlanView.StartWeeklyNum;
  148. newSPTeachingSetting.EndWeeklyNum = specialtyPlanView.EndWeeklyNum;
  149. newSPTeachingSettingInList.Add(newSPTeachingSetting);
  150. }
  151. else
  152. {
  153. specialtyPlan.EM_SpecialtyPlanTeachingSetting.Credit = specialtyPlanView.Credit;
  154. specialtyPlan.EM_SpecialtyPlanTeachingSetting.TheoryCourse = specialtyPlanView.TheoryCourse;
  155. specialtyPlan.EM_SpecialtyPlanTeachingSetting.Practicehours = specialtyPlanView.Practicehours;
  156. specialtyPlan.EM_SpecialtyPlanTeachingSetting.Trialhours = specialtyPlanView.Trialhours;
  157. specialtyPlan.EM_SpecialtyPlanTeachingSetting.TheoryWeeklyNum = specialtyPlanView.TheoryWeeklyNum;
  158. specialtyPlan.EM_SpecialtyPlanTeachingSetting.PracticeWeeklyNum = specialtyPlanView.PracticeWeeklyNum;
  159. specialtyPlan.EM_SpecialtyPlanTeachingSetting.TrialWeeklyNum = specialtyPlanView.TrialWeeklyNum;
  160. specialtyPlan.EM_SpecialtyPlanTeachingSetting.WeeklyHours = specialtyPlanView.WeeklyHours;
  161. specialtyPlan.EM_SpecialtyPlanTeachingSetting.WeeklyNum = specialtyPlanView.WeeklyNum;
  162. specialtyPlan.EM_SpecialtyPlanTeachingSetting.StartWeeklyNum = specialtyPlanView.StartWeeklyNum;
  163. specialtyPlan.EM_SpecialtyPlanTeachingSetting.EndWeeklyNum = specialtyPlanView.EndWeeklyNum;
  164. newSPTeachingSettingUpList.Add(specialtyPlan.EM_SpecialtyPlanTeachingSetting);
  165. }
  166. if (specialtyPlanView.TeachingModeIDList != null && specialtyPlanView.TeachingModeIDList.Count() > 0)
  167. {
  168. specialtyPlanTMDelList.Add(specialtyPlan.SpecialtyPlanID);
  169. foreach (var teachingModeID in specialtyPlanView.TeachingModeIDList)
  170. {
  171. var newSPTeachingMode = new EM_SpecialtyPlanTeachingModeType();
  172. newSPTeachingMode.SpecialtyPlanTeachingModeTypeID = Guid.NewGuid();
  173. newSPTeachingMode.SpecialtyPlanID = specialtyPlan.SpecialtyPlanID;
  174. newSPTeachingMode.TeachingModeID = teachingModeID;
  175. SetNewStatus(newSPTeachingMode);
  176. newSPTeachingModeTypeInList.Add(newSPTeachingMode);
  177. }
  178. }
  179. else
  180. {
  181. specialtyPlanTMDelList.Add(specialtyPlan.SpecialtyPlanID);
  182. }
  183. if (specialtyPlanView.TeachingPlaceIDList != null && specialtyPlanView.TeachingPlaceIDList.Count() > 0)
  184. {
  185. specialtyPlanTPDelList.Add(specialtyPlan.SpecialtyPlanID);
  186. foreach (var teachingPlaceID in specialtyPlanView.TeachingPlaceIDList)
  187. {
  188. var newSPTeachingPlace = new EM_SpecialtyPlanTeachingPlace();
  189. newSPTeachingPlace.SpecialtyPlanTeachingPlaceID = Guid.NewGuid();
  190. newSPTeachingPlace.SpecialtyPlanID = specialtyPlan.SpecialtyPlanID;
  191. newSPTeachingPlace.TeachingPlace = teachingPlaceID;
  192. SetNewStatus(newSPTeachingPlace);
  193. newSPTeachingPlaceInList.Add(newSPTeachingPlace);
  194. }
  195. }
  196. else
  197. {
  198. specialtyPlanTPDelList.Add(specialtyPlan.SpecialtyPlanID);
  199. }
  200. //对应的执行计划信息更新(根据业务主键:学年学期ID、年级专业ID、课程信息ID)
  201. //注:由于相关业务主键冗余且同时存在主外键关联,目前不允许修改相关业务主键
  202. var executablePlan = SpecialtyPlanDAL.ExecutablePlanRepository.GetList(x => x.SchoolyearID == specialtyPlanView.SchoolyearID
  203. && x.GrademajorID == specialtyPlanView.GrademajorID
  204. && x.CoursematerialID == specialtyPlanView.CoursematerialID,
  205. (x => x.EM_ExecutablePlanProfile), (x => x.EM_ExecutablePlanTeachingSetting)).SingleOrDefault();
  206. if (executablePlan == null)
  207. {
  208. //表示不存在对应的执行计划信息(暂不新增)
  209. }
  210. else
  211. {
  212. //表示存在对应的执行计划信息(修改)
  213. executablePlan.SourceTypeID = (int)EM_SourceType.RequiredCourse;
  214. //暂不考虑
  215. //executablePlan.DefaultClassName = specialtyPlanView.CourseName + "-" + specialtyPlanView.GrademajorName;
  216. executablePlan.SpecialtyPlanID = specialtyPlan.SpecialtyPlanID;
  217. executablePlan.SchoolyearID = specialtyPlanView.SchoolyearID;
  218. executablePlan.GrademajorID = specialtyPlanView.GrademajorID;
  219. executablePlan.CoursematerialID = specialtyPlanView.CoursematerialID;
  220. executablePlan.CourseStructureID = specialtyPlanView.CourseStructureID;
  221. executablePlan.CourseCategoryID = specialtyPlanView.CourseCategoryID;
  222. executablePlan.CourseTypeID = specialtyPlanView.CourseTypeID;
  223. executablePlan.CourseQualityID = specialtyPlanView.CourseQualityID;
  224. executablePlan.DepartmentID = specialtyPlanView.DepartmentID;
  225. executablePlan.IsNeedMaterial = specialtyPlanView.IsNeedMaterial;
  226. executablePlan.ResultTypeID = specialtyPlanView.ResultTypeID;
  227. executablePlan.HandleModeID = specialtyPlanView.HandleModeID;
  228. SetModifyStatus(executablePlan);
  229. newExecutablePlanUpList.Add(executablePlan);
  230. if (executablePlan.EM_ExecutablePlanProfile == null)
  231. {
  232. var newProfile = new EM_ExecutablePlanProfile();
  233. newProfile.ExecutablePlanID = executablePlan.ExecutablePlanID;
  234. newProfile.IsSpecialtycore = specialtyPlanView.IsSpecialtycore;
  235. newProfile.IsCooperation = specialtyPlanView.IsCooperation;
  236. newProfile.IsRequired = specialtyPlanView.IsRequired;
  237. newProfile.IsElective = specialtyPlanView.IsElective;
  238. newProfile.IsNetworkCourse = specialtyPlanView.IsNetworkCourse;
  239. newProfile.IsMainCourse = specialtyPlanView.IsMainCourse;
  240. newProfile.CourseFineID = specialtyPlanView.CourseFineID;
  241. newProfile.PracticeTypeID = specialtyPlanView.PracticeTypeID;
  242. newProfile.TeachinglanguageID = specialtyPlanView.TeachinglanguageID;
  243. newProfile.ExaminationModeID = specialtyPlanView.ExaminationModeID;
  244. SetNewStatus(newProfile);
  245. newProfileInList.Add(newProfile);
  246. }
  247. else
  248. {
  249. executablePlan.EM_ExecutablePlanProfile.IsSpecialtycore = specialtyPlanView.IsSpecialtycore;
  250. executablePlan.EM_ExecutablePlanProfile.IsCooperation = specialtyPlanView.IsCooperation;
  251. executablePlan.EM_ExecutablePlanProfile.IsRequired = specialtyPlanView.IsRequired;
  252. executablePlan.EM_ExecutablePlanProfile.IsElective = specialtyPlanView.IsElective;
  253. executablePlan.EM_ExecutablePlanProfile.IsNetworkCourse = specialtyPlanView.IsNetworkCourse;
  254. executablePlan.EM_ExecutablePlanProfile.IsMainCourse = specialtyPlanView.IsMainCourse;
  255. executablePlan.EM_ExecutablePlanProfile.CourseFineID = specialtyPlanView.CourseFineID;
  256. executablePlan.EM_ExecutablePlanProfile.PracticeTypeID = specialtyPlanView.PracticeTypeID;
  257. executablePlan.EM_ExecutablePlanProfile.TeachinglanguageID = specialtyPlanView.TeachinglanguageID;
  258. executablePlan.EM_ExecutablePlanProfile.ExaminationModeID = specialtyPlanView.ExaminationModeID;
  259. SetModifyStatus(executablePlan.EM_ExecutablePlanProfile);
  260. newProfileUpList.Add(executablePlan.EM_ExecutablePlanProfile);
  261. }
  262. if (executablePlan.EM_ExecutablePlanTeachingSetting == null)
  263. {
  264. var newEPTeachingSetting = new EM_ExecutablePlanTeachingSetting();
  265. newEPTeachingSetting.ExecutablePlanID = executablePlan.ExecutablePlanID;
  266. newEPTeachingSetting.Credit = specialtyPlanView.Credit;
  267. newEPTeachingSetting.TheoryCourse = specialtyPlanView.TheoryCourse;
  268. newEPTeachingSetting.Practicehours = specialtyPlanView.Practicehours;
  269. newEPTeachingSetting.Trialhours = specialtyPlanView.Trialhours;
  270. newEPTeachingSetting.TheoryWeeklyNum = specialtyPlanView.TheoryWeeklyNum;
  271. newEPTeachingSetting.PracticeWeeklyNum = specialtyPlanView.PracticeWeeklyNum;
  272. newEPTeachingSetting.TrialWeeklyNum = specialtyPlanView.TrialWeeklyNum;
  273. newEPTeachingSetting.WeeklyHours = specialtyPlanView.WeeklyHours;
  274. newEPTeachingSetting.WeeklyNum = specialtyPlanView.WeeklyNum;
  275. newEPTeachingSetting.StartWeeklyNum = specialtyPlanView.StartWeeklyNum;
  276. newEPTeachingSetting.EndWeeklyNum = specialtyPlanView.EndWeeklyNum;
  277. newEPTeachingSettingInList.Add(newEPTeachingSetting);
  278. }
  279. else
  280. {
  281. //可更新的相关信息
  282. executablePlan.EM_ExecutablePlanTeachingSetting.Credit = specialtyPlanView.Credit;
  283. executablePlan.EM_ExecutablePlanTeachingSetting.TheoryCourse = specialtyPlanView.TheoryCourse;
  284. executablePlan.EM_ExecutablePlanTeachingSetting.Practicehours = specialtyPlanView.Practicehours;
  285. executablePlan.EM_ExecutablePlanTeachingSetting.Trialhours = specialtyPlanView.Trialhours;
  286. if (executablePlan.RecordStatus == (int)EM_ExecuteStatus.NotSubmited)
  287. {
  288. executablePlan.EM_ExecutablePlanTeachingSetting.TheoryWeeklyNum = specialtyPlanView.TheoryWeeklyNum;
  289. executablePlan.EM_ExecutablePlanTeachingSetting.PracticeWeeklyNum = specialtyPlanView.PracticeWeeklyNum;
  290. executablePlan.EM_ExecutablePlanTeachingSetting.TrialWeeklyNum = specialtyPlanView.TrialWeeklyNum;
  291. executablePlan.EM_ExecutablePlanTeachingSetting.WeeklyHours = specialtyPlanView.WeeklyHours;
  292. executablePlan.EM_ExecutablePlanTeachingSetting.WeeklyNum = specialtyPlanView.WeeklyNum;
  293. executablePlan.EM_ExecutablePlanTeachingSetting.StartWeeklyNum = specialtyPlanView.StartWeeklyNum;
  294. executablePlan.EM_ExecutablePlanTeachingSetting.EndWeeklyNum = specialtyPlanView.EndWeeklyNum;
  295. }
  296. newEPTeachingSettingUpList.Add(executablePlan.EM_ExecutablePlanTeachingSetting);
  297. }
  298. if (executablePlan.RecordStatus == (int)EM_ExecuteStatus.NotSubmited)
  299. {
  300. //可更新的相关信息
  301. if (specialtyPlanView.TeachingModeIDList != null && specialtyPlanView.TeachingModeIDList.Count() > 0)
  302. {
  303. executablePlanTMDelList.Add(executablePlan.ExecutablePlanID);
  304. foreach (var newModeType in specialtyPlanView.TeachingModeIDList.ToList())
  305. {
  306. var newEPTeachingModeType = new EM_ExecutablePlanTeachingModeType();
  307. newEPTeachingModeType.ExecutablePlanTeachingModeTypeID = Guid.NewGuid();
  308. newEPTeachingModeType.ExecutablePlanID = executablePlan.ExecutablePlanID;
  309. newEPTeachingModeType.TeachingModeID = newModeType;
  310. this.SetNewStatus(newEPTeachingModeType);
  311. newEPTeachingModeTypeInList.Add(newEPTeachingModeType);
  312. }
  313. }
  314. else
  315. {
  316. executablePlanTMDelList.Add(executablePlan.ExecutablePlanID);
  317. }
  318. }
  319. if (specialtyPlanView.TeachingPlaceIDList != null && specialtyPlanView.TeachingPlaceIDList.Count() > 0)
  320. {
  321. executablePlanTPDelList.Add(executablePlan.ExecutablePlanID);
  322. foreach (var newPlace in specialtyPlanView.TeachingPlaceIDList.ToList())
  323. {
  324. var newEPTeachingPlace = new EM_ExecutablePlanTeachingPlace();
  325. newEPTeachingPlace.ExecutablePlanTeachingPlaceID = Guid.NewGuid();
  326. newEPTeachingPlace.ExecutablePlanID = executablePlan.ExecutablePlanID;
  327. newEPTeachingPlace.TeachingPlace = newPlace;
  328. this.SetNewStatus(newEPTeachingPlace);
  329. newEPTeachingPlaceInList.Add(newEPTeachingPlace);
  330. }
  331. }
  332. else
  333. {
  334. executablePlanTPDelList.Add(executablePlan.ExecutablePlanID);
  335. }
  336. executablePlanIDList.Add(executablePlan.ExecutablePlanID);
  337. }
  338. //存在对应的主外键关联
  339. if (specialtyPlan.EM_ExecutablePlan.Count() > 0)
  340. {
  341. //根据专业计划主键ID查询对应的执行计划信息List
  342. var newExecutablePlanList = SpecialtyPlanDAL.ExecutablePlanRepository
  343. .GetList(x => x.SpecialtyPlanID == specialtyPlan.SpecialtyPlanID,
  344. (x => x.EM_ExecutablePlanProfile), (x => x.EM_ExecutablePlanTeachingSetting)).ToList();
  345. foreach (var newExecutablePlan in newExecutablePlanList)
  346. {
  347. if (!executablePlanIDList.Contains(newExecutablePlan.ExecutablePlanID))
  348. {
  349. //查询对应的专业计划信息(业务主键:学年学期ID、年级专业ID、课程信息ID)
  350. var newSpecialtyPlanView = SpecialtyPlanDAL.GetSpecialtyPlanViewQueryable(x => x.SpecialtyPlanID != specialtyPlan.SpecialtyPlanID
  351. && x.SchoolyearID == newExecutablePlan.SchoolyearID
  352. && x.GrademajorID == newExecutablePlan.GrademajorID
  353. && x.CoursematerialID == newExecutablePlan.CoursematerialID).SingleOrDefault();
  354. if (newSpecialtyPlanView == null)
  355. {
  356. newExecutablePlan.SpecialtyPlanID = null;
  357. SetModifyStatus(newExecutablePlan);
  358. newExecutablePlanUpList.Add(newExecutablePlan);
  359. }
  360. else
  361. {
  362. //来源专业计划默认为必修课
  363. newExecutablePlan.SourceTypeID = (int)EM_SourceType.RequiredCourse;
  364. newExecutablePlan.DefaultClassName = newSpecialtyPlanView.CourseName + "-" + newSpecialtyPlanView.GrademajorName;
  365. newExecutablePlan.SpecialtyPlanID = newSpecialtyPlanView.SpecialtyPlanID;
  366. newExecutablePlan.SchoolyearID = newSpecialtyPlanView.SchoolyearID;
  367. newExecutablePlan.GrademajorID = newSpecialtyPlanView.GrademajorID;
  368. newExecutablePlan.CoursematerialID = newSpecialtyPlanView.CoursematerialID;
  369. newExecutablePlan.CourseStructureID = newSpecialtyPlanView.CourseStructureID;
  370. newExecutablePlan.CourseCategoryID = newSpecialtyPlanView.CourseCategoryID;
  371. newExecutablePlan.CourseTypeID = newSpecialtyPlanView.CourseTypeID;
  372. newExecutablePlan.CourseQualityID = newSpecialtyPlanView.CourseQualityID;
  373. newExecutablePlan.DepartmentID = newSpecialtyPlanView.DepartmentID;
  374. newExecutablePlan.IsNeedMaterial = newSpecialtyPlanView.IsNeedMaterial;
  375. newExecutablePlan.ResultTypeID = newSpecialtyPlanView.ResultTypeID;
  376. newExecutablePlan.HandleModeID = newSpecialtyPlanView.HandleModeID;
  377. SetModifyStatus(newExecutablePlan);
  378. newExecutablePlanUpList.Add(newExecutablePlan);
  379. if (newExecutablePlan.EM_ExecutablePlanProfile == null)
  380. {
  381. var newProfile = new EM_ExecutablePlanProfile();
  382. newProfile.ExecutablePlanID = newExecutablePlan.ExecutablePlanID;
  383. newProfile.IsSpecialtycore = newSpecialtyPlanView.IsSpecialtycore;
  384. newProfile.IsCooperation = newSpecialtyPlanView.IsCooperation;
  385. newProfile.IsRequired = newSpecialtyPlanView.IsRequired;
  386. newProfile.IsElective = newSpecialtyPlanView.IsElective;
  387. newProfile.IsNetworkCourse = newSpecialtyPlanView.IsNetworkCourse;
  388. newProfile.IsMainCourse = newSpecialtyPlanView.IsMainCourse;
  389. newProfile.CourseFineID = newSpecialtyPlanView.CourseFineID;
  390. newProfile.PracticeTypeID = newSpecialtyPlanView.PracticeTypeID;
  391. newProfile.TeachinglanguageID = newSpecialtyPlanView.TeachinglanguageID;
  392. newProfile.ExaminationModeID = newSpecialtyPlanView.ExaminationModeID;
  393. SetNewStatus(newProfile);
  394. newProfileInList.Add(newProfile);
  395. }
  396. else
  397. {
  398. newExecutablePlan.EM_ExecutablePlanProfile.IsSpecialtycore = newSpecialtyPlanView.IsSpecialtycore;
  399. newExecutablePlan.EM_ExecutablePlanProfile.IsCooperation = newSpecialtyPlanView.IsCooperation;
  400. newExecutablePlan.EM_ExecutablePlanProfile.IsRequired = newSpecialtyPlanView.IsRequired;
  401. newExecutablePlan.EM_ExecutablePlanProfile.IsElective = newSpecialtyPlanView.IsElective;
  402. newExecutablePlan.EM_ExecutablePlanProfile.IsNetworkCourse = newSpecialtyPlanView.IsNetworkCourse;
  403. newExecutablePlan.EM_ExecutablePlanProfile.IsMainCourse = newSpecialtyPlanView.IsMainCourse;
  404. newExecutablePlan.EM_ExecutablePlanProfile.CourseFineID = newSpecialtyPlanView.CourseFineID;
  405. newExecutablePlan.EM_ExecutablePlanProfile.PracticeTypeID = newSpecialtyPlanView.PracticeTypeID;
  406. newExecutablePlan.EM_ExecutablePlanProfile.TeachinglanguageID = newSpecialtyPlanView.TeachinglanguageID;
  407. newExecutablePlan.EM_ExecutablePlanProfile.ExaminationModeID = newSpecialtyPlanView.ExaminationModeID;
  408. SetModifyStatus(newExecutablePlan.EM_ExecutablePlanProfile);
  409. newProfileUpList.Add(newExecutablePlan.EM_ExecutablePlanProfile);
  410. }
  411. if (newExecutablePlan.EM_ExecutablePlanTeachingSetting == null)
  412. {
  413. var newEPTeachingSetting = new EM_ExecutablePlanTeachingSetting();
  414. newEPTeachingSetting.ExecutablePlanID = newExecutablePlan.ExecutablePlanID;
  415. newEPTeachingSetting.Credit = newSpecialtyPlanView.Credit;
  416. newEPTeachingSetting.TheoryCourse = newSpecialtyPlanView.TheoryCourse;
  417. newEPTeachingSetting.Practicehours = newSpecialtyPlanView.Practicehours;
  418. newEPTeachingSetting.Trialhours = newSpecialtyPlanView.Trialhours;
  419. newEPTeachingSetting.TheoryWeeklyNum = newSpecialtyPlanView.TheoryWeeklyNum;
  420. newEPTeachingSetting.PracticeWeeklyNum = newSpecialtyPlanView.PracticeWeeklyNum;
  421. newEPTeachingSetting.TrialWeeklyNum = newSpecialtyPlanView.TrialWeeklyNum;
  422. newEPTeachingSetting.WeeklyHours = newSpecialtyPlanView.WeeklyHours;
  423. newEPTeachingSetting.WeeklyNum = newSpecialtyPlanView.WeeklyNum;
  424. newEPTeachingSetting.StartWeeklyNum = newSpecialtyPlanView.StartWeeklyNum;
  425. newEPTeachingSetting.EndWeeklyNum = newSpecialtyPlanView.EndWeeklyNum;
  426. newEPTeachingSettingInList.Add(newEPTeachingSetting);
  427. }
  428. else
  429. {
  430. //可更新的相关信息
  431. newExecutablePlan.EM_ExecutablePlanTeachingSetting.Credit = newSpecialtyPlanView.Credit;
  432. newExecutablePlan.EM_ExecutablePlanTeachingSetting.TheoryCourse = newSpecialtyPlanView.TheoryCourse;
  433. newExecutablePlan.EM_ExecutablePlanTeachingSetting.Practicehours = newSpecialtyPlanView.Practicehours;
  434. newExecutablePlan.EM_ExecutablePlanTeachingSetting.Trialhours = newSpecialtyPlanView.Trialhours;
  435. if (newExecutablePlan.RecordStatus == (int)EM_ExecuteStatus.NotSubmited)
  436. {
  437. newExecutablePlan.EM_ExecutablePlanTeachingSetting.TheoryWeeklyNum = newSpecialtyPlanView.TheoryWeeklyNum;
  438. newExecutablePlan.EM_ExecutablePlanTeachingSetting.PracticeWeeklyNum = newSpecialtyPlanView.PracticeWeeklyNum;
  439. newExecutablePlan.EM_ExecutablePlanTeachingSetting.TrialWeeklyNum = newSpecialtyPlanView.TrialWeeklyNum;
  440. newExecutablePlan.EM_ExecutablePlanTeachingSetting.WeeklyHours = newSpecialtyPlanView.WeeklyHours;
  441. newExecutablePlan.EM_ExecutablePlanTeachingSetting.WeeklyNum = newSpecialtyPlanView.WeeklyNum;
  442. newExecutablePlan.EM_ExecutablePlanTeachingSetting.StartWeeklyNum = newSpecialtyPlanView.StartWeeklyNum;
  443. newExecutablePlan.EM_ExecutablePlanTeachingSetting.EndWeeklyNum = newSpecialtyPlanView.EndWeeklyNum;
  444. }
  445. newEPTeachingSettingUpList.Add(newExecutablePlan.EM_ExecutablePlanTeachingSetting);
  446. }
  447. if (newExecutablePlan.RecordStatus == (int)EM_ExecuteStatus.NotSubmited)
  448. {
  449. //可更新的相关信息
  450. if (newSpecialtyPlanView.TeachingModeIDList != null && newSpecialtyPlanView.TeachingModeIDList.Count() > 0)
  451. {
  452. executablePlanTMDelList.Add(newExecutablePlan.ExecutablePlanID);
  453. foreach (var newModeType in newSpecialtyPlanView.TeachingModeIDList.ToList())
  454. {
  455. var newEPTeachingModeType = new EM_ExecutablePlanTeachingModeType();
  456. newEPTeachingModeType.ExecutablePlanTeachingModeTypeID = Guid.NewGuid();
  457. newEPTeachingModeType.ExecutablePlanID = newExecutablePlan.ExecutablePlanID;
  458. newEPTeachingModeType.TeachingModeID = newModeType;
  459. this.SetNewStatus(newEPTeachingModeType);
  460. newEPTeachingModeTypeInList.Add(newEPTeachingModeType);
  461. }
  462. }
  463. else
  464. {
  465. executablePlanTMDelList.Add(newExecutablePlan.ExecutablePlanID);
  466. }
  467. }
  468. if (newSpecialtyPlanView.TeachingPlaceIDList != null && newSpecialtyPlanView.TeachingPlaceIDList.Count() > 0)
  469. {
  470. executablePlanTPDelList.Add(newExecutablePlan.ExecutablePlanID);
  471. foreach (var newPlace in newSpecialtyPlanView.TeachingPlaceIDList.ToList())
  472. {
  473. var newEPTeachingPlace = new EM_ExecutablePlanTeachingPlace();
  474. newEPTeachingPlace.ExecutablePlanTeachingPlaceID = Guid.NewGuid();
  475. newEPTeachingPlace.ExecutablePlanID = newExecutablePlan.ExecutablePlanID;
  476. newEPTeachingPlace.TeachingPlace = newPlace;
  477. this.SetNewStatus(newEPTeachingPlace);
  478. newEPTeachingPlaceInList.Add(newEPTeachingPlace);
  479. }
  480. }
  481. else
  482. {
  483. executablePlanTPDelList.Add(newExecutablePlan.ExecutablePlanID);
  484. }
  485. }
  486. executablePlanIDList.Add(newExecutablePlan.ExecutablePlanID);
  487. }
  488. }
  489. }
  490. }
  491. }
  492. else
  493. {
  494. //表示新增
  495. var newSpecialtyPlan = new EM_SpecialtyPlan();
  496. newSpecialtyPlan.SpecialtyPlanID = Guid.NewGuid();
  497. newSpecialtyPlan.PlanApplicationID = null;
  498. newSpecialtyPlan.SchoolyearID = specialtyPlanView.SchoolyearID;
  499. newSpecialtyPlan.GrademajorID = specialtyPlanView.GrademajorID;
  500. newSpecialtyPlan.CoursematerialID = specialtyPlanView.CoursematerialID;
  501. newSpecialtyPlan.CourseStructureID = specialtyPlanView.CourseStructureID;
  502. newSpecialtyPlan.CourseCategoryID = specialtyPlanView.CourseCategoryID;
  503. newSpecialtyPlan.CourseTypeID = specialtyPlanView.CourseTypeID;
  504. newSpecialtyPlan.CourseQualityID = specialtyPlanView.CourseQualityID;
  505. newSpecialtyPlan.DepartmentID = specialtyPlanView.DepartmentID;
  506. newSpecialtyPlan.IsSpecialtycore = specialtyPlanView.IsSpecialtycore;
  507. newSpecialtyPlan.IsCooperation = specialtyPlanView.IsCooperation;
  508. newSpecialtyPlan.IsRequired = specialtyPlanView.IsRequired;
  509. newSpecialtyPlan.IsElective = specialtyPlanView.IsElective;
  510. newSpecialtyPlan.IsNetworkCourse = specialtyPlanView.IsNetworkCourse;
  511. newSpecialtyPlan.IsMainCourse = specialtyPlanView.IsMainCourse;
  512. newSpecialtyPlan.IsNeedMaterial = specialtyPlanView.IsNeedMaterial;
  513. newSpecialtyPlan.CourseFineID = specialtyPlanView.CourseFineID;
  514. newSpecialtyPlan.PracticeTypeID = specialtyPlanView.PracticeTypeID;
  515. newSpecialtyPlan.TeachinglanguageID = specialtyPlanView.TeachinglanguageID;
  516. newSpecialtyPlan.ExaminationModeID = specialtyPlanView.ExaminationModeID;
  517. newSpecialtyPlan.ResultTypeID = specialtyPlanView.ResultTypeID;
  518. newSpecialtyPlan.HandleModeID = specialtyPlanView.HandleModeID;
  519. newSpecialtyPlan.Remark = specialtyPlanView.Remark;
  520. SetNewStatus(newSpecialtyPlan);
  521. newSpecialtyPlanInList.Add(newSpecialtyPlan);
  522. var newSPTeachingSetting = new EM_SpecialtyPlanTeachingSetting();
  523. newSPTeachingSetting.SpecialtyPlanID = newSpecialtyPlan.SpecialtyPlanID;
  524. newSPTeachingSetting.Credit = specialtyPlanView.Credit;
  525. newSPTeachingSetting.TheoryCourse = specialtyPlanView.TheoryCourse;
  526. newSPTeachingSetting.Practicehours = specialtyPlanView.Practicehours;
  527. newSPTeachingSetting.Trialhours = specialtyPlanView.Trialhours;
  528. newSPTeachingSetting.TheoryWeeklyNum = specialtyPlanView.TheoryWeeklyNum;
  529. newSPTeachingSetting.PracticeWeeklyNum = specialtyPlanView.PracticeWeeklyNum;
  530. newSPTeachingSetting.TrialWeeklyNum = specialtyPlanView.TrialWeeklyNum;
  531. newSPTeachingSetting.WeeklyHours = specialtyPlanView.WeeklyHours;
  532. newSPTeachingSetting.WeeklyNum = specialtyPlanView.WeeklyNum;
  533. newSPTeachingSetting.StartWeeklyNum = specialtyPlanView.StartWeeklyNum;
  534. newSPTeachingSetting.EndWeeklyNum = specialtyPlanView.EndWeeklyNum;
  535. newSPTeachingSettingInList.Add(newSPTeachingSetting);
  536. if (specialtyPlanView.TeachingModeIDList != null && specialtyPlanView.TeachingModeIDList.Count() > 0)
  537. {
  538. foreach (var teachingModeID in specialtyPlanView.TeachingModeIDList)
  539. {
  540. var newSPTeachingMode = new EM_SpecialtyPlanTeachingModeType();
  541. newSPTeachingMode.SpecialtyPlanTeachingModeTypeID = Guid.NewGuid();
  542. newSPTeachingMode.SpecialtyPlanID = newSpecialtyPlan.SpecialtyPlanID;
  543. newSPTeachingMode.TeachingModeID = teachingModeID;
  544. SetNewStatus(newSPTeachingMode);
  545. newSPTeachingModeTypeInList.Add(newSPTeachingMode);
  546. }
  547. }
  548. if (specialtyPlanView.TeachingPlaceIDList != null && specialtyPlanView.TeachingPlaceIDList.Count() > 0)
  549. {
  550. foreach (var teachingPlaceID in specialtyPlanView.TeachingPlaceIDList)
  551. {
  552. var newSPTeachingPlace = new EM_SpecialtyPlanTeachingPlace();
  553. newSPTeachingPlace.SpecialtyPlanTeachingPlaceID = Guid.NewGuid();
  554. newSPTeachingPlace.SpecialtyPlanID = newSpecialtyPlan.SpecialtyPlanID;
  555. newSPTeachingPlace.TeachingPlace = teachingPlaceID;
  556. SetNewStatus(newSPTeachingPlace);
  557. newSPTeachingPlaceInList.Add(newSPTeachingPlace);
  558. }
  559. }
  560. //对应的执行计划信息更新(根据业务主键:学年学期ID、年级专业ID、课程信息ID)
  561. //注:由于相关业务主键冗余且同时存在主外键关联,目前不允许修改相关业务主键
  562. var executablePlan = SpecialtyPlanDAL.ExecutablePlanRepository.GetList(x => x.SchoolyearID == specialtyPlanView.SchoolyearID
  563. && x.GrademajorID == specialtyPlanView.GrademajorID
  564. && x.CoursematerialID == specialtyPlanView.CoursematerialID,
  565. (x => x.EM_ExecutablePlanProfile), (x => x.EM_ExecutablePlanTeachingSetting)).SingleOrDefault();
  566. if (executablePlan == null)
  567. {
  568. //表示不存在对应的执行计划信息(暂不新增)
  569. }
  570. else
  571. {
  572. //表示存在对应的执行计划信息(修改)
  573. executablePlan.SourceTypeID = (int)EM_SourceType.RequiredCourse;
  574. //暂不考虑
  575. //executablePlan.DefaultClassName = specialtyPlanView.CourseName + "-" + specialtyPlanView.GrademajorName;
  576. executablePlan.SpecialtyPlanID = newSpecialtyPlan.SpecialtyPlanID;
  577. executablePlan.SchoolyearID = specialtyPlanView.SchoolyearID;
  578. executablePlan.GrademajorID = specialtyPlanView.GrademajorID;
  579. executablePlan.CoursematerialID = specialtyPlanView.CoursematerialID;
  580. executablePlan.CourseStructureID = specialtyPlanView.CourseStructureID;
  581. executablePlan.CourseCategoryID = specialtyPlanView.CourseCategoryID;
  582. executablePlan.CourseTypeID = specialtyPlanView.CourseTypeID;
  583. executablePlan.CourseQualityID = specialtyPlanView.CourseQualityID;
  584. executablePlan.DepartmentID = specialtyPlanView.DepartmentID;
  585. executablePlan.IsNeedMaterial = specialtyPlanView.IsNeedMaterial;
  586. executablePlan.ResultTypeID = specialtyPlanView.ResultTypeID;
  587. executablePlan.HandleModeID = specialtyPlanView.HandleModeID;
  588. SetModifyStatus(executablePlan);
  589. newExecutablePlanUpList.Add(executablePlan);
  590. if (executablePlan.EM_ExecutablePlanProfile == null)
  591. {
  592. var newProfile = new EM_ExecutablePlanProfile();
  593. newProfile.ExecutablePlanID = executablePlan.ExecutablePlanID;
  594. newProfile.IsSpecialtycore = specialtyPlanView.IsSpecialtycore;
  595. newProfile.IsCooperation = specialtyPlanView.IsCooperation;
  596. newProfile.IsRequired = specialtyPlanView.IsRequired;
  597. newProfile.IsElective = specialtyPlanView.IsElective;
  598. newProfile.IsNetworkCourse = specialtyPlanView.IsNetworkCourse;
  599. newProfile.IsMainCourse = specialtyPlanView.IsMainCourse;
  600. newProfile.CourseFineID = specialtyPlanView.CourseFineID;
  601. newProfile.PracticeTypeID = specialtyPlanView.PracticeTypeID;
  602. newProfile.TeachinglanguageID = specialtyPlanView.TeachinglanguageID;
  603. newProfile.ExaminationModeID = specialtyPlanView.ExaminationModeID;
  604. SetNewStatus(newProfile);
  605. newProfileInList.Add(newProfile);
  606. }
  607. else
  608. {
  609. executablePlan.EM_ExecutablePlanProfile.IsSpecialtycore = specialtyPlanView.IsSpecialtycore;
  610. executablePlan.EM_ExecutablePlanProfile.IsCooperation = specialtyPlanView.IsCooperation;
  611. executablePlan.EM_ExecutablePlanProfile.IsRequired = specialtyPlanView.IsRequired;
  612. executablePlan.EM_ExecutablePlanProfile.IsElective = specialtyPlanView.IsElective;
  613. executablePlan.EM_ExecutablePlanProfile.IsNetworkCourse = specialtyPlanView.IsNetworkCourse;
  614. executablePlan.EM_ExecutablePlanProfile.IsMainCourse = specialtyPlanView.IsMainCourse;
  615. executablePlan.EM_ExecutablePlanProfile.CourseFineID = specialtyPlanView.CourseFineID;
  616. executablePlan.EM_ExecutablePlanProfile.PracticeTypeID = specialtyPlanView.PracticeTypeID;
  617. executablePlan.EM_ExecutablePlanProfile.TeachinglanguageID = specialtyPlanView.TeachinglanguageID;
  618. executablePlan.EM_ExecutablePlanProfile.ExaminationModeID = specialtyPlanView.ExaminationModeID;
  619. SetModifyStatus(executablePlan.EM_ExecutablePlanProfile);
  620. newProfileUpList.Add(executablePlan.EM_ExecutablePlanProfile);
  621. }
  622. if (executablePlan.EM_ExecutablePlanTeachingSetting == null)
  623. {
  624. var newEPTeachingSetting = new EM_ExecutablePlanTeachingSetting();
  625. newEPTeachingSetting.ExecutablePlanID = executablePlan.ExecutablePlanID;
  626. newEPTeachingSetting.Credit = specialtyPlanView.Credit;
  627. newEPTeachingSetting.TheoryCourse = specialtyPlanView.TheoryCourse;
  628. newEPTeachingSetting.Practicehours = specialtyPlanView.Practicehours;
  629. newEPTeachingSetting.Trialhours = specialtyPlanView.Trialhours;
  630. newEPTeachingSetting.TheoryWeeklyNum = specialtyPlanView.TheoryWeeklyNum;
  631. newEPTeachingSetting.PracticeWeeklyNum = specialtyPlanView.PracticeWeeklyNum;
  632. newEPTeachingSetting.TrialWeeklyNum = specialtyPlanView.TrialWeeklyNum;
  633. newEPTeachingSetting.WeeklyHours = specialtyPlanView.WeeklyHours;
  634. newEPTeachingSetting.WeeklyNum = specialtyPlanView.WeeklyNum;
  635. newEPTeachingSetting.StartWeeklyNum = specialtyPlanView.StartWeeklyNum;
  636. newEPTeachingSetting.EndWeeklyNum = specialtyPlanView.EndWeeklyNum;
  637. newEPTeachingSettingInList.Add(newEPTeachingSetting);
  638. }
  639. else
  640. {
  641. //可更新的相关信息
  642. executablePlan.EM_ExecutablePlanTeachingSetting.Credit = specialtyPlanView.Credit;
  643. executablePlan.EM_ExecutablePlanTeachingSetting.TheoryCourse = specialtyPlanView.TheoryCourse;
  644. executablePlan.EM_ExecutablePlanTeachingSetting.Practicehours = specialtyPlanView.Practicehours;
  645. executablePlan.EM_ExecutablePlanTeachingSetting.Trialhours = specialtyPlanView.Trialhours;
  646. if (executablePlan.RecordStatus == (int)EM_ExecuteStatus.NotSubmited)
  647. {
  648. executablePlan.EM_ExecutablePlanTeachingSetting.TheoryWeeklyNum = specialtyPlanView.TheoryWeeklyNum;
  649. executablePlan.EM_ExecutablePlanTeachingSetting.PracticeWeeklyNum = specialtyPlanView.PracticeWeeklyNum;
  650. executablePlan.EM_ExecutablePlanTeachingSetting.TrialWeeklyNum = specialtyPlanView.TrialWeeklyNum;
  651. executablePlan.EM_ExecutablePlanTeachingSetting.WeeklyHours = specialtyPlanView.WeeklyHours;
  652. executablePlan.EM_ExecutablePlanTeachingSetting.WeeklyNum = specialtyPlanView.WeeklyNum;
  653. executablePlan.EM_ExecutablePlanTeachingSetting.StartWeeklyNum = specialtyPlanView.StartWeeklyNum;
  654. executablePlan.EM_ExecutablePlanTeachingSetting.EndWeeklyNum = specialtyPlanView.EndWeeklyNum;
  655. }
  656. newEPTeachingSettingUpList.Add(executablePlan.EM_ExecutablePlanTeachingSetting);
  657. }
  658. if (executablePlan.RecordStatus == (int)EM_ExecuteStatus.NotSubmited)
  659. {
  660. //可更新的相关信息
  661. if (specialtyPlanView.TeachingModeIDList != null && specialtyPlanView.TeachingModeIDList.Count() > 0)
  662. {
  663. executablePlanTMDelList.Add(executablePlan.ExecutablePlanID);
  664. foreach (var newModeType in specialtyPlanView.TeachingModeIDList.ToList())
  665. {
  666. var newEPTeachingModeType = new EM_ExecutablePlanTeachingModeType();
  667. newEPTeachingModeType.ExecutablePlanTeachingModeTypeID = Guid.NewGuid();
  668. newEPTeachingModeType.ExecutablePlanID = executablePlan.ExecutablePlanID;
  669. newEPTeachingModeType.TeachingModeID = newModeType;
  670. this.SetNewStatus(newEPTeachingModeType);
  671. newEPTeachingModeTypeInList.Add(newEPTeachingModeType);
  672. }
  673. }
  674. else
  675. {
  676. executablePlanTMDelList.Add(executablePlan.ExecutablePlanID);
  677. }
  678. }
  679. if (specialtyPlanView.TeachingPlaceIDList != null && specialtyPlanView.TeachingPlaceIDList.Count() > 0)
  680. {
  681. executablePlanTPDelList.Add(executablePlan.ExecutablePlanID);
  682. foreach (var newPlace in specialtyPlanView.TeachingPlaceIDList.ToList())
  683. {
  684. var newEPTeachingPlace = new EM_ExecutablePlanTeachingPlace();
  685. newEPTeachingPlace.ExecutablePlanTeachingPlaceID = Guid.NewGuid();
  686. newEPTeachingPlace.ExecutablePlanID = executablePlan.ExecutablePlanID;
  687. newEPTeachingPlace.TeachingPlace = newPlace;
  688. this.SetNewStatus(newEPTeachingPlace);
  689. newEPTeachingPlaceInList.Add(newEPTeachingPlace);
  690. }
  691. }
  692. else
  693. {
  694. executablePlanTPDelList.Add(executablePlan.ExecutablePlanID);
  695. }
  696. executablePlanIDList.Add(executablePlan.ExecutablePlanID);
  697. }
  698. }
  699. //事务提交
  700. //UnitOfWork.Commit();
  701. using (TransactionScope ts = new TransactionScope(TransactionScopeOption.RequiresNew, new TransactionOptions { IsolationLevel = IsolationLevel.Serializable }))
  702. {
  703. //删除
  704. UnitOfWork.Delete<EM_SpecialtyPlanTeachingPlace>(x => specialtyPlanTPDelList.Contains(x.SpecialtyPlanID));
  705. UnitOfWork.Delete<EM_SpecialtyPlanTeachingModeType>(x => specialtyPlanTMDelList.Contains(x.SpecialtyPlanID));
  706. //批量插入
  707. UnitOfWork.BulkInsert(newSpecialtyPlanInList);
  708. UnitOfWork.BulkInsert(newSPTeachingSettingInList);
  709. UnitOfWork.BulkInsert(newSPTeachingModeTypeInList);
  710. UnitOfWork.BulkInsert(newSPTeachingPlaceInList);
  711. //批量统一提交更新
  712. if (newSpecialtyPlanUpList != null && newSpecialtyPlanUpList.Count() > 0)
  713. {
  714. UnitOfWork.BatchUpdate(newSpecialtyPlanUpList);
  715. }
  716. //批量统一提交更新
  717. if (newSPTeachingSettingUpList != null && newSPTeachingSettingUpList.Count() > 0)
  718. {
  719. UnitOfWork.BatchUpdate(newSPTeachingSettingUpList);
  720. }
  721. //删除
  722. UnitOfWork.Delete<EM_ExecutablePlanTeachingPlace>(x => executablePlanTPDelList.Contains(x.ExecutablePlanID));
  723. UnitOfWork.Delete<EM_ExecutablePlanTeachingModeType>(x => executablePlanTMDelList.Contains(x.ExecutablePlanID));
  724. //批量插入
  725. UnitOfWork.BulkInsert(newProfileInList);
  726. UnitOfWork.BulkInsert(newEPTeachingSettingInList);
  727. UnitOfWork.BulkInsert(newEPTeachingModeTypeInList);
  728. UnitOfWork.BulkInsert(newEPTeachingPlaceInList);
  729. //批量统一提交更新
  730. if (newExecutablePlanUpList != null && newExecutablePlanUpList.Count() > 0)
  731. {
  732. UnitOfWork.BatchUpdate(newExecutablePlanUpList);
  733. }
  734. //批量统一提交更新
  735. if (newProfileUpList != null && newProfileUpList.Count() > 0)
  736. {
  737. UnitOfWork.BatchUpdate(newProfileUpList);
  738. }
  739. //批量统一提交更新
  740. if (newEPTeachingSettingUpList != null && newEPTeachingSettingUpList.Count() > 0)
  741. {
  742. UnitOfWork.BatchUpdate(newEPTeachingSettingUpList);
  743. }
  744. ts.Complete();
  745. }
  746. }
  747. else
  748. {
  749. throw new Exception("已存在相同的专业计划信息(学年学期、年级专业、课程信息唯一),请核查。");
  750. }
  751. }
  752. catch (Exception ex)
  753. {
  754. throw new Exception(ex.Message);
  755. }
  756. }
  757. }
  758. }