PrintControlController.cs 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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.TerminatePrinter;
  7. using EMIS.ViewModel.TerminatePrinter;
  8. using EMIS.ViewModel;
  9. using EMIS.Web.Controls;
  10. using Bowin.Web.Controls.Mvc;
  11. namespace EMIS.Web.Controllers.TerminatePrinter
  12. {
  13. [Authorization]
  14. public class PrintControlController : Controller
  15. {
  16. public IPrintControlServices PrintControlServices { get; set; }
  17. public ActionResult List()
  18. {
  19. return View();
  20. }
  21. public ActionResult Edit(Guid? printControlID)
  22. {
  23. var printControlView = new PrintControlView();
  24. if (printControlID.HasValue)
  25. {
  26. printControlView = this.PrintControlServices.GetPrintControlView(printControlID.Value);
  27. }
  28. else
  29. {
  30. printControlView.Times = 1;
  31. }
  32. return View(printControlView);
  33. }
  34. [HttpPost]
  35. public ActionResult List(QueryParamsModel pararms)
  36. {
  37. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  38. var yearID = pararms.getExtraInt("ddlYear") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlYear");
  39. return base.Json(PrintControlServices.GetPrintControlViewGrid(configuretView, yearID, pararms.page, pararms.rows));
  40. }
  41. [HttpPost]
  42. public ActionResult Delete(string printControlIDs)
  43. {
  44. try
  45. {
  46. var printControlIDList = printControlIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  47. PrintControlServices.Delete(printControlIDList);
  48. return base.Json(new ReturnMessage { IsSuccess = true, Message = "删除成功" });
  49. }
  50. catch (Exception ex)
  51. {
  52. return base.Json(new ReturnMessage { IsSuccess = false, Message = "删除失败,原因:" + ex.Message + "!" });
  53. }
  54. }
  55. [HttpPost]
  56. public ActionResult Edit(PrintControlView printControlView)
  57. {
  58. try
  59. {
  60. PrintControlServices.Save(printControlView);
  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. }
  77. }