using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using Bowin.Common.Utility; using Bowin.Web.Controls.Mvc; using EMIS.CommonLogic.TeachingMaterial; using EMIS.ViewModel; using EMIS.ViewModel.TeachingMaterial; using EMIS.Web.Controls; using Bowin.Common.Data; using EMIS.CommonLogic.CalendarManage; namespace EMIS.Web.Controllers.TeachingMaterial { public class StockOutStatisticsController : Controller { public IStockOutDetailServices StockOutDetailServices { get; set; } public ISchoolYearServices SchoolYearServices { get; set; } /// /// 出库统计页面 /// /// [HttpGet] public ActionResult List() { //默认当前学年 var schoolYear = SchoolYearServices.GetSchoolYearIsCurrent(true); ViewBag.SchoolYearID = schoolYear == null ? "-1" : schoolYear.SchoolyearID.ToString(); return View(); } /// /// 查询 /// /// /// [HttpPost] public ActionResult List(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); //避开全选值 Guid? publishID = null; Guid? schoolyearID = null; Guid? teachingMaterialID = null; int? stockOutType = 0; publishID = pararms.getExtraGuid("PublishDropdown"); schoolyearID = pararms.getExtraGuid("SchoolYearDropdown"); var teachingMaterialType = pararms.getExtraInt("TeachingMaterialTypeDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("TeachingMaterialTypeDropdown"); teachingMaterialID = pararms.getExtraGuid("TeachingMaterialDropdown"); if (pararms.getExtraInt("StockOutTypeDropdown") != null && pararms.getExtraInt("StockOutTypeDropdown") != DropdownList.SELECT_ALL) { stockOutType = pararms.getExtraInt("StockOutTypeDropdown"); } return base.Json(StockOutDetailServices.GetStockOutStatisticsViewGrid(configuretView, schoolyearID, publishID,teachingMaterialID, teachingMaterialType,stockOutType,(int)pararms.page, (int)pararms.rows)); } /// /// Excel导出 /// /// [HttpPost] public ActionResult Excel() { NpoiExcelHelper neh = new NpoiExcelHelper(); ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null); Guid? publishID = null; Guid? schoolyearID = null; Guid? teachingMaterialID = null; int? stockOutType = 0; publishID = Request.Form["PublishDropdown"].ParseStrTo(); schoolyearID = Request.Form["SchoolYearDropdown"].ParseStrTo(); teachingMaterialID = Request.Form["TeachingMaterialDropdown"].ParseStrTo(); if (Request.Form["StockOutTypeDropdown"].ParseStrTo() != null && Request.Form["StockOutTypeDropdown"].ParseStrTo() != DropdownList.SELECT_ALL) { stockOutType = Request.Form["StockOutTypeDropdown"].ParseStrTo(); } var teachingMaterialType = Request.Form["TeachingMaterialTypeDropdown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["TeachingMaterialTypeDropdown"].ParseStrTo(); var dt = StockOutDetailServices.GetStockOutStatisticsViewList(configuretView, schoolyearID, publishID, teachingMaterialID, teachingMaterialType, stockOutType).Select(x => new { x.SchoolyearName, // x.StockInDocumentNo, // x.StockInType, x.TeachingMaterialCode, x.TeachingMaterialName, x.PublishName, x.SupplierName, x.PublishTime, x.Author, x.StockOutTypeName, x.Quantity, x.Price, x.DiscountStr, x.DiscountPriceStr, x.TotalPriceStr, x.TotalDollarStr //x.HandlerUserName, //x.StockInUserName, //x.StockInTime }).ToTable(); string[] liststring = { "学年学期", "教材编号", "教材名称", "供应商", "出版单位", "版本时间", "作者", "出库类型","数量", "单价", "折扣率", "折合价", "码洋", "实洋" }; neh.Export(dt, liststring, "出库明细信息"); return RedirectToAction("MsgShow", "Common", new { msg = "导出成功!", url = Url.Content("~/StockOutStatistics/List").AddMenuParameter() }); } } }