ExecutableFreeSelectionCouseServices.cs 69 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Linq.Expressions;
  6. using System.Data.Entity;
  7. using Bowin.Common.Linq;
  8. using Bowin.Common.Linq.Entity;
  9. using EMIS.ViewModel.SelectCourse;
  10. using EMIS.ViewModel;
  11. using EMIS.Entities;
  12. using EMIS.DataLogic.SelectCourse;
  13. using EMIS.DataLogic.Repositories;
  14. using EMIS.CommonLogic.SystemServices;
  15. using EMIS.Utility.FormValidate;
  16. using EMIS.ViewModel.EnrollManage.SpecialtyManage;
  17. using EMIS.ViewModel.UniversityManage.ClassroomManage;
  18. using EMIS.DataLogic.EducationSchedule;
  19. using EMIS.DataLogic.SelectCourse.SelectCourseResult;
  20. using System.Transactions;
  21. namespace EMIS.CommonLogic.SelectCourse
  22. {
  23. public class ExecutableFreeSelectionCouseServices : BaseWorkflowServices<EM_FreeSelectionCouseApply>, IExecutableFreeSelectionCouseServices
  24. {
  25. public FreeSelectionCoursePlanDAL FreeSelectionCoursePlanDAL { get; set; }
  26. public ExecutableFreeSelectionCouseRepository ExecutableFreeSelectionCouseRepository { get; set; }
  27. public ExecutableFreeSelectionCouseDAL ExecutableFreeSelectionCouseDAL { get; set; }
  28. public FreeSelectionCourseDAL FreeSelectionCourseDAL { get; set; }
  29. public FreeSelectionCouseTeachingModeRepository FreeSelectionCouseTeachingModeRepository { get; set; }
  30. public ClassroomScheduleDAL ClassroomScheduleDAL { get; set; }
  31. public SelectCourseResultDAL SelectCourseResultDAL { get; set; }
  32. public IStudentSelectCourseServices IStudentSelectCourseServices { get; set; }
  33. public IGridResultSet<ExecutableFreeSelectionCouseView> GetExecutableFreeSelectionCouseViewGrid(ConfiguretView configuretView,
  34. Guid? schoolyearID, Guid? campusID, Guid? collegeID, Guid? departmentID, int? Status, int? isOpened, int pageIndex, int pageSize)
  35. {
  36. Expression<Func<EM_ExecutableFreeSelectionCouse, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  37. if (schoolyearID.HasValue)
  38. exp = exp.And(x => x.SchoolyearID == schoolyearID);
  39. if (campusID.HasValue)
  40. exp = exp.And(x => x.CF_Department.CF_College.CampusID == campusID);
  41. if (collegeID.HasValue)
  42. exp = exp.And(x => x.CF_Department.CollegeID == collegeID);
  43. if (departmentID.HasValue)
  44. exp = exp.And(x => x.DepartmentID == departmentID);
  45. if (isOpened.HasValue)
  46. exp = exp.And(x => x.IsOpened == (isOpened == 1 ? true : false));
  47. if (Status.HasValue)
  48. exp = exp.And(x => x.RecordStatus == Status);
  49. var freeSelectionCourseView = ExecutableFreeSelectionCouseDAL.GetExecutableFreeSelectionCouseViewQueryable(exp);
  50. //if (configuretView.Attribute == "TeacherName" && !string.IsNullOrEmpty(configuretView.ConditionValue))
  51. //{
  52. // var educationMissionClassID = query.Select(x => x.EducationMissionClassID).ToList();
  53. // //获取查询结果教学任务所有教师
  54. // var missionClassTeacherList = educationMissionClassDAL.GetMissionClassTeacherQuery(x => educationMissionClassID.Contains(x.EducationMissionClassID)).ToList();
  55. // //按教师姓名条件查询对应教学任务
  56. // missionClassTeacherList = missionClassTeacherList.Where(x => x.Name == configuretView.ConditionValue).ToList();
  57. // var missionClassIDList = missionClassTeacherList.Select(x => x.EducationMissionClassID).ToList();
  58. // //由于教学任务可能有多个教师授课,所以还要再拿筛选后的教学任务在匹配一次教师
  59. // missionClassTeacherList = educationMissionClassDAL.GetMissionClassTeacherQuery(x => missionClassIDList.Contains(x.EducationMissionClassID)).ToList();
  60. // query = query.Where(x => missionClassIDList.Contains(x.EducationMissionClassID));
  61. // var resultQuery = this.GetQueryByDataRangeByDepartment(query).OrderByDescending(x => x.SchoolyearCode)
  62. // .ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo).ThenByDescending(x => x.GradeYearID)
  63. // .ThenBy(x => x.StandardID).ThenBy(x => x.CourseName).ThenBy(x => x.OrderNo).ThenBy(x => x.Name);
  64. // var result = resultQuery.ToGridResultSet<EducationMissionClassView>(pageIndex, pageSize);
  65. // result.rows.ForEach(x => x.MissionClassTeacherView = new HashSet<MissionClassTeacherView>(missionClassTeacherList.Where(y => y.EducationMissionClassID == x.EducationMissionClassID)));
  66. // return result;
  67. //}
  68. var teacherView = ExecutableFreeSelectionCouseDAL.GetExecutableFreeSelectionCouseTeacherViewQueryable(exp);
  69. var schedulingView = SelectCourseResultDAL.GetScheduling(exp).ToList();
  70. var efsdcIDList = freeSelectionCourseView.Select(x => x.ExecutableFreeSelectionCouseID).ToList();
  71. if (configuretView.Attribute == "TeacherName" && !string.IsNullOrEmpty(configuretView.ConditionValue))
  72. {
  73. teacherView = teacherView.Where(x => x.Name.Contains(configuretView.ConditionValue));
  74. efsdcIDList = teacherView.Select(x => x.ExecutableFreeSelectionCouseID).ToList();
  75. }
  76. else if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  77. {
  78. freeSelectionCourseView = freeSelectionCourseView.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
  79. }
  80. var result = this.GetQueryByDataRangeByCollege(freeSelectionCourseView).Where(x => efsdcIDList.Contains(x.ExecutableFreeSelectionCouseID)).OrderBy(x => x.SchoolyearCode).
  81. ThenBy(x => x.CourseCode).ThenBy(x => x.DefaultClassName).ToGridResultSet(pageIndex, pageSize);
  82. result.rows.ForEach(x =>
  83. {
  84. x.Teachers = new HashSet<ExecutableFreeSelectionCouseTeacherListView>(teacherView
  85. .Where(w => x.ExecutableFreeSelectionCouseID == w.ExecutableFreeSelectionCouseID));
  86. });
  87. if (schedulingView.Count > 0)
  88. {
  89. var schedulingList = IStudentSelectCourseServices.GetWeekdayTimesSegmentName(schedulingView);
  90. result.rows.ForEach(x =>
  91. {
  92. var list = schedulingList.Where(w => w.ID == x.ExecutableFreeSelectionCouseID);
  93. x.WeekdayTimesSegmentName = string.Join(";", list.OrderBy(w => w.Weekday).Select(w => w.WeekdayTimesSegmentName));
  94. });
  95. }
  96. return result;
  97. }
  98. public List<ExecutableFreeSelectionCouseView> GetExecutableFreeSelectionCouseViewList(ConfiguretView configuretView,
  99. Guid? schoolyearID, Guid? campusID, Guid? collegeID, Guid? departmentID, int? Status, int? isOpened)
  100. {
  101. Expression<Func<EM_ExecutableFreeSelectionCouse, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  102. if (schoolyearID.HasValue)
  103. exp = exp.And(x => x.SchoolyearID == schoolyearID);
  104. if (campusID.HasValue)
  105. exp = exp.And(x => x.CF_Department.CF_College.CampusID == campusID);
  106. if (collegeID.HasValue)
  107. exp = exp.And(x => x.CF_Department.CollegeID == collegeID);
  108. if (departmentID.HasValue)
  109. exp = exp.And(x => x.DepartmentID == departmentID);
  110. if (isOpened.HasValue)
  111. exp = exp.And(x => x.IsOpened == (isOpened == 1 ? true : false));
  112. if (Status.HasValue)
  113. exp = exp.And(x => x.RecordStatus == Status);
  114. var freeSelectionCourseView = ExecutableFreeSelectionCouseDAL.GetExecutableFreeSelectionCouseViewQueryable(exp);
  115. var teacherView = ExecutableFreeSelectionCouseDAL.GetExecutableFreeSelectionCouseTeacherViewQueryable(exp);
  116. var efsdcIDList = freeSelectionCourseView.Select(x => x.ExecutableFreeSelectionCouseID).ToList();
  117. if (configuretView.Attribute == "TeacherName" && !string.IsNullOrEmpty(configuretView.ConditionValue))
  118. {
  119. teacherView = teacherView.Where(x => x.Name.Contains(configuretView.ConditionValue));
  120. efsdcIDList = teacherView.Select(x => x.ExecutableFreeSelectionCouseID).ToList();
  121. }
  122. else if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  123. {
  124. freeSelectionCourseView = freeSelectionCourseView.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
  125. }
  126. var schedulingView = SelectCourseResultDAL.GetScheduling(exp).ToList();
  127. var result = freeSelectionCourseView.Where(x => efsdcIDList.Contains(x.ExecutableFreeSelectionCouseID)).OrderBy(x => x.SchoolyearCode).ThenBy(x => x.CourseCode).ThenBy(x => x.DefaultClassName).ToList();
  128. result.ForEach(x =>
  129. {
  130. x.Teachers = new HashSet<ExecutableFreeSelectionCouseTeacherListView>(teacherView
  131. .Where(w => x.ExecutableFreeSelectionCouseID == w.ExecutableFreeSelectionCouseID));
  132. });
  133. if (schedulingView.Count > 0)
  134. {
  135. var schedulingList = IStudentSelectCourseServices.GetWeekdayTimesSegmentName(schedulingView);
  136. result.ForEach(x =>
  137. {
  138. var list = schedulingList.Where(w => w.ID == x.ExecutableFreeSelectionCouseID);
  139. x.WeekdayTimesSegmentName = string.Join(";", list.OrderBy(w => w.Weekday).Select(w => w.WeekdayTimesSegmentName));
  140. });
  141. }
  142. return result;
  143. }
  144. public EM_FreeSelectionCouse GetFreeSelectionCourse(Guid? freeSelectionCourseID)
  145. {
  146. System.Linq.Expressions.Expression<Func<EM_FreeSelectionCouse, bool>> expression =
  147. (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  148. expression = (x => x.FreeSelectionCouseID == freeSelectionCourseID);
  149. return FreeSelectionCourseDAL.FreeSelectionCouseRepository.GetSingle(expression, (x => x.CF_Department), (x => x.EM_Coursematerial));
  150. }
  151. public FreeSelectionCourseView GetFreeSelectionCourseView(Guid? freeSelectionCourseID)
  152. {
  153. var query = FreeSelectionCourseDAL.GetFreeSelectionCourseViewQueryable(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  154. return query.Where(x => x.FreeSelectionCouseID == freeSelectionCourseID).FirstOrDefault();
  155. }
  156. public EM_FreeSelectionCouseTeachingSetting GetFreeSelectionCourseTeachingSetting(Guid? freeSelectionCourseID)
  157. {
  158. //查询条件
  159. System.Linq.Expressions.Expression<Func<EM_FreeSelectionCouseTeachingSetting, bool>> expression = (x => true);
  160. expression = (x => x.FreeSelectionCouseID == freeSelectionCourseID);
  161. return FreeSelectionCourseDAL.FreeSelectionCouseTeachingSettingRepository.GetSingle(expression);
  162. }
  163. private bool TeachingModeTypeAdd(List<int> list, Guid? ExecutableFreeSelectionCouseID)
  164. {
  165. try
  166. {
  167. if (list.Count > 0)
  168. {
  169. UnitOfWork.Delete<EM_ExecutableFreeSelectionCouseTeachingMode>(x => x.ExecutableFreeSelectionCouseID == ExecutableFreeSelectionCouseID);
  170. foreach (var i in list)
  171. {
  172. EM_ExecutableFreeSelectionCouseTeachingMode teachingModeType = new EM_ExecutableFreeSelectionCouseTeachingMode();
  173. teachingModeType.ExecutableFreeSelectionCouseTeachingModeID = Guid.NewGuid();
  174. teachingModeType.ExecutableFreeSelectionCouseID = ExecutableFreeSelectionCouseID;
  175. teachingModeType.TeachingModeID = i;
  176. this.SetNewStatus(teachingModeType);
  177. UnitOfWork.Add(teachingModeType);
  178. }
  179. }
  180. return true;
  181. }
  182. catch (Exception)
  183. {
  184. throw;
  185. }
  186. }
  187. /// <summary>
  188. /// 任选设定获取授课方式
  189. /// </summary>
  190. /// <param name="ExecutableFreeSelectionCouseID"></param>
  191. /// <returns></returns>
  192. public List<int> GetCourseTeachingModeType(Guid? ExecutableFreeSelectionCouseID)
  193. {
  194. var list = ExecutableFreeSelectionCouseDAL.GetTeachingModeType(x => x.ExecutableFreeSelectionCouseID == ExecutableFreeSelectionCouseID)
  195. .Select(x => x.Value ?? 0).ToList();
  196. if (list.Count > 0)
  197. list.Add((int)EMIS.ViewModel.CF_TeachingMode.Theory);
  198. return list;
  199. }
  200. /// <summary>
  201. /// 任选设定可选年级表
  202. /// </summary>
  203. /// <param name="ExecutableFreeSelectionCouseID"></param>
  204. /// <returns></returns>
  205. public List<int> GetCourseGradeYear(Guid? ExecutableFreeSelectionCouseID)
  206. {
  207. List<int> list = new List<int>();
  208. return ExecutableFreeSelectionCouseDAL.GetGradeYear(x => x.ExecutableFreeSelectionCouseID == ExecutableFreeSelectionCouseID)
  209. .Select(x => x.Value ?? 0).ToList();
  210. }
  211. public EM_FreeSelectionCouse GetFreeSelectionCourseCourse(Guid? coursematerialID)
  212. {
  213. //查询条件
  214. System.Linq.Expressions.Expression<Func<EM_FreeSelectionCouse, bool>> expression = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  215. expression = (x => x.CoursematerialID == coursematerialID);
  216. return FreeSelectionCourseDAL.FreeSelectionCouseRepository.GetSingle(expression, (x => x.CF_Department), (x => x.EM_Coursematerial));
  217. }
  218. public ExecutableFreeSelectionCouseView GetExecutableFreeSelectionCouseView(Guid? ExecutableFreeSelectionCouseID)
  219. {
  220. return ExecutableFreeSelectionCouseDAL.GetExecutableFreeSelectionCouseViewQueryable(x => x.ExecutableFreeSelectionCouseID == ExecutableFreeSelectionCouseID)
  221. .FirstOrDefault();
  222. }
  223. public EM_ExecutableFreeSelectionCouse GetExecutableFreeSelectionCouse(Guid? ExecutableFreeSelectionCouseID)
  224. {
  225. //查询条件
  226. System.Linq.Expressions.Expression<Func<EM_ExecutableFreeSelectionCouse, bool>> expression =
  227. (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  228. expression = (x => x.ExecutableFreeSelectionCouseID == ExecutableFreeSelectionCouseID);
  229. return ExecutableFreeSelectionCouseRepository.GetSingle(expression, x => x.EM_ExecutableFreeSelectionCouseSpecialty);
  230. }
  231. public bool ExecutableFreeSelectionCouseAdd(ExecutableFreeSelectionCouseView ExecutableFreeSelectionCouse, IList<ExecutableFreeSelectionCouseTeacherListView> teacherList, IList<ExecutableFreeSelectionCouseSpecialtyListView> specialtyList, IList<ExecutableFreeSelectionCouseSchedulingView> schedulingList, out int? type)
  232. {
  233. try
  234. {
  235. var ApprovalStatus = this.GetCorrectEndStatus();
  236. //schedulingList = schedulingList.Where(x => x.CoursesTimeID != null && x.Weekday != null && x.ClassroomID != null).ToList();
  237. if (schedulingList.Where(x => x.CoursesTimeID == null || x.Weekday == null).ToList().Count > 0)
  238. {
  239. throw new Exception("排课信息不能为空");
  240. }
  241. //else
  242. //{
  243. // var repeat = schedulingList.GroupBy(x => new { x.Weekday, x.CoursesTimeID }).Max().ToList();
  244. // if (repeat.Count > 1)
  245. // throw new Exception("上课时间不能重复");
  246. //}
  247. var SpecialtyIDList = specialtyList.Select(x => x.SpecialtyID).ToList();
  248. var freeSelectionCourse = this.GetFreeSelectionCourseView(ExecutableFreeSelectionCouse.FreeSelectionCouseID);
  249. if (this.FreeSelectionCoursePlanDAL.FreeSelectionCouseApplyRepository
  250. .GetList(x => x.FreeSelectionCouseID == ExecutableFreeSelectionCouse.FreeSelectionCouseID
  251. && x.SchoolyearID == ExecutableFreeSelectionCouse.SchoolyearID
  252. && x.DefaultClassName == ExecutableFreeSelectionCouse.DefaultClassName
  253. && x.DepartmentID == ExecutableFreeSelectionCouse.DepartmentID
  254. && x.CourseTypeID == ExecutableFreeSelectionCouse.CourseTypeID
  255. && x.EM_FreeSelectionCouseApplySpecialty.Any(w => SpecialtyIDList.Contains(w.SpecialtyID))
  256. ).Count() > 0)
  257. {
  258. throw new Exception(freeSelectionCourse.CourseName + "对应的" + ExecutableFreeSelectionCouse.DefaultClassName + "已在该学期申请开课并等待审核。");
  259. }
  260. if (this.ExecutableFreeSelectionCouseRepository
  261. .GetList(x => x.FreeSelectionCouseID == ExecutableFreeSelectionCouse.FreeSelectionCouseID
  262. && x.SchoolyearID == ExecutableFreeSelectionCouse.SchoolyearID
  263. && x.DefaultClassName == ExecutableFreeSelectionCouse.DefaultClassName
  264. && x.DepartmentID == ExecutableFreeSelectionCouse.DepartmentID
  265. && x.CourseTypeID == ExecutableFreeSelectionCouse.CourseTypeID
  266. && x.EM_ExecutableFreeSelectionCouseSpecialty.Any(w => SpecialtyIDList.Contains(w.SpecialtyID))
  267. ).Count() > 0)
  268. {
  269. throw new Exception(freeSelectionCourse.CourseName + "对应的" + ExecutableFreeSelectionCouse.DefaultClassName + "在该学期已经设置任选,无需重复设置。");
  270. }
  271. //如果IsNeedVerify为false时,不验证冲突
  272. if (ExecutableFreeSelectionCouse.IsNeedVerify != false)
  273. {
  274. //判断教师和教室冲突,如果有冲突type返回1,页面js根据type弹出选择框,用户可选择继续保存或不保存,如果不返回1,弹出一般的错误提示框
  275. foreach (var scheduling in schedulingList)
  276. {
  277. //教室不为空时判断教室冲突
  278. if (ExecutableFreeSelectionCouse.ClassroomID != null)
  279. {
  280. //任选设定冲突
  281. var repeatExecutableClassroom = ExecutableFreeSelectionCouseDAL.GetRepeatExecutableFreeSelectionCouseClassroom(scheduling.CoursesTimeID, ExecutableFreeSelectionCouse.ClassroomID, scheduling.Weekday, ExecutableFreeSelectionCouse.SchoolyearID, ExecutableFreeSelectionCouse.StartWeeklyNum, ExecutableFreeSelectionCouse.EndWeeklyNum).FirstOrDefault();
  282. if (repeatExecutableClassroom != null)
  283. {
  284. type = 1;
  285. throw new Exception("检测到排课冲突," + repeatExecutableClassroom.WeekdayName + "第" + repeatExecutableClassroom.StartTimes + "节时间段教室与任选设定【" + repeatExecutableClassroom.DefaultClassName + "】有冲突");
  286. }
  287. //任选申请冲突
  288. var repeatApplyClassroom = ExecutableFreeSelectionCouseDAL.GetRepeatFreeSelectionCouseApplyClassroom(scheduling.CoursesTimeID, ExecutableFreeSelectionCouse.ClassroomID, scheduling.Weekday, ExecutableFreeSelectionCouse.SchoolyearID, ExecutableFreeSelectionCouse.StartWeeklyNum, ExecutableFreeSelectionCouse.EndWeeklyNum, ApprovalStatus).FirstOrDefault();
  289. if (repeatApplyClassroom != null)
  290. {
  291. type = 1;
  292. throw new Exception("检测到排课冲突," + repeatApplyClassroom.WeekdayName + "第" + repeatApplyClassroom.StartTimes + "节时间段教室与开课申请【" + repeatApplyClassroom.DefaultClassName + "】有冲突");
  293. }
  294. //教学任务冲突
  295. var repeatEducationClassroom = ExecutableFreeSelectionCouseDAL.GetRepeatEducationMissionClassroom(scheduling.CoursesTimeID, ExecutableFreeSelectionCouse.ClassroomID, scheduling.Weekday, ExecutableFreeSelectionCouse.SchoolyearID, ExecutableFreeSelectionCouse.StartWeeklyNum, ExecutableFreeSelectionCouse.EndWeeklyNum).FirstOrDefault();
  296. if (repeatEducationClassroom != null)
  297. {
  298. type = 1;
  299. throw new Exception("检测到排课冲突," + "该设定上课时间段教室与教学任务班【" + repeatEducationClassroom.DefaultClassName + "】有冲突");
  300. }
  301. }
  302. //判断教师冲突
  303. //任选设定冲突
  304. var repeatExecutableTeacher = ExecutableFreeSelectionCouseDAL.GetRepeatExecutableFreeSelectionCouseTeacher(teacherList.Select(x => x.UserID).ToList(), scheduling.CoursesTimeID, scheduling.Weekday, ExecutableFreeSelectionCouse.SchoolyearID, ExecutableFreeSelectionCouse.StartWeeklyNum, ExecutableFreeSelectionCouse.EndWeeklyNum).FirstOrDefault();
  305. if (repeatExecutableTeacher != null)
  306. {
  307. type = 1;
  308. throw new Exception("检测到排课冲突," + repeatExecutableTeacher.WeekdayName + "第" + repeatExecutableTeacher.StartTimes + "节时间段教师与任选设定【" + repeatExecutableTeacher.DefaultClassName + "】有冲突");
  309. }
  310. //任选申请冲突
  311. var repeatApplyTeacher = ExecutableFreeSelectionCouseDAL.GetRepeatFreeSelectionCouseApplyTeacher(teacherList.Select(x => x.UserID).ToList(), scheduling.CoursesTimeID, scheduling.Weekday, ExecutableFreeSelectionCouse.SchoolyearID, ExecutableFreeSelectionCouse.StartWeeklyNum, ExecutableFreeSelectionCouse.EndWeeklyNum, ApprovalStatus).FirstOrDefault();
  312. if (repeatApplyTeacher != null)
  313. {
  314. type = 1;
  315. throw new Exception("检测到排课冲突," + repeatApplyTeacher.WeekdayName + "第" + repeatApplyTeacher.StartTimes + "节时间段教师与开课申请【" + repeatApplyTeacher.DefaultClassName + "】有冲突");
  316. }
  317. //教学任务冲突
  318. var repeatEducationTeacher = ExecutableFreeSelectionCouseDAL.GetRepeatEducationMissionTeacher(teacherList.Select(x => x.UserID).ToList(), scheduling.CoursesTimeID, scheduling.Weekday, ExecutableFreeSelectionCouse.SchoolyearID, ExecutableFreeSelectionCouse.StartWeeklyNum, ExecutableFreeSelectionCouse.EndWeeklyNum).FirstOrDefault();
  319. if (repeatEducationTeacher != null)
  320. {
  321. type = 1;
  322. throw new Exception("检测到排课冲突," + "该设定上课时间段教师与教学任务班【" + repeatEducationTeacher.DefaultClassName + "】有冲突");
  323. }
  324. }
  325. }
  326. using (TransactionScope ts = new TransactionScope())
  327. {
  328. //任选设定表
  329. EM_ExecutableFreeSelectionCouse ExecutableFreeSelectionCouseEntity = new EM_ExecutableFreeSelectionCouse();
  330. ExecutableFreeSelectionCouseEntity.ExecutableFreeSelectionCouseID = Guid.NewGuid();
  331. ExecutableFreeSelectionCouseEntity.FreeSelectionCouseID = ExecutableFreeSelectionCouse.FreeSelectionCouseID;
  332. ExecutableFreeSelectionCouseEntity.SchoolyearID = ExecutableFreeSelectionCouse.SchoolyearID;
  333. ExecutableFreeSelectionCouseEntity.DefaultClassName = ExecutableFreeSelectionCouse.DefaultClassName;
  334. //ExecutableFreeSelectionCouseEntity.DefaultClassName = freeSelectionCourse.DepartmentName + "-"
  335. // + freeSelectionCourse.CourseName + "班(任选)";
  336. ExecutableFreeSelectionCouseEntity.DepartmentID = ExecutableFreeSelectionCouse.DepartmentID;
  337. ExecutableFreeSelectionCouseEntity.CourseStructureID = ExecutableFreeSelectionCouse.CourseStructureID;
  338. ExecutableFreeSelectionCouseEntity.CourseCategoryID = ExecutableFreeSelectionCouse.CourseCategoryID;
  339. ExecutableFreeSelectionCouseEntity.CourseTypeID = ExecutableFreeSelectionCouse.CourseTypeID;
  340. ExecutableFreeSelectionCouseEntity.CourseQualityID = ExecutableFreeSelectionCouse.CourseQualityID;
  341. ExecutableFreeSelectionCouseEntity.PracticeTypeID = ExecutableFreeSelectionCouse.PracticeTypeID;
  342. ExecutableFreeSelectionCouseEntity.ExaminationModeID = ExecutableFreeSelectionCouse.ExaminationModeID;
  343. ExecutableFreeSelectionCouseEntity.TeachinglanguageID = ExecutableFreeSelectionCouse.TeachinglanguageID;
  344. ExecutableFreeSelectionCouseEntity.IsNeedMaterial = ExecutableFreeSelectionCouse.IsNeedMaterial;
  345. ExecutableFreeSelectionCouseEntity.PeopleNumlower = ExecutableFreeSelectionCouse.PeopleNumlower;
  346. ExecutableFreeSelectionCouseEntity.PeopleNumlimit = ExecutableFreeSelectionCouse.PeopleNumlimit;
  347. ExecutableFreeSelectionCouseEntity.HandleModeID = ExecutableFreeSelectionCouse.HandleModeID;
  348. ExecutableFreeSelectionCouseEntity.IsOpened = ExecutableFreeSelectionCouse.IsOpened;
  349. ExecutableFreeSelectionCouseEntity.ResultTypeID = ExecutableFreeSelectionCouse.ResultTypeID;
  350. ExecutableFreeSelectionCouseEntity.Remarks = ExecutableFreeSelectionCouse.Remarks;
  351. this.SetNewStatus(ExecutableFreeSelectionCouseEntity);
  352. UnitOfWork.Add(ExecutableFreeSelectionCouseEntity);
  353. //任选设定教学设置表
  354. EM_ExecutableFreeSelectionCouseTeachingSetting freeSelectionCourseTeachingSetting;
  355. freeSelectionCourseTeachingSetting = new EM_ExecutableFreeSelectionCouseTeachingSetting();
  356. freeSelectionCourseTeachingSetting.ExecutableFreeSelectionCouseID = ExecutableFreeSelectionCouseEntity.ExecutableFreeSelectionCouseID;
  357. freeSelectionCourseTeachingSetting.Credit = ExecutableFreeSelectionCouse.Credit;
  358. freeSelectionCourseTeachingSetting.TheoryCourse = ExecutableFreeSelectionCouse.TheoryCourse;
  359. freeSelectionCourseTeachingSetting.Practicehours = ExecutableFreeSelectionCouse.Practicehours;
  360. freeSelectionCourseTeachingSetting.Trialhours = ExecutableFreeSelectionCouse.Trialhours;
  361. freeSelectionCourseTeachingSetting.WeeklyNum = ExecutableFreeSelectionCouse.WeeklyNum;
  362. freeSelectionCourseTeachingSetting.TheoryWeeklyNum = ExecutableFreeSelectionCouse.TheoryWeeklyNum;
  363. freeSelectionCourseTeachingSetting.PracticeWeeklyNum = ExecutableFreeSelectionCouse.PracticeWeeklyNum;
  364. freeSelectionCourseTeachingSetting.TrialWeeklyNum = ExecutableFreeSelectionCouse.TrialWeeklyNum;
  365. freeSelectionCourseTeachingSetting.StartWeeklyNum = ExecutableFreeSelectionCouse.StartWeeklyNum;
  366. freeSelectionCourseTeachingSetting.EndWeeklyNum = ExecutableFreeSelectionCouse.EndWeeklyNum;
  367. freeSelectionCourseTeachingSetting.WeeklyHours = ExecutableFreeSelectionCouse.WeeklyHours;
  368. //SetNewStatus(freeSelectionCourseTeachingSetting);
  369. UnitOfWork.Add(freeSelectionCourseTeachingSetting);
  370. //任选设定课程表
  371. //首先查出至少一个教室
  372. schedulingList.Where(x => x.CoursesTimeID != null && x.Weekday != null).ToList().ForEach(x =>
  373. {
  374. var scheduling = new EM_ExecutableFreeSelectionCouseScheduling
  375. {
  376. ExecutableFreeSelectionCouseSchedulingID = Guid.NewGuid(),
  377. ExecutableFreeSelectionCouseID = ExecutableFreeSelectionCouseEntity.ExecutableFreeSelectionCouseID,
  378. ClassroomID = ExecutableFreeSelectionCouse.ClassroomID, //这一行没有教室时,填查询到的其它行的教室,如果都没有就为空
  379. CoursesTimeID = x.CoursesTimeID,
  380. Weekday = x.Weekday,
  381. };
  382. this.SetNewStatus(scheduling);
  383. this.UnitOfWork.Add(scheduling);
  384. });
  385. //任选设定授课方式表,没有时默认为理论
  386. if (ExecutableFreeSelectionCouse.TeachingModeID != null)
  387. {
  388. var list = ExecutableFreeSelectionCouse.TeachingModeID;
  389. if (list.Count > 0)
  390. {
  391. //UnitOfWork.Delete<EM_FreeSelectionCouseTeachingMode>(x => x.FreeSelectionCouseID == ExecutableFreeSelectionCouse.freeSelectionCourseID);
  392. foreach (var i in list)
  393. {
  394. EM_ExecutableFreeSelectionCouseTeachingMode teachingModeType = new EM_ExecutableFreeSelectionCouseTeachingMode();
  395. teachingModeType.ExecutableFreeSelectionCouseTeachingModeID = Guid.NewGuid();
  396. teachingModeType.ExecutableFreeSelectionCouseID = ExecutableFreeSelectionCouseEntity.ExecutableFreeSelectionCouseID;
  397. teachingModeType.TeachingModeID = i;
  398. //this.SetNewStatus(teachingModeType);
  399. UnitOfWork.Add(teachingModeType);
  400. }
  401. }
  402. }
  403. else
  404. {
  405. EM_ExecutableFreeSelectionCouseTeachingMode teachingModeType = new EM_ExecutableFreeSelectionCouseTeachingMode();
  406. teachingModeType.ExecutableFreeSelectionCouseTeachingModeID = Guid.NewGuid();
  407. teachingModeType.ExecutableFreeSelectionCouseID = ExecutableFreeSelectionCouseEntity.ExecutableFreeSelectionCouseID;
  408. teachingModeType.TeachingModeID = (int)EMIS.ViewModel.CF_TeachingMode.Theory;
  409. UnitOfWork.Add(teachingModeType);
  410. }
  411. //任选设定年级范围表
  412. if (ExecutableFreeSelectionCouse.GradeYear != null)
  413. {
  414. var list = ExecutableFreeSelectionCouse.GradeYear;
  415. if (list.Count > 0)
  416. {
  417. //UnitOfWork.Delete<EM_FreeSelectionCouseTeachingMode>(x => x.FreeSelectionCouseID == ExecutableFreeSelectionCouse.freeSelectionCourseID);
  418. foreach (var i in list)
  419. {
  420. EM_ExecutableFreeSelectionCouseGradeYear gradeYear = new EM_ExecutableFreeSelectionCouseGradeYear();
  421. gradeYear.ExecutableFreeSelectionCouseGradeYearID = Guid.NewGuid();
  422. gradeYear.ExecutableFreeSelectionCouseID = ExecutableFreeSelectionCouseEntity.ExecutableFreeSelectionCouseID;
  423. gradeYear.GradeYear = i;
  424. this.SetNewStatus(gradeYear);
  425. UnitOfWork.Add(gradeYear);
  426. }
  427. }
  428. }
  429. //任选设定专业范围表
  430. if (specialtyList.Count > 0)
  431. {
  432. //UnitOfWork.Delete<EM_FreeSelectionCouseTeachingMode>(x => x.FreeSelectionCouseID == ExecutableFreeSelectionCouse.freeSelectionCourseID);
  433. foreach (var i in specialtyList)
  434. {
  435. EM_ExecutableFreeSelectionCouseSpecialty specialty = new EM_ExecutableFreeSelectionCouseSpecialty();
  436. specialty.ExecutableFreeSelectionCouseSpecialtyID = Guid.NewGuid();
  437. specialty.ExecutableFreeSelectionCouseID = ExecutableFreeSelectionCouseEntity.ExecutableFreeSelectionCouseID;
  438. specialty.SpecialtyID = i.SpecialtyID;
  439. this.SetNewStatus(specialty);
  440. UnitOfWork.Add(specialty);
  441. }
  442. }
  443. //任选设定教师表
  444. teacherList.ToList().ForEach(x =>
  445. {
  446. var freeSelectionTeacher = new EM_ExecutableFreeSelectionCouseTeacher
  447. {
  448. ExecutableFreeSelectionCouseStaffID = Guid.NewGuid(),
  449. ExecutableFreeSelectionCouseID = ExecutableFreeSelectionCouseEntity.ExecutableFreeSelectionCouseID,
  450. UserID = x.UserID,
  451. TeachingMethod = x.TeachingMethod
  452. };
  453. this.SetNewStatus(freeSelectionTeacher);
  454. this.UnitOfWork.Add(freeSelectionTeacher);
  455. });
  456. ExecutableFreeSelectionCouseEntity.RecordStatus = (int)EMIS.ViewModel.EM_SelectCourseResultStatus.NotOpen;
  457. UnitOfWork.Commit();
  458. ts.Complete();
  459. }
  460. type = 0;
  461. return true;
  462. }
  463. catch (Exception)
  464. {
  465. throw;
  466. }
  467. }
  468. public bool ExecutableFreeSelectionCouseUpdate(ExecutableFreeSelectionCouseView ExecutableFreeSelectionCouse, IList<ExecutableFreeSelectionCouseTeacherListView> teacherList, IList<ExecutableFreeSelectionCouseSpecialtyListView> specialtyList, IList<ExecutableFreeSelectionCouseSchedulingView> schedulingList, out int? type)
  469. {
  470. try
  471. {
  472. var ApprovalStatus = this.GetCorrectEndStatus();
  473. //schedulingList = schedulingList.Where(x => x.CoursesTimeID != null && x.Weekday != null && x.ClassroomID != null).ToList();
  474. if (schedulingList.Where(x => x.CoursesTimeID == null || x.Weekday == null).ToList().Count > 0)
  475. {
  476. throw new Exception("排课信息不能为空");
  477. }
  478. var distinctSchedulingList = schedulingList.GroupBy(x => new { x.Weekday, x.CoursesTimeID }).Select(x => new { Weekday = x.Key.Weekday, CoursesTimeID = x.Max(a => a.CoursesTimeID) }).ToList();
  479. //else
  480. //{
  481. // var repeat = schedulingList.GroupBy(x => new { x.Weekday, x.CoursesTimeID }).Max().ToList();
  482. // if (repeat.Count > 1)
  483. // throw new Exception("上课时间不能重复");
  484. //}
  485. var SpecialtyIDList = specialtyList.Select(x => x.SpecialtyID).ToList();
  486. var freeSelectionCourse = this.GetFreeSelectionCourseView(ExecutableFreeSelectionCouse.FreeSelectionCouseID);
  487. var status = this.GetCorrectEndStatus();
  488. if (this.FreeSelectionCoursePlanDAL.FreeSelectionCouseApplyRepository
  489. .GetList(x => x.FreeSelectionCouseID == ExecutableFreeSelectionCouse.FreeSelectionCouseID
  490. && x.SchoolyearID == ExecutableFreeSelectionCouse.SchoolyearID
  491. && x.DepartmentID == ExecutableFreeSelectionCouse.DepartmentID
  492. && x.CourseTypeID == ExecutableFreeSelectionCouse.CourseTypeID
  493. && x.EM_FreeSelectionCouseApplySpecialty.Any(w => SpecialtyIDList.Contains(w.SpecialtyID))
  494. && x.ApprovalStatus != status
  495. && x.DefaultClassName == ExecutableFreeSelectionCouse.DefaultClassName
  496. ).Count() > 0)
  497. {
  498. throw new Exception(freeSelectionCourse.CourseName + "对应的" + ExecutableFreeSelectionCouse.DefaultClassName + "在该学期已经申请过了,无需重复申请。");
  499. }
  500. if (this.ExecutableFreeSelectionCouseRepository
  501. .GetList(x => x.FreeSelectionCouseID == ExecutableFreeSelectionCouse.FreeSelectionCouseID
  502. && x.SchoolyearID == ExecutableFreeSelectionCouse.SchoolyearID
  503. && x.DefaultClassName == ExecutableFreeSelectionCouse.DefaultClassName
  504. && x.DepartmentID == ExecutableFreeSelectionCouse.DepartmentID
  505. && x.EM_ExecutableFreeSelectionCouseSpecialty.Any(w => SpecialtyIDList.Contains(w.SpecialtyID))
  506. && x.ExecutableFreeSelectionCouseID != ExecutableFreeSelectionCouse.ExecutableFreeSelectionCouseID
  507. ).Count() > 0)
  508. {
  509. throw new Exception(freeSelectionCourse.CourseName + "在该学期已经存在。");
  510. }
  511. //如果IsNeedVerify为false时,不验证冲突
  512. if (ExecutableFreeSelectionCouse.IsNeedVerify != false)
  513. {
  514. //判断教师和教室冲突,如果有冲突type返回1,页面js根据type弹出选择框,用户可选择继续保存或不保存,如果不返回1,弹出一般的错误提示框
  515. foreach (var scheduling in schedulingList)
  516. {
  517. //教室不为空时,判断教室
  518. if (ExecutableFreeSelectionCouse.ClassroomID != null)
  519. {
  520. //任选设定冲突
  521. var repeatExecutableClassroom = ExecutableFreeSelectionCouseDAL.GetRepeatExecutableFreeSelectionCouseClassroom(scheduling.CoursesTimeID, ExecutableFreeSelectionCouse.ClassroomID, scheduling.Weekday, ExecutableFreeSelectionCouse.SchoolyearID, ExecutableFreeSelectionCouse.StartWeeklyNum, ExecutableFreeSelectionCouse.EndWeeklyNum)
  522. .Where(x => x.ID != ExecutableFreeSelectionCouse.ExecutableFreeSelectionCouseID).FirstOrDefault();
  523. if (repeatExecutableClassroom != null)
  524. {
  525. type = 1;
  526. throw new Exception(repeatExecutableClassroom.WeekdayName + repeatExecutableClassroom.StartTimes + "时间段教室与任选设定【" + repeatExecutableClassroom.DefaultClassName + "】有冲突");
  527. }
  528. //任选申请冲突
  529. var repeatApplyClassroom = ExecutableFreeSelectionCouseDAL.GetRepeatFreeSelectionCouseApplyClassroom(scheduling.CoursesTimeID, ExecutableFreeSelectionCouse.ClassroomID, scheduling.Weekday, ExecutableFreeSelectionCouse.SchoolyearID, ExecutableFreeSelectionCouse.StartWeeklyNum, ExecutableFreeSelectionCouse.EndWeeklyNum, ApprovalStatus).FirstOrDefault();
  530. if (repeatApplyClassroom != null)
  531. {
  532. type = 1;
  533. throw new Exception("检测到排课冲突," + repeatApplyClassroom.WeekdayName + repeatApplyClassroom.StartTimes + "时间段教室与开课申请【" + repeatApplyClassroom.DefaultClassName + "】有冲突");
  534. }
  535. //教学任务冲突
  536. var repeatEducationClassroom = ExecutableFreeSelectionCouseDAL.GetRepeatEducationMissionClassroom(scheduling.CoursesTimeID, ExecutableFreeSelectionCouse.ClassroomID, scheduling.Weekday, ExecutableFreeSelectionCouse.SchoolyearID, ExecutableFreeSelectionCouse.StartWeeklyNum, ExecutableFreeSelectionCouse.EndWeeklyNum).FirstOrDefault();
  537. if (repeatEducationClassroom != null)
  538. {
  539. type = 1;
  540. throw new Exception("检测到排课冲突," + "该设定上课时间段教室与教学任务班【" + repeatEducationClassroom.DefaultClassName + "】有冲突");
  541. }
  542. }
  543. //任选设定冲突
  544. var repeatExecutableTeacher = ExecutableFreeSelectionCouseDAL.GetRepeatExecutableFreeSelectionCouseTeacher(teacherList.Select(x => x.UserID).ToList(), scheduling.CoursesTimeID, scheduling.Weekday, ExecutableFreeSelectionCouse.SchoolyearID, ExecutableFreeSelectionCouse.StartWeeklyNum, ExecutableFreeSelectionCouse.EndWeeklyNum)
  545. .Where(x => x.ID != ExecutableFreeSelectionCouse.ExecutableFreeSelectionCouseID).FirstOrDefault();
  546. if (repeatExecutableTeacher != null)
  547. {
  548. type = 1;
  549. throw new Exception("检测到排课冲突," + repeatExecutableTeacher.WeekdayName + repeatExecutableTeacher.StartTimes + "时间段教师与任选设定【" + repeatExecutableTeacher.DefaultClassName + "】有冲突");
  550. }
  551. //任选申请冲突
  552. var repeatApplyTeacher = ExecutableFreeSelectionCouseDAL.GetRepeatFreeSelectionCouseApplyTeacher(teacherList.Select(x => x.UserID).ToList(), scheduling.CoursesTimeID, scheduling.Weekday, ExecutableFreeSelectionCouse.SchoolyearID, ExecutableFreeSelectionCouse.StartWeeklyNum, ExecutableFreeSelectionCouse.EndWeeklyNum, ApprovalStatus).FirstOrDefault();
  553. if (repeatApplyTeacher != null)
  554. {
  555. type = 1;
  556. throw new Exception("检测到排课冲突," + repeatApplyTeacher.WeekdayName + repeatApplyTeacher.StartTimes + "时间段教师与开课申请【" + repeatApplyTeacher.DefaultClassName + "】有冲突");
  557. }
  558. //教学任务冲突
  559. var repeatEducationTeacher = ExecutableFreeSelectionCouseDAL.GetRepeatEducationMissionTeacher(teacherList.Select(x => x.UserID).ToList(), scheduling.CoursesTimeID, scheduling.Weekday, ExecutableFreeSelectionCouse.SchoolyearID, ExecutableFreeSelectionCouse.StartWeeklyNum, ExecutableFreeSelectionCouse.EndWeeklyNum).FirstOrDefault();
  560. if (repeatEducationTeacher != null)
  561. {
  562. type = 1;
  563. throw new Exception("检测到排课冲突," + "该设定上课时间段教师与教学任务班【" + repeatEducationTeacher.DefaultClassName + "】有冲突");
  564. }
  565. }
  566. }
  567. using (TransactionScope ts = new TransactionScope())
  568. {
  569. EM_ExecutableFreeSelectionCouse ExecutableFreeSelectionCouseEntity = GetExecutableFreeSelectionCouse(ExecutableFreeSelectionCouse.ExecutableFreeSelectionCouseID);
  570. ExecutableFreeSelectionCouseEntity.FreeSelectionCouseID = ExecutableFreeSelectionCouse.FreeSelectionCouseID;
  571. ExecutableFreeSelectionCouseEntity.SchoolyearID = ExecutableFreeSelectionCouse.SchoolyearID;
  572. ExecutableFreeSelectionCouseEntity.DefaultClassName = ExecutableFreeSelectionCouse.DefaultClassName;
  573. //ExecutableFreeSelectionCouseEntity.DefaultClassName = freeSelectionCourse.DepartmentName + "-"
  574. // + freeSelectionCourse.CourseName + "班(任选)";
  575. ExecutableFreeSelectionCouseEntity.DepartmentID = ExecutableFreeSelectionCouse.DepartmentID;
  576. ExecutableFreeSelectionCouseEntity.CourseStructureID = ExecutableFreeSelectionCouse.CourseStructureID;
  577. ExecutableFreeSelectionCouseEntity.CourseCategoryID = ExecutableFreeSelectionCouse.CourseCategoryID;
  578. ExecutableFreeSelectionCouseEntity.CourseTypeID = ExecutableFreeSelectionCouse.CourseTypeID;
  579. ExecutableFreeSelectionCouseEntity.CourseQualityID = ExecutableFreeSelectionCouse.CourseQualityID;
  580. ExecutableFreeSelectionCouseEntity.PracticeTypeID = ExecutableFreeSelectionCouse.PracticeTypeID;
  581. ExecutableFreeSelectionCouseEntity.ExaminationModeID = ExecutableFreeSelectionCouse.ExaminationModeID;
  582. ExecutableFreeSelectionCouseEntity.TeachinglanguageID = ExecutableFreeSelectionCouse.TeachinglanguageID;
  583. ExecutableFreeSelectionCouseEntity.IsNeedMaterial = ExecutableFreeSelectionCouse.IsNeedMaterial;
  584. ExecutableFreeSelectionCouseEntity.PeopleNumlower = ExecutableFreeSelectionCouse.PeopleNumlower;
  585. ExecutableFreeSelectionCouseEntity.PeopleNumlimit = ExecutableFreeSelectionCouse.PeopleNumlimit;
  586. ExecutableFreeSelectionCouseEntity.HandleModeID = ExecutableFreeSelectionCouse.HandleModeID;
  587. ExecutableFreeSelectionCouseEntity.IsOpened = ExecutableFreeSelectionCouse.IsOpened;
  588. ExecutableFreeSelectionCouseEntity.ResultTypeID = ExecutableFreeSelectionCouse.ResultTypeID;
  589. //ExecutableFreeSelectionCouseEntity.ApprovalStatus = ExecutableFreeSelectionCouse.ApprovalStatus;//(int)EMIS.ViewModel.CF_PlanApplicationStatus.NotSubmitted;
  590. ExecutableFreeSelectionCouseEntity.Remarks = ExecutableFreeSelectionCouse.Remarks;
  591. //任选设定教学设置表
  592. EM_ExecutableFreeSelectionCouseTeachingSetting freeSelectionCourseTeachingSetting = ExecutableFreeSelectionCouseDAL.ExecutableFreeSelectionCouseTeachingSettingRepository.Entities.Where(x => x.ExecutableFreeSelectionCouseID == ExecutableFreeSelectionCouse.ExecutableFreeSelectionCouseID).FirstOrDefault();
  593. //freeSelectionCourseTeachingSetting = new EM_ExecutableFreeSelectionCouseTeachingSetting();
  594. freeSelectionCourseTeachingSetting.ExecutableFreeSelectionCouseID = ExecutableFreeSelectionCouseEntity.ExecutableFreeSelectionCouseID;
  595. freeSelectionCourseTeachingSetting.Credit = ExecutableFreeSelectionCouse.Credit;
  596. freeSelectionCourseTeachingSetting.TheoryCourse = ExecutableFreeSelectionCouse.TheoryCourse;
  597. freeSelectionCourseTeachingSetting.Practicehours = ExecutableFreeSelectionCouse.Practicehours;
  598. freeSelectionCourseTeachingSetting.Trialhours = ExecutableFreeSelectionCouse.Trialhours;
  599. freeSelectionCourseTeachingSetting.WeeklyNum = ExecutableFreeSelectionCouse.WeeklyNum;
  600. freeSelectionCourseTeachingSetting.TheoryWeeklyNum = ExecutableFreeSelectionCouse.TheoryWeeklyNum;
  601. freeSelectionCourseTeachingSetting.PracticeWeeklyNum = ExecutableFreeSelectionCouse.PracticeWeeklyNum;
  602. freeSelectionCourseTeachingSetting.TrialWeeklyNum = ExecutableFreeSelectionCouse.TrialWeeklyNum;
  603. freeSelectionCourseTeachingSetting.StartWeeklyNum = ExecutableFreeSelectionCouse.StartWeeklyNum;
  604. freeSelectionCourseTeachingSetting.EndWeeklyNum = ExecutableFreeSelectionCouse.EndWeeklyNum;
  605. freeSelectionCourseTeachingSetting.WeeklyHours = ExecutableFreeSelectionCouse.WeeklyHours;
  606. //SetNewStatus(freeSelectionCourseTeachingSetting);
  607. //任选设定课程表
  608. this.UnitOfWork.Delete<EM_ExecutableFreeSelectionCouseScheduling>(x => x.ExecutableFreeSelectionCouseID == ExecutableFreeSelectionCouseEntity.ExecutableFreeSelectionCouseID);
  609. distinctSchedulingList.ToList().ForEach(x =>
  610. {
  611. var scheduling = new EM_ExecutableFreeSelectionCouseScheduling
  612. {
  613. ExecutableFreeSelectionCouseSchedulingID = Guid.NewGuid(),
  614. ExecutableFreeSelectionCouseID = ExecutableFreeSelectionCouseEntity.ExecutableFreeSelectionCouseID,
  615. ClassroomID = ExecutableFreeSelectionCouse.ClassroomID, //这一行没有教室时,填查询到的其它行的教室,如果都没有就为空
  616. CoursesTimeID = x.CoursesTimeID,
  617. Weekday = x.Weekday,
  618. };
  619. this.SetNewStatus(scheduling);
  620. this.UnitOfWork.Add(scheduling);
  621. });
  622. //任选设定授课方式表
  623. if (ExecutableFreeSelectionCouse.TeachingModeID != null)
  624. {
  625. TeachingModeTypeAdd(ExecutableFreeSelectionCouse.TeachingModeID, ExecutableFreeSelectionCouseEntity.ExecutableFreeSelectionCouseID);
  626. }
  627. this.SetModifyStatus(ExecutableFreeSelectionCouseEntity);
  628. //
  629. UnitOfWork.Delete<EM_ExecutableFreeSelectionCouseGradeYear>(x => x.ExecutableFreeSelectionCouseID == ExecutableFreeSelectionCouseEntity.ExecutableFreeSelectionCouseID);
  630. if (ExecutableFreeSelectionCouse.GradeYear != null)
  631. {
  632. foreach (var i in ExecutableFreeSelectionCouse.GradeYear)
  633. {
  634. EM_ExecutableFreeSelectionCouseGradeYear gradeYear = new EM_ExecutableFreeSelectionCouseGradeYear();
  635. gradeYear.ExecutableFreeSelectionCouseGradeYearID = Guid.NewGuid();
  636. gradeYear.ExecutableFreeSelectionCouseID = ExecutableFreeSelectionCouseEntity.ExecutableFreeSelectionCouseID;
  637. gradeYear.GradeYear = i;
  638. this.SetNewStatus(gradeYear);
  639. UnitOfWork.Add(gradeYear);
  640. }
  641. }
  642. //
  643. if (specialtyList.Count > 0)
  644. {
  645. UnitOfWork.Delete<EM_ExecutableFreeSelectionCouseSpecialty>(x => x.ExecutableFreeSelectionCouseID == ExecutableFreeSelectionCouseEntity.ExecutableFreeSelectionCouseID);
  646. foreach (var i in specialtyList)
  647. {
  648. EM_ExecutableFreeSelectionCouseSpecialty specialty = new EM_ExecutableFreeSelectionCouseSpecialty();
  649. specialty.ExecutableFreeSelectionCouseSpecialtyID = Guid.NewGuid();
  650. specialty.ExecutableFreeSelectionCouseID = ExecutableFreeSelectionCouseEntity.ExecutableFreeSelectionCouseID;
  651. specialty.SpecialtyID = i.SpecialtyID;
  652. this.SetNewStatus(specialty);
  653. UnitOfWork.Add(specialty);
  654. }
  655. }
  656. this.UnitOfWork.Delete<EM_ExecutableFreeSelectionCouseTeacher>(x => x.ExecutableFreeSelectionCouseID == ExecutableFreeSelectionCouseEntity.ExecutableFreeSelectionCouseID);
  657. teacherList.ToList().ForEach(x =>
  658. {
  659. var freeSelectionTeacher = new EM_ExecutableFreeSelectionCouseTeacher
  660. {
  661. ExecutableFreeSelectionCouseStaffID = Guid.NewGuid(),
  662. ExecutableFreeSelectionCouseID = ExecutableFreeSelectionCouseEntity.ExecutableFreeSelectionCouseID,
  663. UserID = x.UserID,
  664. TeachingMethod = x.TeachingMethod
  665. };
  666. this.SetNewStatus(freeSelectionTeacher);
  667. this.UnitOfWork.Add(freeSelectionTeacher);
  668. });
  669. SetModifyStatus(ExecutableFreeSelectionCouseEntity);
  670. UnitOfWork.Commit();
  671. ts.Complete();
  672. }
  673. type = 0;
  674. return true;
  675. }
  676. catch (Exception)
  677. {
  678. throw;
  679. }
  680. }
  681. public bool ExecutableFreeSelectionCouseUpdate(ExecutableFreeSelectionCouseView ExecutableFreeSelectionCouse, IList<ExecutableFreeSelectionCouseTeacherListView> teacherList)
  682. {
  683. try
  684. {
  685. EM_ExecutableFreeSelectionCouse ExecutableFreeSelectionCouseEntity = GetExecutableFreeSelectionCouse(ExecutableFreeSelectionCouse.ExecutableFreeSelectionCouseID);
  686. this.UnitOfWork.Delete<EM_ExecutableFreeSelectionCouseTeacher>(x => x.ExecutableFreeSelectionCouseID == ExecutableFreeSelectionCouseEntity.ExecutableFreeSelectionCouseID);
  687. teacherList.ToList().ForEach(x =>
  688. {
  689. var freeSelectionTeacher = new EM_ExecutableFreeSelectionCouseTeacher
  690. {
  691. ExecutableFreeSelectionCouseStaffID = Guid.NewGuid(),
  692. ExecutableFreeSelectionCouseID = ExecutableFreeSelectionCouseEntity.ExecutableFreeSelectionCouseID,
  693. UserID = x.UserID,
  694. TeachingMethod = x.TeachingMethod
  695. };
  696. this.SetNewStatus(freeSelectionTeacher);
  697. this.UnitOfWork.Add(freeSelectionTeacher);
  698. });
  699. SetModifyStatus(ExecutableFreeSelectionCouseEntity);
  700. UnitOfWork.Commit();
  701. return true;
  702. }
  703. catch (Exception)
  704. {
  705. throw;
  706. }
  707. }
  708. //开放
  709. public bool ExecutableFreeSelectionCouseOpen(List<Guid?> ExecutableFreeSelectionCouseIDs)
  710. {
  711. try
  712. {
  713. if (ExecutableFreeSelectionCouseIDs.Count > 0)
  714. {
  715. var ExecutableFreeSelectionCouseList = ExecutableFreeSelectionCouseRepository.GetList(x => ExecutableFreeSelectionCouseIDs.Contains(x.ExecutableFreeSelectionCouseID)).ToList();
  716. foreach (var ExecutableFreeSelectionCouse in ExecutableFreeSelectionCouseList)
  717. {
  718. if (ExecutableFreeSelectionCouse.RecordStatus > (int)EMIS.ViewModel.EM_SelectCourseResultStatus.NotOpen) //开放状态
  719. {
  720. throw new Exception("任选设定已开放");
  721. }
  722. }
  723. UnitOfWork.Update<EM_ExecutableFreeSelectionCouse>(x => new EM_ExecutableFreeSelectionCouse { RecordStatus = (int)EMIS.ViewModel.EM_SelectCourseResultStatus.Opened }, x => ExecutableFreeSelectionCouseIDs.Contains(x.ExecutableFreeSelectionCouseID));
  724. this.UnitOfWork.Commit();
  725. return true;
  726. }
  727. return false;
  728. }
  729. catch (Exception)
  730. {
  731. throw;
  732. }
  733. }
  734. //取消开放
  735. public bool ExecutableFreeSelectionCouseCancel(List<Guid?> ExecutableFreeSelectionCouseIDs)
  736. {
  737. try
  738. {
  739. if (ExecutableFreeSelectionCouseIDs.Count > 0)
  740. {
  741. var ExecutableFreeSelectionCouseList = ExecutableFreeSelectionCouseRepository.GetList(x => ExecutableFreeSelectionCouseIDs.Contains(x.ExecutableFreeSelectionCouseID)).ToList();
  742. foreach (var ExecutableFreeSelectionCouse in ExecutableFreeSelectionCouseList)
  743. {
  744. if (ExecutableFreeSelectionCouse.RecordStatus < (int)EMIS.ViewModel.EM_SelectCourseResultStatus.Opened) //开放状态
  745. {
  746. throw new Exception("任选设定未开放");
  747. }
  748. }
  749. UnitOfWork.Update<EM_ExecutableFreeSelectionCouse>(x => new EM_ExecutableFreeSelectionCouse { RecordStatus = (int)EMIS.ViewModel.EM_SelectCourseResultStatus.NotOpen }, x => ExecutableFreeSelectionCouseIDs.Contains(x.ExecutableFreeSelectionCouseID));
  750. this.UnitOfWork.Commit();
  751. return true;
  752. }
  753. return false;
  754. }
  755. catch (Exception)
  756. {
  757. throw;
  758. }
  759. }
  760. public bool ExecutableFreeSelectionCouseDelete(List<Guid?> ExecutableFreeSelectionCouseIDs)
  761. {
  762. try
  763. {
  764. if (ExecutableFreeSelectionCouseIDs.Count > 0)
  765. {
  766. var status = this.GetCorrectEndStatus();
  767. var ExecutableFreeSelectionCouseList = ExecutableFreeSelectionCouseRepository.GetList(x => ExecutableFreeSelectionCouseIDs.Contains(x.ExecutableFreeSelectionCouseID), x => x.EM_ExecutableFreeSelectionCouseSpecialty).ToList();
  768. //任选设定可能来自开课申请,因此要删除相关的开课申请,先在循环外查出对应学年学期已通过的开课申请
  769. var SchoolYearIDList = ExecutableFreeSelectionCouseList.Select(x => x.SchoolyearID).ToList();
  770. var FreeSelectionCouseApplyList = FreeSelectionCoursePlanDAL.FreeSelectionCouseApplyRepository.GetList(
  771. (x => SchoolYearIDList.Contains(x.SchoolyearID) && x.ApprovalStatus == status)
  772. , x => x.EM_FreeSelectionCouseApplySpecialty).ToList();
  773. foreach (var ExecutableFreeSelectionCouse in ExecutableFreeSelectionCouseList)
  774. {
  775. if (ExecutableFreeSelectionCouse.RecordStatus != (int)EMIS.ViewModel.EM_SelectCourseResultStatus.NotOpen)
  776. throw new Exception("只能删除未开放状态的信息。");
  777. var SpecialtyIDList = ExecutableFreeSelectionCouse.EM_ExecutableFreeSelectionCouseSpecialty.Select(x => x.SpecialtyID).ToList();
  778. var freeSelectionCouseApply = FreeSelectionCouseApplyList.Where(
  779. x => x.FreeSelectionCouseID == ExecutableFreeSelectionCouse.FreeSelectionCouseID
  780. && x.SchoolyearID == ExecutableFreeSelectionCouse.SchoolyearID
  781. //&& x.DefaultClassName == ExecutableFreeSelectionCouse.DefaultClassName
  782. && x.DepartmentID == ExecutableFreeSelectionCouse.DepartmentID
  783. && x.CourseTypeID == ExecutableFreeSelectionCouse.CourseTypeID
  784. && x.ApprovalStatus == status
  785. && (SpecialtyIDList.Count == 0 || (SpecialtyIDList.Count > 0 && x.EM_FreeSelectionCouseApplySpecialty.Any(w => SpecialtyIDList.Contains(w.SpecialtyID))))
  786. ).FirstOrDefault();
  787. if (freeSelectionCouseApply != null)
  788. { //删除开课申请
  789. UnitOfWork.Remove<Sys_ProcessRelation>(x => x.formID == freeSelectionCouseApply.FreeSelectionCouseApplyID);
  790. UnitOfWork.Remove<EM_FreeSelectionCouseApplyTeachingSetting>(x => x.FreeSelectionCouseApplyID == freeSelectionCouseApply.FreeSelectionCouseApplyID);
  791. UnitOfWork.Remove<EM_FreeSelectionCouseApplyTeachingMode>(x => x.FreeSelectionCouseApplyID == freeSelectionCouseApply.FreeSelectionCouseApplyID);
  792. UnitOfWork.Remove<EM_FreeSelectionCouseApplyTeacher>(x => x.FreeSelectionCouseApplyID == freeSelectionCouseApply.FreeSelectionCouseApplyID);
  793. UnitOfWork.Remove<EM_FreeSelectionCouseApplyGradeYear>(x => x.FreeSelectionCouseApplyID == freeSelectionCouseApply.FreeSelectionCouseApplyID);
  794. UnitOfWork.Remove<EM_FreeSelectionCouseApplySpecialty>(x => x.FreeSelectionCouseApplyID == freeSelectionCouseApply.FreeSelectionCouseApplyID);
  795. UnitOfWork.Remove<EM_FreeSelectionCouseApplyScheduling>(x => x.FreeSelectionCouseApplyID == freeSelectionCouseApply.FreeSelectionCouseApplyID);
  796. UnitOfWork.Remove<EM_FreeSelectionCouseApply>(x => x.FreeSelectionCouseApplyID == freeSelectionCouseApply.FreeSelectionCouseApplyID);
  797. }
  798. UnitOfWork.Remove<EM_ExecutableFreeSelectionCouseScheduling>(x => x.ExecutableFreeSelectionCouseID == ExecutableFreeSelectionCouse.ExecutableFreeSelectionCouseID);
  799. UnitOfWork.Remove<EM_ExecutableFreeSelectionCouseTeachingSetting>(x => x.ExecutableFreeSelectionCouseID == ExecutableFreeSelectionCouse.ExecutableFreeSelectionCouseID);
  800. UnitOfWork.Remove<EM_ExecutableFreeSelectionCouseTeachingMode>(x => x.ExecutableFreeSelectionCouseID == ExecutableFreeSelectionCouse.ExecutableFreeSelectionCouseID);
  801. UnitOfWork.Remove<EM_ExecutableFreeSelectionCouseTeacher>(x => x.ExecutableFreeSelectionCouseID == ExecutableFreeSelectionCouse.ExecutableFreeSelectionCouseID);
  802. UnitOfWork.Remove<EM_ExecutableFreeSelectionCouseGradeYear>(x => x.ExecutableFreeSelectionCouseID == ExecutableFreeSelectionCouse.ExecutableFreeSelectionCouseID);
  803. UnitOfWork.Remove<EM_ExecutableFreeSelectionCouseSpecialty>(x => x.ExecutableFreeSelectionCouseID == ExecutableFreeSelectionCouse.ExecutableFreeSelectionCouseID);
  804. //UnitOfWork.Remove<EM_ExecutableFreeSelectionCouseStudent>(x => x.ExecutableFreeSelectionCouseID == ExecutableFreeSelectionCouse.ExecutableFreeSelectionCouseID);
  805. ExecutableFreeSelectionCouse.CF_Student = new HashSet<CF_Student>();
  806. UnitOfWork.Delete(ExecutableFreeSelectionCouse, (x => x.CF_Student));
  807. UnitOfWork.Remove(ExecutableFreeSelectionCouse);
  808. }
  809. this.UnitOfWork.Commit();
  810. return true;
  811. }
  812. return false;
  813. }
  814. catch (Exception)
  815. {
  816. throw;
  817. }
  818. }
  819. /// <summary>
  820. /// 开放
  821. /// </summary>
  822. /// <param name="ExecutableFreeSelectionCouseIDs"></param>
  823. /// <returns></returns>
  824. public bool ExecutableFreeSelectionCouseSubmit(List<Guid> ExecutableFreeSelectionCouseIDs)
  825. {
  826. try
  827. {
  828. var ExecutableFreeSelectionCouseList = ExecutableFreeSelectionCouseDAL.ExecutableFreeSelectionCouseRepository.GetList(x => ExecutableFreeSelectionCouseIDs.Contains(x.ExecutableFreeSelectionCouseID));
  829. foreach (var ExecutableFreeSelectionCouse in ExecutableFreeSelectionCouseList)
  830. {
  831. if (ExecutableFreeSelectionCouse.RecordStatus != (int)EMIS.ViewModel.EM_SelectCourseResultStatus.NotOpen && ExecutableFreeSelectionCouse.RecordStatus != (int)EMIS.ViewModel.EM_SelectCourseResultStatus.CancleCreate)
  832. throw new Exception("不能开放当前状态的数据,请核查");
  833. ExecutableFreeSelectionCouse.RecordStatus = (int)EMIS.ViewModel.EM_SelectCourseResultStatus.Opened;
  834. }
  835. UnitOfWork.Commit();
  836. return true;
  837. }
  838. catch (Exception)
  839. {
  840. throw;
  841. }
  842. }
  843. public List<ExecutableFreeSelectionCouseTeacherListView> GetExecutableFreeSelectionCouseTeacherListView(Guid ExecutableFreeSelectionCouseID)
  844. {
  845. var teacherView = ExecutableFreeSelectionCouseDAL.GetExecutableFreeSelectionCouseTeacherViewQueryable(x => x.ExecutableFreeSelectionCouseID == ExecutableFreeSelectionCouseID);
  846. return teacherView.ToList();
  847. }
  848. //查询专业范围
  849. public List<SpecialtyView> GetExecutableFreeSelectionCouseSpecialtyListView(Guid ExecutableFreeSelectionCouseID)
  850. {
  851. var specialtyView = ExecutableFreeSelectionCouseDAL.GetExecutableFreeSelectionCouseSpecialtyViewQueryable(x => x.ExecutableFreeSelectionCouseID == ExecutableFreeSelectionCouseID);
  852. return specialtyView.ToList();
  853. }
  854. public List<ExecutableFreeSelectionCouseSchedulingView> GetSchedulingView(Guid ExecutableFreeSelectionCouseID)
  855. {
  856. //2016年12月1日15:28:47
  857. //TODO :调整教学任务课程进度统计规则[将原按教学任务获取该教学任务下所对应的教学任务班课程进度信息调整为按对应教学任务班进行统计]
  858. //var courseViewList = this.educationMissionClassDAL.GetCourseProcessView(x => x.EducationMissionID == educationMissionID)
  859. // .OrderBy(x => x.Week).ToList();
  860. var courseViewList = this.ExecutableFreeSelectionCouseDAL.GetSchedulingView(x => x.ExecutableFreeSelectionCouseID == ExecutableFreeSelectionCouseID)
  861. .OrderBy(x => x.Weekday).ToList();
  862. return courseViewList;
  863. }
  864. public IGridResultSet<ClassroomView> GetAvailableClassroom(ConfiguretView configuretView, Guid? buildingID,
  865. string schedulingWeek,
  866. int? weekday, Guid courseTimeID, int? classroomTypeID, int? pageIndex, int? pageSize)
  867. {
  868. List<int?> schedulingWeekList = Array.ConvertAll<string, int?>(schedulingWeek.Split('-'), s => Convert.ToInt32(s)).ToList();
  869. for (int i = 1; i + schedulingWeekList.Min() < schedulingWeekList.Max(); i++)
  870. {
  871. schedulingWeekList.Add(i + schedulingWeekList.Min());
  872. }
  873. Expression<Func<CF_Classroom, bool>> exp = (x => true);
  874. if (buildingID.HasValue)
  875. {
  876. exp = exp.And(x => x.BuildingsInfoID == buildingID);
  877. }
  878. var currentSchoolyearID = SelectCourseResultDAL.GetSelectCourseSchoolyear();
  879. var classroomView = ClassroomScheduleDAL.GetAvailableClassroom(currentSchoolyearID,
  880. schedulingWeekList, weekday.Value, courseTimeID, classroomTypeID > 0 ? classroomTypeID : null);
  881. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  882. classroomView = classroomView.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
  883. return classroomView.OrderBy(x => x.BuildingsInfoName)
  884. .ThenBy(x => x.Name)
  885. .ThenBy(x => x.Totalseating).ToGridResultSet(pageIndex, pageSize);
  886. }
  887. /// <summary>
  888. /// 根据起止周次定义班号顺序
  889. /// </summary>
  890. /// <param name="SchoolyearID"></param>
  891. /// <param name="freeSelectionCourseID"></param>
  892. /// <param name="StartWeeklyNum"></param>
  893. /// <param name="EndWeeklyNum"></param>
  894. /// <returns></returns>
  895. public string DefaultClassNo(Guid SchoolyearID, Guid freeSelectionCourseID, string StartWeeklyNum, string EndWeeklyNum)
  896. {
  897. if (StartWeeklyNum != "" && EndWeeklyNum != "")
  898. {
  899. //var freeSelectionCouseApply = ExecutableFreeSelectionCouseRepository.FreeSelectionCouseApplyRepository.GetList(x => x.SchoolyearID == SchoolyearID && x.FreeSelectionCouseID == freeSelectionCourseID, x => x.EM_ExecutableFreeSelectionCouseTeachingSetting).ToList();
  900. var FreeSelectionCouseApplyTeachingSetting = ExecutableFreeSelectionCouseDAL.ExecutableFreeSelectionCouseTeachingSettingRepository.GetList(x => x.EM_ExecutableFreeSelectionCouse.SchoolyearID == SchoolyearID && x.EM_ExecutableFreeSelectionCouse.FreeSelectionCouseID == freeSelectionCourseID);
  901. var list = FreeSelectionCouseApplyTeachingSetting.Select(x => new { WeeklyNum = x.StartWeeklyNum.Value + x.EndWeeklyNum.Value }).ToList();
  902. List<int> l = new List<int> { Convert.ToInt32(StartWeeklyNum) + Convert.ToInt32(EndWeeklyNum) };
  903. list.ForEach(x => l.Add(x.WeeklyNum));
  904. l.Sort();
  905. int index = l.IndexOf(Convert.ToInt32(StartWeeklyNum) + Convert.ToInt32(EndWeeklyNum)) + 1;
  906. return index.ToString();
  907. }
  908. return "";
  909. }
  910. public void SaveTeachers(Guid executableFreeSelectionCouseID, IList<ExecutableFreeSelectionCouseTeacherListView> teacherList)
  911. {
  912. var freeSelectionCourseApply = ExecutableFreeSelectionCouseDAL.ExecutableFreeSelectionCouseRepository
  913. .GetSingle(x => x.ExecutableFreeSelectionCouseID == executableFreeSelectionCouseID, (x => x.EM_ExecutableFreeSelectionCouseTeacher));
  914. freeSelectionCourseApply.EM_ExecutableFreeSelectionCouseTeacher.ToList().ForEach(x => this.UnitOfWork.Remove(x));
  915. //teacherList.ToList().ForEach(x =>
  916. //{
  917. // var freeSelectionCourseApplyStaffEntity = new EM_FreeSelectionCouseApplyStaff
  918. // {
  919. // FreeSelectionCouseApplyStaffID = Guid.NewGuid(),
  920. // FreeSelectionCouseApplyID = freeSelectionCourseApplyID,
  921. // UserID = x.UserID,
  922. // TeachingMethod = x.TeachingMethod
  923. // };
  924. // this.SetNewStatus(freeSelectionCourseApplyStaffEntity);
  925. // this.UnitOfWork.Add(freeSelectionCourseApplyStaffEntity);
  926. //});
  927. this.UnitOfWork.Commit();
  928. }
  929. }
  930. }