RetakeOpenControlController.cs 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using EMIS.CommonLogic.RetakeManage;
  7. using EMIS.ViewModel.RetakeManage;
  8. using EMIS.ViewModel;
  9. using EMIS.Web.Controls;
  10. using Bowin.Common.Utility;
  11. using Bowin.Common.Data;
  12. namespace EMIS.Web.Controllers.RetakeManage
  13. {
  14. [Authorization]
  15. public class RetakeOpenControlController : Controller
  16. {
  17. public IRetakeOpenControlServices RetakeOpenControlServices { get; set; }
  18. /// <summary>
  19. /// 重修控制页面
  20. /// </summary>
  21. /// <returns></returns>
  22. public ActionResult List()
  23. {
  24. return View();
  25. }
  26. /// <summary>
  27. /// 重修控制列表查询
  28. /// </summary>
  29. /// <param name="pararms"></param>
  30. /// <returns></returns>
  31. [HttpPost]
  32. public ActionResult List(QueryParamsModel pararms)
  33. {
  34. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  35. Guid? schoolyearID = pararms.getExtraGuid("ddlSchoolYear");
  36. return base.Json(RetakeOpenControlServices.GetRetakeOpenControlViewList(configuretView, schoolyearID, (int)pararms.page, (int)pararms.rows));
  37. }
  38. /// <summary>
  39. /// 编辑
  40. /// </summary>
  41. /// <param name="RetakeOpenControlID"></param>
  42. /// <returns></returns>
  43. public ActionResult Edit(Guid? RetakeOpenControlID)
  44. {
  45. RetakeOpenControlView retakeOpenControlView = new RetakeOpenControlView();
  46. if (RetakeOpenControlID.HasValue)
  47. {
  48. retakeOpenControlView = RetakeOpenControlServices.GetRetakeOpenControlView(RetakeOpenControlID);
  49. }
  50. else
  51. {
  52. retakeOpenControlView.StartDate = DateTime.Now;
  53. retakeOpenControlView.EndDate = DateTime.Now.AddDays(+1);
  54. }
  55. return View(retakeOpenControlView);
  56. }
  57. /// <summary>
  58. /// 编辑(新增、修改)
  59. /// </summary>
  60. /// <param name="retakeOpenControlView"></param>
  61. /// <returns></returns>
  62. [HttpPost]
  63. public ActionResult Edit(RetakeOpenControlView retakeOpenControlView)
  64. {
  65. try
  66. {
  67. RetakeOpenControlServices.RetakeOpenControlEdit(retakeOpenControlView);
  68. return Json(new ReturnMessage()
  69. {
  70. IsSuccess = true,
  71. Message = "保存成功。"
  72. });
  73. }
  74. catch (Exception ex)
  75. {
  76. return Json(new ReturnMessage()
  77. {
  78. IsSuccess = false,
  79. Message = "保存失败,原因:" + ex.Message
  80. });
  81. }
  82. }
  83. /// <summary>
  84. /// 删除
  85. /// </summary>
  86. /// <param name="retakeOpenControlIDs"></param>
  87. /// <returns></returns>
  88. [HttpPost]
  89. public ActionResult Delete(string retakeOpenControlIDs)
  90. {
  91. try
  92. {
  93. List<Guid?> list = retakeOpenControlIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
  94. .Select(x => (Guid?)new Guid(x)).ToList();
  95. RetakeOpenControlServices.RetakeOpenControlDelete(list);
  96. return base.Json(new ReturnMessage()
  97. {
  98. IsSuccess = true,
  99. Message = "删除成功。"
  100. });
  101. }
  102. catch (Exception ex)
  103. {
  104. return base.Json(new ReturnMessage()
  105. {
  106. IsSuccess = false,
  107. Message = "删除失败,原因:" + ex.Message
  108. });
  109. }
  110. }
  111. /// <summary>
  112. /// Excel导出
  113. /// </summary>
  114. /// <returns></returns>
  115. [HttpPost]
  116. public ActionResult Excel()
  117. {
  118. NpoiExcelHelper neh = new NpoiExcelHelper();
  119. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  120. var schoolyearID = Request.Form["ddlSchoolYear"].ParseStrTo<Guid>();
  121. var dt = RetakeOpenControlServices.GetRetakeOpenControlViewList(configuretView, schoolyearID)
  122. .Select(x => new
  123. {
  124. x.SchoolyearCode,
  125. x.StartDate,
  126. x.EndDate
  127. }).ToTable();
  128. string[] liststring = {
  129. "重修学年学期", "开始时间", "结束时间"
  130. };
  131. neh.Export(dt, liststring, "重修控制信息" + DateTime.Now.ToString("yyyyMMdd"));
  132. return Json(new ReturnMessage()
  133. {
  134. IsSuccess = true,
  135. Message = "导出成功。"
  136. });
  137. }
  138. }
  139. }