123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- 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;
- namespace EMIS.Web.Controllers.TeachingMaterial
- {
- [Authorization]
- public class TeachingMateriaInventoryController : Controller
- {
- //库存管理->教材库存
- public IStockOutServices StockOutServices { get; set; }
- public ISerialNumberServices SerialNumberServices { get; set; }//编号生成
- public IStockInDetailServices StockInDetailServices { get; set; }
- public IStockInServices StockInServices { get; set; }
- public IInventoryServices InventoryServices { get; set; }
- public ITeachingMaterialPoolServices TeachingMaterialPoolServices { get; set; }
- [HttpGet]
- public ActionResult List()
- {
- return View();
- }
- [HttpPost]
- public ActionResult List(QueryParamsModel pararms)
- {
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
- bool? isLate = null;
- if (pararms.getExtraInt("LateDropdown") != null && pararms.getExtraInt("LateDropdown") != DropdownList.SELECT_ALL)
- {
- isLate = pararms.getExtraInt("LateDropdown") == 1 ? true : false; ;
- }
- Guid? publishID = pararms.getExtraGuid("PublishDropdown");//书库ID
- Guid? teachingMaterialDropdownID = pararms.getExtraGuid("TeachingMaterialDropdown");//教材ID
- int? teachingMaterialType = pararms.getExtraInt("TeachingMaterialTypeDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("TeachingMaterialTypeDropdown");
- return base.Json(InventoryServices.GetTeachingMateriaInventoryViewGrid(configuretView, null, teachingMaterialDropdownID, publishID, isLate, teachingMaterialType, (int)pararms.page, (int)pararms.rows));
- }
- #region 2.0 页面数据编辑
- [HttpGet]
- public ActionResult Edit(Guid? teachingMaterialPoolID)
- {
- TeachingMaterialPoolView TeachingMaterialPoolView;
- if (teachingMaterialPoolID != null && teachingMaterialPoolID != Guid.Empty)
- {
- TeachingMaterialPoolView = TeachingMaterialPoolServices.GetSingleTeachingMaterialPool(teachingMaterialPoolID.Value);
- }
- else
- {
- TeachingMaterialPoolView = new TeachingMaterialPoolView()
- {
- TeachingMaterialPoolID = Guid.Empty,
- IsLate = false
- };
- }
- return View(TeachingMaterialPoolView);
- }
- [HttpPost]
- public ActionResult Edit(TeachingMaterialPoolView TeachingMaterialPoolView)
- {
- try
- {
- var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
- TeachingMaterialPoolServices.EditTeachingMateriaInventory(TeachingMaterialPoolView, user.UserID);
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "保存成功!"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "保存失败,原因:" + ex.Message + "!"
- });
- }
- }
- #endregion
- #region 3.0 页面数据Excel导出
- /// <summary>
- /// Excel 导出
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Excel()
- {
- NpoiExcelHelper neh = new NpoiExcelHelper();
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
- bool? isLate = null;
- if (Request.Form["LateDropdown"].ParseStrTo<int>() != null && Request.Form["LateDropdown"].ParseStrTo<int>() != DropdownList.SELECT_ALL)
- {
- isLate = Request.Form["LateDropdown"].ParseStrTo<int>() == 1 ? true : false;
- }
- Guid? teachingMaterialDropdownID = Request.Form["TeachingMaterialDropdown"].ParseStrTo<Guid>();
- Guid? publishID = Request.Form["PublishDropdown"].ParseStrTo<Guid>();
- int? teachingMaterialType = Request.Form["TeachingMaterialTypeDropdown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["TeachingMaterialTypeDropdown"].ParseStrTo<int>();
- var dt = InventoryServices.GetTeachingMateriaInventoryViewList(configuretView, teachingMaterialDropdownID, teachingMaterialDropdownID, publishID, isLate, teachingMaterialType).Select(x => new
- {
- x.TeachingMaterialCode,
- x.TeachingMaterialName,
- x.CoursematerialCode,
- x.CoursematerialName,
- x.ISBN,
- x.PublishTime,
- x.PublishName,
- x.Author,
- x.MinInventory,
- x.PresentInventory,
- x.Price,
- x.Total,
- x.IsLateName,
- x.ModifyTime
- }).ToTable();
- string[] liststring = { "教材编号", "教材名称", "课程代码", "课程名称", "ISBN", "版本时间", "出版单位", "作者", "最小库存量", "当前库存量", "单价", "码洋", "是否过期", "最近响应时间" };
- neh.Export(dt, liststring, "教材库存信息");
- return RedirectToAction("MsgShow", "Common", new
- {
- msg = "导出成功!",
- url = Url.Content("~/TeachingMateriaInventory/List").AddMenuParameter()
- });
- }
- #endregion
- }
- }
|