SpecialtyCourseServices.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Transactions;
  6. using Bowin.Common.Utility;
  7. using EMIS.Entities;
  8. using EMIS.DataLogic.CultureplanManage.PlanManagement;
  9. using EMIS.ViewModel.CultureplanManage;
  10. namespace EMIS.ExtensionLogic.ServiceLogic.CultureplanManage.PlanManagement
  11. {
  12. public class SpecialtyCourseServices : EMIS.CommonLogic.CultureplanManage.PlanManagement.SpecialtyCourseServices
  13. {
  14. /// <summary>
  15. /// 编辑(新增、修改,业务主键:专业信息ID、开课学期、课程信息ID、开课教研室(2020.11.17梁剑提出))
  16. /// </summary>
  17. /// <param name="specialtyCourseView"></param>
  18. public override void SpecialtyCourseEdit(SpecialtyCourseView specialtyCourseView)
  19. {
  20. try
  21. {
  22. //查询数据库进行验证
  23. var specialtyCourseVerify = SpecialtyCourseDAL.SpecialtyCourseRepository
  24. .GetList(x => x.SpecialtyCourseID != specialtyCourseView.SpecialtyCourseID
  25. && x.SpecialtyID == specialtyCourseView.SpecialtyID
  26. && x.StarttermID == specialtyCourseView.StarttermID
  27. && x.CoursematerialID == specialtyCourseView.CoursematerialID
  28. && x.DepartmentID == specialtyCourseView.DepartmentID).SingleOrDefault();
  29. if (specialtyCourseVerify == null)
  30. {
  31. //查询对应的专业信息
  32. var specialty = SpecialtyCourseDAL.SpecialtyRepository
  33. .GetList(x => x.SpecialtyID == specialtyCourseView.SpecialtyID).SingleOrDefault();
  34. if (specialty == null)
  35. {
  36. throw new Exception("专业信息不存在,请检查。");
  37. }
  38. //对学制和开课学期进行判断
  39. var maxStartterm = Convert.ToInt32(Math.Ceiling(specialty.LearnSystem.Value * 2 - 1)) + 1;
  40. if (specialtyCourseView.StarttermID > maxStartterm)
  41. {
  42. throw new Exception("开课学期超出学制范围,请检查。");
  43. }
  44. List<EM_SpecialtyCourse> newSpecialtyCourseInList = new List<EM_SpecialtyCourse>();
  45. List<EM_SpecialtyCourse> newSpecialtyCourseUpList = new List<EM_SpecialtyCourse>();
  46. List<EM_SpecialtyCourseTeachingSetting> newTeachingSettingInList = new List<EM_SpecialtyCourseTeachingSetting>();
  47. List<EM_SpecialtyCourseTeachingSetting> newTeachingSettingUpList = new List<EM_SpecialtyCourseTeachingSetting>();
  48. List<EM_TeachingModeType> newTeachingModeTypeInList = new List<EM_TeachingModeType>();
  49. List<EMIS.Entities.EM_TeachingPlace> newTeachingPlaceInList = new List<EMIS.Entities.EM_TeachingPlace>();
  50. List<Guid?> specialtyCourseTMDelList = new List<Guid?>();
  51. List<Guid?> specialtyCourseTPDelList = new List<Guid?>();
  52. //数据有误验证
  53. if (specialtyCourseView.SpecialtyCourseID != Guid.Empty)
  54. {
  55. var specialtyCourse = SpecialtyCourseDAL.SpecialtyCourseRepository
  56. .GetList(x => x.SpecialtyCourseID == specialtyCourseView.SpecialtyCourseID,
  57. (x => x.EM_SpecialtyCourseTeachingSetting)).SingleOrDefault();
  58. if (specialtyCourse == null)
  59. {
  60. throw new Exception("数据有误,请核查。");
  61. }
  62. else
  63. {
  64. //表示修改
  65. specialtyCourse.SpecialtyID = specialtyCourseView.SpecialtyID;
  66. specialtyCourse.StarttermID = specialtyCourseView.StarttermID;
  67. specialtyCourse.CoursematerialID = specialtyCourseView.CoursematerialID;
  68. specialtyCourse.CourseStructureID = specialtyCourseView.CourseStructureID;
  69. specialtyCourse.CourseCategoryID = specialtyCourseView.CourseCategoryID;
  70. specialtyCourse.CourseTypeID = specialtyCourseView.CourseTypeID;
  71. specialtyCourse.CourseQualityID = specialtyCourseView.CourseQualityID;
  72. specialtyCourse.DepartmentID = specialtyCourseView.DepartmentID;
  73. specialtyCourse.IsSpecialtycore = specialtyCourseView.IsSpecialtycore;
  74. specialtyCourse.IsCooperation = specialtyCourseView.IsCooperation;
  75. specialtyCourse.IsRequired = specialtyCourseView.IsRequired;
  76. specialtyCourse.IsElective = specialtyCourseView.IsElective;
  77. specialtyCourse.IsNetworkCourse = specialtyCourseView.IsNetworkCourse;
  78. specialtyCourse.IsMainCourse = specialtyCourseView.IsMainCourse;
  79. specialtyCourse.IsNeedMaterial = specialtyCourseView.IsNeedMaterial;
  80. specialtyCourse.CourseFineID = specialtyCourseView.CourseFineID;
  81. specialtyCourse.PracticeTypeID = specialtyCourseView.PracticeTypeID;
  82. specialtyCourse.TeachinglanguageID = specialtyCourseView.TeachinglanguageID;
  83. specialtyCourse.ExaminationModeID = specialtyCourseView.ExaminationModeID;
  84. specialtyCourse.ResultTypeID = specialtyCourseView.ResultTypeID;
  85. specialtyCourse.HandleModeID = specialtyCourseView.HandleModeID;
  86. specialtyCourse.IsEnable = specialtyCourseView.IsEnable;
  87. specialtyCourse.Remark = specialtyCourseView.Remark;
  88. SetModifyStatus(specialtyCourse);
  89. newSpecialtyCourseUpList.Add(specialtyCourse);
  90. if (specialtyCourse.EM_SpecialtyCourseTeachingSetting == null)
  91. {
  92. var newTeachingSetting = new EM_SpecialtyCourseTeachingSetting();
  93. newTeachingSetting.SpecialtyCourseID = specialtyCourse.SpecialtyCourseID;
  94. newTeachingSetting.Credit = specialtyCourseView.Credit;
  95. newTeachingSetting.TheoryCourse = specialtyCourseView.TheoryCourse;
  96. newTeachingSetting.Practicehours = specialtyCourseView.Practicehours;
  97. newTeachingSetting.Trialhours = specialtyCourseView.Trialhours;
  98. newTeachingSetting.TheoryWeeklyNum = specialtyCourseView.TheoryWeeklyNum;
  99. newTeachingSetting.PracticeWeeklyNum = specialtyCourseView.PracticeWeeklyNum;
  100. newTeachingSetting.TrialWeeklyNum = specialtyCourseView.TrialWeeklyNum;
  101. newTeachingSetting.WeeklyHours = specialtyCourseView.WeeklyHours;
  102. newTeachingSetting.WeeklyNum = specialtyCourseView.WeeklyNum;
  103. newTeachingSetting.StartWeeklyNum = specialtyCourseView.StartWeeklyNum;
  104. newTeachingSetting.EndWeeklyNum = specialtyCourseView.EndWeeklyNum;
  105. newTeachingSettingInList.Add(newTeachingSetting);
  106. }
  107. else
  108. {
  109. specialtyCourse.EM_SpecialtyCourseTeachingSetting.Credit = specialtyCourseView.Credit;
  110. specialtyCourse.EM_SpecialtyCourseTeachingSetting.TheoryCourse = specialtyCourseView.TheoryCourse;
  111. specialtyCourse.EM_SpecialtyCourseTeachingSetting.Practicehours = specialtyCourseView.Practicehours;
  112. specialtyCourse.EM_SpecialtyCourseTeachingSetting.Trialhours = specialtyCourseView.Trialhours;
  113. specialtyCourse.EM_SpecialtyCourseTeachingSetting.TheoryWeeklyNum = specialtyCourseView.TheoryWeeklyNum;
  114. specialtyCourse.EM_SpecialtyCourseTeachingSetting.PracticeWeeklyNum = specialtyCourseView.PracticeWeeklyNum;
  115. specialtyCourse.EM_SpecialtyCourseTeachingSetting.TrialWeeklyNum = specialtyCourseView.TrialWeeklyNum;
  116. specialtyCourse.EM_SpecialtyCourseTeachingSetting.WeeklyHours = specialtyCourseView.WeeklyHours;
  117. specialtyCourse.EM_SpecialtyCourseTeachingSetting.WeeklyNum = specialtyCourseView.WeeklyNum;
  118. specialtyCourse.EM_SpecialtyCourseTeachingSetting.StartWeeklyNum = specialtyCourseView.StartWeeklyNum;
  119. specialtyCourse.EM_SpecialtyCourseTeachingSetting.EndWeeklyNum = specialtyCourseView.EndWeeklyNum;
  120. newTeachingSettingUpList.Add(specialtyCourse.EM_SpecialtyCourseTeachingSetting);
  121. }
  122. if (specialtyCourseView.TeachingModeIDList != null && specialtyCourseView.TeachingModeIDList.Count() > 0)
  123. {
  124. specialtyCourseTMDelList.Add(specialtyCourse.SpecialtyCourseID);
  125. foreach (var teachingModeID in specialtyCourseView.TeachingModeIDList)
  126. {
  127. var newTeachingMode = new EM_TeachingModeType();
  128. newTeachingMode.TeachingModeTypeID = Guid.NewGuid();
  129. newTeachingMode.SpecialtyCourseID = specialtyCourse.SpecialtyCourseID;
  130. newTeachingMode.TeachingModeID = teachingModeID;
  131. SetNewStatus(newTeachingMode);
  132. newTeachingModeTypeInList.Add(newTeachingMode);
  133. }
  134. }
  135. else
  136. {
  137. specialtyCourseTMDelList.Add(specialtyCourse.SpecialtyCourseID);
  138. }
  139. if (specialtyCourseView.TeachingPlaceIDList != null && specialtyCourseView.TeachingPlaceIDList.Count() > 0)
  140. {
  141. specialtyCourseTPDelList.Add(specialtyCourse.SpecialtyCourseID);
  142. foreach (var teachingPlaceID in specialtyCourseView.TeachingPlaceIDList)
  143. {
  144. var newTeachingPlace = new EMIS.Entities.EM_TeachingPlace();
  145. newTeachingPlace.TeachingPlaceID = Guid.NewGuid();
  146. newTeachingPlace.SpecialtyCourseID = specialtyCourse.SpecialtyCourseID;
  147. newTeachingPlace.TeachingPlace = teachingPlaceID;
  148. SetNewStatus(newTeachingPlace);
  149. newTeachingPlaceInList.Add(newTeachingPlace);
  150. }
  151. }
  152. else
  153. {
  154. specialtyCourseTPDelList.Add(specialtyCourse.SpecialtyCourseID);
  155. }
  156. }
  157. }
  158. else
  159. {
  160. //表示新增
  161. var newSpecialtyCourse = new EM_SpecialtyCourse();
  162. newSpecialtyCourse.SpecialtyCourseID = Guid.NewGuid();
  163. newSpecialtyCourse.SpecialtyID = specialtyCourseView.SpecialtyID;
  164. newSpecialtyCourse.StarttermID = specialtyCourseView.StarttermID;
  165. newSpecialtyCourse.CoursematerialID = specialtyCourseView.CoursematerialID;
  166. newSpecialtyCourse.CourseStructureID = specialtyCourseView.CourseStructureID;
  167. newSpecialtyCourse.CourseCategoryID = specialtyCourseView.CourseCategoryID;
  168. newSpecialtyCourse.CourseTypeID = specialtyCourseView.CourseTypeID;
  169. newSpecialtyCourse.CourseQualityID = specialtyCourseView.CourseQualityID;
  170. newSpecialtyCourse.DepartmentID = specialtyCourseView.DepartmentID;
  171. newSpecialtyCourse.IsSpecialtycore = specialtyCourseView.IsSpecialtycore;
  172. newSpecialtyCourse.IsCooperation = specialtyCourseView.IsCooperation;
  173. newSpecialtyCourse.IsRequired = specialtyCourseView.IsRequired;
  174. newSpecialtyCourse.IsElective = specialtyCourseView.IsElective;
  175. newSpecialtyCourse.IsNetworkCourse = specialtyCourseView.IsNetworkCourse;
  176. newSpecialtyCourse.IsMainCourse = specialtyCourseView.IsMainCourse;
  177. newSpecialtyCourse.IsNeedMaterial = specialtyCourseView.IsNeedMaterial;
  178. newSpecialtyCourse.CourseFineID = specialtyCourseView.CourseFineID;
  179. newSpecialtyCourse.PracticeTypeID = specialtyCourseView.PracticeTypeID;
  180. newSpecialtyCourse.TeachinglanguageID = specialtyCourseView.TeachinglanguageID;
  181. newSpecialtyCourse.ExaminationModeID = specialtyCourseView.ExaminationModeID;
  182. newSpecialtyCourse.ResultTypeID = specialtyCourseView.ResultTypeID;
  183. newSpecialtyCourse.HandleModeID = specialtyCourseView.HandleModeID;
  184. newSpecialtyCourse.IsEnable = specialtyCourseView.IsEnable;
  185. newSpecialtyCourse.Remark = specialtyCourseView.Remark;
  186. SetNewStatus(newSpecialtyCourse);
  187. newSpecialtyCourseInList.Add(newSpecialtyCourse);
  188. var newTeachingSetting = new EM_SpecialtyCourseTeachingSetting();
  189. newTeachingSetting.SpecialtyCourseID = newSpecialtyCourse.SpecialtyCourseID;
  190. newTeachingSetting.Credit = specialtyCourseView.Credit;
  191. newTeachingSetting.TheoryCourse = specialtyCourseView.TheoryCourse;
  192. newTeachingSetting.Practicehours = specialtyCourseView.Practicehours;
  193. newTeachingSetting.Trialhours = specialtyCourseView.Trialhours;
  194. newTeachingSetting.TheoryWeeklyNum = specialtyCourseView.TheoryWeeklyNum;
  195. newTeachingSetting.PracticeWeeklyNum = specialtyCourseView.PracticeWeeklyNum;
  196. newTeachingSetting.TrialWeeklyNum = specialtyCourseView.TrialWeeklyNum;
  197. newTeachingSetting.WeeklyHours = specialtyCourseView.WeeklyHours;
  198. newTeachingSetting.WeeklyNum = specialtyCourseView.WeeklyNum;
  199. newTeachingSetting.StartWeeklyNum = specialtyCourseView.StartWeeklyNum;
  200. newTeachingSetting.EndWeeklyNum = specialtyCourseView.EndWeeklyNum;
  201. newTeachingSettingInList.Add(newTeachingSetting);
  202. if (specialtyCourseView.TeachingModeIDList != null && specialtyCourseView.TeachingModeIDList.Count() > 0)
  203. {
  204. foreach (var teachingModeID in specialtyCourseView.TeachingModeIDList)
  205. {
  206. var newTeachingMode = new EM_TeachingModeType();
  207. newTeachingMode.TeachingModeTypeID = Guid.NewGuid();
  208. newTeachingMode.SpecialtyCourseID = newSpecialtyCourse.SpecialtyCourseID;
  209. newTeachingMode.TeachingModeID = teachingModeID;
  210. SetNewStatus(newTeachingMode);
  211. newTeachingModeTypeInList.Add(newTeachingMode);
  212. }
  213. }
  214. if (specialtyCourseView.TeachingPlaceIDList != null && specialtyCourseView.TeachingPlaceIDList.Count() > 0)
  215. {
  216. foreach (var teachingPlaceID in specialtyCourseView.TeachingPlaceIDList)
  217. {
  218. var newTeachingPlace = new EMIS.Entities.EM_TeachingPlace();
  219. newTeachingPlace.TeachingPlaceID = Guid.NewGuid();
  220. newTeachingPlace.SpecialtyCourseID = newSpecialtyCourse.SpecialtyCourseID;
  221. newTeachingPlace.TeachingPlace = teachingPlaceID;
  222. SetNewStatus(newTeachingPlace);
  223. newTeachingPlaceInList.Add(newTeachingPlace);
  224. }
  225. }
  226. }
  227. //事务提交
  228. //UnitOfWork.Commit();
  229. using (TransactionScope ts = new TransactionScope())
  230. {
  231. //删除
  232. UnitOfWork.Delete<EMIS.Entities.EM_TeachingPlace>(x => specialtyCourseTPDelList.Contains(x.SpecialtyCourseID));
  233. UnitOfWork.Delete<EM_TeachingModeType>(x => specialtyCourseTMDelList.Contains(x.SpecialtyCourseID));
  234. //批量插入
  235. UnitOfWork.BulkInsert(newSpecialtyCourseInList);
  236. UnitOfWork.BulkInsert(newTeachingSettingInList);
  237. UnitOfWork.BulkInsert(newTeachingModeTypeInList);
  238. UnitOfWork.BulkInsert(newTeachingPlaceInList);
  239. //批量统一提交更新
  240. if (newSpecialtyCourseUpList != null && newSpecialtyCourseUpList.Count() > 0)
  241. {
  242. UnitOfWork.BatchUpdate(newSpecialtyCourseUpList);
  243. }
  244. //批量统一提交更新
  245. if (newTeachingSettingUpList != null && newTeachingSettingUpList.Count() > 0)
  246. {
  247. UnitOfWork.BatchUpdate(newTeachingSettingUpList);
  248. }
  249. ts.Complete();
  250. }
  251. }
  252. else
  253. {
  254. throw new Exception("已存在相同的专业课程信息(专业信息、开课学期、课程信息唯一),请核查。");
  255. }
  256. }
  257. catch (Exception ex)
  258. {
  259. throw new Exception(ex.Message);
  260. }
  261. }
  262. }
  263. }