InSchoolSettingController.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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.Web.Controls;
  10. using EMIS.ViewModel;
  11. using EMIS.ViewModel.StudentManage.StudentStatistics;
  12. using EMIS.CommonLogic.StudentManage.StudentStatistics;
  13. namespace EMIS.Web.Controllers.StudentManage.StudentStatistics
  14. {
  15. [Authorization]
  16. public class InSchoolSettingController : Controller
  17. {
  18. public IInSchoolSettingServices InSchoolSettingServices { 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 inSchoolStatusID = pararms.getExtraInt("DictionaryInSchoolStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryInSchoolStatus");
  37. var isSelected = pararms.getExtraInt("DictionaryIsSelected") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryIsSelected");
  38. var isDisplayID = pararms.getExtraInt("DictionaryIsDisplay") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryIsDisplay");
  39. return base.Json(InSchoolSettingServices.GetInSchoolSettingViewGrid(configuretView, inSchoolStatusID, isSelected, isDisplayID, (int)pararms.page, (int)pararms.rows));
  40. }
  41. /// <summary>
  42. /// 设置(新增、修改、删除)
  43. /// </summary>
  44. /// <returns></returns>
  45. [HttpPost]
  46. public ActionResult Edit()
  47. {
  48. try
  49. {
  50. var inSchoolSettingViewList = DataGrid.GetTableData<InSchoolSettingView>("dgInSchoolSettingList");
  51. InSchoolSettingServices.InSchoolSettingEdit(inSchoolSettingViewList);
  52. return Json(new ReturnMessage()
  53. {
  54. IsSuccess = true,
  55. Message = "设置成功。"
  56. });
  57. }
  58. catch (Exception ex)
  59. {
  60. return Json(new ReturnMessage()
  61. {
  62. IsSuccess = false,
  63. Message = "设置失败,原因:" + ex.Message
  64. });
  65. }
  66. }
  67. /// <summary>
  68. /// Excel导出
  69. /// </summary>
  70. /// <returns></returns>
  71. [HttpPost]
  72. public ActionResult Excel()
  73. {
  74. NpoiExcelHelper neh = new NpoiExcelHelper();
  75. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  76. var inSchoolStatusID = Request.Form["DictionaryInSchoolStatus"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryInSchoolStatus"].ParseStrTo<int>();
  77. var isSelected = Request.Form["DictionaryIsSelected"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryIsSelected"].ParseStrTo<int>();
  78. var isDisplayID = Request.Form["DictionaryIsDisplay"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryIsDisplay"].ParseStrTo<int>();
  79. var dt = InSchoolSettingServices.GetInSchoolSettingViewList(configuretView, inSchoolStatusID, isSelected, isDisplayID)
  80. .Select(x => new
  81. {
  82. x.InSchoolStatusID,
  83. x.InSchoolStatusName,
  84. x.IsSelectedName,
  85. x.IsDisplayName,
  86. x.CreateUserName,
  87. x.ModifyUserName,
  88. x.ModifyTime
  89. }).ToTable();
  90. string[] liststring = {
  91. "类型代码", "在校状态", "是否选中", "是否显示", "创建人", "修改人", "修改时间"
  92. };
  93. neh.Export(dt, liststring, "在校设定信息" + DateTime.Now.ToString("yyyyMMdd"));
  94. return Json(new ReturnMessage()
  95. {
  96. IsSuccess = true,
  97. Message = "导出成功。"
  98. });
  99. }
  100. }
  101. }