StudentChangeController.cs 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. using System;
  2. using System.Text;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Web;
  6. using System.Web.Mvc;
  7. using System.Collections;
  8. using Bowin.Common.Data;
  9. using Bowin.Common.Exceptions;
  10. using Bowin.Common.Utility;
  11. using Bowin.Web.Controls.Mvc;
  12. using EMIS.Web.Controls;
  13. using EMIS.Utility;
  14. using EMIS.ViewModel;
  15. using EMIS.ViewModel.StudentManage.StudentChange;
  16. using EMIS.CommonLogic.StudentWeb.Change;
  17. using EMIS.CommonLogic.StudentManage.StudentProfile;
  18. namespace EMIS.Web.Controllers.StudentWeb.Change
  19. {
  20. [Authorization]
  21. public class StudentChangeController : Controller
  22. {
  23. public Lazy<IStudentChangeServices> StudentChangeServices { get; set; }
  24. public Lazy<IStudentServices> StudentServices { 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 user = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  43. return base.Json(StudentChangeServices.Value.GetStudentChangeViewGrid(configuretView, user.UserID, (int)pararms.page, (int)pararms.rows));
  44. }
  45. /// <summary>
  46. /// 编辑
  47. /// </summary>
  48. /// <param name="studentChangeID"></param>
  49. /// <returns></returns>
  50. [HttpGet]
  51. public ActionResult Edit(Guid? studentChangeID)
  52. {
  53. var user = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  54. if (user == null)
  55. {
  56. throw new Exception("登录超时,请退出系统重新登录。");
  57. }
  58. StudentChangeView studentChangeView = new StudentChangeView();
  59. if (studentChangeID.HasValue && studentChangeID != Guid.Empty)
  60. {
  61. studentChangeView = StudentChangeServices.Value.GetStudentChangeView(studentChangeID);
  62. }
  63. else
  64. {
  65. var studentView = StudentServices.Value.GetStudentView(user.UserID);
  66. if(studentView == null)
  67. {
  68. throw new Exception("登录超时,请退出系统重新登录。");
  69. }
  70. else
  71. {
  72. studentChangeView.UserID = studentView.UserID;
  73. studentChangeView.StudentNo = studentView.StudentNo;
  74. studentChangeView.Name = studentView.Name;
  75. studentChangeView.SexID = studentView.SexID;
  76. studentChangeView.BeforeCollegeID = studentView.CollegeID;
  77. studentChangeView.BeforeGradeID = studentView.GradeID;
  78. studentChangeView.BeforeStandardID = studentView.StandardID;
  79. studentChangeView.BeforeEducationID = studentView.EducationID;
  80. studentChangeView.BeforeLearningformID = studentView.LearningformID;
  81. studentChangeView.BeforeLearnSystem = studentView.LearnSystem;
  82. studentChangeView.BeforeClassmajorID = studentView.ClassmajorID;
  83. studentChangeView.BeforeInSchoolStatusID = studentView.InSchoolStatusID;
  84. studentChangeView.BeforeStudentStatus = studentView.StudentStatus;
  85. studentChangeView.AfterCollegeID = studentView.CollegeID;
  86. studentChangeView.AfterGradeID = studentView.GradeID;
  87. studentChangeView.AfterStandardID = studentView.StandardID;
  88. studentChangeView.AfterEducationID = studentView.EducationID;
  89. studentChangeView.AfterLearningformID = studentView.LearningformID;
  90. studentChangeView.AfterLearnSystem = studentView.LearnSystem;
  91. studentChangeView.AfterClassmajorID = studentView.ClassmajorID;
  92. studentChangeView.AfterInSchoolStatusID = studentView.InSchoolStatusID;
  93. studentChangeView.AfterStudentStatus = studentView.StudentStatus;
  94. }
  95. }
  96. return View(studentChangeView);
  97. }
  98. /// <summary>
  99. /// 编辑
  100. /// </summary>
  101. /// <param name="studentChangeView"></param>
  102. /// <returns></returns>
  103. [HttpPost]
  104. public ActionResult Edit(StudentChangeView studentChangeView)
  105. {
  106. try
  107. {
  108. StudentChangeServices.Value.StudentChangeEdit(studentChangeView);
  109. return Json(new ReturnMessage()
  110. {
  111. IsSuccess = true,
  112. Message = "保存成功。"
  113. });
  114. }
  115. catch (Exception ex)
  116. {
  117. return Json(new ReturnMessage()
  118. {
  119. IsSuccess = false,
  120. Message = "保存失败,原因:" + ex.Message
  121. });
  122. }
  123. }
  124. /// <summary>
  125. /// 删除
  126. /// </summary>
  127. /// <param name="studentChangeIDs"></param>
  128. /// <returns></returns>
  129. [HttpPost]
  130. public ActionResult Delete(string studentChangeIDs)
  131. {
  132. try
  133. {
  134. List<Guid?> list = studentChangeIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  135. StudentChangeServices.Value.StudentChangeDelete(list);
  136. return Json(new ReturnMessage()
  137. {
  138. IsSuccess = true,
  139. Message = "删除成功。"
  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. /// <param name="studentChangeIDs"></param>
  155. /// <returns></returns>
  156. [HttpPost]
  157. public ActionResult Submit(string studentChangeIDs)
  158. {
  159. try
  160. {
  161. var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
  162. List<Guid> list = studentChangeIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList();
  163. string result = StudentChangeServices.Value.StudentChangeSubmit(list, user.UserID, "");
  164. return Json(new ReturnMessage()
  165. {
  166. IsSuccess = true,
  167. Message = "提交成功" + result + "。"
  168. });
  169. }
  170. catch (Exception ex)
  171. {
  172. return Json(new ReturnMessage()
  173. {
  174. IsSuccess = false,
  175. Message = "提交失败,原因:" + ex.Message
  176. });
  177. }
  178. }
  179. /// <summary>
  180. /// 申请表报表
  181. /// </summary>
  182. /// <returns></returns>
  183. public ActionResult ApplyReport()
  184. {
  185. var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  186. ViewBag.LoginUserID = curUser.UserID.ToString();
  187. var dataRangeID = StudentServices.Value.GetDataRangeID();
  188. ViewBag.DataRangeID = dataRangeID;
  189. return View();
  190. }
  191. /// <summary>
  192. /// Excel导出
  193. /// </summary>
  194. /// <returns></returns>
  195. [HttpPost]
  196. public ActionResult Excel()
  197. {
  198. NpoiExcelHelper neh = new NpoiExcelHelper();
  199. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  200. var user = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  201. var dt = StudentChangeServices.Value.GetStudentChangeViewList(configuretView, user.UserID)
  202. .Select(x => new
  203. {
  204. x.SchoolyearCode,
  205. x.StudentNo,
  206. x.Name,
  207. x.SexName,
  208. x.ChangeTypeName,
  209. x.InSchoolStatusName,
  210. x.BeforeStandardName,
  211. x.BeforeClassmajorName,
  212. x.BeforeInSchoolStatusName,
  213. x.AfterStandardName,
  214. x.AfterClassmajorName,
  215. x.AfterInSchoolStatusName,
  216. x.ChangeReasonName,
  217. x.Description,
  218. ChangeDate = (x.ChangeDate.HasValue ? x.ChangeDate.Value.ToString("yyyyMMdd") : ""),
  219. x.ApprovalStatusName
  220. }).ToTable();
  221. string[] liststring = {
  222. "异动学期", "学号", "姓名", "性别", "异动类型", "在校状态", "异动前专业", "异动前班级", "在校状态(前)",
  223. "异动后专业", "异动后班级", "在校状态(后)", "异动原因", "申请说明", "异动日期", "审核状态"
  224. };
  225. neh.Export(dt, liststring, "异动申请信息(" + user.LoginID + ")" + DateTime.Now.ToString("yyyyMMdd"));
  226. return Json(new ReturnMessage()
  227. {
  228. IsSuccess = true,
  229. Message = "导出成功。"
  230. });
  231. }
  232. }
  233. }