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导出
///
/// Excel 导出
///
///
[HttpPost]
public ActionResult Excel()
{
NpoiExcelHelper neh = new NpoiExcelHelper();
ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
bool? isLate = null;
if (Request.Form["LateDropdown"].ParseStrTo() != null && Request.Form["LateDropdown"].ParseStrTo() != DropdownList.SELECT_ALL)
{
isLate = Request.Form["LateDropdown"].ParseStrTo() == 1 ? true : false;
}
Guid? teachingMaterialDropdownID = Request.Form["TeachingMaterialDropdown"].ParseStrTo();
Guid? publishID = Request.Form["PublishDropdown"].ParseStrTo();
int? teachingMaterialType = Request.Form["TeachingMaterialTypeDropdown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["TeachingMaterialTypeDropdown"].ParseStrTo();
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
}
}