SelectCourseResultController.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  1. using EMIS.CommonLogic.SelectCourse.SelectCourseResult;
  2. using EMIS.ViewModel;
  3. using EMIS.Web.Controls;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Web;
  8. using System.Web.Mvc;
  9. using Bowin.Common.Utility;
  10. using EMIS.ViewModel.SelectCourse;
  11. using EMIS.CommonLogic.SelectCourse;
  12. using Bowin.Web.Controls.Mvc;
  13. using Bowin.Common.Linq.Entity;
  14. using Bowin.Common.Data;
  15. using EMIS.ViewModel.Students;
  16. using EMIS.ViewModel.SelectCourse.SelectCourseResult;
  17. using EMIS.Utility;
  18. namespace EMIS.Web.Controllers.SelectCourseManage.SelectCourseResult
  19. {
  20. [Authorization]
  21. public class SelectCourseResultController : Controller
  22. {
  23. public ISelectCourseResultServices SelectCourseResultServices { get; set; }
  24. public IOptionalCourseSettingServices optionalCourseSettingServices { get; set; }
  25. public IExecutableFreeSelectionCouseServices ExecutableFreeSelectionCouseServices { get; set; }
  26. /// <summary>
  27. /// 选课结果页面
  28. /// </summary>
  29. /// <returns></returns>
  30. public ActionResult List()
  31. {
  32. return View();
  33. }
  34. [HttpPost]
  35. public ActionResult List(QueryParamsModel pararms)
  36. {
  37. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  38. var schoolyearID = pararms.getExtraGuid("SchoolYear");
  39. var collegeID = pararms.getExtraGuid("CollegeComboGrid");
  40. var coursematerialID = pararms.getExtraGuid("CoursematerialComboGrid");
  41. var courseTypeID = pararms.getExtraInt("DictionaryCourseType") == -1 ? null : pararms.getExtraInt("DictionaryCourseType");
  42. var selectCourseTypeID = pararms.getExtraInt("DictionarySelectCourseType") == -1 ? null : pararms.getExtraInt("DictionarySelectCourseType");
  43. var isCreated = pararms.getExtraInt("DictionaryIsCreated") == -1 ? null : pararms.getExtraInt("DictionaryIsCreated");
  44. var isOpen = pararms.getExtraInt("DictionaryIsOpen") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryIsOpen");
  45. var result = SelectCourseResultServices.GetSelectCourseResultViewList(configuretView, schoolyearID, collegeID, coursematerialID, courseTypeID, selectCourseTypeID,isCreated,isOpen, (int)pararms.page, (int)pararms.rows);
  46. return Json(result);
  47. }
  48. /// <summary>
  49. /// 编辑
  50. /// </summary>
  51. /// <returns></returns>
  52. public ActionResult Edit(Guid? ID,string Type)
  53. {
  54. if (Type == "0") //限选
  55. {
  56. OptionalCourseSettingView optionalCourseSettingView = new OptionalCourseSettingView();
  57. if (ID.HasValue && ID != Guid.Empty)
  58. optionalCourseSettingView = optionalCourseSettingServices.GetOptionalCourseSettingView(ID);
  59. return View(optionalCourseSettingView);
  60. }
  61. else //任选
  62. {
  63. OptionalCourseSettingView optionalCourseSettingView = new OptionalCourseSettingView();
  64. if (ID.HasValue && ID != Guid.Empty)
  65. optionalCourseSettingView = optionalCourseSettingServices.GetOptionalCourseSettingView(ID);
  66. return View(optionalCourseSettingView);
  67. }
  68. }
  69. /// <summary>
  70. /// 保存修改
  71. /// </summary>
  72. /// <param name="optionalCourseSettingView"></param>
  73. /// <returns></returns>
  74. [HttpPost]
  75. public ActionResult Edit(OptionalCourseSettingView optionalCourseSettingView)
  76. {
  77. try
  78. {
  79. var teacherList = DataGrid.GetTableData<OptionalCourseTeacherListView>("dgTeacherList");
  80. SelectCourseResultServices.OptionalCourseSettingUpdate(optionalCourseSettingView, teacherList);
  81. return Json(new ReturnMessage()
  82. {
  83. IsSuccess = true,
  84. Message = "保存成功。"
  85. });
  86. }
  87. catch (Exception ex)
  88. {
  89. return Json(new ReturnMessage()
  90. {
  91. IsSuccess = false,
  92. Message = "保存失败:" + ex.Message
  93. });
  94. }
  95. }
  96. /// <summary>
  97. /// 编辑
  98. /// </summary>
  99. /// <returns></returns>
  100. public ActionResult EditFreeSelection(Guid? ID, string Type)
  101. {
  102. ExecutableFreeSelectionCouseView executableFreeSelectionCouseView = new ExecutableFreeSelectionCouseView();
  103. if (ID.HasValue && ID != Guid.Empty)
  104. executableFreeSelectionCouseView = ExecutableFreeSelectionCouseServices.GetExecutableFreeSelectionCouseView(ID);
  105. return View(executableFreeSelectionCouseView);
  106. }
  107. [HttpPost]
  108. public ActionResult EditFreeSelection(ExecutableFreeSelectionCouseView executableFreeSelectionCouseView)
  109. {
  110. try
  111. {
  112. var teacherList = DataGrid.GetTableData<ExecutableFreeSelectionCouseTeacherListView>("dgTeacherList");
  113. ExecutableFreeSelectionCouseServices.ExecutableFreeSelectionCouseUpdate(executableFreeSelectionCouseView, teacherList);
  114. return Json(new ReturnMessage()
  115. {
  116. IsSuccess = true,
  117. Message = "保存成功!"
  118. });
  119. }
  120. catch (Exception ex)
  121. {
  122. return Json(new ReturnMessage()
  123. {
  124. IsSuccess = false,
  125. Message = "保存失败:" + ex.Message
  126. });
  127. }
  128. }
  129. /// <summary>
  130. /// 获取任务班授课老师
  131. /// </summary>
  132. /// <param name="educationMissionClassID"></param>
  133. /// <returns></returns>
  134. [HttpPost]
  135. public ActionResult TeacherList(Guid executableOptionalCourseID)
  136. {
  137. var teacherList = optionalCourseSettingServices.GetEducationMissionClassTeacherListViewList(executableOptionalCourseID);
  138. return Json(new GridResultSet<OptionalCourseTeacherListView>() { rows = teacherList, total = teacherList.Count });
  139. }
  140. public ActionResult StudentList(Guid ID, string Type)
  141. {
  142. ViewBag.ID = ID;
  143. ViewBag.Type = Type;
  144. return View();
  145. }
  146. /// <summary>
  147. ///
  148. /// </summary>
  149. /// <param name="pararms"></param>
  150. /// <returns></returns>
  151. [HttpPost]
  152. public ActionResult StudentViewList(QueryParamsModel pararms) //QueryParamsModel pararms
  153. {
  154. var ID = Request["ID"].ParseStrTo<Guid>();
  155. var type = Request["Type"];
  156. var result = SelectCourseResultServices.GetSelectCourseStudentViewGrid(ID.Value, type, 0, 0);
  157. return Json(result);
  158. }
  159. /// <summary>
  160. /// 学生名单
  161. /// </summary>
  162. /// <param name="selectCourseResult"></param>
  163. /// <returns></returns>
  164. [HttpPost]
  165. public ActionResult StudentList(SelectCourseResultView selectCourseResult)
  166. {
  167. try
  168. {
  169. var studentList = DataGrid.GetTableData<StudentsView>("dgStudentList");
  170. //// var addTeacherList = addTeacherListJson.JsonToObject<List<ExecutableFreeSelectionCouseTeacherListView>>();
  171. SelectCourseResultServices.EditStudent(selectCourseResult, studentList);
  172. return Json(new ReturnMessage { IsSuccess = true, Message = "保存成功。" });
  173. }
  174. catch (Exception ex)
  175. {
  176. return Json(new ReturnMessage { IsSuccess = false, Message = ex.Message });
  177. }
  178. }
  179. /// <summary>
  180. /// 添加学生名单
  181. /// </summary>
  182. /// <returns></returns>
  183. public ActionResult StudentAdd()
  184. {
  185. return View();
  186. }
  187. /// <summary>
  188. /// 学生选课名单Excel导出
  189. /// </summary>
  190. /// <returns></returns>
  191. [HttpPost]
  192. public ActionResult Excel_StudentList()
  193. {
  194. NpoiExcelHelper neh = new NpoiExcelHelper();
  195. var ID = Request["ID"].ParseStrTo<Guid>();
  196. var type = Request["Type"];
  197. var dt = SelectCourseResultServices.GetSelectCourseStudentViewList(ID.Value, type)
  198. .Select(x => new
  199. {
  200. x.SchoolYearCode,
  201. x.DefaultClassName,
  202. x.CoursematerialCode,
  203. x.CoursematerialName,
  204. x.CourseTypeName,
  205. x.LoginID,
  206. x.UserName,
  207. x.SexName,
  208. x.ClassmajorName,
  209. x.InSchoolStatusName,
  210. x.StudentStatusName
  211. }).ToTable();
  212. string[] liststring = { "学年学期", "选修任务班名称", "课程代码", "课程名称", "课程类型",
  213. "学号", "姓名","性别", "班级名称","在校状态", "学籍状态" };
  214. neh.Export(dt, liststring, "选课结果学生名单" + DateTime.Now.ToString("yyyyMMdd"));
  215. return RedirectToAction("MsgShow", "Common", new
  216. {
  217. msg = "导出成功!",
  218. url = Url.Content("~/SelectCourseResult/List").AddMenuParameter()
  219. });
  220. }
  221. [HttpPost]
  222. public ActionResult Excel()
  223. {
  224. //return View();
  225. NpoiExcelHelper neh = new NpoiExcelHelper();
  226. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  227. //避开全选值
  228. if (configuretView.Attribute == DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = "";
  229. var schoolyearID = Request.Form["SchoolYear"].ParseStrTo<Guid>();
  230. var collegeID = Request.Form["CollegeComboGrid"].ParseStrTo<Guid>();
  231. var coursematerialID = Request.Form["CoursematerialComboGrid"].ParseStrTo<Guid>();
  232. var courseTypeID = Request.Form["DictionaryCourseType"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryCourseType"].ParseStrTo<int>();
  233. var selectCourseTypeID = Request.Form["DictionarySelectCourseType"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionarySelectCourseType"].ParseStrTo<int>();
  234. var isCreated = Request.Form["DictionaryIsCreated"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryIsCreated"].ParseStrTo<int>();
  235. var isOpen = Request.Form["DictionaryIsOpen"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryIsOpen"].ParseStrTo<int>();
  236. var dt = SelectCourseResultServices.GetSelectCourseResultViewList(configuretView, schoolyearID, collegeID, coursematerialID, courseTypeID, selectCourseTypeID, isCreated,isOpen)
  237. .Select(x => new
  238. {
  239. x.SchoolYearCode,
  240. x.DefaultClassName,
  241. //x.CourseCode,
  242. x.CourseName,
  243. x.CourseTypeName,
  244. //x.CourseCategoryName,
  245. x.CourseQualityName,
  246. x.Credit,
  247. x.Totalhours,
  248. x.WeekdayTimesSegmentName,
  249. x.PeopleNumlower,
  250. x.PeopleNumlimit,
  251. x.StudentTotalNum,
  252. x.SelectCourseTypeName,
  253. //x.TeachingModeName,
  254. //x.SchoolcodeName,
  255. x.ClassroomName,
  256. x.TeacherName,
  257. x.DepartmentName,
  258. //x.IsOpenedDesc
  259. x.RecordStatusName
  260. }).ToTable();
  261. string[] liststring = { "学年学期",
  262. "选修任务班名称",
  263. "课程名称", "课程类型",
  264. "课程性质",
  265. "学分",
  266. "总学时","上课时间", "人数下限", "人数上限",
  267. "已选人数", "选修类型",
  268. "教室信息",
  269. "教师姓名",
  270. "开课教研室",
  271. "状态"
  272. };
  273. neh.Export(dt, liststring, "选课结果");
  274. return RedirectToAction("MsgShow", "Common", new
  275. {
  276. msg = "导出成功!",
  277. url = Url.Content("~/SelectCourseResult/List").AddMenuParameter()
  278. });
  279. }
  280. /// <summary>
  281. /// 生成任务班
  282. /// </summary>
  283. /// <returns></returns>
  284. [HttpPost]
  285. public ActionResult GenerateEducationMissionClassSubminit(string teachingPlanIDs, string Types)
  286. {
  287. try
  288. {
  289. List<Guid?> list = new List<Guid?>();
  290. for (int i = 0; i < teachingPlanIDs.Split(',').Length; i++)
  291. {
  292. string id = teachingPlanIDs.Split(',')[i];
  293. if (!string.IsNullOrEmpty(id))
  294. {
  295. Guid teachingPlanID = new Guid(id);
  296. list.Add(teachingPlanID);
  297. }
  298. }
  299. SelectCourseResultServices.ChooseEducationMissionClass(list, Types);
  300. return Json(new ReturnMessage()
  301. {
  302. IsSuccess = true,
  303. Message = "开班成功,已生成教学任务班!"
  304. });
  305. }
  306. catch (Exception ex)
  307. {
  308. return Json(new ReturnMessage()
  309. {
  310. IsSuccess = false,
  311. Message = "生成任务班失败,原因:" + ex.Message
  312. });
  313. }
  314. }
  315. /// <summary>
  316. /// 取消开班
  317. /// </summary>
  318. /// <returns></returns>
  319. [HttpPost]
  320. public ActionResult CancelEducationMissionClass(string teachingPlanIDs)
  321. {
  322. try
  323. {
  324. List<Guid?> list = new List<Guid?>();
  325. for (int i = 0; i < teachingPlanIDs.Split(',').Length; i++)
  326. {
  327. string id = teachingPlanIDs.Split(',')[i];
  328. if (!string.IsNullOrEmpty(id))
  329. {
  330. Guid teachingPlanID = new Guid(id);
  331. list.Add(teachingPlanID);
  332. }
  333. }
  334. SelectCourseResultServices.CancelEducationMissionClass(list);
  335. return this.Json("取消开班成功!");
  336. }
  337. catch (Exception ex)
  338. {
  339. return this.Json("取消开班失败,原因:" + ex.Message);
  340. }
  341. }
  342. [HttpPost]
  343. public ActionResult CheckEnouthNum(string IDs)
  344. {
  345. try
  346. {
  347. List<Guid?> list = new List<Guid?>();
  348. for (int i = 0; i < IDs.Split(',').Length; i++)
  349. {
  350. string id = IDs.Split(',')[i];
  351. if (!string.IsNullOrEmpty(id))
  352. {
  353. Guid ID = new Guid(id);
  354. list.Add(ID);
  355. }
  356. }
  357. var result = SelectCourseResultServices.CheckEnouthNum(list);
  358. return Json(new ReturnMessage<bool>()
  359. {
  360. IsSuccess = true,
  361. Data = result
  362. });
  363. }
  364. catch (Exception ex)
  365. {
  366. return Json(new ReturnMessage()
  367. {
  368. IsSuccess = true,
  369. Message = "检查任务班生成情况失败:" + ex.Message
  370. });
  371. }
  372. }
  373. //[HttpPost]
  374. //public ActionResult CheckHaveTeacherOrClassroom(string IDs)
  375. //{
  376. // try
  377. // {
  378. // List<Guid?> list = new List<Guid?>();
  379. // for (int i = 0; i < IDs.Split(',').Length; i++)
  380. // {
  381. // string id = IDs.Split(',')[i];
  382. // if (!string.IsNullOrEmpty(id))
  383. // {
  384. // Guid ID = new Guid(id);
  385. // list.Add(ID);
  386. // }
  387. // }
  388. // var result = SelectCourseResultServices.CheckEnouthNum(list);
  389. // return Json(new ReturnMessage<bool>()
  390. // {
  391. // IsSuccess = true,
  392. // Data = result
  393. // });
  394. // }
  395. // catch (Exception ex)
  396. // {
  397. // return Json(new ReturnMessage()
  398. // {
  399. // IsSuccess = true,
  400. // Message = "检查任务班生成情况失败:" + ex.Message
  401. // });
  402. // }
  403. //}
  404. }
  405. }