StockOutStatisticsController.cs 4.9 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 Bowin.Common.Utility;
  7. using Bowin.Web.Controls.Mvc;
  8. using EMIS.CommonLogic.TeachingMaterial;
  9. using EMIS.ViewModel;
  10. using EMIS.ViewModel.TeachingMaterial;
  11. using EMIS.Web.Controls;
  12. using Bowin.Common.Data;
  13. using EMIS.CommonLogic.CalendarManage;
  14. namespace EMIS.Web.Controllers.TeachingMaterial
  15. {
  16. public class StockOutStatisticsController : Controller
  17. {
  18. public IStockOutDetailServices StockOutDetailServices { get; set; }
  19. public ISchoolYearServices SchoolYearServices { get; set; }
  20. /// <summary>
  21. /// 出库统计页面
  22. /// </summary>
  23. /// <returns></returns>
  24. [HttpGet]
  25. public ActionResult List()
  26. {
  27. //默认当前学年
  28. var schoolYear = SchoolYearServices.GetSchoolYearIsCurrent(true);
  29. ViewBag.SchoolYearID = schoolYear == null ? "-1" : schoolYear.SchoolyearID.ToString();
  30. return View();
  31. }
  32. /// <summary>
  33. /// 查询
  34. /// </summary>
  35. /// <param name="pararms"></param>
  36. /// <returns></returns>
  37. [HttpPost]
  38. public ActionResult List(QueryParamsModel pararms)
  39. {
  40. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  41. //避开全选值
  42. Guid? publishID = null;
  43. Guid? schoolyearID = null;
  44. Guid? teachingMaterialID = null;
  45. int? stockOutType = 0;
  46. publishID = pararms.getExtraGuid("PublishDropdown");
  47. schoolyearID = pararms.getExtraGuid("SchoolYearDropdown");
  48. var teachingMaterialType = pararms.getExtraInt("TeachingMaterialTypeDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("TeachingMaterialTypeDropdown");
  49. teachingMaterialID = pararms.getExtraGuid("TeachingMaterialDropdown");
  50. if (pararms.getExtraInt("StockOutTypeDropdown") != null && pararms.getExtraInt("StockOutTypeDropdown") != DropdownList.SELECT_ALL)
  51. {
  52. stockOutType = pararms.getExtraInt("StockOutTypeDropdown");
  53. }
  54. return base.Json(StockOutDetailServices.GetStockOutStatisticsViewGrid(configuretView, schoolyearID, publishID,teachingMaterialID, teachingMaterialType,stockOutType,(int)pararms.page, (int)pararms.rows));
  55. }
  56. /// <summary>
  57. /// Excel导出
  58. /// </summary>
  59. /// <returns></returns>
  60. [HttpPost]
  61. public ActionResult Excel()
  62. {
  63. NpoiExcelHelper neh = new NpoiExcelHelper();
  64. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  65. Guid? publishID = null;
  66. Guid? schoolyearID = null;
  67. Guid? teachingMaterialID = null;
  68. int? stockOutType = 0;
  69. publishID = Request.Form["PublishDropdown"].ParseStrTo<Guid>();
  70. schoolyearID = Request.Form["SchoolYearDropdown"].ParseStrTo<Guid>();
  71. teachingMaterialID = Request.Form["TeachingMaterialDropdown"].ParseStrTo<Guid>();
  72. if (Request.Form["StockOutTypeDropdown"].ParseStrTo<int>() != null && Request.Form["StockOutTypeDropdown"].ParseStrTo<int>() != DropdownList.SELECT_ALL)
  73. {
  74. stockOutType = Request.Form["StockOutTypeDropdown"].ParseStrTo<int>();
  75. }
  76. var teachingMaterialType = Request.Form["TeachingMaterialTypeDropdown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["TeachingMaterialTypeDropdown"].ParseStrTo<int>();
  77. var dt = StockOutDetailServices.GetStockOutStatisticsViewList(configuretView, schoolyearID, publishID, teachingMaterialID, teachingMaterialType, stockOutType).Select(x => new
  78. {
  79. x.SchoolyearName,
  80. // x.StockInDocumentNo,
  81. // x.StockInType,
  82. x.TeachingMaterialCode,
  83. x.TeachingMaterialName,
  84. x.PublishName,
  85. x.SupplierName,
  86. x.PublishTime,
  87. x.Author,
  88. x.StockOutTypeName,
  89. x.Quantity,
  90. x.Price,
  91. x.DiscountStr,
  92. x.DiscountPriceStr,
  93. x.TotalPriceStr,
  94. x.TotalDollarStr
  95. //x.HandlerUserName,
  96. //x.StockInUserName,
  97. //x.StockInTime
  98. }).ToTable();
  99. string[] liststring = { "学年学期", "教材编号", "教材名称", "供应商",
  100. "出版单位", "版本时间", "作者", "出库类型","数量", "单价", "折扣率", "折合价", "码洋", "实洋" };
  101. neh.Export(dt, liststring, "出库明细信息");
  102. return RedirectToAction("MsgShow", "Common", new
  103. {
  104. msg = "导出成功!",
  105. url = Url.Content("~/StockOutStatistics/List").AddMenuParameter()
  106. });
  107. }
  108. }
  109. }