PurchasingStatisticsController.cs 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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 EMIS.ViewModel;
  8. using EMIS.Web.Controls;
  9. using Bowin.Common.Data;
  10. using EMIS.CommonLogic.ProcurementPlan;
  11. using Bowin.Common.Linq.Entity;
  12. using EMIS.CommonLogic.CalendarManage;
  13. namespace EMIS.Web.Controllers.ProcurementPlan
  14. {
  15. [Authorization]
  16. public class PurchasingStatisticsController : Controller
  17. {
  18. public IPurchasingStatisticsServices PurchasingStatisticsServices { get; set; }
  19. public ISchoolYearServices schoolYearServices { get; set; }
  20. [HttpGet]
  21. public ActionResult List()
  22. {
  23. //默认加载当前校历下学年学期的下一个学期
  24. var schoolYearView = schoolYearServices.GetSchoolYearIsCurrent(true);
  25. var schoolyear = schoolYearServices.GetSchoolYearViewListAfterCurrent().OrderBy(x => x.Code).Where(x => x.Value > schoolYearView.Value).FirstOrDefault();
  26. ViewBag.SchoolYearID = schoolyear.SchoolYearID;
  27. return View();
  28. }
  29. /// <summary>
  30. /// 列表查询
  31. /// </summary>
  32. /// <param name="pararms"></param>
  33. /// <returns></returns>
  34. [HttpPost]
  35. public ActionResult List(QueryParamsModel pararms)
  36. {
  37. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  38. //避开全选值
  39. Guid? publishID = null;
  40. Guid? coursematerialID = null;
  41. Guid? teachingMaterialPoolID = null;
  42. Guid? schoolyearID = null;
  43. schoolyearID = pararms.getExtraGuid("SchoolYearDropdown");
  44. publishID = pararms.getExtraGuid("PublishDropdown"); ;
  45. coursematerialID = pararms.getExtraGuid("CourseDropdown"); ;
  46. teachingMaterialPoolID = pararms.getExtraGuid("TeachingMaterialDropdown"); ;
  47. return base.Json(PurchasingStatisticsServices.GetPurchasingStatisticsViewGrid(configuretView, schoolyearID, teachingMaterialPoolID, coursematerialID, publishID, (int)pararms.page, (int)pararms.rows));
  48. }
  49. #region 2.0 页面Excel表格导出
  50. [HttpPost]
  51. public ActionResult Excel()
  52. {
  53. //避开全选值
  54. Guid? publishID = null;
  55. Guid? coursematerialID = null;
  56. Guid? teachingMaterialPoolID = null;
  57. Guid? schoolyearID = null;
  58. schoolyearID = Request.Form["SchoolYearDropdown"].ParseStrTo<Guid>();
  59. publishID = Request.Form["PublishDropdown"].ParseStrTo<Guid>();
  60. coursematerialID = Request.Form["CourseDropdown"].ParseStrTo<Guid>();
  61. teachingMaterialPoolID = Request.Form["TeachingMaterialDropdown"].ParseStrTo<Guid>();
  62. NpoiExcelHelper neh = new NpoiExcelHelper();
  63. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  64. var dt = PurchasingStatisticsServices.GetPurchasingStatisticsList(configuretView, schoolyearID, teachingMaterialPoolID, coursematerialID, publishID).Select(x => new
  65. {
  66. x.SchoolyearName,
  67. x.TeachingMaterialCode,
  68. x.CoursematerialName,
  69. x.ISBN,
  70. x.TeachingMaterialName,
  71. x.Price,
  72. x.PublishTime,
  73. x.PublishName,
  74. x.Author,
  75. x.CountNumber
  76. }).OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToTable();
  77. string[] liststring = { "学年学期","教材编号","课程名称","ISBN","教材名称","单价"
  78. ,"版本时间","出版单位","作者","总征订量"};
  79. neh.Export(dt, liststring, "采购统计信息");
  80. return RedirectToAction("MsgShow", "Common", new
  81. {
  82. msg = "导出成功!",
  83. url = Url.Content("~/PurchasingStatistics/List").AddMenuParameter()
  84. });
  85. }
  86. #endregion
  87. }
  88. }