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.
 
 
 
 
 
 

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