RetakePlanResultTaskController.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using EMIS.ViewModel;
  7. using EMIS.Web.Controls;
  8. using Bowin.Web.Controls.Mvc;
  9. using EMIS.CommonLogic.RetakeManage;
  10. using Bowin.Common.Utility;
  11. using Bowin.Common.Data;
  12. using EMIS.CommonLogic.RetakeManage.General;
  13. using EMIS.ViewModel.RetakeManage;
  14. using EMIS.Utility.FormValidate;
  15. using Bowin.Common.Linq.Entity;
  16. using Bowin.Common.JSON;
  17. using EMIS.Utility;
  18. namespace EMIS.Web.Controllers.RetakeManage.General
  19. {
  20. [Authorization]
  21. public class RetakePlanResultTaskController : Controller
  22. {
  23. public IRetakePlanTaskServices RetakePlanTaskServices { get; set; }
  24. public IRetakePlanResultServices RetakePlanResultTaskServices { get; set; }
  25. /// <summary>
  26. /// 重修班级页面
  27. /// </summary>
  28. /// <returns></returns>
  29. public ActionResult List()
  30. {
  31. return View();
  32. }
  33. /// <summary>
  34. /// 重修班级列表查询
  35. /// </summary>
  36. /// <param name="pararms"></param>
  37. /// <returns></returns>
  38. [HttpPost]
  39. public ActionResult List(QueryParamsModel pararms)
  40. {
  41. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  42. var schoolyearID = pararms.getExtraGuid("SchoolYearDropdown").ToString() == DropdownList.SELECT_ALL.ToString() ? null : pararms.getExtraGuid("SchoolYearDropdown");
  43. //开课院系所
  44. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  45. //开课教研室
  46. var departmentID = pararms.getExtraGuid("DepartmentComboGrid");
  47. var coursematerialID = pararms.getExtraGuid("CoursematerialComboGrid");
  48. var retakeTypeID = pararms.getExtraInt("DictionaryRetakeType") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryRetakeType");
  49. var statusID = pararms.getExtraInt("DictionaryStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryStatus");
  50. return Json(RetakePlanResultTaskServices.GetRetakePlanResultTaskView(configuretView, schoolyearID, collegeID, departmentID,
  51. coursematerialID, retakeTypeID, statusID, (int)pararms.page, (int)pararms.rows));
  52. }
  53. /// <summary>
  54. /// 编辑
  55. /// </summary>
  56. /// <param name="RetakePlanID"></param>
  57. /// <returns></returns>
  58. public ActionResult Edit(Guid? retakePlanID)
  59. {
  60. RetakePlanTaskSettingView retakePlanTaskView = new RetakePlanTaskSettingView();
  61. if (retakePlanID != Guid.Empty && retakePlanID.HasValue)
  62. {
  63. retakePlanTaskView = RetakePlanTaskServices.GetRetakePlanTaskUpdateView(retakePlanID);
  64. //处理方式(暂时无效)
  65. retakePlanTaskView.HandleModeID = retakePlanTaskView.HandleModeID.HasValue ?
  66. retakePlanTaskView.HandleModeID : (int)EMIS.ViewModel.CF_HandleMode.RequiredCourse;
  67. //重修任务状态标识
  68. ViewBag.Status = retakePlanTaskView.RecordStatus;
  69. }
  70. else
  71. {
  72. retakePlanTaskView.ExaminationModeID = (int)CF_ExaminationMode.WrittenExam;
  73. retakePlanTaskView.IsRequired = true;
  74. retakePlanTaskView.PeopleNumlimit = 0;
  75. retakePlanTaskView.PeopleNumlower = 0;
  76. }
  77. return View(retakePlanTaskView);
  78. }
  79. /// <summary>
  80. /// 编辑
  81. /// </summary>
  82. /// <param name="RetakePlanTaskSetting"></param>
  83. /// <returns></returns>
  84. [HttpPost]
  85. public ActionResult Edit(RetakePlanTaskSettingView retakePlanTaskSettingView)
  86. {
  87. int? type = 0;
  88. try
  89. {
  90. //排课明细列表
  91. var schedulingList = DataGrid.GetTableData<RetakePlanSettingSchedulingView>("dgSchedulingList");
  92. //任课教师列表
  93. var teacherList = DataGrid.GetTableData<RetakePlanTeacherListView>("dgTeacherList");
  94. RetakePlanTaskServices.RetakePlanTaskSet(retakePlanTaskSettingView, teacherList, schedulingList, out type);
  95. return Json(new ReturnMessage()
  96. {
  97. IsSuccess = true,
  98. Message = "保存成功。"
  99. });
  100. }
  101. catch (Exception ex)
  102. {
  103. //如果验证到排课冲突type返回1,页面js根据type弹出选择框
  104. //用户可选择继续保存或不保存,如果不返回1,弹出一般的错误提示框
  105. if (type == 1)
  106. {
  107. return Json(new ReturnMessage()
  108. {
  109. Type = 1,
  110. IsSuccess = false,
  111. Message = "保存失败:" + ex.Message
  112. });
  113. }
  114. else
  115. {
  116. return Json(new ReturnMessage()
  117. {
  118. Type = 2,
  119. IsSuccess = false,
  120. Message = "保存失败:" + ex.Message
  121. });
  122. }
  123. }
  124. }
  125. /// <summary>
  126. /// 开班(重修计划)
  127. /// </summary>
  128. /// <param name="RetakePlanIDs"></param>
  129. /// <returns></returns>
  130. [HttpPost]
  131. public ActionResult Generate(string RetakePlanIDs)
  132. {
  133. try
  134. {
  135. string result = RetakePlanResultTaskServices.RetakePlanResultGenerate(RetakePlanIDs);
  136. return Json(new ReturnMessage()
  137. {
  138. IsSuccess = true,
  139. Message = "" + result + "。"
  140. });
  141. }
  142. catch (Exception ex)
  143. {
  144. return Json(new ReturnMessage()
  145. {
  146. IsSuccess = false,
  147. Message = "开班失败,原因:" + ex.Message + "。"
  148. });
  149. }
  150. }
  151. /// <summary>
  152. /// 重修计划名单列表信息
  153. /// </summary>
  154. /// <returns></returns>
  155. public ActionResult StudentPlanDetail()
  156. {
  157. return View();
  158. }
  159. /// <summary>
  160. /// 重修计划名单列表信息
  161. /// </summary>
  162. /// <param name="pararms"></param>
  163. /// <returns></returns>
  164. [HttpPost]
  165. public ActionResult StudentPlanDetail(QueryParamsModel pararms)
  166. {
  167. var retakePlanID = Request["RetakePlanID"].ParseStrTo<Guid>();
  168. return Json(RetakePlanTaskServices.GetRetakePlanTaskStudentView(retakePlanID, (int)pararms.page, (int)pararms.rows));
  169. }
  170. /// <summary>
  171. /// 重修计划名单Excel导出
  172. /// </summary>
  173. /// <param name="pararms"></param>
  174. /// <returns></returns>
  175. [HttpPost]
  176. public ActionResult StudentPlanDetail_Excel(QueryParamsModel pararms)
  177. {
  178. NpoiExcelHelper neh = new NpoiExcelHelper();
  179. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  180. var retakePlanID = Request["RetakePlanID"].ParseStrTo<Guid>();
  181. var dt = RetakePlanTaskServices.GetRetakePlanTaskStudentViewList(configuretView, retakePlanID)
  182. .Select(x => new
  183. {
  184. x.SchoolyearCode,
  185. x.ClassName,
  186. x.RecordStatusName,
  187. x.RetakeTypeName,
  188. x.LoginID,
  189. x.UserName,
  190. x.SexName,
  191. x.InSchoolStatusName,
  192. x.StudentStatusName,
  193. x.ClassmajorCode,
  194. x.ClassmajorName,
  195. x.GrademajorCode,
  196. x.GrademajorName,
  197. x.CourseCode,
  198. x.CourseName,
  199. x.CourseTypeDesc,
  200. x.CourseCredit,
  201. x.Totalhours,
  202. x.SchoolyearNumDesc,
  203. x.StarttermDesc,
  204. x.DepartmentCode,
  205. x.DepartmentName,
  206. x.ApplyStatusName
  207. }).ToTable();
  208. string[] liststring = {
  209. "重修学年学期", "重修班级名称", "重修任务状态", "重修类型", "学号", "姓名", "性别", "在校状态",
  210. "学籍状态", "班级编号", "班级名称", "年级专业编号", "年级专业名称", "课程代码", "课程名称",
  211. "课程类型", "课程学分", "总学时", "开课学年", "开课学期", "开课教研室代码", "开课教研室名称",
  212. "报名状态"
  213. };
  214. neh.Export(dt, liststring, "重修计划名单信息" + DateTime.Now.ToString("yyyyMMddhhmmss"));
  215. return RedirectToAction("MsgShow", "Common", new
  216. {
  217. msg = "导出成功。",
  218. url = Url.Content("~/RetakePlanResultTask/List").AddMenuParameter()
  219. });
  220. }
  221. /// <summary>
  222. /// 检测重修报名人数是否超过人数下限和人数上限范围
  223. /// </summary>
  224. /// <param name="retakePlanIDs"></param>
  225. /// <returns></returns>
  226. [HttpPost]
  227. public ActionResult IsOverRange(string retakePlanIDs)
  228. {
  229. try
  230. {
  231. var result = RetakePlanResultTaskServices.IsOverRange(retakePlanIDs);
  232. return Json(new ReturnMessage<bool>()
  233. {
  234. IsSuccess = true,
  235. Data = result
  236. });
  237. }
  238. catch (Exception ex)
  239. {
  240. return Json(new ReturnMessage<bool>()
  241. {
  242. IsSuccess = false,
  243. Data = false,
  244. Message = ex.Message
  245. });
  246. }
  247. }
  248. /// <summary>
  249. /// 查询对应的重修班级报名名单
  250. /// </summary>
  251. /// <returns></returns>
  252. public ActionResult StudentDetail()
  253. {
  254. return View();
  255. }
  256. /// <summary>
  257. /// 查询对应的重修班级报名名单
  258. /// </summary>
  259. /// <param name="pararms"></param>
  260. /// <returns></returns>
  261. [HttpPost]
  262. public ActionResult StudentDetail(QueryParamsModel pararms)
  263. {
  264. var retakePlanID = Request["RetakePlanID"].ParseStrTo<Guid>();
  265. return Json(RetakePlanResultTaskServices.GetRetakePlanResultTaskStudentView(retakePlanID, (int)pararms.page, (int)pararms.rows));
  266. }
  267. /// <summary>
  268. /// 重修班级报名名单报名(从计划人数中选择)
  269. /// </summary>
  270. /// <returns></returns>
  271. public ActionResult StudentSelect()
  272. {
  273. var retakePlanID = Request["RetakePlanID"].ParseStrTo<Guid>();
  274. ViewBag.RetakePlanID = retakePlanID;
  275. return View();
  276. }
  277. /// <summary>
  278. /// 重修班级报名名单报名(从计划人数中选择)
  279. /// </summary>
  280. /// <param name="retakePlanTaskView"></param>
  281. /// <param name="UserIDs"></param>
  282. /// <returns></returns>
  283. [HttpPost]
  284. public ActionResult StudentSelect(RetakePlanTaskView retakePlanTaskView, string UserIDs)
  285. {
  286. try
  287. {
  288. string result = RetakePlanResultTaskServices.AddStudent(retakePlanTaskView.RetakePlanID, retakePlanTaskView.UserIDs);
  289. return Json(new ReturnMessage()
  290. {
  291. IsSuccess = true,
  292. Message = "报名成功" + result + "。"
  293. });
  294. }
  295. catch (Exception ex)
  296. {
  297. return Json(new ReturnMessage()
  298. {
  299. IsSuccess = false,
  300. Message = "报名失败,原因:" + ex.Message + "。"
  301. });
  302. }
  303. }
  304. /// <summary>
  305. /// 查询对应的重修班级未报名名单列表(未报名名单)
  306. /// </summary>
  307. /// <param name="pararms"></param>
  308. /// <returns></returns>
  309. [HttpPost]
  310. public ActionResult BaseStudentViewList(QueryParamsModel pararms)
  311. {
  312. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  313. var retakePlanID = new Guid(Request["RetakePlanID"]);
  314. var gradeYearID = pararms.getExtraInt("ddlYear") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlYear");
  315. var standardID = pararms.getExtraInt("cbgStandard") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("cbgStandard");
  316. var classmajorID = pararms.getExtraGuid("cbgClassmajor");
  317. //在校状态
  318. var inSchoolStatus = pararms.getExtraInt("DictionaryInschoolStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryInschoolStatus");
  319. return Json(RetakePlanResultTaskServices.GetStudentView(configuretView, retakePlanID, gradeYearID, standardID,
  320. classmajorID, inSchoolStatus, (int)pararms.page, (int)pararms.rows));
  321. }
  322. /// <summary>
  323. /// 删除(重修报名名单删除,取消报名)
  324. /// </summary>
  325. /// <param name="retakePlanID"></param>
  326. /// <param name="UserIDs"></param>
  327. /// <returns></returns>
  328. [HttpPost]
  329. public ActionResult DeleteStudent(string retakePlanID, string UserIDs)
  330. {
  331. try
  332. {
  333. Guid ID = new Guid(retakePlanID);
  334. RetakePlanResultTaskServices.DeleteStudent(ID, UserIDs);
  335. return Json(new ReturnMessage()
  336. {
  337. IsSuccess = true,
  338. Message = "取消报名成功。"
  339. });
  340. }
  341. catch (Exception ex)
  342. {
  343. return Json(new ReturnMessage()
  344. {
  345. IsSuccess = false,
  346. Message = "取消报名失败,原因:" + ex.Message
  347. });
  348. }
  349. }
  350. /// <summary>
  351. /// 重修班级报名名单Excel导出
  352. /// </summary>
  353. /// <returns></returns>
  354. [HttpPost]
  355. public ActionResult StudentDetailt_Excel()
  356. {
  357. NpoiExcelHelper neh = new NpoiExcelHelper();
  358. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  359. var retakePlanID = Request["RetakePlanID"].ParseStrTo<Guid>();
  360. var dt = RetakePlanResultTaskServices.GetRetakePlanResultTaskStudentViewList(configuretView, retakePlanID)
  361. .Select(x => new
  362. {
  363. x.SchoolyearCode,
  364. x.ClassName,
  365. x.RecordStatusName,
  366. x.RetakeTypeName,
  367. x.LoginID,
  368. x.UserName,
  369. x.SexName,
  370. x.InSchoolStatusName,
  371. x.StudentStatusName,
  372. x.ClassmajorCode,
  373. x.ClassmajorName,
  374. x.GrademajorCode,
  375. x.GrademajorName,
  376. x.CourseCode,
  377. x.CourseName,
  378. x.CourseTypeDesc,
  379. x.CourseCredit,
  380. x.Totalhours,
  381. x.SchoolyearNumDesc,
  382. x.StarttermDesc,
  383. x.DepartmentCode,
  384. x.DepartmentName,
  385. x.ApplyStatusName
  386. }).ToTable();
  387. string[] liststring = {
  388. "重修学年学期", "重修班级名称", "重修任务状态", "重修类型", "学号", "姓名", "性别", "在校状态",
  389. "学籍状态", "班级编号", "班级名称", "年级专业编号", "年级专业名称", "课程代码", "课程名称",
  390. "课程类型", "课程学分", "总学时", "开课学年", "开课学期", "开课教研室代码", "开课教研室名称",
  391. "报名状态"
  392. };
  393. neh.Export(dt, liststring, "重修报名信息" + DateTime.Now.ToString("yyyyMMddhhmmss"));
  394. return RedirectToAction("MsgShow", "Common", new
  395. {
  396. msg = "导出成功。",
  397. url = Url.Content("~/RetakePlanTask/List").AddMenuParameter()
  398. });
  399. }
  400. /// <summary>
  401. /// Excel导出
  402. /// </summary>
  403. /// <returns></returns>
  404. [HttpPost]
  405. public ActionResult Excel()
  406. {
  407. NpoiExcelHelper neh = new NpoiExcelHelper();
  408. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  409. var schoolyearID = Request.Form["SchoolYearDropdown"] == DropdownList.SELECT_ALL.ToString() ? null : Request.Form["SchoolyearDropdown"].ParseStrTo<Guid>();
  410. //开课院系所
  411. var collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
  412. //开课教研室
  413. var departmentID = Request.Form["DepartmentComboGrid"].ParseStrTo<Guid>();
  414. var coursematerialID = Request.Form["CoursematerialComboGrid"].ParseStrTo<Guid>();
  415. var retakeTypeID = Request.Form["DictionaryRetakeType"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryRetakeType"].ParseStrTo<int>();
  416. var statusID = Request.Form["DictionaryStatus"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryStatus"].ParseStrTo<int>();
  417. var dt = RetakePlanResultTaskServices.GetRetakePlanResultTaskViewList(configuretView, schoolyearID, collegeID, departmentID,
  418. coursematerialID, retakeTypeID, statusID)
  419. .Select(x => new
  420. {
  421. x.SchoolyearCode,
  422. x.ClassName,
  423. x.RetakeTypeName,
  424. x.CourseCode,
  425. x.CourseName,
  426. x.CourseTypeName,
  427. x.Credit,
  428. x.Totalhours,
  429. x.StartEndWeeklyNum,
  430. x.WeekdayTimesSegmentName,
  431. x.ClassroomName,
  432. x.TeacherName,
  433. x.PeopleNumlower,
  434. x.PeopleNumlimit,
  435. x.DepartmentName,
  436. x.CourseCollegeName,
  437. x.PlanNumber,
  438. x.ApplyNumber,
  439. x.RecordStatusName
  440. }).ToTable();
  441. string[] liststring = {
  442. "重修学年学期", "重修班级名称", "重修类型", "课程代码", "课程名称", "课程类型", "课程学分",
  443. "总学时", "起止周次", "上课时间", "教室", "任课教师", "人数下限", "人数上限","开课教研室",
  444. "开课" + RSL.Get("CollegeName"), "计划人数", "已报人数", "重修任务状态"
  445. };
  446. neh.Export(dt, liststring, "重修班级信息" + DateTime.Now.ToString("yyyyMMddhhmmss"));
  447. return RedirectToAction("MsgShow", "Common", new
  448. {
  449. msg = "导出成功。",
  450. url = Url.Content("~/RetakePlanTask/List").AddMenuParameter()
  451. });
  452. }
  453. }
  454. }