MinorConditionController.cs 3.8 KB

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