MinorRegistListController.cs 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using EMIS.ViewModel;
  7. using EMIS.Web.Controls;
  8. using Bowin.Web.Controls.Mvc;
  9. using EMIS.CommonLogic.MinorManage.MinorApply;
  10. using Bowin.Common.Utility;
  11. using Bowin.Common.Data;
  12. using EMIS.ViewModel.MinorManage.MinorApply;
  13. namespace EMIS.Web.Controllers.MinorManage.MinorApply
  14. {
  15. [Authorization]
  16. public class MinorRegistListController : Controller
  17. {
  18. //
  19. // GET: /MinorRegistList/
  20. public IMinorApplyServices minorApplyServices { get; set; }
  21. public ActionResult List()
  22. {
  23. return View();
  24. }
  25. [HttpPost]
  26. public ActionResult List(QueryParamsModel pararms)
  27. {
  28. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  29. var schoolyearID = pararms.getExtraGuid("SchoolyearDropdown");
  30. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  31. var yearID = pararms.getExtraInt("SchoolyearDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("SchoolyearDictionaryDropDown");
  32. var standardID = pararms.getExtraInt("StandardDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardDictionaryDropDown");
  33. var classmajorID = pararms.getExtraGuid("ClassmajorDropdown");
  34. var minorStandardID = pararms.getExtraInt("MinorStandardDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("MinorStandardDropDown");
  35. var approvalStatus = minorApplyServices.GetCorrectEndStatus();
  36. return base.Json(minorApplyServices.MinorApplyViewGrid(configuretView, schoolyearID, collegeID, yearID, standardID, classmajorID, minorStandardID, approvalStatus, (int)pararms.page, (int)pararms.rows));
  37. }
  38. [HttpGet]
  39. public ActionResult Edit(Guid? minorApplyID)
  40. {
  41. MinorApplyView minorApplyView = new MinorApplyView();
  42. if (minorApplyID.HasValue)
  43. {
  44. minorApplyView = minorApplyServices.GetMinorApplyView(minorApplyID);
  45. }
  46. return View(minorApplyView);
  47. }
  48. /// <summary>
  49. /// 修改
  50. /// </summary>
  51. /// <param name="graduationApplyView"></param>
  52. /// <returns></returns>
  53. [HttpPost]
  54. public ActionResult Edit(MinorApplyView minorApplyView)
  55. {
  56. try
  57. {
  58. minorApplyServices.MinorApplyEdit(minorApplyView);
  59. return Json(new ReturnMessage()
  60. {
  61. IsSuccess = true,
  62. Message = "保存成功。"
  63. });
  64. }
  65. catch (Exception ex)
  66. {
  67. return Json(new ReturnMessage()
  68. {
  69. IsSuccess = false,
  70. Message = "保存失败,原因:" + ex.Message + "。"
  71. });
  72. }
  73. }
  74. [HttpPost]
  75. public ActionResult Excel()
  76. {
  77. NpoiExcelHelper neh = new NpoiExcelHelper();
  78. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  79. var schoolyearID = Request.Form["SchoolyearDropdown"] == DropdownList.SELECT_ALL.ToString() ? null : Request.Form["SchoolyearDropdown"].ParseStrTo<Guid>();
  80. var collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
  81. var yearID = Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo<int>();
  82. var standardID = Request.Form["StandardDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["StandardDropDown"].ParseStrTo<int>();
  83. var classmajorID = Request.Form["ClassmajorDropdown"] == DropdownList.SELECT_ALL.ToString() ? null : Request.Form["ClassmajorDropdown"].ParseStrTo<Guid>();
  84. var minorStandardID = Request.Form["MinorStandardDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["MinorStandardDropDown"].ParseStrTo<int>();
  85. var approvalStatus = minorApplyServices.GetCorrectEndStatus();
  86. var minorApplyIDString = Request.Form["SelectedID"];
  87. var minorApplyIDList = minorApplyIDString.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  88. var dt = minorApplyServices.GetMinorApplyViewList(configuretView, schoolyearID, collegeID, yearID, standardID, classmajorID, minorStandardID, approvalStatus, minorApplyIDList)
  89. .Select(x => new
  90. {
  91. x.SchoolyearCode,
  92. x.GrademajorName,
  93. x.ClassmajorName,
  94. x.LoginID,
  95. x.UserName,
  96. x.GrademinorCode,
  97. x.GrademinorName,
  98. x.RecordStatusStr
  99. }).ToTable();
  100. string[] liststring = { "学年学期", "年级专业", "班级名称", "学号", "姓名", "辅修专业代码", "辅修专业名称", "状态" };
  101. neh.Export(dt, liststring, "辅修报名信息" + DateTime.Now.ToString("yyyyMMdd"));
  102. return Json(new ReturnMessage()
  103. {
  104. IsSuccess = true,
  105. Message = "导出成功。"
  106. });
  107. }
  108. [HttpPost]
  109. public ActionResult Delete(string minorApplyIDs)
  110. {
  111. try
  112. {
  113. List<Guid?> list = minorApplyIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
  114. .Select(x => (Guid?)new Guid(x)).ToList();
  115. minorApplyServices.MinorApplyDelete(list);
  116. return base.Json("删除成功。");
  117. }
  118. catch (Exception ex)
  119. {
  120. return base.Json("删除失败,原因:" + ex.Message + "。");
  121. }
  122. }
  123. }
  124. }