ChangeRecordController.cs 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. using System;
  2. using System.Linq;
  3. using System.Web;
  4. using System.Web.Mvc;
  5. using Bowin.Common.Exceptions;
  6. using Bowin.Common.Linq;
  7. using Bowin.Common.Utility;
  8. using Bowin.Web.Controls.Mvc;
  9. using EMIS.CommonLogic.Students;
  10. using EMIS.ViewModel;
  11. using EMIS.ViewModel.DifferentDynamic;
  12. using EMIS.Web.Controls;
  13. using EMIS.CommonLogic.CalendarManage;
  14. namespace EMIS.Web.Controllers.StudentWeb.MyProfileManager
  15. {
  16. [Authorization]
  17. public class ChangeRecordController : Controller
  18. {
  19. public ISchoolYearServices SchoolYearServices { get; set; }
  20. public IDifferentDynamicServices DifferentDynamicServices { get; set; }
  21. public IStudentRecordServices StudentRecordService { get; set; }
  22. //[StaticFileWriteFilter]
  23. public ActionResult List()
  24. {
  25. var user = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  26. ViewBag.UserID = user.UserID;
  27. return View();
  28. }
  29. /// <summary>
  30. /// 列表查询
  31. /// </summary>
  32. /// <param name="pararms"></param>
  33. /// <returns></returns>
  34. [HttpPost]
  35. public ActionResult List(QueryParamsModel pararms)
  36. {
  37. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  38. var campusID = pararms.getExtraGuid("CampusDropdown"); //校区
  39. var collegeID = pararms.getExtraGuid("CollegeDropdown"); //院系所
  40. var year = CheckIsSelectAll(pararms.getExtraInt("DictionarySchoolyear")); //年级
  41. var standard = CheckIsSelectAll(pararms.getExtraInt("DictionaryStandard")); //专业名称
  42. var education = CheckIsSelectAll(pararms.getExtraInt("DictionaryEducation")); //培养层次
  43. var learningform = CheckIsSelectAll(pararms.getExtraInt("DictionaryLearningform")); //学习形式
  44. var classmajorID = pararms.getExtraGuid("ClassmajorDropdown"); //班级名称
  45. var schoolYearID = pararms.getExtraGuid("SchoolYearDropdown"); //异动学期
  46. var differentDynamicType = CheckIsSelectAll(pararms.getExtraInt("DictionaryDifferentDynamicType")); //异动类型
  47. var differentDynamicStatus = CheckIsSelectAll(pararms.getExtraInt("DictionaryDifferentDynamicStatus")); //审批状态
  48. var result = DifferentDynamicServices.GetDifferentDynamicViewGrid(configuretView, campusID, collegeID, year, standard, education, learningform, classmajorID, schoolYearID, differentDynamicType, differentDynamicStatus,null, (int)pararms.page, (int)pararms.rows, 0);
  49. return Json(result);
  50. }
  51. public ActionResult Edit(Guid? id)
  52. {
  53. var vm = new DifferentDynamicView();
  54. var schoolYear = SchoolYearServices.GetSchoolYearIsCurrent(true);
  55. if (id != null && id != Guid.Empty)
  56. {
  57. vm = DifferentDynamicServices.GetDifferentDynamicView(id);
  58. }
  59. else
  60. {
  61. var user = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  62. var Student = StudentRecordService.GetStudentByStudentNo(user.UserID);
  63. vm.ClassmajorID = Student.ClassID;
  64. vm.ClassmajorName = Student.ClassName;
  65. vm.InSchoolStatusID = Student.InSchoolStatusID;
  66. vm.StudentStatus = Student.StudentStatus;
  67. vm.StandardID = Student.StandardID;
  68. vm.UserID = user.UserID;
  69. vm.SchoolyearID = schoolYear.SchoolyearID;
  70. vm.ApplyTypeID = (int)CF_ChangeApplyType.Normal;
  71. }
  72. var isView = (vm.EntityApprovalStatus.HasValue && vm.EntityApprovalStatus != DifferentDynamicServices.GetStartStatus()) ? true : false;
  73. ViewBag.IsView = isView;
  74. ViewBag.StartStatusID = DifferentDynamicServices.GetStartStatus();
  75. return View(vm);
  76. }
  77. /// <summary>
  78. /// 新增或更新
  79. /// </summary>
  80. /// <param name="vm"></param>
  81. /// <returns></returns>
  82. [HttpPost]
  83. public ActionResult Edit(DifferentDynamicView vm)
  84. {
  85. try
  86. {
  87. DifferentDynamicServices.AddOrUpdateDifferentDynamic(vm);
  88. return Json(new ReturnMessage()
  89. {
  90. IsSuccess = true,
  91. Message = "保存成功!"
  92. });
  93. }
  94. catch (Exception ex)
  95. {
  96. return Json(new ReturnMessage()
  97. {
  98. IsSuccess = false,
  99. Message = "保存失败,原因:" + ex.Message
  100. });
  101. }
  102. }
  103. /// <summary>
  104. /// 删除
  105. /// </summary>
  106. /// <param name="ids"></param>
  107. /// <returns></returns>
  108. [HttpPost]
  109. public ActionResult Delete(string ids)
  110. {
  111. try
  112. {
  113. var list = ids.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(s => Guid.Parse(s)).ToList();
  114. DifferentDynamicServices.DeleteDifferentDynamic(list);
  115. return base.Json("删除成功");
  116. }
  117. catch (Exception ex)
  118. {
  119. string mge = ex.Message;
  120. System.Data.SqlClient.SqlException num = ExceptionHelper.GetSqlException(ex);
  121. if (num != null)
  122. {
  123. if (num.Number == 547)
  124. //mge = "请先删除所有关联的数据,如:专业计划、选修计划等!";
  125. mge = "请先删除所有关联的数据!";
  126. }
  127. return base.Json("删除失败,原因:" + mge);
  128. }
  129. }
  130. /// <summary>
  131. /// 提交
  132. /// </summary>
  133. /// <param name="planApplicationIDs"></param>
  134. /// <returns></returns>
  135. [HttpPost]
  136. public ActionResult Submit(string ids)
  137. {
  138. try
  139. {
  140. var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
  141. var list = ids.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(s => Guid.Parse(s)).ToList();
  142. DifferentDynamicServices.Submit(list, user.UserID);
  143. return Json("提交成功");
  144. }
  145. catch (Exception ex)
  146. {
  147. string mge = ex.Message;
  148. return Json("提交失败,原因:" + mge);
  149. }
  150. }
  151. [HttpPost]
  152. public ActionResult Excel()
  153. {
  154. NpoiExcelHelper neh = new NpoiExcelHelper();
  155. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  156. //避开全选值
  157. //var roleID = Request.Form["Role"].ParseStrTo<Guid>();
  158. var campusID = Request.Form["CampusDropdown"].ParseStrTo<Guid>(); //校区
  159. var collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>(); //院系所
  160. var year = CheckIsSelectAll(Request.Form["DictionarySchoolyear"].ParseStrTo<int>()); //年级
  161. var standard = CheckIsSelectAll(Request.Form["DictionaryStandard"].ParseStrTo<int>()); //专业名称
  162. var education = CheckIsSelectAll(Request.Form["DictionaryEducation"].ParseStrTo<int>()); //培养层次
  163. var learningform = CheckIsSelectAll(Request.Form["DictionaryLearningform"].ParseStrTo<int>()); //学习形式
  164. var classmajorID = Request.Form["ClassmajorDropdown"].ParseStrTo<Guid>(); //班级名称
  165. var schoolYearID = Request.Form["SchoolYearDropdown"].ParseStrTo<Guid>(); //异动学期
  166. var differentDynamicType = CheckIsSelectAll(Request.Form["DictionaryDifferentDynamicType"].ParseStrTo<int>()); //异动类型
  167. var differentDynamicStatus = CheckIsSelectAll(Request.Form["DictionaryDifferentDynamicStatus"].ParseStrTo<int>()); //审批状态
  168. var result = DifferentDynamicServices.GetDifferentDynamicViewList(configuretView, campusID, collegeID, year, standard, education, learningform, classmajorID, schoolYearID, differentDynamicType, differentDynamicStatus,null,0);
  169. var dt = result.Select(s => new
  170. {
  171. s.SchoolyearCode,
  172. s.LoginID,
  173. s.Name,
  174. s.DifferentDynamicTypeName,
  175. s.Reason,
  176. s.InSchoolStatusName,
  177. s.StudentStatusName,
  178. s.StandardName,
  179. s.ClassmajorName,
  180. s.AfterStandardName,
  181. s.AfterClassmajorName,
  182. s.AfterInSchoolStatusName,
  183. s.AfterStudentStatusName,
  184. s.ReturnSchoolyearCode,
  185. s.ApprovalStatusName,
  186. s.ReportStatusName,
  187. }).ToTable();
  188. string[] liststring = { "异动学期", "学号", "姓名", "异动类型", "异动原因", "在校状态", "学籍状态",
  189. "异动前专业", "异动前班级", "异动后专业", "异动后班级", "异动后在校状态", "异动后学籍状态",
  190. "返校学期", "审批状态", "注册状态" };
  191. neh.Export(dt, liststring, "异动申请");
  192. return RedirectToAction("MsgShow", "Common", new
  193. {
  194. msg = "导出成功!",
  195. url = Url.Action("List").AddMenuParameter()
  196. });
  197. }
  198. protected static int? CheckIsSelectAll(int? argment)
  199. {
  200. return argment == DropdownList.SELECT_ALL ? null : argment;
  201. }
  202. }
  203. }