RetakePlanStudentApplyServices.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Linq.Expressions;
  6. using Bowin.Common.Linq.Entity;
  7. using Bowin.Common.Linq;
  8. using EMIS.DataLogic.RetakeManage;
  9. using EMIS.Entities;
  10. using EMIS.ViewModel;
  11. using EMIS.ViewModel.RetakeManage;
  12. using EMIS.Utility;
  13. using EMIS.CommonLogic.SystemServices;
  14. using EMIS.ViewModel.EducationManage;
  15. using EMIS.DataLogic.EducationManage;
  16. using EMIS.CommonLogic.EducationSchedule;
  17. using EMIS.DataLogic.SystemSetting;
  18. using EMIS.CommonLogic.RetakeManage.General;
  19. using EMIS.DataLogic.Common.Students;
  20. using System.Transactions;
  21. using EMIS.DataLogic.Repositories;
  22. namespace EMIS.CommonLogic.RetakeManage.General
  23. {
  24. public class RetakePlanStudentApplyServices : BaseServices, IRetakePlanStudentApplyServices
  25. {
  26. public RetakeConditionDAL RetakeConditionDAL { get; set; }
  27. public RetakePlanStudentApplyDAL RetakePlanStudentApplyDAL { get; set; }
  28. public RetakePlanDAL RetakePlanDAL { get; set; }
  29. public Lazy<IParameterServices> ParameterServices { get; set; }
  30. public DictionaryDAL DictionaryDAL { get; set; }
  31. public StudentsDAL StudentsDAL { get; set; }
  32. public Lazy<IRetakeOpenControlServices> IRetakeOpenControlServices { get; set; }
  33. public ParameterRepository ParameterRepository { get; set; }
  34. public RetakePlanTaskDAL RetakePlanTaskDAL { get; set; }
  35. public RetakePlanResultDAL RetakePlanResultDAL { get; set; }
  36. /// <summary>
  37. /// 查询学生平台进入报名信息View(只查询重修计划状态为已开放)
  38. /// </summary>
  39. /// <param name="configuretView"></param>
  40. /// <param name="userID"></param>
  41. /// <param name="schoolyearID"></param>
  42. /// <param name="coursematerialID"></param>
  43. /// <param name="pageIndex"></param>
  44. /// <param name="pageSize"></param>
  45. /// <returns></returns>
  46. public IGridResultSet<RetakePlanStudentApplyView> GetRetakePlanStudentApplyView(ConfiguretView configuretView, Guid userID,
  47. Guid? schoolyearID, Guid? coursematerialID, int? generalPurposeID, int? pageIndex, int? pageSize)
  48. {
  49. //重修计划
  50. Expression<Func<ER_RetakePlan, bool>> expRetakePlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  51. //重修任务状态为已开放状态的信息
  52. expRetakePlan = expRetakePlan.And(x => x.RecordStatus == (int)ER_RetakePlanStatus.Opened);
  53. if (schoolyearID.HasValue)
  54. {
  55. //重修学年学期
  56. expRetakePlan = expRetakePlan.And(x => x.SchoolyearID == schoolyearID);
  57. }
  58. if (coursematerialID.HasValue)
  59. {
  60. //课程信息
  61. expRetakePlan = expRetakePlan.And(x => x.CoursematerialID == coursematerialID);
  62. }
  63. //重修计划名单
  64. Expression<Func<ER_RetakePlanStudent, bool>> expRetakePlanStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  65. //学生信息ID
  66. expRetakePlanStudent = expRetakePlanStudent.And(x => x.UserID == userID);
  67. //查询对应的进入报名信息
  68. var query = RetakePlanStudentApplyDAL.GetRetakePlanStudentApplyView(expRetakePlan, expRetakePlanStudent);
  69. if (generalPurposeID.HasValue)
  70. {
  71. //报名状态
  72. if (generalPurposeID.Value == (int)CF_GeneralPurpose.IsYes)
  73. {
  74. query = query.Where(x => x.ApplyStatus == true);
  75. }
  76. if (generalPurposeID.Value == (int)CF_GeneralPurpose.IsNo)
  77. {
  78. query = query.Where(x => x.ApplyStatus == false);
  79. }
  80. }
  81. //列表查询条件
  82. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  83. {
  84. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  85. }
  86. var result = query.OrderBy(x => x.SchoolyearCode.Length).ThenBy(x => x.SchoolyearCode)
  87. .ThenBy(x => x.CourseCollegeNo.Length).ThenBy(x => x.CourseCollegeNo)
  88. .ThenBy(x => x.RetakeTypeID).ThenBy(x => x.CourseCode.Length)
  89. .ThenBy(x => x.CourseCode).ThenBy(x => x.CourseTypeID)
  90. .ThenBy(x => x.Credit).ThenBy(x => x.ClassName)
  91. .ToGridResultSet(pageIndex, pageSize);
  92. //查询重修学年学期对应的重修开放控制信息
  93. var retakeOpenControlView = IRetakeOpenControlServices.Value.GetRetakeOpenControlViewBySchoolyearID(schoolyearID);
  94. //根据对应的重修开放控制信息进行判断(操作状态,精确到分秒)
  95. result.rows.ForEach(x => x.CanSelect =
  96. (retakeOpenControlView != null
  97. &&
  98. !(
  99. x.PeopleNumlimit != null && x.PeopleNumlimit > 0
  100. && x.ApplyNumber.Value >= x.PeopleNumlimit.Value
  101. && x.ApplyStatus.Value == false
  102. )
  103. &&
  104. (
  105. x.SchoolyearID == retakeOpenControlView.SchoolyearID
  106. && retakeOpenControlView.StartDate <= DateTime.Now
  107. && retakeOpenControlView.EndDate >= DateTime.Now
  108. )
  109. ) ? true : false
  110. );
  111. //查询对应的重修计划IDList
  112. var retakePlanIDList = query.Select(x => x.RetakePlanID).ToList();
  113. //查询对应的课程表信息
  114. var schedulingList = RetakePlanTaskDAL.GetSchedulingView(x => retakePlanIDList.Contains(x.RetakePlanID.Value)).ToList();
  115. //查询合并显示的课程表信息
  116. var weekdayTimesList = this.GetWeekdayTimesSegmentName(schedulingList);
  117. result.rows.ForEach(x =>
  118. {
  119. var list = weekdayTimesList.Where(w => w.ID == x.RetakePlanID);
  120. x.WeekdayTimesSegmentName = string.Join(";", list.OrderBy(w => w.Weekday).Select(w => w.WeekdayTimesSegmentName));
  121. x.ClassroomName = schedulingList.Where(w => w.ID == x.RetakePlanID).Select(w => w.ClassroomName).FirstOrDefault();
  122. });
  123. //查询合并显示的任课老师信息
  124. var teacherList = RetakePlanResultDAL.GetRetakePlanTeacherView(x => retakePlanIDList.Contains(x.RetakePlanID));
  125. result.rows.ForEach(x =>
  126. x.TeacherName = string.Join(",", teacherList.Where(w => w.RetakePlanID == x.RetakePlanID).Select(w => w.TeacherName)));
  127. return result;
  128. }
  129. /// <summary>
  130. /// 查询重修课程信息View(学生平台,暂不排除未开放状态的重修计划)
  131. /// </summary>
  132. /// <param name="configuretView"></param>
  133. /// <param name="userID"></param>
  134. /// <param name="schoolyearID"></param>
  135. /// <param name="coursematerialID"></param>
  136. /// <param name="retakePlanStatusID"></param>
  137. /// <param name="pageIndex"></param>
  138. /// <param name="pageSize"></param>
  139. /// <returns></returns>
  140. public IGridResultSet<RetakePlanStudentApplyView> GetStudentRetakeCourseView(ConfiguretView configuretView, Guid userID,
  141. Guid? schoolyearID, Guid? coursematerialID, int? retakePlanStatusID, int? pageIndex, int? pageSize)
  142. {
  143. //重修计划
  144. Expression<Func<ER_RetakePlan, bool>> expRetakePlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  145. ////排除重修任务状态为未开放状态的信息
  146. //expRetakePlan = expRetakePlan.And(x => x.RecordStatus != (int)ER_RetakePlanStatus.NotOpened);
  147. if (schoolyearID.HasValue)
  148. {
  149. //重修学年学期
  150. expRetakePlan = expRetakePlan.And(x => x.SchoolyearID == schoolyearID);
  151. }
  152. if (coursematerialID.HasValue)
  153. {
  154. //课程信息
  155. expRetakePlan = expRetakePlan.And(x => x.CoursematerialID == coursematerialID);
  156. }
  157. if (retakePlanStatusID.HasValue)
  158. {
  159. //重修任务状态
  160. expRetakePlan = expRetakePlan.And(x => x.RecordStatus == retakePlanStatusID);
  161. }
  162. //重修计划名单
  163. Expression<Func<ER_RetakePlanStudent, bool>> expRetakePlanStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  164. //学生信息ID
  165. expRetakePlanStudent = expRetakePlanStudent.And(x => x.UserID == userID);
  166. //查询对应的进入报名信息
  167. var query = RetakePlanStudentApplyDAL.GetStudentRetakeCourseView(expRetakePlan, expRetakePlanStudent);
  168. //列表查询条件
  169. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  170. {
  171. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  172. }
  173. var result = query.OrderBy(x => x.SchoolyearCode.Length).ThenBy(x => x.SchoolyearCode)
  174. .ThenBy(x => x.CourseCollegeNo.Length).ThenBy(x => x.CourseCollegeNo)
  175. .ThenBy(x => x.RetakeTypeID).ThenBy(x => x.CourseCode.Length)
  176. .ThenBy(x => x.CourseCode).ThenBy(x => x.CourseTypeID)
  177. .ThenBy(x => x.Credit).ThenBy(x => x.ClassName)
  178. .ToGridResultSet(pageIndex, pageSize);
  179. //查询对应的重修计划IDList
  180. var retakePlanIDList = query.Select(x => x.RetakePlanID).ToList();
  181. //查询对应的课程表信息
  182. var schedulingList = RetakePlanTaskDAL.GetSchedulingView(x => retakePlanIDList.Contains(x.RetakePlanID.Value)).ToList();
  183. //查询合并显示的课程表信息
  184. var weekdayTimesList = this.GetWeekdayTimesSegmentName(schedulingList);
  185. result.rows.ForEach(x =>
  186. {
  187. var list = weekdayTimesList.Where(w => w.ID == x.RetakePlanID);
  188. x.WeekdayTimesSegmentName = string.Join(";", list.OrderBy(w => w.Weekday).Select(w => w.WeekdayTimesSegmentName));
  189. x.ClassroomName = schedulingList.Where(w => w.ID == x.RetakePlanID).Select(w => w.ClassroomName).FirstOrDefault();
  190. });
  191. //查询合并显示的任课老师信息
  192. var teacherList = RetakePlanResultDAL.GetRetakePlanTeacherView(x => retakePlanIDList.Contains(x.RetakePlanID));
  193. result.rows.ForEach(x =>
  194. x.TeacherName = string.Join(",", teacherList.Where(w => w.RetakePlanID == x.RetakePlanID).Select(w => w.TeacherName)));
  195. return result;
  196. }
  197. /// <summary>
  198. /// 查询重修课程信息View(学生平台,暂不排除未开放状态的重修计划)
  199. /// </summary>
  200. /// <param name="configuretView"></param>
  201. /// <param name="userID"></param>
  202. /// <param name="schoolyearID"></param>
  203. /// <param name="coursematerialID"></param>
  204. /// <param name="retakePlanStatusID"></param>
  205. /// <returns></returns>
  206. public List<RetakePlanStudentApplyView> GetStudentRetakeCourseView(ConfiguretView configuretView, Guid userID,
  207. Guid? schoolyearID, Guid? coursematerialID, int? retakePlanStatusID)
  208. {
  209. //重修计划
  210. Expression<Func<ER_RetakePlan, bool>> expRetakePlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  211. ////排除重修任务状态为未开放状态的信息
  212. //expRetakePlan = expRetakePlan.And(x => x.RecordStatus != (int)ER_RetakePlanStatus.NotOpened);
  213. if (schoolyearID.HasValue)
  214. {
  215. //重修学年学期
  216. expRetakePlan = expRetakePlan.And(x => x.SchoolyearID == schoolyearID);
  217. }
  218. if (coursematerialID.HasValue)
  219. {
  220. //课程信息
  221. expRetakePlan = expRetakePlan.And(x => x.CoursematerialID == coursematerialID);
  222. }
  223. if (retakePlanStatusID.HasValue)
  224. {
  225. //重修任务状态
  226. expRetakePlan = expRetakePlan.And(x => x.RecordStatus == retakePlanStatusID);
  227. }
  228. //重修计划名单
  229. Expression<Func<ER_RetakePlanStudent, bool>> expRetakePlanStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  230. //学生信息ID
  231. expRetakePlanStudent = expRetakePlanStudent.And(x => x.UserID == userID);
  232. //查询对应的进入报名信息
  233. var query = RetakePlanStudentApplyDAL.GetStudentRetakeCourseView(expRetakePlan, expRetakePlanStudent);
  234. //列表查询条件
  235. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  236. {
  237. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  238. }
  239. var result = query.OrderBy(x => x.SchoolyearCode.Length).ThenBy(x => x.SchoolyearCode)
  240. .ThenBy(x => x.CourseCollegeNo.Length).ThenBy(x => x.CourseCollegeNo)
  241. .ThenBy(x => x.RetakeTypeID).ThenBy(x => x.CourseCode.Length)
  242. .ThenBy(x => x.CourseCode).ThenBy(x => x.CourseTypeID)
  243. .ThenBy(x => x.Credit).ThenBy(x => x.ClassName)
  244. .ToList();
  245. //查询对应的重修计划IDList
  246. var retakePlanIDList = query.Select(x => x.RetakePlanID).ToList();
  247. //查询对应的课程表信息
  248. var schedulingList = RetakePlanTaskDAL.GetSchedulingView(x => retakePlanIDList.Contains(x.RetakePlanID.Value)).ToList();
  249. //查询合并显示的课程表信息
  250. var weekdayTimesList = this.GetWeekdayTimesSegmentName(schedulingList);
  251. result.ForEach(x =>
  252. {
  253. var list = weekdayTimesList.Where(w => w.ID == x.RetakePlanID);
  254. x.WeekdayTimesSegmentName = string.Join(";", list.OrderBy(w => w.Weekday).Select(w => w.WeekdayTimesSegmentName));
  255. x.ClassroomName = schedulingList.Where(w => w.ID == x.RetakePlanID).Select(w => w.ClassroomName).FirstOrDefault();
  256. });
  257. //查询合并显示的任课老师信息
  258. var teacherList = RetakePlanResultDAL.GetRetakePlanTeacherView(x => retakePlanIDList.Contains(x.RetakePlanID));
  259. result.ForEach(x =>
  260. x.TeacherName = string.Join(",", teacherList.Where(w => w.RetakePlanID == x.RetakePlanID).Select(w => w.TeacherName)));
  261. return result;
  262. }
  263. /// <summary>
  264. /// 查询合并显示的课程表信息
  265. /// </summary>
  266. /// <param name="SourceList">上课时间</param>
  267. /// <returns></returns>
  268. public List<RetakePlanSettingSchedulingView> GetWeekdayTimesSegmentName(List<RetakePlanSettingSchedulingView> SourceList)
  269. {
  270. List<RetakePlanSettingSchedulingView> newList = new List<RetakePlanSettingSchedulingView>();
  271. var idList = SourceList.Select(x => x.ID).Distinct().ToList();
  272. foreach (var id in idList)
  273. { //循环处理每个任选课的上课时间
  274. var list = SourceList.Where(x => x.ID == id).ToList();
  275. var weekdayList = list.Select(x => x.Weekday).Distinct().ToList();
  276. foreach (var weekday in weekdayList)
  277. { //先循环同一星期日期
  278. var tmpList = list.Where(x => x.Weekday == weekday).OrderBy(x => x.StartTimes).ToList();
  279. string WeekdayTimesSegmentName = tmpList.FirstOrDefault().WeekdayName + tmpList.FirstOrDefault().StartTimes;
  280. var array = tmpList.Select(x => new { x.StartTimes, x.EndTimes }).ToArray();
  281. for (int i = 0; i < array.Length; i++)
  282. { //将同一天的节次合并,相邻的节次用“-”将最开始节次和最后节次合并,例:1/2/3合并成“1-3”,
  283. //如果不是相邻的先用逗号隔开,再用“-”合并,例:1/2/3和5/6,合并成“1-3,5-6”
  284. if (i > 0 && (array[i].StartTimes > array[i - 1].EndTimes + 1))
  285. { //不相邻的先用逗号隔开,再用“-”合并
  286. WeekdayTimesSegmentName += "-" + array[i - 1].EndTimes + "节," + array[i].StartTimes;
  287. }
  288. if (i + 1 == array.Length)
  289. WeekdayTimesSegmentName += "-" + array[i].EndTimes + "节";
  290. }
  291. newList.Add(new RetakePlanSettingSchedulingView { ID = tmpList.FirstOrDefault().ID, WeekdayTimesSegmentName = WeekdayTimesSegmentName.Replace("星期", ""), Weekday = tmpList.FirstOrDefault().Weekday });
  292. }
  293. }
  294. return newList;
  295. }
  296. /// <summary>
  297. /// 学生平台重修报名(注:1、检测重修开放时间,2、检测人数上限,3、检测重修课程重复,4、检测重修收费控制-暂时不考虑,5、检测排课冲突)
  298. /// </summary>
  299. /// <param name="RetakePlanStudentID"></param>
  300. /// <param name="UserID"></param>
  301. public void Apply(Guid RetakePlanStudentID, Guid UserID)
  302. {
  303. try
  304. {
  305. using (TransactionScope ts = new TransactionScope())
  306. {
  307. //查询对应的重修计划名单信息View
  308. var retakePlanView = RetakePlanStudentApplyDAL.RetakePlanStudentRepository
  309. .GetList(x => x.RetakePlanStudentID == RetakePlanStudentID,
  310. (x => x.ER_RetakePlan),
  311. (x => x.ER_RetakePlan.CF_Student),
  312. (x => x.ER_RetakePlan.ER_RetakePlanSetting),
  313. (x => x.ER_RetakePlan.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting),
  314. (x => x.ER_RetakePlan.ER_RetakePlanSettingScheduling)
  315. ).SingleOrDefault();
  316. if (retakePlanView == null)
  317. {
  318. throw new Exception("不存在此报名信息(请尝试刷新后再试)");
  319. }
  320. if (retakePlanView.ER_RetakePlan.RecordStatus != (int)EMIS.ViewModel.ER_RetakePlanStatus.Opened)
  321. {
  322. throw new Exception("只能对已开放状态的信息进行报名(请尝试刷新后再试)");
  323. }
  324. //查询重修学年学期对应的重修开放控制信息
  325. var retakeOpenControlView = IRetakeOpenControlServices.Value
  326. .GetRetakeOpenControl(retakePlanView.ER_RetakePlan.SchoolyearID);
  327. //对重修开放时间进行判断
  328. if (retakeOpenControlView == null)
  329. {
  330. throw new Exception("重修报名已关闭(请尝试刷新后再试)");
  331. }
  332. if (DateTime.Now > retakeOpenControlView.EndDate)
  333. {
  334. throw new Exception("重修报名已结束(请尝试刷新后再试)");
  335. }
  336. if (DateTime.Now < retakeOpenControlView.StartDate)
  337. {
  338. throw new Exception("重修报名即将开始(请尝试刷新后再试)");
  339. }
  340. //对人数上限进行判断
  341. if (retakePlanView.ER_RetakePlan.PeopleNumlimit != null && retakePlanView.ER_RetakePlan.PeopleNumlimit != 0
  342. && (retakePlanView.ER_RetakePlan.CF_Student.Count() + 1) > retakePlanView.ER_RetakePlan.PeopleNumlimit.Value)
  343. {
  344. throw new Exception("报名人数已达上限(请尝试刷新后再试)");
  345. }
  346. //对重修课程重复进行判断(同一课程信息ID、同一重修类型、同一重修学年学期、同一课程类型、同一学分、同一开课教研室)
  347. var retakePlanStudentApply = RetakePlanStudentApplyDAL.RetakePlanRepository
  348. .GetSingle(x =>
  349. x.CoursematerialID == retakePlanView.ER_RetakePlan.CoursematerialID
  350. && x.RetakeTypeID == retakePlanView.ER_RetakePlan.RetakeTypeID
  351. && x.SchoolyearID == retakePlanView.ER_RetakePlan.SchoolyearID
  352. //&& x.CourseTypeID == retakePlanView.ER_RetakePlan.CourseTypeID
  353. //&& x.Credit == retakePlanView.ER_RetakePlan.Credit
  354. //&& x.ER_RetakePlanSetting.DepartmentID == retakePlanView.ER_RetakePlan.ER_RetakePlanSetting.DepartmentID
  355. && x.CF_Student.Any(w => w.UserID == UserID));
  356. if (retakePlanStudentApply != null)
  357. {
  358. throw new Exception("您已对此类型的重修课程进行了报名,不允许重复报名");
  359. }
  360. //检测重修收费控制(暂时不考虑)
  361. //对排课冲突进行判断
  362. var schedulingList = retakePlanView.ER_RetakePlan.ER_RetakePlanSettingScheduling.ToList();
  363. if (schedulingList.Count > 0)
  364. {
  365. foreach (var scheduling in schedulingList)
  366. {
  367. var repeatTime = RetakePlanStudentApplyDAL.GetRepeatTime(UserID, retakePlanView.RetakePlanID,
  368. scheduling.CoursesTimeID, scheduling.Weekday, retakePlanView.ER_RetakePlan.SchoolyearID,
  369. retakePlanView.ER_RetakePlan.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.StartWeeklyNum,
  370. retakePlanView.ER_RetakePlan.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.EndWeeklyNum
  371. ).FirstOrDefault();
  372. if (repeatTime != null)
  373. {
  374. if (repeatTime.Type == 1)
  375. {
  376. throw new Exception("上课时间冲突,不允许报名(" + repeatTime.DefaultClassName + ")");
  377. }
  378. else if (repeatTime.Type == 2)
  379. {
  380. throw new Exception("上课时间冲突,不允许报名(" + repeatTime.DefaultClassName + ")");
  381. }
  382. else if (repeatTime.Type == 3)
  383. {
  384. throw new Exception("上课时间冲突,不允许报名(" + repeatTime.DefaultClassName + ")");
  385. }
  386. }
  387. }
  388. }
  389. //查询对应的学生信息View
  390. var studentView = RetakePlanStudentApplyDAL.StudentRepository
  391. .GetSingle(x => x.UserID == UserID, (x => x.CF_Classmajor.CF_Grademajor));
  392. //重修报名
  393. retakePlanView.ER_RetakePlan.CF_Student.Add(studentView);
  394. UnitOfWork.Commit();
  395. ts.Complete();
  396. }
  397. }
  398. catch (Exception ex)
  399. {
  400. throw new Exception(ex.Message);
  401. }
  402. }
  403. /// <summary>
  404. /// 学生平台重修取消报名(注:1、检测重修开放时间,2、取消报名控制-暂时不考虑)
  405. /// </summary>
  406. /// <param name="RetakePlanStudentID"></param>
  407. /// <param name="UserID"></param>
  408. public void CancleApply(Guid RetakePlanStudentID, Guid UserID)
  409. {
  410. try
  411. {
  412. using (TransactionScope ts = new TransactionScope())
  413. {
  414. //查询对应的重修计划名单信息View
  415. var retakePlanView = RetakePlanStudentApplyDAL.RetakePlanStudentRepository
  416. .GetList(x => x.RetakePlanStudentID == RetakePlanStudentID,
  417. (x => x.ER_RetakePlan),
  418. (x => x.ER_RetakePlan.CF_Student)
  419. ).SingleOrDefault();
  420. if (retakePlanView == null)
  421. {
  422. throw new Exception("不存在此报名信息(请尝试刷新后再试)");
  423. }
  424. if (retakePlanView.ER_RetakePlan.RecordStatus != (int)EMIS.ViewModel.ER_RetakePlanStatus.Opened)
  425. {
  426. throw new Exception("只能对已开放状态的信息进行取消报名(请尝试刷新后再试)");
  427. }
  428. //查询重修学年学期对应的重修开放控制信息
  429. var retakeOpenControlView = IRetakeOpenControlServices.Value
  430. .GetRetakeOpenControl(retakePlanView.ER_RetakePlan.SchoolyearID);
  431. //对重修开放时间进行判断
  432. if (retakeOpenControlView == null)
  433. {
  434. throw new Exception("重修报名已关闭(请尝试刷新后再试)");
  435. }
  436. if (DateTime.Now > retakeOpenControlView.EndDate)
  437. {
  438. throw new Exception("重修报名已结束(请尝试刷新后再试)");
  439. }
  440. if (DateTime.Now < retakeOpenControlView.StartDate)
  441. {
  442. throw new Exception("重修报名即将开始(请尝试刷新后再试)");
  443. }
  444. //取消报名控制(暂时不考虑)
  445. //重修报名取消
  446. retakePlanView.ER_RetakePlan.CF_Student.RemoveWhere(x => x.UserID == UserID);
  447. UnitOfWork.Commit();
  448. ts.Complete();
  449. }
  450. }
  451. catch (Exception ex)
  452. {
  453. throw new Exception(ex.Message);
  454. }
  455. }
  456. }
  457. }