DegreeConditionController.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using Bowin.Web.Controls.Mvc;
  7. using Bowin.Common.Utility;
  8. using Bowin.Common.Data;
  9. using EMIS.ViewModel;
  10. using EMIS.Web.Controls;
  11. using EMIS.CommonLogic.DegreeManage.DegreeSetting;
  12. using EMIS.ViewModel.DegreeManage.DegreeSetting;
  13. namespace EMIS.Web.Controllers.DegreeManage.DegreeSetting
  14. {
  15. [Authorization]
  16. public class DegreeConditionController : Controller
  17. {
  18. public IDegreeConditionServices DegreeConditionServices { get; set; }
  19. /// <summary>
  20. /// 学位条件页面
  21. /// </summary>
  22. /// <returns></returns>
  23. public ActionResult List()
  24. {
  25. return View();
  26. }
  27. /// <summary>
  28. /// 学位条件列表查询
  29. /// </summary>
  30. /// <param name="pararms"></param>
  31. /// <returns></returns>
  32. [HttpPost]
  33. public ActionResult List(QueryParamsModel pararms)
  34. {
  35. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  36. var isCurrent = pararms.getExtraInt("IsCurrentDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsCurrentDropDown");
  37. return base.Json(DegreeConditionServices.GetDegreeConditionViewGrid(configuretView, isCurrent,
  38. (int)pararms.page, (int)pararms.rows));
  39. }
  40. /// <summary>
  41. /// 编辑
  42. /// </summary>
  43. /// <param name="DegreeConditionID"></param>
  44. /// <returns></returns>
  45. [HttpGet]
  46. public ActionResult Edit(Guid? DegreeConditionID)
  47. {
  48. DegreeConditionView degreeConditionView = new DegreeConditionView();
  49. if (DegreeConditionID.HasValue && DegreeConditionID != Guid.Empty)
  50. {
  51. degreeConditionView = DegreeConditionServices.GetDegreeConditionView(DegreeConditionID);
  52. }
  53. else
  54. {
  55. degreeConditionView.IsEnable = true;
  56. }
  57. return View(degreeConditionView);
  58. }
  59. /// <summary>
  60. /// 编辑
  61. /// </summary>
  62. /// <param name="degreeConditionView"></param>
  63. /// <returns></returns>
  64. [HttpPost]
  65. public ActionResult Edit(DegreeConditionView degreeConditionView)
  66. {
  67. try
  68. {
  69. DegreeConditionServices.DegreeConditionEdit(degreeConditionView);
  70. return Json(new ReturnMessage()
  71. {
  72. IsSuccess = true,
  73. Message = "保存成功。"
  74. });
  75. }
  76. catch (Exception ex)
  77. {
  78. return Json(new ReturnMessage()
  79. {
  80. IsSuccess = false,
  81. Message = "保存失败,原因:" + ex.Message + "。"
  82. });
  83. }
  84. }
  85. /// <summary>
  86. /// Excel导出
  87. /// </summary>
  88. /// <returns></returns>
  89. [HttpPost]
  90. public ActionResult Excel()
  91. {
  92. NpoiExcelHelper neh = new NpoiExcelHelper();
  93. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  94. int? isCurrent = Request["IsCurrentDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request["IsCurrentDropDown"].ParseStrTo<int>();
  95. var dt = DegreeConditionServices.GetDegreeConditionViewList(configuretView, isCurrent)
  96. .Select(x => new
  97. {
  98. x.OrderNo,
  99. x.Title,
  100. x.IsEnableName
  101. }).ToTable();
  102. string[] liststring = {
  103. "序号", "条件名称", "启用状态"
  104. };
  105. neh.Export(dt, liststring, "学位条件信息" + DateTime.Now.ToString("yyyyMMdd"));
  106. return Json(new ReturnMessage()
  107. {
  108. IsSuccess = true,
  109. Message = "导出成功。"
  110. });
  111. }
  112. }
  113. }