OptionalCourseSettingServices.cs 53 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data.Entity;
  4. using System.Linq;
  5. using System.Linq.Expressions;
  6. using System.Text;
  7. using EMIS.DataLogic.CultureplanManage.PlanManagement;
  8. using EMIS.ViewModel.SelectCourse;
  9. using EMIS.ViewModel;
  10. using EMIS.DataLogic.SelectCourse;
  11. using EMIS.Entities;
  12. using Bowin.Common.Linq;
  13. using Bowin.Common.Linq.Entity;
  14. using EMIS.ViewModel.CacheManage;
  15. using EMIS.CommonLogic.SystemServices;
  16. using EMIS.DataLogic.GraduationManage.GraduationManage;
  17. using EMIS.DataLogic.GraduationManage.GraduationSetting;
  18. using EMIS.ViewModel.GraduationManage.GraduationManage;
  19. using EMIS.ViewModel.CultureplanManage.PlanManagement;
  20. using EMIS.DataLogic.Common.CalendarManage;
  21. using EMIS.DataLogic.UniversityManage.SpecialtyClassManage;
  22. using Bowin.Common.Exceptions;
  23. using EMIS.DataLogic.Repositories;
  24. namespace EMIS.CommonLogic.SelectCourse
  25. {
  26. public class OptionalCourseSettingServices : BaseServices, IOptionalCourseSettingServices
  27. {
  28. public ExecutableOptionalCourseTeachingSettingRepository executableOptionalCourseTeachingSettingRepository { get; set; }
  29. public ExecutableOptionalCourseTeacherRepository executableOptionalCourseTeacherRepository { get; set; }
  30. public ExecutableOptionalCourseTeachingModeRepository executableOptionalCourseTeachingModeRepository { get; set; }
  31. public ClassmajorDAL classmajorDAL { get; set; }
  32. public OptionalCourseSettingDAL optionalCourseSettingDAL { get; set; }
  33. public OptionalCoursePlanDAL optionalCoursePlanDAL { get; set; }
  34. public SchoolYearDAL schoolYearDAL { get; set; }
  35. public GrademajorDAL GrademajorDAL { get; set; }
  36. public IGridResultSet<OptionalCourseSettingView> GetOptionalCourseSettingViewGrid(ConfiguretView configuretView, Guid? collegeID, int? standardID, Guid? coursematerialID, Guid? schoolYearID, int? Years, int? Status, int? isOpened, int pageIndex, int pageSize)
  37. {
  38. Expression<Func<EM_ExecutableOptionalCourse, bool>> openControlSettingExp = (x => true);
  39. Expression<Func<EM_OptionalCoursePlan, bool>> exp = (x => true);
  40. Expression<Func<EMIS.Entities.CF_Schoolyear, bool>> schoolYearExp = (x => true);
  41. Expression<Func<CF_Grademajor, bool>> gradeMajorExp = (x => true);
  42. //IQueryable<ViewModel.SelectCourse.OptionalCourseSettingView> query =
  43. // optionalCourseSettingDAL.GetOpenControlSettingView(exp,openControlSettingExp, schoolYearExp, gradeMajorExp)
  44. // .OrderByDescending(x => x.SchoolYearCode);
  45. var query = optionalCourseSettingDAL.GetOpenControlSettingView(openControlSettingExp, exp, schoolYearExp, gradeMajorExp);
  46. if (collegeID.HasValue)
  47. query = query.Where(x => x.CollegeID == collegeID);
  48. if (standardID.HasValue)
  49. query = query.Where(x => x.StandardID == standardID);
  50. if (coursematerialID.HasValue)
  51. query = query.Where(x => x.CoursematerialID == coursematerialID);
  52. if (schoolYearID.HasValue)
  53. query = query.Where(x => x.SchoolyearID == schoolYearID);
  54. if (Years.HasValue)
  55. query = query.Where(x => x.Years == Years);
  56. if (Status.HasValue)
  57. query = query.Where(x => x.RecordStatus == Status);
  58. //if (schoolYearNumID.HasValue)
  59. // query = query.Where(x => x.SchoolyearNumID == schoolYearNumID);
  60. //if (schoolCodeID.HasValue)
  61. // query = query.Where(x => x.SchoolcodeID == schoolCodeID);
  62. //if (isEnable.HasValue)
  63. // query = query.Where(x => x.IsEnable == (isEnable == 1 ? true : false));
  64. if (isOpened.HasValue)
  65. query = query.Where(x => x.IsOpened == (isOpened == 1 ? true : false));
  66. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  67. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
  68. var result = this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.SchoolYearCode).ThenBy(x => x.GrademajorCode).
  69. ThenBy(x => x.CourseCode).ThenBy(x => x.DefaultClassName).ToGridResultSet<OptionalCourseSettingView>(pageIndex, pageSize);
  70. //var result = this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.SchoolYearCode).ThenByDescending(x => x.GrademajorCode).ThenBy(x => x.DefaultClassName).ToGridResultSet<OptionalCourseSettingView>(pageIndex, pageSize);
  71. return result;
  72. }
  73. public List<OptionalCourseSettingView> GetOptionalCourseSettingViewList(ConfiguretView configuretView, Guid? collegeID, int? standardID, Guid? coursematerialID, Guid? schoolYearID, int? Years, int? Status, int? isOpened)
  74. {
  75. Expression<Func<EM_ExecutableOptionalCourse, bool>> openControlSettingExp = (x => true);
  76. Expression<Func<EM_OptionalCoursePlan, bool>> exp = (x => true);
  77. Expression<Func<EMIS.Entities.CF_Schoolyear, bool>> schoolYearExp = (x => true);
  78. Expression<Func<CF_Grademajor, bool>> gradeMajorExp = (x => true);
  79. //IQueryable<ViewModel.SelectCourse.OptionalCourseSettingView> query =
  80. // optionalCourseSettingDAL.GetOpenControlSettingView(exp,openControlSettingExp, schoolYearExp, gradeMajorExp)
  81. // .OrderByDescending(x => x.SchoolYearCode);
  82. var query = optionalCourseSettingDAL.GetOpenControlSettingView(openControlSettingExp, exp, schoolYearExp, gradeMajorExp);
  83. if (collegeID.HasValue)
  84. query = query.Where(x => x.CollegeID == collegeID);
  85. if (standardID.HasValue)
  86. query = query.Where(x => x.StandardID == standardID);
  87. if (coursematerialID.HasValue)
  88. query = query.Where(x => x.CoursematerialID == coursematerialID);
  89. if (schoolYearID.HasValue)
  90. query = query.Where(x => x.SchoolyearID == schoolYearID);
  91. if (Years.HasValue)
  92. query = query.Where(x => x.Years == Years);
  93. if (Status.HasValue)
  94. query = query.Where(x => x.RecordStatus == Status);
  95. //if (schoolYearNumID.HasValue)
  96. // query = query.Where(x => x.SchoolyearNumID == schoolYearNumID);
  97. //if (schoolCodeID.HasValue)
  98. // query = query.Where(x => x.SchoolcodeID == schoolCodeID);
  99. //if (isEnable.HasValue)
  100. // query = query.Where(x => x.IsEnable == (isEnable == 1 ? true : false));
  101. if (isOpened.HasValue)
  102. query = query.Where(x => x.IsOpened == (isOpened == 1 ? true : false));
  103. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  104. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
  105. //var result = this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.SchoolYearCode).ThenByDescending(x => x.GrademajorCode).ThenBy(x => x.DefaultClassName).ToList();
  106. var result = this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.SchoolYearCode).ThenBy(x => x.GrademajorCode).ThenBy(x => x.CourseCode).ToList();
  107. return result;
  108. }
  109. /// <summary>
  110. /// 获取限选计划实体
  111. /// </summary>
  112. /// <param name="optionalCourseID"></param>
  113. /// <returns></returns>
  114. public EM_ExecutableOptionalCourse GetOptionalCourseSettingEntity(Guid? executableOptionalCourseID)
  115. {
  116. return optionalCourseSettingDAL.ExecutableOptionalCourseRepository.GetSingle(x => x.ExecutableOptionalCourseID == executableOptionalCourseID);
  117. }
  118. // <summary>
  119. /// 获取限选计划视图
  120. /// </summary>
  121. /// <param name="optionalCourseID"></param>
  122. /// <returns></returns>
  123. public OptionalCourseSettingView GetOptionalCourseSettingView(Guid? executableOptionalCourseID)
  124. {
  125. var query = optionalCourseSettingDAL.GetOpenControlSettingView(x => x.ExecutableOptionalCourseID == executableOptionalCourseID, x => true, x => true, x => true).FirstOrDefault();
  126. return query;
  127. }
  128. /// <summary>
  129. /// 添加
  130. /// </summary>
  131. /// <param name="specialtyPlan"></param>
  132. /// <returns></returns>
  133. public void OptionalCourseSettingCreate(OptionalCourseSettingCreateView OptionalCourseSettingView)
  134. {
  135. int susCount = 0; //成功数
  136. int susAddCount = 0; //新增数
  137. int susUpdateCount = 0; //修改数
  138. int susNoUpdateCount = 0; //不能修改数
  139. try
  140. {
  141. // var schoolYearList = this.schoolYearDAL.schoolyearRepository.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE).ToList();
  142. var courseSchoolyear = schoolYearDAL.schoolyearRepository.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE).FirstOrDefault(x => x.SchoolyearID == OptionalCourseSettingView.SchoolyearID);
  143. //所选年级专业与限选计划的专业匹配,关联出限选计划
  144. Expression<Func<CF_Grademajor, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  145. Expression<Func<EM_OptionalCoursePlan, bool>> opExp = (x => x.IsEnable == true);//&& x.RecordStatus > 0);
  146. var query = optionalCoursePlanDAL.GetGrademajorOptionalCoursePlanViewQueryable(opExp, exp);
  147. if (OptionalCourseSettingView.GrademajorID != null) //年级专业不为空时,以年级专业和学年学期为条件查询专业计划表
  148. {
  149. query = query.Where(x => x.GrademajorID == OptionalCourseSettingView.GrademajorID);
  150. }
  151. else //年级专业为空时,以学年学期为关键条件,联合校区、院系所、年级、专业代码查询专业计划表
  152. {
  153. if (OptionalCourseSettingView.CampusID != null)
  154. {
  155. query = query.Where(x => x.CampusID == OptionalCourseSettingView.CampusID);
  156. }
  157. if (OptionalCourseSettingView.CollegeID != null)
  158. {
  159. query = query.Where(x => x.CollegeID == OptionalCourseSettingView.CollegeID);
  160. }
  161. if (OptionalCourseSettingView.Years != null)
  162. {
  163. query = query.Where(x => x.Years == OptionalCourseSettingView.Years);
  164. }
  165. if (OptionalCourseSettingView.StandardID != null)
  166. {
  167. query = query.Where(x => x.StandardID == OptionalCourseSettingView.StandardID);
  168. }
  169. }
  170. if (OptionalCourseSettingView.CoursematerialID != null)
  171. {
  172. query = query.Where(x => x.CoursematerialID == OptionalCourseSettingView.CoursematerialID);
  173. }
  174. query = query.Where(x => x.SchoolValue == courseSchoolyear.Value);
  175. List<OptionalCoursePlanView> optionalCoursePlanViewList = query.ToList();
  176. var executableOptionalCourseList = query.Join(optionalCourseSettingDAL.ExecutableOptionalCourseRepository.Entities,
  177. (x => new { OptionalCourseID = (Guid?)x.OptionalCourseID, x.GrademajorID, SchoolyearID = OptionalCourseSettingView.SchoolyearID }),
  178. (x => new { x.OptionalCourseID, x.GrademajorID, x.SchoolyearID }),
  179. (x, y) => y).Include(x => x.EM_ExecutableOptionalCourseTeachingSetting).ToList();
  180. if (optionalCoursePlanViewList == null || optionalCoursePlanViewList.Count < 1)
  181. {
  182. throw new Exception("未能匹配到已启用但未生成的限选计划数据,请核查。");
  183. }
  184. var insertList = new List<EM_ExecutableOptionalCourse>();
  185. var insertTeachingSettingList = new List<EM_ExecutableOptionalCourseTeachingSetting>();
  186. var insertTeachingModeList = new List<EM_ExecutableOptionalCourseTeachingMode>();
  187. var updateList = new List<EM_ExecutableOptionalCourse>();
  188. var updateTechingSettingList = new List<EM_ExecutableOptionalCourseTeachingSetting>();
  189. foreach (var optionalCourse in optionalCoursePlanViewList)
  190. {
  191. EM_ExecutableOptionalCourse executableOptionalCourse = executableOptionalCourseList.FirstOrDefault(
  192. x => x.OptionalCourseID == optionalCourse.OptionalCourseID && x.GrademajorID == optionalCourse.GrademajorID && x.SchoolyearID == OptionalCourseSettingView.SchoolyearID);
  193. if (executableOptionalCourse != null)
  194. {
  195. if (executableOptionalCourse.RecordStatus == (int)EM_SelectCourseResultStatus.NotOpen)
  196. {
  197. EM_ExecutableOptionalCourseTeachingSetting ExecutableOptionalCourseTeachingSetting = executableOptionalCourse.EM_ExecutableOptionalCourseTeachingSetting;
  198. ExecutableOptionalCourseTeachingSetting.Credit = optionalCourse.Credit;
  199. ExecutableOptionalCourseTeachingSetting.TheoryCourse = optionalCourse.TheoryCourse;
  200. ExecutableOptionalCourseTeachingSetting.Practicehours = optionalCourse.Practicehours;
  201. ExecutableOptionalCourseTeachingSetting.Trialhours = optionalCourse.Trialhours;
  202. ExecutableOptionalCourseTeachingSetting.WeeklyNum = optionalCourse.WeeklyNum;
  203. ExecutableOptionalCourseTeachingSetting.TheoryWeeklyNum = optionalCourse.TheoryWeeklyNum;
  204. ExecutableOptionalCourseTeachingSetting.PracticeWeeklyNum = optionalCourse.PracticeWeeklyNum;
  205. ExecutableOptionalCourseTeachingSetting.TrialWeeklyNum = optionalCourse.TrialWeeklyNum;
  206. ExecutableOptionalCourseTeachingSetting.StartWeeklyNum = optionalCourse.StartWeeklyNum;
  207. ExecutableOptionalCourseTeachingSetting.EndWeeklyNum = optionalCourse.EndWeeklyNum;
  208. ExecutableOptionalCourseTeachingSetting.WeeklyHours = optionalCourse.WeeklyHours;
  209. SetModifyStatus(executableOptionalCourse);
  210. executableOptionalCourse.RecordStatus = (int)EM_SelectCourseResultStatus.NotOpen;
  211. susUpdateCount++;
  212. updateTechingSettingList.Add(ExecutableOptionalCourseTeachingSetting);
  213. updateList.Add(executableOptionalCourse);
  214. }
  215. else
  216. {
  217. susNoUpdateCount++;
  218. }
  219. }
  220. else
  221. {
  222. executableOptionalCourse = new EM_ExecutableOptionalCourse();
  223. executableOptionalCourse.ExecutableOptionalCourseID = Guid.NewGuid();
  224. executableOptionalCourse.DefaultClassName = optionalCourse.DefaultClassName + "_" + optionalCourse.CourseName + "(限选)";
  225. executableOptionalCourse.IsEnable = false;
  226. executableOptionalCourse.IsOpened = false;
  227. SetNewStatus(executableOptionalCourse);
  228. executableOptionalCourse.RecordStatus = (int)EM_SelectCourseResultStatus.NotOpen;
  229. //插入限选设定关联班数据
  230. CF_Classmajor clas = GetClassmajor(optionalCourse.ClassmajorID);
  231. if (clas != null)
  232. {
  233. executableOptionalCourse.CF_Classmajor = new HashSet<CF_Classmajor>();
  234. executableOptionalCourse.CF_Classmajor.Add(clas);
  235. }
  236. susAddCount++;
  237. executableOptionalCourse.GrademajorID = optionalCourse.GrademajorID;
  238. executableOptionalCourse.OptionalCourseID = optionalCourse.OptionalCourseID;
  239. executableOptionalCourse.SchoolyearID = OptionalCourseSettingView.SchoolyearID;
  240. executableOptionalCourse.DepartmentID = optionalCourse.DepartmentID;
  241. executableOptionalCourse.CourseStructureID = optionalCourse.CourseStructureID;
  242. executableOptionalCourse.CourseCategoryID = optionalCourse.CourseCategoryID;
  243. executableOptionalCourse.CourseTypeID = optionalCourse.CourseTypeID;
  244. executableOptionalCourse.CourseQualityID = optionalCourse.CourseQualityID;
  245. executableOptionalCourse.PracticeTypeID = optionalCourse.PracticeTypeID;
  246. executableOptionalCourse.ExaminationModeID = optionalCourse.ExaminationModeID;
  247. executableOptionalCourse.TeachinglanguageID = optionalCourse.TeachinglanguageID;
  248. executableOptionalCourse.PeopleNumlower = optionalCourse.PeopleNumlower;
  249. executableOptionalCourse.PeopleNumlimit = optionalCourse.PeopleNumlimit;
  250. executableOptionalCourse.ResultTypeID = optionalCourse.ResultTypeID;
  251. insertList.Add(executableOptionalCourse);
  252. EM_ExecutableOptionalCourseTeachingSetting optionalCourseTeachingSetting = new EM_ExecutableOptionalCourseTeachingSetting();
  253. optionalCourseTeachingSetting.ExecutableOptionalCourseID = executableOptionalCourse.ExecutableOptionalCourseID;
  254. optionalCourseTeachingSetting.Credit = optionalCourse.Credit;
  255. optionalCourseTeachingSetting.TheoryCourse = optionalCourse.TheoryCourse;
  256. optionalCourseTeachingSetting.Practicehours = optionalCourse.Practicehours;
  257. optionalCourseTeachingSetting.Trialhours = optionalCourse.Trialhours;
  258. optionalCourseTeachingSetting.WeeklyNum = optionalCourse.WeeklyNum;
  259. optionalCourseTeachingSetting.TheoryWeeklyNum = optionalCourse.TheoryWeeklyNum;
  260. optionalCourseTeachingSetting.PracticeWeeklyNum = optionalCourse.PracticeWeeklyNum;
  261. optionalCourseTeachingSetting.TrialWeeklyNum = optionalCourse.TrialWeeklyNum;
  262. optionalCourseTeachingSetting.StartWeeklyNum = optionalCourse.StartWeeklyNum;
  263. optionalCourseTeachingSetting.EndWeeklyNum = optionalCourse.EndWeeklyNum;
  264. optionalCourseTeachingSetting.WeeklyHours = optionalCourse.WeeklyHours;
  265. insertTeachingSettingList.Add(optionalCourseTeachingSetting);
  266. if (optionalCourse.TeachingModeID != null)
  267. {
  268. foreach (var i in optionalCourse.TeachingModeID)
  269. {
  270. EM_ExecutableOptionalCourseTeachingMode optionalCourseTeachingMode = new EM_ExecutableOptionalCourseTeachingMode();
  271. optionalCourseTeachingMode.ExecutableOptionalCourseTeachingModeID = Guid.NewGuid();
  272. optionalCourseTeachingMode.ExecutableOptionalCourseID = executableOptionalCourse.ExecutableOptionalCourseID;
  273. optionalCourseTeachingMode.TeachingModeID = i;
  274. SetNewStatus(optionalCourseTeachingMode);
  275. insertTeachingModeList.Add(optionalCourseTeachingMode);
  276. }
  277. }
  278. }
  279. susCount++;
  280. }
  281. UnitOfWork.BatchUpdate(updateList);
  282. UnitOfWork.BatchUpdate(updateTechingSettingList);
  283. UnitOfWork.BulkInsert(insertList);
  284. UnitOfWork.BulkInsert(insertTeachingSettingList);
  285. UnitOfWork.BulkInsert(insertTeachingModeList);
  286. //UnitOfWork.Commit();
  287. if (susNoUpdateCount > 0)
  288. {
  289. throw new SuccessException(string.Format("保存成功{0}条记录,其中新增{1}条,更新{2}条,有{3}条已开放,不能修改。", susCount, susAddCount, susUpdateCount,susNoUpdateCount));
  290. }
  291. else
  292. throw new SuccessException(string.Format("保存成功{0}条记录,其中新增{1}条,更新{2}条。", susCount, susAddCount, susUpdateCount));
  293. //throw new SuccessException(string.Format("新增{0}条。", susAddCount));
  294. }
  295. catch (Exception ex)
  296. {
  297. throw;
  298. //throw new Exception(string.Format("保存成功{0}条记录,第{1}条出错," + ex.Message, susCount, susCount + 1));
  299. }
  300. }
  301. /// <summary>
  302. /// 更新
  303. /// </summary>
  304. /// <param name="optionalCourseSettingView"></param>
  305. /// <returns></returns>
  306. public void OptionalCourseSettingUpdate(OptionalCourseSettingView optionalCourseSettingView, IList<OptionalCourseTeacherListView> teacherList, IList<OptionalCourseClassListView> classList)
  307. {
  308. try
  309. {
  310. if (optionalCourseSettingView.ExecutableOptionalCourseID != null && optionalCourseSettingView.ExecutableOptionalCourseID != Guid.Empty)
  311. {
  312. EM_ExecutableOptionalCourse optionalCoursePlan = GetOptionalCourseSettingEntity(optionalCourseSettingView.ExecutableOptionalCourseID);
  313. //EM_ExecutableOptionalCourseTeachingMode optionalCourseTeachingMode = executableOptionalCourseTeachingModeRepository.Entities.Where(x => x.ExecutableOptionalCourseID == optionalCoursePlan.ExecutableOptionalCourseID).SingleOrDefault();
  314. EM_ExecutableOptionalCourseTeachingSetting optionalCourseTeachingSetting = executableOptionalCourseTeachingSettingRepository.Entities.Where(x => x.ExecutableOptionalCourseID == optionalCoursePlan.ExecutableOptionalCourseID).SingleOrDefault();
  315. //EM_ExecutableOptionalCourseTeacher optionalCourseTeacher = executableOptionalCourseTeacherRepository.Entities.Where(x=>x.ExecutableOptionalCourseID==optionalCoursePlan.ExecutableOptionalCourseID).SingleOrDefault();
  316. //CF_Classmajor clas=GetClassmajor(optionalCourseSettingView.ClassmajorID);
  317. //var classList = GetClassmajorList(optionalCourseSettingView.ExecutableOptionalCourseID);
  318. if (optionalCoursePlan != null)
  319. {
  320. //if (optionalCoursePlan.IsOpened == true && optionalCoursePlan.RecordStatus == (int)EMIS.ViewModel.EM_SelectCourseResultStatus.NotOpen)
  321. // throw new Exception("只能开放“已提交”状态的数据,请核查,请核查。");
  322. //var query = optionalCourseSettingDAL.GetOpenControlSettingClassmajorView(x => x.RecordStatus > 0 && x.ExecutableOptionalCourseID == optionalCoursePlan.ExecutableOptionalCourseID).ToList();
  323. var query = optionalCourseSettingDAL.GetExecutableOptionalCourseClassmajorList().Where(x => x.ExecutableOptionalCourseID == optionalCoursePlan.ExecutableOptionalCourseID).ToList();
  324. optionalCoursePlan.CF_Classmajor = new HashSet<CF_Classmajor>();
  325. if (query.Count > 0 && classList.Count > 0)
  326. {
  327. //if (optionalCourseSettingIDs.Count > 0)
  328. //{
  329. // for (int i = 0; i < optionalCourseSettingIDs.Count; i++)
  330. // {
  331. // Guid optionalCourseSettingID = optionalCourseSettingIDs[i];
  332. // var executableOptionalCourse = optionalCourseSettingDAL.executableOptionalCourseRepository.GetSingle(
  333. // x => x.ExecutableOptionalCourseID == optionalCourseSettingID);
  334. // executableOptionalCourse.CF_Classmajor = new HashSet<CF_Classmajor>();
  335. // UnitOfWork.Delete(executableOptionalCourse, (x => x.CF_Classmajor));
  336. // }
  337. //}
  338. //optionalCoursePlan.CF_Classmajor.Clear();
  339. //optionalCoursePlan.CF_Classmajor.r;
  340. //删除限选设定关联班数据
  341. UnitOfWork.Delete(optionalCoursePlan, (x => x.CF_Classmajor));
  342. }
  343. optionalCoursePlan.CF_Classmajor = new HashSet<CF_Classmajor>();
  344. //插入限选设定关联班数据
  345. foreach (var list in classList)
  346. {
  347. CF_Classmajor clas = GetClassmajor(list.ClassmajorID);
  348. optionalCoursePlan.CF_Classmajor.Add(clas);
  349. }
  350. optionalCoursePlan.DefaultClassName = optionalCourseSettingView.DefaultClassName;
  351. optionalCoursePlan.DepartmentID = optionalCourseSettingView.DepartmentID;
  352. optionalCoursePlan.CourseStructureID = optionalCourseSettingView.CourseStructureID;
  353. optionalCoursePlan.CourseCategoryID = optionalCourseSettingView.CourseCategoryID;
  354. optionalCoursePlan.CourseTypeID = optionalCourseSettingView.CourseTypeID;
  355. optionalCoursePlan.CourseQualityID = optionalCourseSettingView.CourseQualityID;
  356. optionalCoursePlan.PracticeTypeID = optionalCourseSettingView.PracticeTypeID;
  357. optionalCoursePlan.ExaminationModeID = optionalCourseSettingView.ExaminationModeID;
  358. optionalCoursePlan.TeachinglanguageID = optionalCourseSettingView.TeachinglanguageID;
  359. optionalCoursePlan.IsEnable = optionalCourseSettingView.IsEnable;
  360. //optionalCoursePlan.No = optionalCourseSettingView.No;
  361. //optionalCoursePlan.HandleModeID = optionalCourseSettingView.HandleModeID;
  362. //optionalCoursePlan.IsNeedMaterial = optionalCourseSettingView.IsNeedMaterial;
  363. optionalCoursePlan.PeopleNumlower = optionalCourseSettingView.PeopleNumlower;
  364. optionalCoursePlan.PeopleNumlimit = optionalCourseSettingView.PeopleNumlimit;
  365. optionalCoursePlan.IsOpened = optionalCourseSettingView.IsOpened;
  366. optionalCoursePlan.ResultTypeID = optionalCourseSettingView.ResultTypeID;
  367. optionalCoursePlan.Remarks = optionalCourseSettingView.Remarks;
  368. if (optionalCourseSettingView.TeachingModeID != null)
  369. {
  370. UnitOfWork.Delete<EM_ExecutableOptionalCourseTeachingMode>(x => x.ExecutableOptionalCourseID == optionalCourseSettingView.ExecutableOptionalCourseID);
  371. foreach (var i in optionalCourseSettingView.TeachingModeID)
  372. {
  373. EM_ExecutableOptionalCourseTeachingMode optionalCourseTeachingMode = new EM_ExecutableOptionalCourseTeachingMode();
  374. optionalCourseTeachingMode.ExecutableOptionalCourseTeachingModeID = Guid.NewGuid();
  375. optionalCourseTeachingMode.ExecutableOptionalCourseID = optionalCoursePlan.ExecutableOptionalCourseID;
  376. optionalCourseTeachingMode.TeachingModeID = i;
  377. SetNewStatus(optionalCourseTeachingMode);
  378. UnitOfWork.Add(optionalCourseTeachingMode);
  379. }
  380. }
  381. //限选设定授课方式表
  382. //if (optionalCourseTeachingMode != null)
  383. //{
  384. // SetModifyStatus(optionalCourseTeachingMode);
  385. //}
  386. //else
  387. //{
  388. // optionalCourseTeachingMode = new EM_ExecutableOptionalCourseTeachingMode();
  389. // optionalCourseTeachingMode.ExecutableOptionalCourseTeachingModeID = Guid.NewGuid();
  390. // optionalCourseTeachingMode.ExecutableOptionalCourseID = optionalCoursePlan.ExecutableOptionalCourseID;
  391. // optionalCourseTeachingMode.TeachingModeID = optionalCourseSettingView.TeachingModeID;
  392. // SetNewStatus(optionalCourseTeachingMode);
  393. // UnitOfWork.Add(optionalCourseTeachingMode);
  394. //}
  395. //optionalCourseTeachingMode.TeachingModeID = optionalCourseSettingView.TeachingModeID;
  396. ////限选设定授课老师表
  397. //if (optionalCourseTeacher != null)
  398. //{
  399. // SetModifyStatus(optionalCourseTeacher);
  400. //}
  401. //else
  402. //{
  403. // optionalCourseTeacher = new EM_ExecutableOptionalCourseTeacher();
  404. // optionalCourseTeacher.ExecutableOptionalCourseTeacherID = Guid.NewGuid();
  405. // optionalCourseTeacher.ExecutableOptionalCourseID = optionalCoursePlan.ExecutableOptionalCourseID;
  406. // SetNewStatus(optionalCourseTeacher);
  407. // UnitOfWork.Add(optionalCourseTeacher);
  408. //}
  409. ////optionalCourseTeacher.UserID = optionalCourseSettingView.TeacherID;
  410. //optionalCourseTeacher.TeachingMethod = optionalCourseSettingView.TeachingMethod;
  411. //删除教师
  412. UnitOfWork.Delete<EM_ExecutableOptionalCourseTeacher>(x => x.ExecutableOptionalCourseID == optionalCoursePlan.ExecutableOptionalCourseID);
  413. //添加教师
  414. if (teacherList.Count > 0)
  415. {
  416. foreach (var teacher in teacherList)
  417. {
  418. EM_ExecutableOptionalCourseTeacher executableOptionalCourseTeacher = new EM_ExecutableOptionalCourseTeacher();
  419. executableOptionalCourseTeacher.ExecutableOptionalCourseTeacherID = Guid.NewGuid();
  420. executableOptionalCourseTeacher.ExecutableOptionalCourseID = optionalCoursePlan.ExecutableOptionalCourseID;
  421. executableOptionalCourseTeacher.UserID = teacher.UserID;
  422. executableOptionalCourseTeacher.TeachingMethod = teacher.TeachingMethod;
  423. SetNewStatus(executableOptionalCourseTeacher);
  424. UnitOfWork.Add(executableOptionalCourseTeacher);
  425. }
  426. }
  427. //限选设定教学设置表
  428. if (optionalCourseTeachingSetting != null)
  429. {
  430. UnitOfWork.Update(optionalCourseTeachingSetting);
  431. }
  432. else
  433. {
  434. optionalCourseTeachingSetting = new EM_ExecutableOptionalCourseTeachingSetting();
  435. optionalCourseTeachingSetting.ExecutableOptionalCourseID = optionalCourseSettingView.ExecutableOptionalCourseID.Value;
  436. UnitOfWork.Add(optionalCourseTeachingSetting);
  437. }
  438. optionalCourseTeachingSetting.Credit = optionalCourseSettingView.Credit;
  439. optionalCourseTeachingSetting.TheoryCourse = optionalCourseSettingView.TheoryCourse;
  440. optionalCourseTeachingSetting.Practicehours = optionalCourseSettingView.Practicehours;
  441. optionalCourseTeachingSetting.Trialhours = optionalCourseSettingView.Trialhours;
  442. optionalCourseTeachingSetting.WeeklyNum = optionalCourseSettingView.WeeklyNum;
  443. if (optionalCourseSettingView.WeeklyNum == 0 || optionalCourseSettingView.WeeklyNum == null)
  444. {
  445. var t = (optionalCourseSettingView.TheoryCourse.Value + optionalCourseSettingView.Practicehours.Value);
  446. var w = (optionalCourseSettingView.TheoryWeeklyNum.Value + optionalCourseSettingView.PracticeWeeklyNum.Value);
  447. if (w != 0 && t != 0)
  448. optionalCourseTeachingSetting.WeeklyNum = t / w / 2;
  449. }
  450. optionalCourseTeachingSetting.TheoryWeeklyNum = optionalCourseSettingView.TheoryWeeklyNum;
  451. optionalCourseTeachingSetting.PracticeWeeklyNum = optionalCourseSettingView.PracticeWeeklyNum;
  452. optionalCourseTeachingSetting.TrialWeeklyNum = optionalCourseSettingView.TrialWeeklyNum;
  453. optionalCourseTeachingSetting.StartWeeklyNum = optionalCourseSettingView.StartWeeklyNum;
  454. optionalCourseTeachingSetting.EndWeeklyNum = optionalCourseSettingView.EndWeeklyNum;
  455. optionalCourseTeachingSetting.WeeklyHours = optionalCourseSettingView.WeeklyHours;
  456. this.SetModifyStatus(optionalCoursePlan);
  457. UnitOfWork.Commit();
  458. }
  459. }
  460. else
  461. {
  462. var optionalCourse=optionalCourseSettingDAL.ExecutableOptionalCourseRepository.GetSingle(
  463. x => x.OptionalCourseID==optionalCourseSettingView.OptionalCourseID
  464. &&x.SchoolyearID==optionalCourseSettingView.SchoolyearID
  465. &&x.GrademajorID==optionalCourseSettingView.GrademajorID);
  466. if (optionalCourse!=null)
  467. {
  468. throw new Exception("已存在重复的数据。");
  469. }
  470. EM_ExecutableOptionalCourse optionalCoursePlan = new EM_ExecutableOptionalCourse();
  471. optionalCoursePlan.ExecutableOptionalCourseID = Guid.NewGuid();
  472. optionalCoursePlan.OptionalCourseID = optionalCourseSettingView.OptionalCourseID;
  473. optionalCoursePlan.SchoolyearID = optionalCourseSettingView.SchoolyearID;
  474. optionalCoursePlan.GrademajorID = optionalCourseSettingView.GrademajorID;
  475. optionalCoursePlan.DepartmentID = optionalCourseSettingView.DepartmentID;
  476. optionalCoursePlan.DefaultClassName = optionalCourseSettingView.DefaultClassName;
  477. optionalCoursePlan.CourseStructureID=optionalCourseSettingView.CourseStructureID;
  478. optionalCoursePlan.CourseCategoryID=optionalCourseSettingView.CourseCategoryID;
  479. optionalCoursePlan.CourseTypeID=optionalCourseSettingView.CourseTypeID;
  480. optionalCoursePlan.CourseQualityID=optionalCourseSettingView.CourseQualityID;
  481. optionalCoursePlan.PracticeTypeID=optionalCourseSettingView.PracticeTypeID;
  482. optionalCoursePlan.ExaminationModeID=optionalCourseSettingView.ExaminationModeID;
  483. optionalCoursePlan.TeachinglanguageID=optionalCourseSettingView.TeachinglanguageID;
  484. optionalCoursePlan.IsEnable = optionalCourseSettingView.IsEnable;
  485. optionalCoursePlan.ResultTypeID=optionalCourseSettingView.ResultTypeID;
  486. optionalCoursePlan.Remarks=optionalCourseSettingView.Remarks;
  487. optionalCoursePlan.PeopleNumlimit=optionalCourseSettingView.PeopleNumlimit;
  488. optionalCoursePlan.PeopleNumlower=optionalCourseSettingView.PeopleNumlower;
  489. optionalCoursePlan.IsOpened = optionalCourseSettingView.IsOpened;
  490. this.SetNewStatus(optionalCoursePlan);
  491. optionalCoursePlan.CF_Classmajor = new HashSet<CF_Classmajor>();
  492. //插入限选设定关联班数据
  493. foreach (var list in classList)
  494. {
  495. CF_Classmajor clas = GetClassmajor(list.ClassmajorID);
  496. optionalCoursePlan.CF_Classmajor.Add(clas);
  497. }
  498. UnitOfWork.Add(optionalCoursePlan);
  499. if (optionalCourseSettingView.TeachingModeID != null)
  500. {
  501. foreach (var i in optionalCourseSettingView.TeachingModeID)
  502. {
  503. EM_ExecutableOptionalCourseTeachingMode optionalCourseTeachingMode = new EM_ExecutableOptionalCourseTeachingMode();
  504. optionalCourseTeachingMode.ExecutableOptionalCourseTeachingModeID = Guid.NewGuid();
  505. optionalCourseTeachingMode.ExecutableOptionalCourseID = optionalCoursePlan.ExecutableOptionalCourseID;
  506. optionalCourseTeachingMode.TeachingModeID = i;
  507. SetNewStatus(optionalCourseTeachingMode);
  508. UnitOfWork.Add(optionalCourseTeachingMode);
  509. }
  510. }
  511. if (teacherList.Count > 0)
  512. {
  513. foreach (var teacher in teacherList)
  514. {
  515. EM_ExecutableOptionalCourseTeacher executableOptionalCourseTeacher = new EM_ExecutableOptionalCourseTeacher();
  516. executableOptionalCourseTeacher.ExecutableOptionalCourseTeacherID = Guid.NewGuid();
  517. executableOptionalCourseTeacher.ExecutableOptionalCourseID = optionalCoursePlan.ExecutableOptionalCourseID;
  518. executableOptionalCourseTeacher.UserID = teacher.UserID;
  519. executableOptionalCourseTeacher.TeachingMethod = teacher.TeachingMethod;
  520. SetNewStatus(executableOptionalCourseTeacher);
  521. UnitOfWork.Add(executableOptionalCourseTeacher);
  522. }
  523. }
  524. EM_ExecutableOptionalCourseTeachingSetting optionalCourseTeachingSetting = new EM_ExecutableOptionalCourseTeachingSetting();
  525. optionalCourseTeachingSetting.ExecutableOptionalCourseID = optionalCoursePlan.ExecutableOptionalCourseID;
  526. optionalCourseTeachingSetting.Credit = optionalCourseSettingView.Credit;
  527. optionalCourseTeachingSetting.TheoryCourse = optionalCourseSettingView.TheoryCourse;
  528. optionalCourseTeachingSetting.Practicehours = optionalCourseSettingView.Practicehours;
  529. optionalCourseTeachingSetting.Trialhours = optionalCourseSettingView.Trialhours;
  530. optionalCourseTeachingSetting.WeeklyNum = optionalCourseSettingView.WeeklyNum;
  531. if (optionalCourseSettingView.WeeklyNum == 0 || optionalCourseSettingView.WeeklyNum == null)
  532. {
  533. var t = (optionalCourseSettingView.TheoryCourse.Value + optionalCourseSettingView.Practicehours.Value);
  534. var w = (optionalCourseSettingView.TheoryWeeklyNum.Value + optionalCourseSettingView.PracticeWeeklyNum.Value);
  535. if (w != 0 && t != 0)
  536. optionalCourseTeachingSetting.WeeklyNum = t / w / 2;
  537. }
  538. optionalCourseTeachingSetting.TheoryWeeklyNum = optionalCourseSettingView.TheoryWeeklyNum;
  539. optionalCourseTeachingSetting.PracticeWeeklyNum = optionalCourseSettingView.PracticeWeeklyNum;
  540. optionalCourseTeachingSetting.TrialWeeklyNum = optionalCourseSettingView.TrialWeeklyNum;
  541. optionalCourseTeachingSetting.StartWeeklyNum = optionalCourseSettingView.StartWeeklyNum;
  542. optionalCourseTeachingSetting.EndWeeklyNum = optionalCourseSettingView.EndWeeklyNum;
  543. optionalCourseTeachingSetting.WeeklyHours = optionalCourseSettingView.WeeklyHours;
  544. UnitOfWork.Commit();
  545. }
  546. }
  547. catch (Exception)
  548. {
  549. throw;
  550. }
  551. }
  552. public List<string> GetTeachingModeType(Guid? specialtyCourseID)
  553. {
  554. return optionalCourseSettingDAL.GetTeachingModeTypeQueryble(specialtyCourseID);
  555. }
  556. /// <summary>
  557. /// 删除
  558. /// </summary>
  559. /// <param name="optionalCourseIDs"></param>
  560. /// <returns></returns>
  561. public bool OptionalCourseSettingDelete(List<Guid> optionalCourseSettingIDs)
  562. {
  563. try
  564. {
  565. if (optionalCourseSettingIDs.Count > 0)
  566. {
  567. for (int i = 0; i < optionalCourseSettingIDs.Count; i++)
  568. {
  569. Guid optionalCourseSettingID = optionalCourseSettingIDs[i];
  570. var executableOptionalCourse = optionalCourseSettingDAL.ExecutableOptionalCourseRepository.GetSingle(
  571. x => x.ExecutableOptionalCourseID == optionalCourseSettingID);
  572. if (executableOptionalCourse != null)
  573. {
  574. if (executableOptionalCourse.RecordStatus > (int)EMIS.ViewModel.EM_SelectCourseResultStatus.NotOpen)
  575. throw new Exception("只能删除未开放状态的信息。");
  576. //if (executableOptionalCourse.IsEnable==true)
  577. // throw new Exception("该限选已启用不能能删除。");
  578. if (executableOptionalCourse.RecordStatus == (int)EMIS.ViewModel.EM_SelectCourseResultStatus.Opened)
  579. throw new Exception("只能删除未开放状态的信息。");
  580. }
  581. executableOptionalCourse.CF_Classmajor = new HashSet<CF_Classmajor>();
  582. executableOptionalCourse.CF_Student = new HashSet<CF_Student>();
  583. UnitOfWork.Delete(executableOptionalCourse, (x => x.CF_Classmajor));
  584. UnitOfWork.Delete(executableOptionalCourse, (x => x.CF_Student));
  585. }
  586. //EM_ExecutableOptionalCourse em = new EM_ExecutableOptionalCourse();
  587. //em.CF_Classmajor = new HashSet<CF_Classmajor>();
  588. ////optionalCoursePlan.CF_Classmajor.Clear();
  589. ////optionalCoursePlan.CF_Classmajor.r;
  590. //UnitOfWork.Delete(em.ExecutableOptionalCourseID., x => x.CF_Classmajor);
  591. //限选设定教学设置表
  592. UnitOfWork.Delete<EM_ExecutableOptionalCourseTeachingSetting>(x => optionalCourseSettingIDs.Contains(x.ExecutableOptionalCourseID));
  593. //限选设定授课老师表
  594. UnitOfWork.Delete<EM_ExecutableOptionalCourseTeacher>(x => optionalCourseSettingIDs.Contains(x.ExecutableOptionalCourseID.Value));
  595. //限选设定授课方式表
  596. UnitOfWork.Delete<EM_ExecutableOptionalCourseTeachingMode>(x => optionalCourseSettingIDs.Contains(x.ExecutableOptionalCourseID.Value));
  597. //限选计划
  598. UnitOfWork.Delete<EM_ExecutableOptionalCourse>(x => optionalCourseSettingIDs.Contains(x.ExecutableOptionalCourseID));
  599. return true;
  600. }
  601. return false;
  602. }
  603. catch (Exception)
  604. {
  605. throw;
  606. }
  607. }
  608. /// <summary>
  609. /// 现在是开放操作
  610. /// </summary>
  611. /// <param name="optionalCourseIDs"></param>
  612. /// <returns></returns>
  613. public bool OptionalCourseSettingSubmit(List<Guid> optionalCourseSettingIDs)
  614. {
  615. try
  616. {
  617. if (optionalCourseSettingIDs.Count > 0)
  618. {
  619. //Expression<Func<EM_ExecutableOptionalCourse, bool>> exp = (x => true);
  620. //Expression<Func<EM_OptionalCoursePlan, bool>> exp1 = (x => true);
  621. //Expression<Func<EMIS.Entities.CF_Schoolyear, bool>> exp2 = (x => true);
  622. //Expression<Func<CF_Grademajor, bool>> exp3 = (x => true);
  623. for (int i = 0; i < optionalCourseSettingIDs.Count; i++)
  624. {
  625. Guid optionalCourseSettingID = optionalCourseSettingIDs[i];
  626. var executableOptionalCourse = optionalCourseSettingDAL.ExecutableOptionalCourseRepository.GetSingle(
  627. x => x.ExecutableOptionalCourseID == optionalCourseSettingID && (x.RecordStatus == (int)EMIS.ViewModel.EM_SelectCourseResultStatus.NotOpen || x.RecordStatus == (int)EMIS.ViewModel.EM_SelectCourseResultStatus.CancleCreate));
  628. if (executableOptionalCourse != null)
  629. {
  630. EM_OptionalCoursePlan ocp = optionalCoursePlanDAL.OptionalCoursePlanRepository.GetSingle(x => x.OptionalCourseID == executableOptionalCourse.OptionalCourseID);
  631. //查询要开放的限选设定及相关班级
  632. var query = optionalCourseSettingDAL.GetSubmitcompareClassmajor().Where(x => x.ExecutableOptionalCourseID == executableOptionalCourse.ExecutableOptionalCourseID);
  633. List<Guid> clas = query.Select(x => x.ClassmajorID).ToList(); //相关班级ID
  634. //查询所有限选设定及相关班级
  635. var query1 = optionalCourseSettingDAL.GetSubmitcompareClassmajor().Where(x =>
  636. x.ExecutableOptionalCourseID != executableOptionalCourse.ExecutableOptionalCourseID &&
  637. x.SchoolyearID == executableOptionalCourse.SchoolyearID &&
  638. x.CoursematerialID == ocp.CoursematerialID);
  639. var list = query1.ToList();
  640. //查询要开放的限选设定及相关授课老师ID
  641. var teacherList = optionalCourseSettingDAL.GetEducationMissionClassTeacherListViewQueryble().
  642. Where(x => x.ExecutableOptionalCourseID == executableOptionalCourse.ExecutableOptionalCourseID).
  643. Select(x => x.UserID).ToList();
  644. if (teacherList.Count > 0) //有授课老师才进行判断
  645. {
  646. //查询要开放的数据中班级是否有重复
  647. var result = list.Where(x => optionalCourseSettingIDs.Contains(x.ExecutableOptionalCourseID) && clas.Contains(x.ClassmajorID)).ToList();
  648. if (result.Count > 0)
  649. { //班级重复的数据中查询老师是否也是重复
  650. var IDs = result.Select(x => x.ExecutableOptionalCourseID).ToList();
  651. var teacher = optionalCourseSettingDAL.ExecutableOptionalCourseRepository.Entities.Where(x =>
  652. IDs.Contains(x.ExecutableOptionalCourseID) &&
  653. x.ExecutableOptionalCourseID != executableOptionalCourse.ExecutableOptionalCourseID &&
  654. x.EM_ExecutableOptionalCourseTeacher.Count() == teacherList.Count &&
  655. x.EM_ExecutableOptionalCourseTeacher.Count() == (x.EM_ExecutableOptionalCourseTeacher.
  656. Where(w => teacherList.Contains(w.UserID.Value)).Count()));
  657. if (teacher.ToList().Count > 0)
  658. throw new Exception(string.Format("【{0}】和【{1}】存在相同的开放班级和授课老师,请核查。", result[0].DefaultClassName, executableOptionalCourse.DefaultClassName));
  659. //throw new Exception(string.Format("【{0}】和【{1}】存在相同的开放班级,请核查。", result[0].DefaultClassName, executableOptionalCourse.DefaultClassName));
  660. }
  661. var result1 = list.Where(x => x.RecordStatus > (int)EMIS.ViewModel.EM_SelectCourseResultStatus.NotOpen && clas.Contains(x.ClassmajorID)).ToList();
  662. if (result1.Count > 0)
  663. {
  664. var IDs = result1.Select(x => x.ExecutableOptionalCourseID).ToList();
  665. var teacher = optionalCourseSettingDAL.ExecutableOptionalCourseRepository.Entities.Where(x =>
  666. IDs.Contains(x.ExecutableOptionalCourseID) &&
  667. x.EM_ExecutableOptionalCourseTeacher.Count() == teacherList.Count &&
  668. x.EM_ExecutableOptionalCourseTeacher.Count() == (x.EM_ExecutableOptionalCourseTeacher.
  669. Where(w => teacherList.Contains(w.UserID.Value)).Count()));
  670. if (teacher.ToList().Count > 0)
  671. throw new Exception(string.Format("已开放的【{0}】和准备开放的【{1}】存在相同的开放班级和授课老师,请核查。", result1[0].DefaultClassName, executableOptionalCourse.DefaultClassName));
  672. //throw new Exception(string.Format("已开放的【{0}】和准备开放的【{1}】存在相同的开放班级,请核查。", result1[0].DefaultClassName, executableOptionalCourse.DefaultClassName));
  673. }
  674. }
  675. executableOptionalCourse.RecordStatus = (int)EM_SelectCourseResultStatus.Opened;
  676. }
  677. else
  678. throw new Exception("当前状态的数据不能开放,请核查");
  679. }
  680. UnitOfWork.Commit();
  681. return true;
  682. }
  683. return false;
  684. }
  685. catch (Exception)
  686. {
  687. throw;
  688. }
  689. }
  690. //取消开放
  691. public bool OptionalCourseSettingCancel(List<Guid?> optionalCourseSettingIDs)
  692. {
  693. try
  694. {
  695. if (optionalCourseSettingIDs.Count > 0)
  696. {
  697. var ExecutableOptionalCourseList = optionalCourseSettingDAL.ExecutableOptionalCourseRepository.GetList(x => optionalCourseSettingIDs.Contains(x.ExecutableOptionalCourseID)).ToList();
  698. foreach (var ExecutableOptionalCourse in ExecutableOptionalCourseList)
  699. {
  700. if (ExecutableOptionalCourse.RecordStatus < (int)EMIS.ViewModel.EM_SelectCourseResultStatus.Opened) //开放状态
  701. {
  702. throw new Exception("限选设定未开放");
  703. }
  704. }
  705. UnitOfWork.Update<EM_ExecutableOptionalCourse>(x => new EM_ExecutableOptionalCourse { RecordStatus = (int)EMIS.ViewModel.EM_SelectCourseResultStatus.NotOpen }, x => optionalCourseSettingIDs.Contains(x.ExecutableOptionalCourseID));
  706. this.UnitOfWork.Commit();
  707. return true;
  708. }
  709. return false;
  710. }
  711. catch (Exception)
  712. {
  713. throw;
  714. }
  715. }
  716. /// <summary>
  717. /// 获取授课老师
  718. /// </summary>
  719. /// <param name="educationMissionClassID"></param>
  720. /// <returns></returns>
  721. public List<OptionalCourseTeacherListView> GetEducationMissionClassTeacherListViewList(Guid executableOptionalCourseID)
  722. {
  723. return optionalCourseSettingDAL.GetEducationMissionClassTeacherListViewQueryble().Where(x => x.ExecutableOptionalCourseID == executableOptionalCourseID).OrderBy(x => x.TeachingMethod).ToList();
  724. }
  725. public List<OptionalCourseClassListView> GetClassmajorList(Guid? executableOptionalCourseID)
  726. {
  727. //查询条件
  728. var query = optionalCourseSettingDAL.GetExecutableOptionalCourseClassmajorList().Where(x => x.ExecutableOptionalCourseID == executableOptionalCourseID).OrderBy(x => x.No).ToList();
  729. return query;
  730. //return classmajorDAL.classmajorRepository.GetSingle(w => w.ClassmajorID == classmajorID);
  731. }
  732. public CF_Classmajor GetClassmajor(Guid? classmajorID)
  733. {
  734. //查询条件
  735. return classmajorDAL.ClassmajorRepository.GetSingle(w => w.ClassmajorID == classmajorID);
  736. }
  737. }
  738. }