MisconductController.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  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.Data;
  7. using Bowin.Common.Utility;
  8. using Bowin.Web.Controls.Mvc;
  9. using EMIS.CommonLogic.ScoreManage;
  10. using EMIS.ViewModel;
  11. using EMIS.Web.Controls;
  12. using EMIS.Utility.FormValidate;
  13. using EMIS.ViewModel.ScoreManage;
  14. namespace EMIS.Web.Controllers.ScoreManage
  15. {
  16. [Authorization]
  17. public class MisconductController : Controller
  18. {
  19. public IMisconductServices MisconductServices { get; set; }
  20. /// <summary>
  21. /// 违纪名单页面
  22. /// </summary>
  23. /// <returns></returns>
  24. public ActionResult List()
  25. {
  26. ViewBag.StartStatusID = MisconductServices.GetStartStatus();
  27. return View();
  28. }
  29. public ActionResult Edit(Guid? misconductID)
  30. {
  31. MisconductView misconductView = new MisconductView();
  32. if (misconductID.HasValue)
  33. {
  34. misconductView = this.MisconductServices.GetMisconductView(misconductID.Value);
  35. }
  36. else
  37. {
  38. //默认值
  39. misconductView.SchoolyearID = BaseExtensions.GetCurrentSchoolYearID();
  40. }
  41. return View(misconductView);
  42. }
  43. public ActionResult View(Guid misconductID)
  44. {
  45. MisconductView misconductView = new MisconductView();
  46. misconductView = this.MisconductServices.GetMisconductView(misconductID);
  47. return View(misconductView);
  48. }
  49. [HttpPost]
  50. public ActionResult List(QueryParamsModel pararms)
  51. {
  52. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  53. var schoolyearID = pararms.getExtraGuid("ddlSchoolYear");
  54. var collegeID = pararms.getExtraGuid("cbgCollege");
  55. var yearID = pararms.getExtraInt("ddlYear") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlYear");
  56. var standardID = pararms.getExtraInt("cbgStandard") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("cbgStandard");
  57. var classmajorID = pararms.getExtraGuid("cbgClassmajor");
  58. var examsCategoryID = pararms.getExtraInt("ddlExamsCategory") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlExamsCategory");
  59. var examsStateID = pararms.getExtraInt("ddlExamsState") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlExamsState");
  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(MisconductServices.GetMisconductGridView(configuretView, schoolyearID, collegeID, yearID, standardID,
  65. classmajorID, examsCategoryID, examsStateID, recordstatus,learningformID,education,LearnSystem, (int)pararms.page, (int)pararms.rows));
  66. }
  67. [HttpPost]
  68. public ActionResult Edit(MisconductView misconductView)
  69. {
  70. try
  71. {
  72. this.MisconductServices.Save(misconductView);
  73. return Json(new ReturnMessage { IsSuccess = true, Message = "保存成功。" });
  74. }
  75. catch (Exception ex)
  76. {
  77. return Json(new ReturnMessage { IsSuccess = false, Message = "保存失败:" + ex.Message });
  78. }
  79. }
  80. /// <summary>
  81. /// 导出Excel
  82. /// </summary>
  83. /// <returns></returns>
  84. [HttpPost]
  85. public ActionResult Excel()
  86. {
  87. NpoiExcelHelper neh = new NpoiExcelHelper();
  88. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  89. var schoolyearID = Request.Form["ddlSchoolYear"].ParseStrTo<Guid>();
  90. var collegeID = Request.Form["cbgCollege"].ParseStrTo<Guid>();
  91. var yearID = Request.Form["ddlYear"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["ddlYear"].ParseStrTo<int>();
  92. var standardID = Request.Form["cbgStandard"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["cbgStandard"].ParseStrTo<int>();
  93. var classmajorID = Request.Form["cbgClassmajor"].ParseStrTo<Guid>();
  94. var examsCategoryID = Request.Form["ddlExamsCategory"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["ddlExamsCategory"].ParseStrTo<int>();
  95. var examsStateID = Request.Form["ddlExamsState"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["ddlExamsState"].ParseStrTo<int>();
  96. var recordstatus = Request.Form["ddlRecordStatus"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["ddlRecordStatus"].ParseStrTo<int>();
  97. var learningformID = Request.Form["LearningformDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["LearningformDictionaryDropDown"].ParseStrTo<int>();
  98. var education = Request.Form["DictionaryEducation"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryEducation"].ParseStrTo<int>();
  99. var LearnSystem = Request.Form["DictionaryLearnSystem"].ToString();
  100. var dt = MisconductServices.GetMisconductViewList(configuretView, schoolyearID, collegeID, yearID, standardID,
  101. classmajorID, examsCategoryID, examsStateID, recordstatus, learningformID, education, LearnSystem).Select(x => new
  102. {
  103. x.LoginID,
  104. x.Name,
  105. x.ClassmajorName,
  106. x.SchoolyearCode,
  107. x.CourseCode,
  108. x.CourseName,
  109. x.ExamsCategoryName,
  110. x.ExamsStateName,
  111. x.RecordStatusName
  112. }).ToTable();
  113. string[] liststring = { "学号", "姓名", "班级", "学年学期", "课程代码", "课程名称", "考试性质", "考试状态", "状态" };
  114. neh.Export(dt, liststring, "违纪名单");
  115. return RedirectToAction("MsgShow", "Common", new
  116. {
  117. msg = "导出成功!",
  118. url = Url.Action("List").AddMenuParameter()
  119. });
  120. }
  121. [HttpPost]
  122. public ActionResult Submit(string misconductIDs)
  123. {
  124. var misconductIDList = misconductIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList();
  125. var curUserID = CustomPrincipal.Current.UserID;
  126. if (misconductIDList.Count == 0)
  127. {
  128. return Json(new ReturnMessage { IsSuccess = false, Message = "请选择至少一条记录进行提交。" });
  129. }
  130. try
  131. {
  132. this.MisconductServices.StartUp(misconductIDList, curUserID);
  133. return Json(new ReturnMessage { IsSuccess = true, Message = "提交成功。" });
  134. }
  135. catch (Exception ex)
  136. {
  137. return Json(new ReturnMessage { IsSuccess = false, Message = "提交失败:" + ex.Message });
  138. }
  139. }
  140. [HttpPost]
  141. public ActionResult Approve(string misconductIDs, Guid actionID, string comment)
  142. {
  143. var misconductIDList = misconductIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList();
  144. var curUserID = CustomPrincipal.Current.UserID;
  145. if (misconductIDList.Count == 0)
  146. {
  147. return Json(new ReturnMessage { IsSuccess = false, Message = "请选择至少一条记录进行审核。" });
  148. }
  149. try
  150. {
  151. this.MisconductServices.Approve(misconductIDList, curUserID, actionID, comment);
  152. return Json(new ReturnMessage { IsSuccess = true, Message = "审核成功。" });
  153. }
  154. catch (Exception ex)
  155. {
  156. return Json(new ReturnMessage { IsSuccess = false, Message = "审核失败:" + ex.Message });
  157. }
  158. }
  159. [HttpPost]
  160. public ActionResult Cancel(string misconductIDs, string comment)
  161. {
  162. var misconductIDList = misconductIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList();
  163. var curUserID = CustomPrincipal.Current.UserID;
  164. if (misconductIDList.Count == 0)
  165. {
  166. return Json(new ReturnMessage { IsSuccess = false, Message = "请选择至少一条记录进行撤销。" });
  167. }
  168. try
  169. {
  170. this.MisconductServices.Cancel(misconductIDList, curUserID, comment);
  171. return Json(new ReturnMessage { IsSuccess = true, Message = "撤销成功。" });
  172. }
  173. catch (Exception ex)
  174. {
  175. return Json(new ReturnMessage { IsSuccess = false, Message = "撤销失败:" + ex.Message });
  176. }
  177. }
  178. [HttpPost]
  179. public ActionResult Delete(string misconductIDs)
  180. {
  181. var misconductIDList = misconductIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList();
  182. try
  183. {
  184. this.MisconductServices.Delete(misconductIDList);
  185. return Json(new ReturnMessage { IsSuccess = true, Message = "删除成功。" });
  186. }
  187. catch (Exception ex)
  188. {
  189. return Json(new ReturnMessage { IsSuccess = false, Message = "删除失败:" + ex.Message });
  190. }
  191. }
  192. [HttpPost]
  193. public ActionResult GetMisconductExamsStateList(DropdownListBindType? bindType)
  194. {
  195. List<DropdownListItem> list = MisconductServices.GetMisconductExamsStateList()
  196. .Select(x => new DropdownListItem { Text = x.Name, Value = x.Value }).ToList();
  197. DropdownListBindType dbt = bindType == null ? DropdownListBindType.SelectAll : bindType.Value;
  198. DropdownList.FormatDropdownItemList(dbt, list);
  199. return base.Json(list);
  200. }
  201. [HttpPost]
  202. public ActionResult GetCoursematerial(QueryParamsModel pararms, Guid? schoolyearID, Guid? userID)
  203. {
  204. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  205. return Json(MisconductServices.GetMisconductCoursematerialGridView(configuretView, schoolyearID, userID, (int)pararms.page, (int)pararms.rows));
  206. }
  207. }
  208. }