You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

696 lines
28 KiB

  1. using Learun.Util;
  2. using System.Data;
  3. using Learun.Application.TwoDevelopment.EducationalAdministration;
  4. using System.Web.Mvc;
  5. using System.Collections.Generic;
  6. using System;
  7. using System.Linq;
  8. namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers
  9. {
  10. /// <summary>
  11. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  12. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  13. /// 创 建:超级管理员
  14. /// 日 期:2019-05-14 10:02
  15. /// 描 述:选修课课程信息
  16. /// </summary>
  17. public class OpenLessonPlanOfElectiveController : MvcControllerBase
  18. {
  19. private OpenLessonPlanOfElectiveIBLL openLessonPlanOfElectiveIBLL = new OpenLessonPlanOfElectiveBLL();
  20. private StuSelectLessonListOfElectiveIBLL stuSelectLessonListOfElectiveIBLL = new StuSelectLessonListOfElectiveBLL();
  21. private StuInfoBasicIBLL stuInfoBasicIBLL = new StuInfoBasicBLL();
  22. private ClassInfoIBLL classInfoIBLL = new ClassInfoBLL();
  23. private ElectiveMajorIBLL electiveMajorIBLL = new ElectiveMajorBLL();
  24. CdMajorIBLL CdMajorIBLL = new CdMajorBLL();
  25. private StuSelectLessonListOfElectivePreIBLL stuSelectLessonListOfElectivePreIBLL = new StuSelectLessonListOfElectivePreBLL();
  26. private OpenLessonPlanOfElectiveChangeIBLL openLessonPlanOfElectiveChangeIBLL = new OpenLessonPlanOfElectiveChangeBLL();
  27. #region 视图功能
  28. /// <summary>
  29. /// 主页面
  30. /// <summary>
  31. /// <returns></returns>
  32. [HttpGet]
  33. public ActionResult Index()
  34. {
  35. return View();
  36. }
  37. [HttpGet]
  38. public ActionResult MergeIndex()
  39. {
  40. return View();
  41. }
  42. /// <summary>
  43. /// 表单页
  44. /// <summary>
  45. /// <returns></returns>
  46. [HttpGet]
  47. public ActionResult Form()
  48. {
  49. return View();
  50. }
  51. /// <summary>
  52. /// 学子在线-选课中心
  53. /// <summary>
  54. /// <returns></returns>
  55. [HttpGet]
  56. public ActionResult StudentIndex()
  57. {
  58. var loginuser = LoginUserInfo.Get();
  59. var studentinfo = stuInfoBasicIBLL.GetStuInfoBasicEntityByStuNo(loginuser.account);
  60. if (studentinfo != null)
  61. {
  62. ViewBag.StuMajorNo = CdMajorIBLL.GetCdMajorEntityByMajorNo(studentinfo.MajorNo)?.ID;
  63. ViewBag.StuGrade = studentinfo.Grade;
  64. }
  65. ViewBag.WebApiUrl = Config.GetValue("WebApi");
  66. return View();
  67. }
  68. /// <summary>
  69. /// 表单页
  70. /// <summary>
  71. /// <returns></returns>
  72. [HttpGet]
  73. public ActionResult ModifyForm()
  74. {
  75. return View();
  76. }
  77. #endregion
  78. #region 获取数据
  79. /// <summary>
  80. /// 获取页面显示列表数据
  81. /// <summary>
  82. /// <param name="queryJson">查询参数</param>
  83. /// <returns></returns>
  84. [HttpGet]
  85. [AjaxOnly]
  86. public ActionResult GetPageList(string pagination, string queryJson)
  87. {
  88. Pagination paginationobj = pagination.ToObject<Pagination>();
  89. var data = openLessonPlanOfElectiveIBLL.GetPageList(paginationobj, queryJson);
  90. var jsonData = new
  91. {
  92. rows = data,
  93. total = paginationobj.total,
  94. page = paginationobj.page,
  95. records = paginationobj.records
  96. };
  97. return Success(jsonData);
  98. }
  99. [HttpGet]
  100. [AjaxOnly]
  101. public ActionResult GetPageListOfMerge(string pagination, string queryJson)
  102. {
  103. Pagination paginationobj = pagination.ToObject<Pagination>();
  104. var data = openLessonPlanOfElectiveIBLL.GetPageListOfMerge(paginationobj, queryJson);
  105. var jsonData = new
  106. {
  107. rows = data,
  108. total = paginationobj.total,
  109. page = paginationobj.page,
  110. records = paginationobj.records
  111. };
  112. return Success(jsonData);
  113. }
  114. /// <summary>
  115. /// 获取表单数据
  116. /// <summary>
  117. /// <returns></returns>
  118. [HttpGet]
  119. [AjaxOnly]
  120. public ActionResult GetFormData(string keyValue)
  121. {
  122. var OpenLessonPlanOfElectiveData = openLessonPlanOfElectiveIBLL.GetOpenLessonPlanOfElectiveEntity(keyValue);
  123. var jsonData = new
  124. {
  125. OpenLessonPlanOfElective = OpenLessonPlanOfElectiveData,
  126. };
  127. return Success(jsonData);
  128. }
  129. /// <summary>
  130. /// 获取页面显示列表数据【学子在线-选课中心】
  131. /// <summary>
  132. /// <param name="queryJson">查询参数</param>
  133. /// <returns></returns>
  134. [HttpGet]
  135. [AjaxOnly]
  136. public ActionResult GetPageListOfStudent(string pagination, string queryJson)
  137. {
  138. Pagination paginationobj = pagination.ToObject<Pagination>();
  139. var data = openLessonPlanOfElectiveIBLL.GetPageListOfStudent(paginationobj, queryJson).OrderByDescending(x => x.AcademicYearNo).ThenByDescending(x => x.Semester).ThenBy(x => x.LessonNo).ThenBy(x => x.EmpNo);
  140. var jsonData = new
  141. {
  142. rows = data,
  143. total = paginationobj.total,
  144. page = paginationobj.page,
  145. records = paginationobj.records
  146. };
  147. return Success(jsonData);
  148. }
  149. #endregion
  150. #region 提交数据
  151. /// <summary>
  152. /// 删除实体数据
  153. /// <param name="keyValue">主键</param>
  154. /// <summary>
  155. /// <returns></returns>
  156. [HttpPost]
  157. [AjaxOnly]
  158. public ActionResult DeleteForm(string keyValue)
  159. {
  160. openLessonPlanOfElectiveIBLL.DeleteEntity(keyValue);
  161. return Success("删除成功!");
  162. }
  163. /// <summary>
  164. /// 保存实体数据(新增、修改)
  165. /// <param name="keyValue">主键</param>
  166. /// <summary>
  167. /// <returns></returns>
  168. [HttpPost]
  169. [ValidateAntiForgeryToken]
  170. [AjaxOnly]
  171. public ActionResult SaveForm(string keyValue, string strEntity)
  172. {
  173. var loginUserInfo = LoginUserInfo.Get();
  174. OpenLessonPlanOfElectiveEntity entity = strEntity.ToObject<OpenLessonPlanOfElectiveEntity>();
  175. entity.ModifyTime = DateTime.Now;
  176. entity.ModifyUserId = loginUserInfo.userId;
  177. entity.ModifyUserName = loginUserInfo.realName;
  178. openLessonPlanOfElectiveIBLL.SaveEntity(keyValue, entity);
  179. return Success("保存成功!");
  180. }
  181. /// <summary>
  182. /// 保存实体数据(新增、修改)
  183. /// <param name="keyValue">主键</param>
  184. /// <summary>
  185. /// <returns></returns>
  186. [HttpPost]
  187. [ValidateAntiForgeryToken]
  188. [AjaxOnly]
  189. public ActionResult SaveModifyForm(string keyValue, string strEntity)
  190. {
  191. OpenLessonPlanOfElectiveChangeEntity entity = strEntity.ToObject<OpenLessonPlanOfElectiveChangeEntity>();
  192. if (string.IsNullOrEmpty(entity.AfterLessonNo) && string.IsNullOrEmpty(entity.AfterEmpNo) && string.IsNullOrEmpty(entity.AfterClassRoomNo))
  193. {
  194. return Fail("未选择新课程、新教师、新教室!");
  195. }
  196. if (!string.IsNullOrEmpty(entity.AfterLessonNo) && !string.IsNullOrEmpty(entity.AfterEmpNo) && !string.IsNullOrEmpty(entity.AfterClassRoomNo) && entity.AfterLessonNo == entity.LessonNo && entity.AfterEmpNo == entity.EmpNo && entity.AfterClassRoomNo == entity.ClassRoomNo)
  197. {
  198. return Fail("未改变新课程、新教师、新教室!");
  199. }
  200. var loginUserInfo = LoginUserInfo.Get();
  201. var model = new OpenLessonPlanOfElectiveChangeEntity();
  202. model.CreateTime = DateTime.Now;
  203. model.CreateUserId = loginUserInfo.userId;
  204. model.CreateUserName = loginUserInfo.realName;
  205. model.OLPEId = keyValue;
  206. model.BeforeLessonNo = entity.LessonNo;
  207. model.AfterLessonNo = entity.LessonNo;
  208. model.BeforeEmpNo = entity.EmpNo;
  209. model.AfterEmpNo = entity.EmpNo;
  210. model.BeforeClassRoomNo = entity.ClassRoomNo;
  211. model.AfterClassRoomNo = entity.ClassRoomNo;
  212. if (!string.IsNullOrEmpty(entity.AfterLessonNo))
  213. {
  214. model.AfterLessonNo = entity.AfterLessonNo;
  215. }
  216. if (!string.IsNullOrEmpty(entity.AfterEmpNo))
  217. {
  218. model.AfterEmpNo = entity.AfterEmpNo;
  219. }
  220. if (!string.IsNullOrEmpty(entity.AfterClassRoomNo))
  221. {
  222. model.AfterClassRoomNo = entity.AfterClassRoomNo;
  223. }
  224. openLessonPlanOfElectiveChangeIBLL.SaveEntity("", model);
  225. //修改选修课相关表
  226. openLessonPlanOfElectiveIBLL.DoElectiveChange(model);
  227. return Success("保存成功!");
  228. }
  229. #endregion
  230. #region 扩展数据
  231. /// <summary>
  232. /// 判断选课是否开始
  233. /// </summary>
  234. /// <returns></returns>
  235. public ActionResult IsSelectElectiveLesson()
  236. {
  237. var entity = openLessonPlanOfElectiveIBLL.GetEADateArrangeEntityAboutElective();
  238. if (entity != null)
  239. {
  240. return Fail("选课已经开始!");
  241. }
  242. return Success("选课还未开始!");
  243. }
  244. /// <summary>
  245. /// 取消报名
  246. /// </summary>
  247. /// <param name="keyvalue"></param>
  248. /// <returns></returns>
  249. public ActionResult CancelApply(string keyvalue)
  250. {
  251. var loginUserInfo = LoginUserInfo.Get();
  252. //学员信息
  253. var stuInfoBasicEntity = stuInfoBasicIBLL.GetStuInfoBasicEntityByStuNo(loginUserInfo.enCode);
  254. if (stuInfoBasicEntity == null)
  255. {
  256. return Fail("当前学员不存在!");
  257. }
  258. //课程信息
  259. var olpeEntity = openLessonPlanOfElectiveIBLL.GetOpenLessonPlanOfElectiveEntity(keyvalue);
  260. if (olpeEntity == null)
  261. {
  262. return Fail("当前课程不存在!");
  263. }
  264. //当前学员是否已经报名该课程
  265. var sslleEntity = stuSelectLessonListOfElectiveIBLL.GetStuSelectLessonListOfElectiveEntityByStuNo(loginUserInfo.enCode, keyvalue);
  266. if (sslleEntity != null)
  267. {
  268. if (sslleEntity.Status != 2)
  269. {
  270. stuSelectLessonListOfElectiveIBLL.DeleteEntity(sslleEntity.Id);
  271. return Success("取消成功");
  272. }
  273. else
  274. {
  275. return Fail("取消失败,当前课程已报名成功!");
  276. }
  277. }
  278. else
  279. {
  280. return Fail("当前课程未报名,无需取消!");
  281. }
  282. }
  283. /// <summary>
  284. /// 选修课报名:弃用
  285. /// </summary>
  286. /// <param name="keyvalue"></param>
  287. /// <returns></returns>
  288. public ActionResult ElectiveLessonApply(string keyvalue)
  289. {
  290. var loginUserInfo = LoginUserInfo.Get();
  291. //学员信息
  292. var stuInfoBasicEntity = stuInfoBasicIBLL.GetStuInfoBasicEntityByStuNo(loginUserInfo.enCode);
  293. if (stuInfoBasicEntity == null)
  294. {
  295. return Fail("当前学员不存在!");
  296. }
  297. //课程信息
  298. var olpeEntity = openLessonPlanOfElectiveIBLL.GetOpenLessonPlanOfElectiveEntity(keyvalue);
  299. if (olpeEntity == null)
  300. {
  301. return Fail("当前课程不存在!");
  302. }
  303. //所选课程的报名人数是否已满
  304. //if (olpeEntity.StuNum >= olpeEntity.StuNumMax)
  305. //{
  306. // return Fail("当前课程报名人数已满,请选择其他课程!");
  307. //}
  308. //模式二:
  309. var aa = stuSelectLessonListOfElectiveIBLL.GetStuSelectLessonListOfElectiveListByOLPEId(olpeEntity.Id);
  310. var aaa = aa.Where(x => x.Status == 1 || x.Status == 2).Count();
  311. if (aaa >= olpeEntity.StuNumMax)
  312. {
  313. return Fail("当前课程报名人数已满,请选择其他课程!");
  314. }
  315. //当前学员本学期是否有报名课程
  316. var sslleEntity = stuSelectLessonListOfElectiveIBLL.GetStuSelectLessonListOfElectiveEntityByStuNo(loginUserInfo.enCode, "");
  317. if (sslleEntity != null)
  318. {
  319. if (sslleEntity.OLPEId != keyvalue && sslleEntity.Status != 3)
  320. {
  321. return Fail("已存在报名课程,每学期只能选择一门选修课!如需报名其他课程请先取消。");
  322. }
  323. if (sslleEntity.Status == 1)
  324. {
  325. return Fail("报名审核中,请耐心等待!");
  326. }
  327. else if (sslleEntity.Status == 2)
  328. {
  329. return Fail("已存在报名成功的课程,只能选择一门选修课!");
  330. }
  331. else if (sslleEntity.Status == 3)//移除报名失败的数据
  332. {
  333. stuSelectLessonListOfElectiveIBLL.DeleteEntity(sslleEntity.Id);
  334. }
  335. }
  336. //新增报名数据
  337. var model = new StuSelectLessonListOfElectiveEntity()
  338. {
  339. OLPEId = olpeEntity.Id,
  340. NoticeBookNo = stuInfoBasicEntity.NoticeNo,
  341. StuNo = stuInfoBasicEntity.StuNo,
  342. DeptNo = stuInfoBasicEntity.DeptNo,
  343. MajorNo = stuInfoBasicEntity.MajorNo,
  344. ClassNo = stuInfoBasicEntity.ClassNo,
  345. MajorDetailNo = stuInfoBasicEntity.MajorDetailNo,
  346. MajorDetailName = stuInfoBasicEntity.MajorDetailName,
  347. StuName = stuInfoBasicEntity.StuName,
  348. GenderNo = stuInfoBasicEntity.GenderNo,
  349. Grade = stuInfoBasicEntity.Grade,
  350. AcademicYearNo = olpeEntity.AcademicYearNo,
  351. Semester = olpeEntity.Semester,
  352. LessonNo = olpeEntity.LessonNo,
  353. LessonName = olpeEntity.LessonName,
  354. LessonSortNo = olpeEntity.LessonSortNo,
  355. LessonSection = olpeEntity.LessonSection,
  356. LessonTime = olpeEntity.LessonTime,
  357. EmpNo = olpeEntity.EmpNo,
  358. EmpName = olpeEntity.EmpName,
  359. ClassRoomNo = olpeEntity.ClassRoomNo,
  360. ClassRoomName = olpeEntity.ClassRoomName,
  361. StudyScore = olpeEntity.StudyScore,
  362. StartWeek = olpeEntity.StartWeek,
  363. EndWeek = olpeEntity.EndWeek,
  364. StartDate = olpeEntity.StartDate,
  365. EndDate = olpeEntity.EndDate,
  366. CreateTime = DateTime.Now,
  367. Status = 1,
  368. OrdinaryScoreScale = 1,
  369. TermInScoreScale = 1,
  370. TermEndScoreScale = 1,
  371. OtherScoreScale = 1
  372. };
  373. stuSelectLessonListOfElectiveIBLL.SaveEntity("", model);
  374. return Success("报名成功");
  375. }
  376. /// <summary>
  377. /// 判断登录学生是否可以选课
  378. /// </summary>
  379. /// <returns></returns>
  380. public ActionResult IsCanApplyElectiveLesson()
  381. {
  382. var loginUserInfo = LoginUserInfo.Get();
  383. var stuInfoBasicEntity = stuInfoBasicIBLL.GetStuInfoBasicEntityByStuNo(loginUserInfo.account);
  384. if (stuInfoBasicEntity == null)
  385. {
  386. return Fail("学籍信息不存在!");
  387. }
  388. var classInfoEntity = classInfoIBLL.GetClassInfoEntityByClassNo(stuInfoBasicEntity.ClassNo);
  389. //var yearAndSemester = Common.GetSemesterAndYear();
  390. //var electiveMajorList = electiveMajorIBLL.GetList(yearAndSemester.AcademicYearShort, yearAndSemester.Semester).ToList();
  391. //if (electiveMajorList.Any()) //有设置选修专业,进行专业判断;没有设置选修专业,都可以选课
  392. //{
  393. // var majorList = electiveMajorList.Select(x => x.MajorNo);
  394. // if (!majorList.Contains(classInfoEntity?.MajorNo))
  395. // {
  396. // return Fail("不可以选课!");
  397. // }
  398. //}
  399. //todo:
  400. return Success("可以选课!");
  401. }
  402. /// <summary>
  403. /// 判断队列结果
  404. /// </summary>
  405. /// <returns></returns>
  406. public ActionResult GetApplyResult(string keyvalue)
  407. {
  408. var loginUserInfo = LoginUserInfo.Get();
  409. //学员信息
  410. var stuInfoBasicEntity = stuInfoBasicIBLL.GetStuInfoBasicEntityByStuNo(loginUserInfo.enCode);
  411. if (stuInfoBasicEntity == null)
  412. {
  413. return Success("当前学员不存在!");
  414. }
  415. //课程信息
  416. var olpeEntity = openLessonPlanOfElectiveIBLL.GetOpenLessonPlanOfElectiveEntity(keyvalue);
  417. if (olpeEntity == null)
  418. {
  419. return Success("当前课程不存在!");
  420. }
  421. //当前学员本学期是否有报名课程:每学期一门
  422. //var sslleEntity = stuSelectLessonListOfElectiveIBLL.GetStuSelectLessonListOfElectiveEntityByStuNo(loginUserInfo.enCode, "");
  423. //if (sslleEntity != null)
  424. //{
  425. // if (sslleEntity.OLPEId != keyvalue && sslleEntity.Status != 3)
  426. // {
  427. // return Success("已存在报名课程,每学期只能选择一门选修课!如需报名其他课程请先取消。");
  428. // }
  429. // if (sslleEntity.Status == 1)
  430. // {
  431. // return Success("报名审核中,请耐心等待!");
  432. // }
  433. // else if (sslleEntity.Status == 2)
  434. // {
  435. // return Success("已存在报名成功的课程,只能选择一门选修课!");
  436. // }
  437. //}
  438. //else
  439. //{
  440. // //所选课程的报名人数是否已满
  441. // var aa = stuSelectLessonListOfElectiveIBLL.GetStuSelectLessonListOfElectiveListByOLPEId(keyvalue);
  442. // var aaa = aa.Count(x => x.Status == 1 || x.Status == 2);
  443. // if (aaa >= olpeEntity.StuNumMax)
  444. // {
  445. // return Success("当前课程报名人数已满,请选择其他课程!");
  446. // }
  447. //}
  448. //每学期两门
  449. var sslleEntity = stuSelectLessonListOfElectiveIBLL.GetStuSelectLessonListOfElectiveEntityByStuNo(loginUserInfo.enCode, keyvalue);
  450. if (sslleEntity != null)
  451. {
  452. if (sslleEntity.Status == 1)
  453. {
  454. return Success("当前课程报名审核中,请耐心等待!");
  455. }
  456. else if (sslleEntity.Status == 2)
  457. {
  458. return Success("当前课程已报名成功!");
  459. }
  460. }
  461. else
  462. {
  463. //所选课程的报名人数是否已满
  464. var aa = stuSelectLessonListOfElectiveIBLL.GetStuSelectLessonListOfElectiveListByOLPEId(keyvalue);
  465. var aaa = aa.Count(x => x.Status == 1 || x.Status == 2);
  466. if (aaa >= olpeEntity.StuNumMax)
  467. {
  468. return Success("当前课程报名人数已满,请选择其他课程!");
  469. }
  470. //每学期最多两门
  471. var sslleList = stuSelectLessonListOfElectiveIBLL.GetStuSelectLessonListOfElectiveListByStuNo(loginUserInfo.enCode);
  472. var sslleListOfNow = sslleList.Where(x => x.AcademicYearNo == olpeEntity.AcademicYearNo && x.Semester == olpeEntity.Semester);
  473. var sslleListOfNow1 = sslleListOfNow.Where(x => x.Status == 1 || x.Status == 2);
  474. //if (sslleListOfNow1.Count() >= 2)
  475. if (sslleListOfNow1.Count() >= Config.GetValue("ElectiveLessonApplyMax").ToInt())
  476. {
  477. return Success("每学期最多选择" + Config.GetValue("ElectiveLessonApplyMax").ToInt() + "门选修课!");
  478. }
  479. //相同时间不能报名
  480. if (sslleListOfNow1.Where(x => x.LessonSection == olpeEntity.LessonSection).Any())
  481. {
  482. //相同时间不能报名
  483. return Success("本学期此时间段已有报名的选修课!");
  484. }
  485. }
  486. return Fail("正在提交,请等待!");
  487. }
  488. /// <summary>
  489. /// 取消报名(预)
  490. /// </summary>
  491. /// <param name="keyvalue"></param>
  492. /// <returns></returns>
  493. public ActionResult CancelApplyPre(string keyvalue)
  494. {
  495. var loginUserInfo = LoginUserInfo.Get();
  496. //学员信息
  497. var stuInfoBasicEntity = stuInfoBasicIBLL.GetStuInfoBasicEntityByStuNo(loginUserInfo.enCode);
  498. if (stuInfoBasicEntity == null)
  499. {
  500. return Fail("当前学员不存在!");
  501. }
  502. //课程信息
  503. var olpeEntity = openLessonPlanOfElectiveIBLL.GetOpenLessonPlanOfElectiveEntity(keyvalue);
  504. if (olpeEntity == null)
  505. {
  506. return Fail("当前课程不存在!");
  507. }
  508. //当前学员是否已经报名该课程
  509. var sslleEntity = stuSelectLessonListOfElectivePreIBLL.GetStuSelectLessonListOfElectivePreEntityByStuNo(loginUserInfo.enCode, keyvalue);
  510. if (sslleEntity != null)
  511. {
  512. if (sslleEntity.Status != 2)
  513. {
  514. stuSelectLessonListOfElectivePreIBLL.DeleteEntity(sslleEntity.Id);
  515. return Success("取消成功");
  516. }
  517. else
  518. {
  519. return Fail("取消失败,当前课程已报名成功!");
  520. }
  521. }
  522. else
  523. {
  524. return Fail("当前课程未报名,无需取消!");
  525. }
  526. }
  527. /// <summary>
  528. /// 选修课报名(预)
  529. /// </summary>
  530. /// <param name="keyvalue"></param>
  531. /// <returns></returns>
  532. public ActionResult ElectiveLessonApplyPre(string keyvalue)
  533. {
  534. var loginUserInfo = LoginUserInfo.Get();
  535. //学员信息
  536. var stuInfoBasicEntity = stuInfoBasicIBLL.GetStuInfoBasicEntityByStuNo(loginUserInfo.enCode);
  537. if (stuInfoBasicEntity == null)
  538. {
  539. return Fail("当前学员不存在!");
  540. }
  541. //课程信息
  542. var olpeEntity = openLessonPlanOfElectiveIBLL.GetOpenLessonPlanOfElectiveEntity(keyvalue);
  543. if (olpeEntity == null)
  544. {
  545. return Fail("当前课程不存在!");
  546. }
  547. //所选课程的报名人数是否已满
  548. var aa = stuSelectLessonListOfElectivePreIBLL.GetStuSelectLessonListOfElectivePreListByOLPEId(olpeEntity.Id);
  549. var aaa = aa.Where(x => x.Status == 2).Count();
  550. if (aaa >= olpeEntity.StuNumMax)
  551. {
  552. return Fail("当前课程报名人数已满,请选择其他课程!");
  553. }
  554. //当前学员本学期是否有报名课程:每学期一门
  555. //var sslleEntity = stuSelectLessonListOfElectivePreIBLL.GetStuSelectLessonListOfElectivePreEntityByStuNo(loginUserInfo.enCode, "");
  556. //if (sslleEntity != null)
  557. //{
  558. // if (sslleEntity.OLPEId != keyvalue && sslleEntity.Status != 3)
  559. // {
  560. // return Fail("已存在报名课程,每学期只能选择一门选修课!如需报名其他课程请先取消。");
  561. // }
  562. // if (sslleEntity.Status == 1)
  563. // {
  564. // return Fail("报名审核中,请耐心等待!");
  565. // }
  566. // else if (sslleEntity.Status == 2)
  567. // {
  568. // return Fail("已存在报名成功的课程,只能选择一门选修课!");
  569. // }
  570. // else if (sslleEntity.Status == 3)//移除报名失败的数据
  571. // {
  572. // stuSelectLessonListOfElectivePreIBLL.DeleteEntity(sslleEntity.Id);
  573. // }
  574. //}
  575. //每学期两门
  576. var sslleList = stuSelectLessonListOfElectivePreIBLL.GetStuSelectLessonListOfElectivePreListByStuNo(loginUserInfo.enCode);
  577. var sslleListOfNow = sslleList.Where(x => x.AcademicYearNo == olpeEntity.AcademicYearNo && x.Semester == olpeEntity.Semester);
  578. var sslleListOfNow1 = sslleListOfNow.Where(x => x.Status == 1 || x.Status == 2);
  579. var sslleListOfNow2 = sslleListOfNow.Where(x => x.Status == 3);
  580. if (sslleListOfNow1.Count() >= Config.GetValue("ElectiveLessonApplyMax").ToInt())
  581. {
  582. return Fail("每学期最多选择" + Config.GetValue("ElectiveLessonApplyMax").ToInt() + "门选修课!");
  583. }
  584. else
  585. {
  586. var m = sslleListOfNow1.FirstOrDefault(x => x.OLPEId == olpeEntity.Id);
  587. if (m != null)
  588. {
  589. if (m.Status == 1)
  590. {
  591. return Fail("当前课程报名审核中,请耐心等待!");
  592. }
  593. else if (m.Status == 2)
  594. {
  595. return Fail("当前课程已报名成功!");
  596. }
  597. }
  598. }
  599. if (sslleListOfNow2.Count() > 0)
  600. {
  601. foreach (var item in sslleListOfNow2)
  602. {
  603. stuSelectLessonListOfElectivePreIBLL.DeleteEntity(item.Id);
  604. }
  605. }
  606. //新增报名数据
  607. var model = new StuSelectLessonListOfElectivePreEntity()
  608. {
  609. OLPEId = olpeEntity.Id,
  610. NoticeBookNo = stuInfoBasicEntity.NoticeNo,
  611. StuNo = stuInfoBasicEntity.StuNo,
  612. DeptNo = stuInfoBasicEntity.DeptNo,
  613. MajorNo = stuInfoBasicEntity.MajorNo,
  614. ClassNo = stuInfoBasicEntity.ClassNo,
  615. MajorDetailNo = stuInfoBasicEntity.MajorDetailNo,
  616. MajorDetailName = stuInfoBasicEntity.MajorDetailName,
  617. StuName = stuInfoBasicEntity.StuName,
  618. GenderNo = stuInfoBasicEntity.GenderNo,
  619. Grade = stuInfoBasicEntity.Grade,
  620. AcademicYearNo = olpeEntity.AcademicYearNo,
  621. Semester = olpeEntity.Semester,
  622. LessonNo = olpeEntity.LessonNo,
  623. LessonName = olpeEntity.LessonName,
  624. LessonSortNo = olpeEntity.LessonSortNo,
  625. LessonSection = olpeEntity.LessonSection,
  626. LessonTime = olpeEntity.LessonTime,
  627. EmpNo = olpeEntity.EmpNo,
  628. EmpName = olpeEntity.EmpName,
  629. ClassRoomNo = olpeEntity.ClassRoomNo,
  630. ClassRoomName = olpeEntity.ClassRoomName,
  631. StudyScore = olpeEntity.StudyScore,
  632. StartWeek = olpeEntity.StartWeek,
  633. EndWeek = olpeEntity.EndWeek,
  634. StartDate = olpeEntity.StartDate,
  635. EndDate = olpeEntity.EndDate,
  636. CreateTime = DateTime.Now,
  637. Status = 1,
  638. OrdinaryScoreScale = 1,
  639. TermInScoreScale = 1,
  640. TermEndScoreScale = 1,
  641. OtherScoreScale = 1,
  642. F_SchoolId = olpeEntity.F_SchoolId
  643. };
  644. stuSelectLessonListOfElectivePreIBLL.SaveEntity("", model);
  645. return Success("报名成功");
  646. }
  647. #endregion
  648. }
  649. }