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.
 
 
 
 
 
 

885 lines
34 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. [HttpGet]
  80. public ActionResult FormElective()
  81. {
  82. return View();
  83. }
  84. /// <summary>
  85. /// 选 成绩比例设置
  86. /// </summary>
  87. /// <returns></returns>
  88. [HttpGet]
  89. public ActionResult IndexElective()
  90. {
  91. return View();
  92. }
  93. /// <summary>
  94. /// 选 成绩比例设置
  95. /// </summary>
  96. /// <returns></returns>
  97. [HttpGet]
  98. public ActionResult FormOfElective()
  99. {
  100. return View();
  101. }
  102. #endregion
  103. #region 获取数据
  104. /// <summary>
  105. /// 获取页面显示列表数据
  106. /// <summary>
  107. /// <param name="queryJson">查询参数</param>
  108. /// <returns></returns>
  109. [HttpGet]
  110. [AjaxOnly]
  111. public ActionResult GetPageList(string pagination, string queryJson)
  112. {
  113. Pagination paginationobj = pagination.ToObject<Pagination>();
  114. var data = openLessonPlanOfElectiveIBLL.GetPageList(paginationobj, queryJson);
  115. var jsonData = new
  116. {
  117. rows = data,
  118. total = paginationobj.total,
  119. page = paginationobj.page,
  120. records = paginationobj.records
  121. };
  122. return Success(jsonData);
  123. }
  124. /// <summary>
  125. /// 获取页面显示列表数据
  126. /// <summary>
  127. /// <param name="queryJson">查询参数</param>
  128. /// <returns></returns>
  129. [HttpGet]
  130. [AjaxOnly]
  131. public ActionResult GetPageListElective(string pagination, string queryJson)
  132. {
  133. Pagination paginationobj = pagination.ToObject<Pagination>();
  134. var data = openLessonPlanOfElectiveIBLL.GetPageListElective(paginationobj, queryJson);
  135. var jsonData = new
  136. {
  137. rows = data,
  138. total = paginationobj.total,
  139. page = paginationobj.page,
  140. records = paginationobj.records
  141. };
  142. return Success(jsonData);
  143. }
  144. [HttpGet]
  145. [AjaxOnly]
  146. public ActionResult GetPageListOfMerge(string pagination, string queryJson)
  147. {
  148. Pagination paginationobj = pagination.ToObject<Pagination>();
  149. var data = openLessonPlanOfElectiveIBLL.GetPageListOfMerge(paginationobj, queryJson);
  150. var jsonData = new
  151. {
  152. rows = data,
  153. total = paginationobj.total,
  154. page = paginationobj.page,
  155. records = paginationobj.records
  156. };
  157. return Success(jsonData);
  158. }
  159. /// <summary>
  160. /// 获取表单数据
  161. /// <summary>
  162. /// <returns></returns>
  163. [HttpGet]
  164. [AjaxOnly]
  165. public ActionResult GetFormData(string keyValue)
  166. {
  167. var OpenLessonPlanOfElectiveData = openLessonPlanOfElectiveIBLL.GetOpenLessonPlanOfElectiveEntity(keyValue);
  168. var jsonData = new
  169. {
  170. OpenLessonPlanOfElective = OpenLessonPlanOfElectiveData,
  171. };
  172. return Success(jsonData);
  173. }
  174. /// <summary>
  175. /// 获取页面显示列表数据【学子在线-选课中心】
  176. /// <summary>
  177. /// <param name="queryJson">查询参数</param>
  178. /// <returns></returns>
  179. [HttpGet]
  180. [AjaxOnly]
  181. public ActionResult GetPageListOfStudent(string pagination, string queryJson)
  182. {
  183. Pagination paginationobj = pagination.ToObject<Pagination>();
  184. var data = openLessonPlanOfElectiveIBLL.GetPageListOfStudent(paginationobj, queryJson).OrderByDescending(x => x.AcademicYearNo).ThenByDescending(x => x.Semester).ThenBy(x => x.LessonNo).ThenBy(x => x.EmpNo);
  185. var jsonData = new
  186. {
  187. rows = data,
  188. total = paginationobj.total,
  189. page = paginationobj.page,
  190. records = paginationobj.records
  191. };
  192. return Success(jsonData);
  193. }
  194. /// <summary>
  195. /// 获取表单数据
  196. /// <summary>
  197. /// <returns></returns>
  198. [HttpGet]
  199. [AjaxOnly]
  200. public ActionResult GetOpenLessonPlanEntityByJson(string queryJson)
  201. {
  202. var OpenLessonPlanData = openLessonPlanOfElectiveIBLL.GetOpenLessonPlanEntityByJson(queryJson);
  203. var jsonData = new
  204. {
  205. OpenLessonPlanOfElective = OpenLessonPlanData,
  206. };
  207. return Success(jsonData);
  208. }
  209. /// <summary>
  210. /// 获取表单数据
  211. /// <summary>
  212. /// <returns></returns>
  213. [HttpGet]
  214. [AjaxOnly]
  215. public ActionResult GetStuSelectLessonListEntityByJson(string queryJson)
  216. {
  217. var StuSelectLessonListData = openLessonPlanOfElectiveIBLL.GetStuSelectLessonListEntityByJson(queryJson);
  218. var jsonData = new
  219. {
  220. StuSelectLessonListOfElective = StuSelectLessonListData,
  221. };
  222. return Success(jsonData);
  223. }
  224. #endregion
  225. #region 提交数据
  226. /// <summary>
  227. /// 删除实体数据
  228. /// <param name="keyValue">主键</param>
  229. /// <summary>
  230. /// <returns></returns>
  231. [HttpPost]
  232. [AjaxOnly]
  233. public ActionResult DeleteForm(string keyValue)
  234. {
  235. openLessonPlanOfElectiveIBLL.DeleteEntity(keyValue);
  236. return Success("删除成功!");
  237. }
  238. /// <summary>
  239. /// 保存实体数据(新增、修改)
  240. /// <param name="keyValue">主键</param>
  241. /// <summary>
  242. /// <returns></returns>
  243. [HttpPost]
  244. [ValidateAntiForgeryToken]
  245. [AjaxOnly]
  246. public ActionResult SaveForm(string keyValue, string strEntity)
  247. {
  248. var loginUserInfo = LoginUserInfo.Get();
  249. OpenLessonPlanOfElectiveEntity entity = strEntity.ToObject<OpenLessonPlanOfElectiveEntity>();
  250. entity.ModifyTime = DateTime.Now;
  251. entity.ModifyUserId = loginUserInfo.userId;
  252. entity.ModifyUserName = loginUserInfo.realName;
  253. openLessonPlanOfElectiveIBLL.SaveEntity(keyValue, entity);
  254. return Success("保存成功!");
  255. }
  256. [HttpPost]
  257. [ValidateAntiForgeryToken]
  258. [AjaxOnly]
  259. public ActionResult AddForm(string keyValue, string strEntity)
  260. {
  261. var loginUserInfo = LoginUserInfo.Get();
  262. OpenLessonPlanOfElectiveEntity entity = strEntity.ToObject<OpenLessonPlanOfElectiveEntity>();
  263. entity.ModifyTime = DateTime.Now;
  264. entity.ModifyUserId = loginUserInfo.userId;
  265. entity.ModifyUserName = loginUserInfo.realName;
  266. entity.LessonSection = "57,58";
  267. entity.LessonTime = "18:00-18:45,18:45-19:30";
  268. entity.F_SchoolId = loginUserInfo.companyId;
  269. entity.LessonSortNo = "2";
  270. entity.MakeDate = DateTime.Now;
  271. entity.CheckMark = "1";
  272. openLessonPlanOfElectiveIBLL.AddForm(keyValue, entity);
  273. return Success("保存成功!");
  274. }
  275. /// <summary>
  276. /// 保存实体数据(新增、修改)
  277. /// <param name="keyValue">主键</param>
  278. /// <summary>
  279. /// <returns></returns>
  280. [HttpPost]
  281. [ValidateAntiForgeryToken]
  282. [AjaxOnly]
  283. public ActionResult SaveModifyForm(string keyValue, string strEntity)
  284. {
  285. OpenLessonPlanOfElectiveChangeEntity entity = strEntity.ToObject<OpenLessonPlanOfElectiveChangeEntity>();
  286. if (string.IsNullOrEmpty(entity.AfterLessonNo) && string.IsNullOrEmpty(entity.AfterEmpNo) && string.IsNullOrEmpty(entity.AfterClassRoomNo))
  287. {
  288. return Fail("未选择新课程、新教师、新教室!");
  289. }
  290. 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)
  291. {
  292. return Fail("未改变新课程、新教师、新教室!");
  293. }
  294. var loginUserInfo = LoginUserInfo.Get();
  295. var model = new OpenLessonPlanOfElectiveChangeEntity();
  296. model.CreateTime = DateTime.Now;
  297. model.CreateUserId = loginUserInfo.userId;
  298. model.CreateUserName = loginUserInfo.realName;
  299. model.OLPEId = keyValue;
  300. model.BeforeLessonNo = entity.LessonNo;
  301. model.AfterLessonNo = entity.LessonNo;
  302. model.BeforeEmpNo = entity.EmpNo;
  303. model.AfterEmpNo = entity.EmpNo;
  304. model.BeforeClassRoomNo = entity.ClassRoomNo;
  305. model.AfterClassRoomNo = entity.ClassRoomNo;
  306. if (!string.IsNullOrEmpty(entity.AfterLessonNo))
  307. {
  308. model.AfterLessonNo = entity.AfterLessonNo;
  309. var lesson = dataSourceIBLL.GetDataTable("LessonInfo", "t.lessonno='" + entity.AfterLessonNo + "'");
  310. if (lesson != null && lesson.Rows.Count > 0)
  311. {
  312. model.AfterLessonName = lesson.Rows[0]["lessonname"].ToString();
  313. }
  314. }
  315. else
  316. {
  317. var lesson = dataSourceIBLL.GetDataTable("LessonInfo", "t.lessonno='" + entity.LessonNo + "'");
  318. if (lesson != null && lesson.Rows.Count > 0)
  319. {
  320. model.AfterLessonName = lesson.Rows[0]["lessonname"].ToString();
  321. }
  322. }
  323. if (!string.IsNullOrEmpty(entity.AfterEmpNo))
  324. {
  325. model.AfterEmpNo = entity.AfterEmpNo;
  326. var emp = dataSourceIBLL.GetDataTable("EmpInfo", "t.empno='" + entity.AfterEmpNo + "'");
  327. if (emp != null && emp.Rows.Count > 0)
  328. {
  329. model.AfterEmpName = emp.Rows[0]["empname"].ToString();
  330. }
  331. }
  332. else
  333. {
  334. var emp = dataSourceIBLL.GetDataTable("EmpInfo", "t.empno='" + entity.EmpNo + "'");
  335. if (emp != null && emp.Rows.Count > 0)
  336. {
  337. model.AfterEmpName = emp.Rows[0]["empname"].ToString();
  338. }
  339. }
  340. if (!string.IsNullOrEmpty(entity.AfterClassRoomNo))
  341. {
  342. model.AfterClassRoomNo = entity.AfterClassRoomNo;
  343. var classRoom = dataSourceIBLL.GetDataTable("ClassRoomInfo", "t.classroomno='" + entity.AfterClassRoomNo + "'");
  344. if (classRoom != null && classRoom.Rows.Count > 0)
  345. {
  346. model.AfterClassRoomName = classRoom.Rows[0]["classroomname"].ToString();
  347. }
  348. }
  349. else
  350. {
  351. var classRoom = dataSourceIBLL.GetDataTable("ClassRoomInfo", "t.classroomno='" + entity.ClassRoomNo + "'");
  352. if (classRoom != null && classRoom.Rows.Count > 0)
  353. {
  354. model.AfterClassRoomName = classRoom.Rows[0]["classroomname"].ToString();
  355. }
  356. }
  357. openLessonPlanOfElectiveChangeIBLL.SaveEntity("", model);
  358. //修改选修课相关表
  359. openLessonPlanOfElectiveIBLL.DoElectiveChange(model);
  360. return Success("保存成功!");
  361. }
  362. /// <summary>
  363. /// 设置成绩比例
  364. /// </summary>
  365. /// <param name="queryJson"></param>
  366. /// <param name="strEntity"></param>
  367. /// <returns></returns>
  368. [HttpPost]
  369. [ValidateAntiForgeryToken]
  370. [AjaxOnly]
  371. public ActionResult SaveFormOfElective(string keyValue, string strEntity)
  372. {
  373. OpenLessonPlanOfElectiveEntity entity = strEntity.ToObject<OpenLessonPlanOfElectiveEntity>();
  374. openLessonPlanOfElectiveIBLL.SaveFormOfElective(keyValue, entity);
  375. return Success("保存成功!");
  376. }
  377. #endregion
  378. #region 扩展数据
  379. /// <summary>
  380. /// 判断选课是否开始
  381. /// </summary>
  382. /// <returns></returns>
  383. public ActionResult IsSelectElectiveLesson()
  384. {
  385. var entity = openLessonPlanOfElectiveIBLL.GetEADateArrangeEntityAboutElective();
  386. if (entity != null)
  387. {
  388. return Fail("选课已经开始!");
  389. }
  390. return Success("选课还未开始!");
  391. }
  392. /// <summary>
  393. /// 取消报名
  394. /// </summary>
  395. /// <param name="keyvalue"></param>
  396. /// <returns></returns>
  397. public ActionResult CancelApply(string keyvalue)
  398. {
  399. var loginUserInfo = LoginUserInfo.Get();
  400. //学员信息
  401. var stuInfoBasicEntity = stuInfoBasicIBLL.GetStuInfoBasicEntityByStuNo(loginUserInfo.enCode);
  402. if (stuInfoBasicEntity == null)
  403. {
  404. return Fail("当前学员不存在!");
  405. }
  406. //课程信息
  407. var olpeEntity = openLessonPlanOfElectiveIBLL.GetOpenLessonPlanOfElectiveEntity(keyvalue);
  408. if (olpeEntity == null)
  409. {
  410. return Fail("当前课程不存在!");
  411. }
  412. //当前学员是否已经报名该课程
  413. var sslleEntity = stuSelectLessonListOfElectiveIBLL.GetStuSelectLessonListOfElectiveEntityByStuNo(loginUserInfo.enCode, keyvalue);
  414. if (sslleEntity != null)
  415. {
  416. if (sslleEntity.Status != 2)
  417. {
  418. stuSelectLessonListOfElectiveIBLL.DeleteEntity(sslleEntity.Id);
  419. return Success("取消成功");
  420. }
  421. else
  422. {
  423. return Fail("取消失败,当前课程已报名成功!");
  424. }
  425. }
  426. else
  427. {
  428. return Fail("当前课程未报名,无需取消!");
  429. }
  430. }
  431. /// <summary>
  432. /// 选修课报名:弃用
  433. /// </summary>
  434. /// <param name="keyvalue"></param>
  435. /// <returns></returns>
  436. public ActionResult ElectiveLessonApply(string keyvalue)
  437. {
  438. var loginUserInfo = LoginUserInfo.Get();
  439. //学员信息
  440. var stuInfoBasicEntity = stuInfoBasicIBLL.GetStuInfoBasicEntityByStuNo(loginUserInfo.enCode);
  441. if (stuInfoBasicEntity == null)
  442. {
  443. return Fail("当前学员不存在!");
  444. }
  445. //课程信息
  446. var olpeEntity = openLessonPlanOfElectiveIBLL.GetOpenLessonPlanOfElectiveEntity(keyvalue);
  447. if (olpeEntity == null)
  448. {
  449. return Fail("当前课程不存在!");
  450. }
  451. //所选课程的报名人数是否已满
  452. //if (olpeEntity.StuNum >= olpeEntity.StuNumMax)
  453. //{
  454. // return Fail("当前课程报名人数已满,请选择其他课程!");
  455. //}
  456. //模式二:
  457. var aa = stuSelectLessonListOfElectiveIBLL.GetStuSelectLessonListOfElectiveListByOLPEId(olpeEntity.Id);
  458. var aaa = aa.Where(x => x.Status == 1 || x.Status == 2).Count();
  459. if (aaa >= olpeEntity.StuNumMax)
  460. {
  461. return Fail("当前课程报名人数已满,请选择其他课程!");
  462. }
  463. //当前学员本学期是否有报名课程
  464. var sslleEntity = stuSelectLessonListOfElectiveIBLL.GetStuSelectLessonListOfElectiveEntityByStuNo(loginUserInfo.enCode, "");
  465. if (sslleEntity != null)
  466. {
  467. if (sslleEntity.OLPEId != keyvalue && sslleEntity.Status != 3)
  468. {
  469. return Fail("已存在报名课程,每学期只能选择一门选修课!如需报名其他课程请先取消。");
  470. }
  471. if (sslleEntity.Status == 1)
  472. {
  473. return Fail("报名审核中,请耐心等待!");
  474. }
  475. else if (sslleEntity.Status == 2)
  476. {
  477. return Fail("已存在报名成功的课程,只能选择一门选修课!");
  478. }
  479. else if (sslleEntity.Status == 3)//移除报名失败的数据
  480. {
  481. stuSelectLessonListOfElectiveIBLL.DeleteEntity(sslleEntity.Id);
  482. }
  483. }
  484. //新增报名数据
  485. var model = new StuSelectLessonListOfElectiveEntity()
  486. {
  487. OLPEId = olpeEntity.Id,
  488. NoticeBookNo = stuInfoBasicEntity.NoticeNo,
  489. StuNo = stuInfoBasicEntity.StuNo,
  490. DeptNo = stuInfoBasicEntity.DeptNo,
  491. MajorNo = stuInfoBasicEntity.MajorNo,
  492. ClassNo = stuInfoBasicEntity.ClassNo,
  493. MajorDetailNo = stuInfoBasicEntity.MajorDetailNo,
  494. MajorDetailName = stuInfoBasicEntity.MajorDetailName,
  495. StuName = stuInfoBasicEntity.StuName,
  496. GenderNo = stuInfoBasicEntity.GenderNo,
  497. Grade = stuInfoBasicEntity.Grade,
  498. AcademicYearNo = olpeEntity.AcademicYearNo,
  499. Semester = olpeEntity.Semester,
  500. LessonNo = olpeEntity.LessonNo,
  501. LessonName = olpeEntity.LessonName,
  502. LessonSortNo = olpeEntity.LessonSortNo,
  503. LessonSection = olpeEntity.LessonSection,
  504. LessonTime = olpeEntity.LessonTime,
  505. EmpNo = olpeEntity.EmpNo,
  506. EmpName = olpeEntity.EmpName,
  507. ClassRoomNo = olpeEntity.ClassRoomNo,
  508. ClassRoomName = olpeEntity.ClassRoomName,
  509. StudyScore = olpeEntity.StudyScore,
  510. StartWeek = olpeEntity.StartWeek,
  511. EndWeek = olpeEntity.EndWeek,
  512. StartDate = olpeEntity.StartDate,
  513. EndDate = olpeEntity.EndDate,
  514. CreateTime = DateTime.Now,
  515. Status = 1,
  516. OrdinaryScoreScale = 1,
  517. TermInScoreScale = 1,
  518. TermEndScoreScale = 1,
  519. OtherScoreScale = 1
  520. };
  521. stuSelectLessonListOfElectiveIBLL.SaveEntity("", model);
  522. return Success("报名成功");
  523. }
  524. /// <summary>
  525. /// 判断登录学生是否可以选课
  526. /// </summary>
  527. /// <returns></returns>
  528. public ActionResult IsCanApplyElectiveLesson()
  529. {
  530. var loginUserInfo = LoginUserInfo.Get();
  531. var stuInfoBasicEntity = stuInfoBasicIBLL.GetStuInfoBasicEntityByStuNo(loginUserInfo.account);
  532. if (stuInfoBasicEntity == null)
  533. {
  534. return Fail("学籍信息不存在!");
  535. }
  536. var classInfoEntity = classInfoIBLL.GetClassInfoEntityByClassNo(stuInfoBasicEntity.ClassNo);
  537. //var yearAndSemester = Common.GetSemesterAndYear();
  538. //var electiveMajorList = electiveMajorIBLL.GetList(yearAndSemester.AcademicYearShort, yearAndSemester.Semester).ToList();
  539. //if (electiveMajorList.Any()) //有设置选修专业,进行专业判断;没有设置选修专业,都可以选课
  540. //{
  541. // var majorList = electiveMajorList.Select(x => x.MajorNo);
  542. // if (!majorList.Contains(classInfoEntity?.MajorNo))
  543. // {
  544. // return Fail("不可以选课!");
  545. // }
  546. //}
  547. //todo:
  548. return Success("可以选课!");
  549. }
  550. /// <summary>
  551. /// 判断队列结果
  552. /// </summary>
  553. /// <returns></returns>
  554. public ActionResult GetApplyResult(string keyvalue)
  555. {
  556. var loginUserInfo = LoginUserInfo.Get();
  557. //学员信息
  558. var stuInfoBasicEntity = stuInfoBasicIBLL.GetStuInfoBasicEntityByStuNo(loginUserInfo.enCode);
  559. if (stuInfoBasicEntity == null)
  560. {
  561. return Success("当前学员不存在!");
  562. }
  563. //课程信息
  564. var olpeEntity = openLessonPlanOfElectiveIBLL.GetOpenLessonPlanOfElectiveEntity(keyvalue);
  565. if (olpeEntity == null)
  566. {
  567. return Success("当前课程不存在!");
  568. }
  569. //当前学员本学期是否有报名课程:每学期一门
  570. //var sslleEntity = stuSelectLessonListOfElectiveIBLL.GetStuSelectLessonListOfElectiveEntityByStuNo(loginUserInfo.enCode, "");
  571. //if (sslleEntity != null)
  572. //{
  573. // if (sslleEntity.OLPEId != keyvalue && sslleEntity.Status != 3)
  574. // {
  575. // return Success("已存在报名课程,每学期只能选择一门选修课!如需报名其他课程请先取消。");
  576. // }
  577. // if (sslleEntity.Status == 1)
  578. // {
  579. // return Success("报名审核中,请耐心等待!");
  580. // }
  581. // else if (sslleEntity.Status == 2)
  582. // {
  583. // return Success("已存在报名成功的课程,只能选择一门选修课!");
  584. // }
  585. //}
  586. //else
  587. //{
  588. // //所选课程的报名人数是否已满
  589. // var aa = stuSelectLessonListOfElectiveIBLL.GetStuSelectLessonListOfElectiveListByOLPEId(keyvalue);
  590. // var aaa = aa.Count(x => x.Status == 1 || x.Status == 2);
  591. // if (aaa >= olpeEntity.StuNumMax)
  592. // {
  593. // return Success("当前课程报名人数已满,请选择其他课程!");
  594. // }
  595. //}
  596. //每学期两门
  597. var sslleEntity = stuSelectLessonListOfElectiveIBLL.GetStuSelectLessonListOfElectiveEntityByStuNo(loginUserInfo.enCode, keyvalue);
  598. if (sslleEntity != null)
  599. {
  600. if (sslleEntity.Status == 1)
  601. {
  602. return Success("当前课程报名审核中,请耐心等待!");
  603. }
  604. else if (sslleEntity.Status == 2)
  605. {
  606. return Success("当前课程已报名成功!");
  607. }
  608. }
  609. else
  610. {
  611. //所选课程的报名人数是否已满
  612. var aa = stuSelectLessonListOfElectiveIBLL.GetStuSelectLessonListOfElectiveListByOLPEId(keyvalue);
  613. var aaa = aa.Count(x => x.Status == 1 || x.Status == 2);
  614. if (aaa >= olpeEntity.StuNumMax)
  615. {
  616. return Success("当前课程报名人数已满,请选择其他课程!");
  617. }
  618. //每学期最多两门
  619. var sslleList = stuSelectLessonListOfElectiveIBLL.GetStuSelectLessonListOfElectiveListByStuNo(loginUserInfo.enCode);
  620. var sslleListOfNow = sslleList.Where(x => x.AcademicYearNo == olpeEntity.AcademicYearNo && x.Semester == olpeEntity.Semester);
  621. var sslleListOfNow1 = sslleListOfNow.Where(x => x.Status == 1 || x.Status == 2);
  622. //if (sslleListOfNow1.Count() >= 2)
  623. if (sslleListOfNow1.Count() >= Config.GetValue("ElectiveLessonApplyMax").ToInt())
  624. {
  625. return Success("每学期最多选择" + Config.GetValue("ElectiveLessonApplyMax").ToInt() + "门选修课!");
  626. }
  627. //相同时间不能报名
  628. if (sslleListOfNow1.Where(x => x.LessonSection == olpeEntity.LessonSection).Any())
  629. {
  630. //相同时间不能报名
  631. return Success("本学期此时间段已有报名的选修课!");
  632. }
  633. }
  634. return Fail("正在提交,请等待!");
  635. }
  636. /// <summary>
  637. /// 取消报名(预)
  638. /// </summary>
  639. /// <param name="keyvalue"></param>
  640. /// <returns></returns>
  641. public ActionResult CancelApplyPre(string keyvalue)
  642. {
  643. var loginUserInfo = LoginUserInfo.Get();
  644. //学员信息
  645. var stuInfoBasicEntity = stuInfoBasicIBLL.GetStuInfoBasicEntityByStuNo(loginUserInfo.enCode);
  646. if (stuInfoBasicEntity == null)
  647. {
  648. return Fail("当前学员不存在!");
  649. }
  650. //课程信息
  651. var olpeEntity = openLessonPlanOfElectiveIBLL.GetOpenLessonPlanOfElectiveEntity(keyvalue);
  652. if (olpeEntity == null)
  653. {
  654. return Fail("当前课程不存在!");
  655. }
  656. //当前学员是否已经报名该课程
  657. var sslleEntity = stuSelectLessonListOfElectivePreIBLL.GetStuSelectLessonListOfElectivePreEntityByStuNo(loginUserInfo.enCode, keyvalue);
  658. if (sslleEntity != null)
  659. {
  660. if (sslleEntity.Status != 2)
  661. {
  662. stuSelectLessonListOfElectivePreIBLL.DeleteEntity(sslleEntity.Id);
  663. return Success("取消成功");
  664. }
  665. else
  666. {
  667. return Fail("取消失败,当前课程已报名成功!");
  668. }
  669. }
  670. else
  671. {
  672. return Fail("当前课程未报名,无需取消!");
  673. }
  674. }
  675. /// <summary>
  676. /// 选修课报名(预)
  677. /// </summary>
  678. /// <param name="keyvalue"></param>
  679. /// <returns></returns>
  680. public ActionResult ElectiveLessonApplyPre(string keyvalue)
  681. {
  682. var loginUserInfo = LoginUserInfo.Get();
  683. //学员信息
  684. var stuInfoBasicEntity = stuInfoBasicIBLL.GetStuInfoBasicEntityByStuNo(loginUserInfo.enCode);
  685. if (stuInfoBasicEntity == null)
  686. {
  687. return Fail("当前学员不存在!");
  688. }
  689. //课程信息
  690. var olpeEntity = openLessonPlanOfElectiveIBLL.GetOpenLessonPlanOfElectiveEntity(keyvalue);
  691. if (olpeEntity == null)
  692. {
  693. return Fail("当前课程不存在!");
  694. }
  695. //所选课程的报名人数是否已满
  696. var aa = stuSelectLessonListOfElectivePreIBLL.GetStuSelectLessonListOfElectivePreListByOLPEId(olpeEntity.Id);
  697. var aaa = aa.Where(x => x.Status == 2).Count();
  698. if (aaa >= olpeEntity.StuNumMax)
  699. {
  700. return Fail("当前课程报名人数已满,请选择其他课程!");
  701. }
  702. //当前学员本学期是否有报名课程:每学期一门
  703. //var sslleEntity = stuSelectLessonListOfElectivePreIBLL.GetStuSelectLessonListOfElectivePreEntityByStuNo(loginUserInfo.enCode, "");
  704. //if (sslleEntity != null)
  705. //{
  706. // if (sslleEntity.OLPEId != keyvalue && sslleEntity.Status != 3)
  707. // {
  708. // return Fail("已存在报名课程,每学期只能选择一门选修课!如需报名其他课程请先取消。");
  709. // }
  710. // if (sslleEntity.Status == 1)
  711. // {
  712. // return Fail("报名审核中,请耐心等待!");
  713. // }
  714. // else if (sslleEntity.Status == 2)
  715. // {
  716. // return Fail("已存在报名成功的课程,只能选择一门选修课!");
  717. // }
  718. // else if (sslleEntity.Status == 3)//移除报名失败的数据
  719. // {
  720. // stuSelectLessonListOfElectivePreIBLL.DeleteEntity(sslleEntity.Id);
  721. // }
  722. //}
  723. //每学期两门
  724. var sslleList = stuSelectLessonListOfElectivePreIBLL.GetStuSelectLessonListOfElectivePreListByStuNo(loginUserInfo.enCode);
  725. var sslleListOfNow = sslleList.Where(x => x.AcademicYearNo == olpeEntity.AcademicYearNo && x.Semester == olpeEntity.Semester);
  726. var sslleListOfNow1 = sslleListOfNow.Where(x => x.Status == 1 || x.Status == 2);
  727. var sslleListOfNow2 = sslleListOfNow.Where(x => x.Status == 3);
  728. if (sslleListOfNow1.Count() >= Config.GetValue("ElectiveLessonApplyMax").ToInt())
  729. {
  730. return Fail("每学期最多选择" + Config.GetValue("ElectiveLessonApplyMax").ToInt() + "门选修课!");
  731. }
  732. else
  733. {
  734. var m = sslleListOfNow1.FirstOrDefault(x => x.OLPEId == olpeEntity.Id);
  735. if (m != null)
  736. {
  737. if (m.Status == 1)
  738. {
  739. return Fail("当前课程报名审核中,请耐心等待!");
  740. }
  741. else if (m.Status == 2)
  742. {
  743. return Fail("当前课程已报名成功!");
  744. }
  745. }
  746. }
  747. if (sslleListOfNow2.Count() > 0)
  748. {
  749. foreach (var item in sslleListOfNow2)
  750. {
  751. stuSelectLessonListOfElectivePreIBLL.DeleteEntity(item.Id);
  752. }
  753. }
  754. //新增报名数据
  755. var model = new StuSelectLessonListOfElectivePreEntity()
  756. {
  757. OLPEId = olpeEntity.Id,
  758. NoticeBookNo = stuInfoBasicEntity.NoticeNo,
  759. StuNo = stuInfoBasicEntity.StuNo,
  760. DeptNo = stuInfoBasicEntity.DeptNo,
  761. MajorNo = stuInfoBasicEntity.MajorNo,
  762. ClassNo = stuInfoBasicEntity.ClassNo,
  763. MajorDetailNo = stuInfoBasicEntity.MajorDetailNo,
  764. MajorDetailName = stuInfoBasicEntity.MajorDetailName,
  765. StuName = stuInfoBasicEntity.StuName,
  766. GenderNo = stuInfoBasicEntity.GenderNo,
  767. Grade = stuInfoBasicEntity.Grade,
  768. AcademicYearNo = olpeEntity.AcademicYearNo,
  769. Semester = olpeEntity.Semester,
  770. LessonNo = olpeEntity.LessonNo,
  771. LessonName = olpeEntity.LessonName,
  772. LessonSortNo = olpeEntity.LessonSortNo,
  773. LessonSection = olpeEntity.LessonSection,
  774. LessonTime = olpeEntity.LessonTime,
  775. EmpNo = olpeEntity.EmpNo,
  776. EmpName = olpeEntity.EmpName,
  777. ClassRoomNo = olpeEntity.ClassRoomNo,
  778. ClassRoomName = olpeEntity.ClassRoomName,
  779. StudyScore = olpeEntity.StudyScore,
  780. StartWeek = olpeEntity.StartWeek,
  781. EndWeek = olpeEntity.EndWeek,
  782. StartDate = olpeEntity.StartDate,
  783. EndDate = olpeEntity.EndDate,
  784. CreateTime = DateTime.Now,
  785. Status = 1,
  786. OrdinaryScoreScale = 1,
  787. TermInScoreScale = 1,
  788. TermEndScoreScale = 1,
  789. OtherScoreScale = 1,
  790. F_SchoolId = olpeEntity.F_SchoolId
  791. };
  792. stuSelectLessonListOfElectivePreIBLL.SaveEntity("", model);
  793. return Success("报名成功");
  794. }
  795. /// <summary>
  796. /// 初始化学生选课记录
  797. /// </summary>
  798. /// <returns></returns>
  799. public ActionResult InitStuSelectLesson(string keyvalue)
  800. {
  801. openLessonPlanOfElectiveIBLL.InitStuSelectLesson(keyvalue);
  802. return Success("操作成功!");
  803. }
  804. #endregion
  805. /// <summary>
  806. /// 保存实体数据(新增、修改)
  807. /// <param name="keyValue">主键</param>
  808. /// <summary>
  809. /// <returns></returns>
  810. [HttpPost]
  811. [ValidateAntiForgeryToken]
  812. [AjaxOnly]
  813. public ActionResult SaveFormOfClass(string queryJson, string strEntity)
  814. {
  815. StuSelectLessonListOfElectiveEntity entity = strEntity.ToObject<StuSelectLessonListOfElectiveEntity>();
  816. openLessonPlanOfElectiveIBLL.SaveStuSelectLessonListScaleByJson(queryJson, entity);
  817. return Success("保存成功!");
  818. }
  819. }
  820. }