ExaminationSuspensionController.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using Bowin.Common.Utility;
  7. using Bowin.Common.Data;
  8. using Bowin.Web.Controls.Mvc;
  9. using EMIS.ViewModel;
  10. using EMIS.Web.Controls;
  11. using EMIS.CommonLogic.ScoreManage;
  12. using EMIS.Utility.FormValidate;
  13. using EMIS.ViewModel.ScoreManage;
  14. using EMIS.ViewModel.WorkflowManage;
  15. using Bowin.Common.JSON;
  16. namespace EMIS.Web.Controllers.ScoreManage
  17. {
  18. [Authorization]
  19. public class ExaminationSuspensionController : Controller
  20. {
  21. public IExaminationSuspensionServices ExaminationSuspensionServices { get; set; }
  22. /// <summary>
  23. /// 缓考名单页面
  24. /// </summary>
  25. /// <returns></returns>
  26. public ActionResult List()
  27. {
  28. ViewBag.StartStatusID = this.ExaminationSuspensionServices.GetStartStatus();
  29. return View();
  30. }
  31. public ActionResult StudentList()
  32. {
  33. ViewBag.StartStatusID = ExaminationSuspensionServices.GetStartStatus();
  34. return View();
  35. }
  36. public ActionResult Edit(Guid? examinationSuspensionID)
  37. {
  38. ExaminationSuspensionView examinationSuspensionView = new ExaminationSuspensionView();
  39. if (examinationSuspensionID.HasValue)
  40. {
  41. examinationSuspensionView = this.ExaminationSuspensionServices.GetExaminationSuspensionView(examinationSuspensionID.Value);
  42. }
  43. else
  44. {
  45. //默认值
  46. examinationSuspensionView.ExamsCategoryID = (int)EMIS.ViewModel.CF_ExamsCategory.FinalExam;
  47. }
  48. return View(examinationSuspensionView);
  49. }
  50. [HttpPost]
  51. public ActionResult List(QueryParamsModel pararms)
  52. {
  53. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  54. var schoolyearID = pararms.getExtraGuid("ddlSchoolYear");
  55. var collegeID = pararms.getExtraGuid("cbgCollege");
  56. var yearID = pararms.getExtraInt("ddlYear") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlYear");
  57. var standardID = pararms.getExtraInt("cbgStandard") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("cbgStandard");
  58. var classmajorID = pararms.getExtraGuid("cbgClassmajor");
  59. var examsCategoryID = pararms.getExtraInt("ddlExamsCategory") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlExamsCategory");
  60. var recordstatus = pararms.getExtraInt("ddlRecordStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlRecordStatus");
  61. var learningformID = pararms.getExtraInt("LearningformDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("LearningformDictionaryDropDown");
  62. var education = pararms.getExtraInt("DictionaryEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEducation");
  63. var LearnSystem = pararms.getExtraString("DictionaryLearnSystem");
  64. return Json(ExaminationSuspensionServices.GetExaminationSuspensionGridView(configuretView, schoolyearID, collegeID, yearID, standardID,
  65. classmajorID, examsCategoryID, recordstatus,learningformID,education,LearnSystem, (int)pararms.page, (int)pararms.rows));
  66. }
  67. /// <summary>
  68. /// 导出Excel
  69. /// </summary>
  70. /// <returns></returns>
  71. [HttpPost]
  72. public ActionResult Excel()
  73. {
  74. NpoiExcelHelper neh = new NpoiExcelHelper();
  75. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  76. var schoolyearID = Request.Form["ddlSchoolYear"].ParseStrTo<Guid>();
  77. var collegeID = Request.Form["cbgCollege"].ParseStrTo<Guid>();
  78. var yearID = Request.Form["ddlYear"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["ddlYear"].ParseStrTo<int>();
  79. var standardID = Request.Form["cbgStandard"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["cbgStandard"].ParseStrTo<int>();
  80. var classmajorID = Request.Form["cbgClassmajor"].ParseStrTo<Guid>();
  81. var examsCategoryID = Request.Form["ddlExamsCategory"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["ddlExamsCategory"].ParseStrTo<int>();
  82. var recordstatus = Request.Form["ddlRecordStatus"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["ddlRecordStatus"].ParseStrTo<int>();
  83. var learningformID = Request.Form["LearningformDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["LearningformDictionaryDropDown"].ParseStrTo<int>();
  84. var education = Request.Form["DictionaryEducation"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryEducation"].ParseStrTo<int>();
  85. var LearnSystem = Request.Form["DictionaryLearnSystem"].ToString();
  86. var dt = ExaminationSuspensionServices.GetExaminationSuspensionViewList(configuretView, schoolyearID, collegeID, yearID, standardID,
  87. classmajorID, examsCategoryID, recordstatus, learningformID, education, LearnSystem).Select(x => new
  88. {
  89. x.LoginID,
  90. x.Name,
  91. x.ClassmajorName,
  92. x.SchoolyearCode,
  93. x.CourseCode,
  94. x.CourseName,
  95. x.ExamsCategoryName,
  96. CreateTime = x.CreateTime.ToStringEx("yyyy-MM-dd"),
  97. x.RecordStatusName
  98. }).ToTable();
  99. string[] liststring = { "学号", "姓名", "班级", "学年学期", "课程代码","课程名称","考试性质", "申请日期", "状态" };
  100. neh.Export(dt, liststring, "缓考名单");
  101. return RedirectToAction("MsgShow", "Common", new
  102. {
  103. msg = "导出成功!",
  104. url = Url.Action("List").AddMenuParameter()
  105. });
  106. }
  107. [HttpPost]
  108. public ActionResult StudentList(QueryParamsModel pararms)
  109. {
  110. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  111. return Json(ExaminationSuspensionServices.GetExaminationSuspensionStudentGridView(configuretView, CustomPrincipal.Current.UserID,
  112. (int)pararms.page, (int)pararms.rows));
  113. }
  114. [HttpPost]
  115. public ActionResult GetCoursematerial(QueryParamsModel pararms)
  116. {
  117. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  118. return Json(ExaminationSuspensionServices.GetExaminationSuspensionCoursematerialGridView(configuretView, (int)pararms.page, (int)pararms.rows));
  119. }
  120. [HttpPost]
  121. public ActionResult GetCoursematerialForTeacher(QueryParamsModel pararms)
  122. {
  123. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  124. var UserID = pararms.getExtraGuid("UserID");
  125. return Json(ExaminationSuspensionServices.GetExaminationSuspensionCoursematerialGridViewForTeacher(configuretView, UserID, (int)pararms.page, (int)pararms.rows));
  126. }
  127. [HttpPost]
  128. public ActionResult Edit(ExaminationSuspensionView examinationSuspensionView)
  129. {
  130. try
  131. {
  132. examinationSuspensionView.UserID = CustomPrincipal.Current.UserID;
  133. examinationSuspensionView.SchoolyearID = BaseExtensions.GetCurrentSchoolYearID();
  134. examinationSuspensionView.ExamsCategoryID = (int)CF_ExamsCategory.FinalExam;
  135. this.ExaminationSuspensionServices.Save(examinationSuspensionView);
  136. return Json(new ReturnMessage { IsSuccess = true, Message = "保存成功。" });
  137. }
  138. catch (Exception ex)
  139. {
  140. return Json(new ReturnMessage { IsSuccess = false, Message = "保存失败:" + ex.Message });
  141. }
  142. }
  143. [HttpPost]
  144. public ActionResult Cancel(string examinationSuspensionIDs, string comment)
  145. {
  146. var examinationSuspensionIDList = examinationSuspensionIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList();
  147. var curUserID = CustomPrincipal.Current.UserID;
  148. if (examinationSuspensionIDList.Count == 0)
  149. {
  150. return Json(new ReturnMessage { IsSuccess = false, Message = "请选择至少一条记录进行撤销。" });
  151. }
  152. try
  153. {
  154. this.ExaminationSuspensionServices.Cancel(examinationSuspensionIDList, curUserID, comment);
  155. return Json(new ReturnMessage { IsSuccess = true, Message = "撤销成功。" });
  156. }
  157. catch (Exception ex)
  158. {
  159. return Json(new ReturnMessage { IsSuccess = false, Message = "撤销失败:" + ex.Message });
  160. }
  161. }
  162. //[HttpPost]
  163. //public ActionResult Rollback(string examinationSuspensionIDs, string comment)
  164. //{
  165. // var examinationSuspensionIDList = examinationSuspensionIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList();
  166. // var curUserID = CustomPrincipal.Current.UserID;
  167. // if (examinationSuspensionIDList.Count == 0)
  168. // {
  169. // return Json(new ReturnMessage { IsSuccess = false, Message = "请选择至少一条记录进行退回。" });
  170. // }
  171. // try
  172. // {
  173. // var actionViewList = this.ExaminationSuspensionServices.GetActionView(examinationSuspensionIDList[0], curUserID);
  174. // var actionView = actionViewList.FirstOrDefault(x => x.ActionName != "同意");
  175. // foreach (var examinationSuspensionID in examinationSuspensionIDList)
  176. // {
  177. // this.ExaminationSuspensionServices.Approve(examinationSuspensionID, curUserID, actionView.ActionID, comment);
  178. // }
  179. // return Json(new ReturnMessage { IsSuccess = true, Message = "退回成功。" });
  180. // }
  181. // catch (Exception ex)
  182. // {
  183. // return Json(new ReturnMessage { IsSuccess = false, Message = "退回失败:" + ex.Message });
  184. // }
  185. //}
  186. [HttpPost]
  187. public ActionResult Delete(string examinationSuspensionIDs)
  188. {
  189. var examinationSuspensionIDList = examinationSuspensionIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList();
  190. try
  191. {
  192. this.ExaminationSuspensionServices.Delete(examinationSuspensionIDList);
  193. return Json(new ReturnMessage { IsSuccess = true, Message = "删除成功。" });
  194. }
  195. catch (Exception ex)
  196. {
  197. return Json(new ReturnMessage { IsSuccess = false, Message = "删除失败:" + ex.Message });
  198. }
  199. }
  200. [HttpPost]
  201. public ActionResult Submit(string examinationSuspensionIDs)
  202. {
  203. var examinationSuspensionIDList = examinationSuspensionIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList();
  204. var curUserID = CustomPrincipal.Current.UserID;
  205. if (examinationSuspensionIDList.Count == 0)
  206. {
  207. return Json(new ReturnMessage { IsSuccess = false, Message = "请选择至少一条记录进行提交。" });
  208. }
  209. try
  210. {
  211. this.ExaminationSuspensionServices.StartUp(examinationSuspensionIDList, curUserID);
  212. return Json(new ReturnMessage { IsSuccess = true, Message = "提交成功。" });
  213. }
  214. catch (Exception ex)
  215. {
  216. return Json(new ReturnMessage { IsSuccess = false, Message = "提交失败:" + ex.Message });
  217. }
  218. }
  219. [HttpGet]
  220. public ActionResult applyEdit(Guid examinationSuspensionID)
  221. {
  222. var es=ExaminationSuspensionServices.GetExaminationSuspensionView(examinationSuspensionID);
  223. return View(es);
  224. }
  225. public ActionResult TeacherEdit(Guid? examinationSuspensionID)
  226. {
  227. ExaminationSuspensionView examinationSuspensionView = new ExaminationSuspensionView();
  228. if (examinationSuspensionID.HasValue)
  229. {
  230. examinationSuspensionView = this.ExaminationSuspensionServices.GetExaminationSuspensionView(examinationSuspensionID.Value);
  231. }
  232. else
  233. {
  234. //默认值
  235. examinationSuspensionView.ExamsCategoryID = (int)EMIS.ViewModel.CF_ExamsCategory.FinalExam;
  236. }
  237. ViewBag.CoursematerialID = examinationSuspensionView.CoursematerialID;
  238. return View(examinationSuspensionView);
  239. }
  240. [HttpPost]
  241. public ActionResult TeacherEdit(ExaminationSuspensionView examinationSuspensionView)
  242. {
  243. try
  244. {
  245. examinationSuspensionView.SchoolyearID = BaseExtensions.GetCurrentSchoolYearID();
  246. examinationSuspensionView.ExamsCategoryID = (int)CF_ExamsCategory.FinalExam;
  247. this.ExaminationSuspensionServices.Save(examinationSuspensionView);
  248. return Json(new ReturnMessage { IsSuccess = true, Message = "保存成功。" });
  249. }
  250. catch (Exception ex)
  251. {
  252. return Json(new ReturnMessage { IsSuccess = false, Message = "保存失败:" + ex.Message });
  253. }
  254. }
  255. [HttpPost]
  256. public ActionResult Approve(string examinationSuspensionIDs, Guid actionID, string comment)
  257. {
  258. var examinationSuspensionIDList = examinationSuspensionIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList();
  259. var curUserID = CustomPrincipal.Current.UserID;
  260. if (examinationSuspensionIDList.Count == 0)
  261. {
  262. return Json(new ReturnMessage { IsSuccess = false, Message = "请选择至少一条记录进行审核。" });
  263. }
  264. try
  265. {
  266. this.ExaminationSuspensionServices.Approve(examinationSuspensionIDList, curUserID, (Guid)actionID, comment);
  267. return Json(new ReturnMessage { IsSuccess = true, Message = "审核成功。" });
  268. }
  269. catch (Exception ex)
  270. {
  271. return Json(new ReturnMessage { IsSuccess = false, Message = "审核失败:" + ex.Message });
  272. }
  273. }
  274. }
  275. }