StudentPrintTimesController.cs 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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.Data;
  8. using Bowin.Common.Utility;
  9. using EMIS.CommonLogic.TerminatePrinter;
  10. using EMIS.ViewModel;
  11. using EMIS.Web.Controls;
  12. using EMIS.Utility;
  13. namespace EMIS.Web.Controllers.TerminatePrinter
  14. {
  15. [Authorization]
  16. public class StudentPrintTimesController : Controller
  17. {
  18. public IStudentPrintTimesServices StudentPrintTimesServices { get; set; }
  19. public ActionResult List()
  20. {
  21. return View();
  22. }
  23. [HttpPost]
  24. public ActionResult List(QueryParamsModel pararms)
  25. {
  26. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  27. var collegeID = pararms.getExtraGuid("cgbCollege");
  28. var yearID = pararms.getExtraInt("ddlYear") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlYear");
  29. var standardID = pararms.getExtraInt("cbgStandard") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("cbgStandard");
  30. var classmajorID = pararms.getExtraGuid("cbgClassmajor");
  31. return base.Json(StudentPrintTimesServices.GetStudentPrintTimesViewGrid(configuretView, collegeID, yearID, standardID, classmajorID, pararms.page, pararms.rows));
  32. }
  33. [HttpPost]
  34. public ActionResult Excel()
  35. {
  36. NpoiExcelHelper neh = new NpoiExcelHelper();
  37. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  38. var collegeID = Request.Form["cgbCollege"].ParseStrTo<Guid>();
  39. var yearID = Request.Form["ddlYear"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["ddlYear"].ParseStrTo<int>();
  40. var standardID = Request.Form["cbgStandard"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["cbgStandard"].ParseStrTo<int>();
  41. var classmajorID = Request.Form["cbgClassmajor"].ParseStrTo<Guid>();
  42. var dt = StudentPrintTimesServices.GetStudentPrintTimesViewGrid(configuretView, collegeID, yearID, standardID, classmajorID)
  43. .Select(x => new
  44. {
  45. x.CollegeName,
  46. x.YearID,
  47. x.StandardDesc,
  48. x.ClassmajorName,
  49. x.LoginID,
  50. x.Name,
  51. x.IsInSchoolDesc,
  52. x.Times
  53. }).ToTable();
  54. string[] liststring = {
  55. RSL.Get("College"), "年级", "专业", "班级", "学号", "姓名",
  56. "在校状态", "已打印次数"
  57. };
  58. neh.Export(dt, liststring, "学生打印次数表" + DateTime.Now.ToString("yyyyMMdd"));
  59. return Json(new ReturnMessage()
  60. {
  61. IsSuccess = true,
  62. Message = "导出成功。"
  63. });
  64. }
  65. [HttpPost]
  66. public ActionResult BatchUpdate(string userIDs, int times)
  67. {
  68. try
  69. {
  70. var userIDList = userIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList();
  71. StudentPrintTimesServices.BatchUpdate(userIDList, times);
  72. return base.Json(new ReturnMessage { IsSuccess = true, Message = "批量修改成功。" });
  73. }
  74. catch (Exception ex)
  75. {
  76. return base.Json(new ReturnMessage { IsSuccess = false, Message = "批量修改失败,原因:" + ex.Message + "。" });
  77. }
  78. }
  79. }
  80. }