using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using EMIS.CommonLogic.TerminatePrinter; using EMIS.ViewModel.TerminatePrinter; using EMIS.ViewModel; using EMIS.Web.Controls; using Bowin.Web.Controls.Mvc; namespace EMIS.Web.Controllers.TerminatePrinter { [Authorization] public class PrintControlController : Controller { public IPrintControlServices PrintControlServices { get; set; } public ActionResult List() { return View(); } public ActionResult Edit(Guid? printControlID) { var printControlView = new PrintControlView(); if (printControlID.HasValue) { printControlView = this.PrintControlServices.GetPrintControlView(printControlID.Value); } else { printControlView.Times = 1; } return View(printControlView); } [HttpPost] public ActionResult List(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var yearID = pararms.getExtraInt("ddlYear") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlYear"); return base.Json(PrintControlServices.GetPrintControlViewGrid(configuretView, yearID, pararms.page, pararms.rows)); } [HttpPost] public ActionResult Delete(string printControlIDs) { try { var printControlIDList = printControlIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList(); PrintControlServices.Delete(printControlIDList); return base.Json(new ReturnMessage { IsSuccess = true, Message = "删除成功" }); } catch (Exception ex) { return base.Json(new ReturnMessage { IsSuccess = false, Message = "删除失败,原因:" + ex.Message + "!" }); } } [HttpPost] public ActionResult Edit(PrintControlView printControlView) { try { PrintControlServices.Save(printControlView); return Json(new ReturnMessage() { IsSuccess = true, Message = "保存成功。" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "保存失败:" + ex.Message }); } } } }