ExaminationExemptionController.cs 15 KB

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