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.
 
 
 
 
 
 

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