public ActionResult List(string DockDoorID = "", int PageIndex = 1, int PageSize = 10) { try { //初始化物件 var m = new DockDoorListViewModel(); m.Authority = Tool.GetPageAuthority(); m.Parameters = new Models.ViewModel.DockDoor.QueryParameter(); m.Pages = new Pages(); //設定參數 m.Parameters.DockDoorID = DockDoorID; m.Pages.PageIndex = PageIndex; m.Pages.PageSize = PageSize; //清單資料 var dt = DockDoorDataAccess.GetDockDoorList(DockDoorID, null, null, null, m.Pages); m.List = Util.ToList <ListItem>(dt); return(View(m)); } catch { return(RedirectToAction("Error", "Home")); } }
public ActionResult Export(DockDoorListViewModel m) { //分頁物件,設定單頁筆數為最大值 Pages pages = new Pages(); pages.PageSize = int.MaxValue; //取回資料 DataTable dt = DockDoorDataAccess.GetDockDoorList(null, m.Parameters.DockDoorID, null, null, pages); //轉為二進位資料流 var numList = new List <int>(); MemoryStream ms = NPOITools.RenderDataTableToExcel(dt, numList) as MemoryStream; return(File(ms.ToArray(), "application/vnd.ms-excel")); }