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.
 
 
 
 
 
 

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