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.SystemServices; using EMIS.CommonLogic.CalendarManage; namespace EMIS.Web.Controllers.TeachingMaterial { [Authorization] public class InventoryManagementController : Controller { public IStockOutServices StockOutServices { get; set; } public IStockInDetailServices StockInDetailServices { get; set; } public IStockInServices StockInServices { get; set; } public IInventoryServices InventoryServices { 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); var schoolYear = SchoolYearServices.GetSchoolYearIsCurrent(true); //避开全选值 Guid? publishID = null; Guid? schoolyearID = null; Guid? teachingMaterialID = null; 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 (schoolyearID == null) { schoolyearID = (Guid)schoolYear.SchoolyearID; } return base.Json(InventoryServices.GetInventoryManagementViewGrid(configuretView, schoolyearID, teachingMaterialID, teachingMaterialType, publishID, (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; publishID = Request.Form["PublishDropdown"].ParseStrTo(); schoolyearID = Request.Form["SchoolYearDropdown"].ParseStrTo(); var teachingMaterialType = Request.Form["TeachingMaterialTypeDropdown"].ParseStrTo(); if (Request.Form["TeachingMaterialTypeDropdown"].ParseStrTo() != DropdownList.SELECT_ALL && Request.Form["TeachingMaterialTypeDropdown"].ParseStrTo() != null) { teachingMaterialType = Request.Form["TeachingMaterialTypeDropdown"].ParseStrTo(); } teachingMaterialID = Request.Form["TeachingMaterialDropdown"].ParseStrTo(); var dt = InventoryServices.GetInventoryManagementViewList(configuretView, schoolyearID, teachingMaterialID, teachingMaterialType, publishID).Select(x => new { x.SchoolYearName, x.TeachingMaterialCode, x.TeachingMaterialName, x.ISBN, x.MinInventory, x.InventoryCollectQtyStr, x.StockInQty, x.StockOutQty, x.PresentInventory, x.Price, }).ToTable(); string[] liststring = { "学年学期", "教材编号", "教材名称", "ISBN", "最小库存量", "原库存量", "入库数量", "出库数量", "当前库存量", "单价" }; neh.Export(dt, liststring, "库存统计信息"); return RedirectToAction("MsgShow", "Common", new { msg = "导出成功!", url = Url.Content("~/InventoryManagement/List").AddMenuParameter() }); } /// /// 库存明细Excel导出 /// /// /// [HttpPost] public ActionResult InventoryExcel(Guid? teachingMaterialPoolID) { NpoiExcelHelper neh = new NpoiExcelHelper(); var dt = InventoryServices.GetTeachingMateriaInventoryViewList(teachingMaterialPoolID).Select(x => new { x.PublishName, x.TeachingMaterialCode, x.TeachingMaterialName, x.CoursematerialCode, x.CoursematerialName, x.ISBN, x.PublishTime, x.Author, x.IsLateName, x.Price, x.MinInventory, x.PresentInventory, x.Total, x.ModifyTime, x.Desc }).ToTable(); string[] liststring = { "书库名称", "教材编号", "教材名称", "课程代码", "课程名称", "ISBN", "版本时间", "出版单位", "作者", "是否过期", "单价", "最小库存量", "当前库存量", "码洋", "最近响应时间", "备注" }; neh.Export(dt, liststring, "教材库存信息"); return RedirectToAction("MsgShow", "Common", new { msg = "导出成功!", url = Url.Content("~/InventoryManagement/List").AddMenuParameter() }); } /// /// 出库明细Excel导出 /// /// /// /// [HttpPost] public ActionResult StockInExcel(Guid? teachingMaterialPoolID, Guid? schoolyearID) { NpoiExcelHelper neh = new NpoiExcelHelper(); var dt = InventoryServices.GetStockInDetailByValueViewList(teachingMaterialPoolID, schoolyearID).Select(x => new { x.SchoolyearName, x.StockInDocumentNo, x.TeachingMaterialCode, x.TeachingMaterialName, x.Quantity, x.Price, x.DiscountStr, x.DiscountPriceStr, x.TotalPriceStr, x.TotalDollarStr, x.HandlerUserName, x.StockInTime }).ToTable(); string[] liststring = { "学年学期", "入库单据号", "教材编号", "教材名称", "数量", "单价", "折扣率", "折合价", "码洋", "总价", "经手人", "入库日期" }; neh.Export(dt, liststring, "入库明细信息"); return RedirectToAction("MsgShow", "Common", new { msg = "导出成功!", url = Url.Content("~/InventoryManagement/List").AddMenuParameter() }); } /// /// 入库明细Excel导出 /// /// [HttpPost] public ActionResult StockOutExcel() { Guid? teachingMaterialPoolID = Request.Params["teachingMaterialPoolID"].ParseStrTo(); Guid? schoolyearID = Request.Params["schoolyearID"].ParseStrTo(); var SchoolYearEntity = SchoolYearServices.GetSchoolYear(schoolyearID); NpoiExcelHelper neh = new NpoiExcelHelper(); var dt = InventoryServices.GetStockOutDetailByValueViewList(teachingMaterialPoolID, SchoolYearEntity.Value, schoolyearID).Select(x => new { x.SchoolyearName, x.StockOutNo, x.GetBookNo, x.TeachingMaterialCode, x.TeachingMaterialName, x.StockOutTypeNameStr, x.Quantity, x.Price, x.DiscountStr, x.DiscountPriceStr, x.TotalPriceStr, x.TotalDollarStr, x.RecipientUserName, x.StockOutTime, x.Desc }).ToTable(); string[] liststring = { "学年学期","出库单据号", "领书人", "教材编号", "教材名称","出库类型", "数量", "单价", "折扣率", "折合价", "码洋", "总价", "签收人", "出库日期","出库说明" }; neh.Export(dt, liststring, "出库明细信息"); return RedirectToAction("MsgShow", "Common", new { msg = "导出成功!", url = Url.Content("~/InventoryManagement/List").AddMenuParameter() }); } /// /// 库存明细 /// /// /// [HttpGet] public ActionResult InventoryDetail(string teachingMaterialPoolID) { if (!string.IsNullOrEmpty(teachingMaterialPoolID)) ViewData["teachingMaterialPoolID"] = teachingMaterialPoolID; return View(); } [HttpPost] public ActionResult InventoryDetail(Guid? teachingMaterialPoolID) { return base.Json(InventoryServices.GetTeachingMateriaInventoryViewGrid(teachingMaterialPoolID)); } /// /// 入库明细 /// /// /// /// [HttpGet] public ActionResult StockInDetail(string teachingMaterialPoolID, string schoolyearID, string discountPrice) { if (!string.IsNullOrEmpty(teachingMaterialPoolID)) ViewBag.teachingMaterialPoolID = teachingMaterialPoolID; if (!string.IsNullOrEmpty(schoolyearID)) ViewBag.schoolyearID = schoolyearID; if (!string.IsNullOrEmpty(discountPrice)) ViewBag.discountPrice = discountPrice; return View(); } [HttpPost] public ActionResult StockInDetail(QueryParamsModel pararms) { Guid? teachingMaterialPoolID = Request.Params["teachingMaterialPoolID"].ParseStrTo(); Guid? schoolyearID = Request.Params["schoolyearID"].ParseStrTo(); decimal? discountPrice = Request.Params["discountPrice"].ParseStrTo(); var SchoolYearEntity = SchoolYearServices.GetSchoolYear(schoolyearID); return base.Json(InventoryServices.GetStockInDetailByValueViewGrid(teachingMaterialPoolID, schoolyearID, discountPrice, (int)pararms.page, (int)pararms.rows)); } /// /// 出库明细 /// /// /// /// [HttpGet] public ActionResult StockOutDetail(string teachingMaterialPoolID, string schoolyearID, string discountPrice) { if (!string.IsNullOrEmpty(teachingMaterialPoolID)) ViewBag.teachingMaterialPoolID = teachingMaterialPoolID; if (!string.IsNullOrEmpty(schoolyearID)) ViewBag.schoolyearID = schoolyearID; if (!string.IsNullOrEmpty(discountPrice)) ViewBag.discountPrice = discountPrice; return View(); } [HttpPost] public ActionResult StockOutDetail(QueryParamsModel pararms) { Guid? teachingMaterialPoolID = Request.Params["teachingMaterialPoolID"].ParseStrTo(); Guid? schoolyearID = Request.Params["schoolyearID"].ParseStrTo(); decimal? discountPrice = Request.Params["discountPrice"].ParseStrTo(); var SchoolYearEntity = SchoolYearServices.GetSchoolYear(schoolyearID); return base.Json(InventoryServices.GetStockOutDetailByValueViewGrid(teachingMaterialPoolID, SchoolYearEntity.Value, schoolyearID, discountPrice, (int)pararms.page, (int)pararms.rows)); } } }