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.

OpenLessonPlanOfElectiveController.cs 36 KiB

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