MinorGraduationConditionController.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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.MinorGraduation.MinorGraduationSetting;
  7. using EMIS.ViewModel;
  8. using EMIS.Web.Controls;
  9. using Bowin.Web.Controls.Mvc;
  10. using EMIS.ViewModel.MinorGraduation.MinorGraduationSetting;
  11. using Bowin.Common.Utility;
  12. using Bowin.Common.Data;
  13. namespace EMIS.Web.Controllers.MinorGraduation.MinorGraduationSetting
  14. {
  15. public class MinorGraduationConditionController : Controller
  16. {
  17. //
  18. // GET: /MinorGraduationCondition/
  19. public IMinorGraduationConditionServices minorGraduationConditionServices { get; set; }
  20. public ActionResult List()
  21. {
  22. return View();
  23. }
  24. [HttpPost]
  25. public ActionResult List(QueryParamsModel pararms)
  26. {
  27. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  28. var isCurrent = pararms.getExtraInt("IsCurrentDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsCurrentDropDown");
  29. return base.Json(minorGraduationConditionServices.GetMinorGraduationConditionViewGrid(configuretView, isCurrent, (int)pararms.page, (int)pararms.rows));
  30. }
  31. /// <summary>
  32. /// 编辑
  33. /// </summary>
  34. /// <param name="GraduationConditionID"></param>
  35. /// <returns></returns>
  36. [HttpGet]
  37. public ActionResult Edit(Guid? minorGraduationConditionID)
  38. {
  39. MinorGraduationConditionView minorGraduationConditionView = new MinorGraduationConditionView();
  40. if (minorGraduationConditionID.HasValue && minorGraduationConditionID != Guid.Empty)
  41. {
  42. minorGraduationConditionView = minorGraduationConditionServices.GetMinorGraduationConditionView(minorGraduationConditionID);
  43. }
  44. else
  45. {
  46. minorGraduationConditionView.IsEnable = true;
  47. }
  48. return View(minorGraduationConditionView);
  49. }
  50. /// <summary>
  51. /// 编辑
  52. /// </summary>
  53. /// <param name="graduationConditionView"></param>
  54. /// <returns></returns>
  55. [HttpPost]
  56. public ActionResult Edit(MinorGraduationConditionView minorGraduationConditionView)
  57. {
  58. try
  59. {
  60. minorGraduationConditionServices.MinorGraduationConditionEdit(minorGraduationConditionView);
  61. return Json(new ReturnMessage()
  62. {
  63. IsSuccess = true,
  64. Message = "保存成功。"
  65. });
  66. }
  67. catch (Exception ex)
  68. {
  69. return Json(new ReturnMessage()
  70. {
  71. IsSuccess = false,
  72. Message = "保存失败,原因:" + ex.Message + "。"
  73. });
  74. }
  75. }
  76. [HttpPost]
  77. public ActionResult Excel()
  78. {
  79. NpoiExcelHelper neh = new NpoiExcelHelper();
  80. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  81. int? isCurrent = Request["IsCurrentDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request["IsCurrentDropDown"].ParseStrTo<int>();
  82. var minorGraduationConditionIDString = Request.Form["SelectedID"];
  83. var minorGraduationConditionIDList = minorGraduationConditionIDString.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  84. var dt = minorGraduationConditionServices.GetGraduationViewList(configuretView, isCurrent, minorGraduationConditionIDList)
  85. .Select(x => new
  86. {
  87. x.Title,
  88. x.IsEnableName
  89. }).ToTable();
  90. string[] liststring = { "条件名称", "启用状态" };
  91. neh.Export(dt, liststring, "辅修毕业条件信息" + DateTime.Now.ToString("yyyyMMdd"));
  92. return Json(new ReturnMessage()
  93. {
  94. IsSuccess = true,
  95. Message = "导出成功。"
  96. });
  97. }
  98. }
  99. }