Beispiel #1
0
        public FileResult ExportExcel(客戶資料ViewModel 客戶資料)
        {
            List <string> show_col = new List <string> {
                "客戶名稱", "統一編號", "電話", "傳真", "地址", "Email", "客戶分類"
            };

            return(Excel.exportExcel(repo.GetFilterItem(客戶資料.搜尋客戶名稱, 客戶資料.篩選分類, 客戶資料.sort_col, 客戶資料.isSort),
                                     "客戶資料", show_col, new List <string>()));
        }
Beispiel #2
0
        public ActionResult Index(客戶資料ViewModel 客戶資料)
        {
            var client = repo.All();

            if (!string.IsNullOrEmpty(客戶資料.搜尋客戶名稱))
            {
                client = repo.FindName(客戶資料.搜尋客戶名稱, client);
            }
            if (!string.IsNullOrEmpty(客戶資料.篩選分類))
            {
                client = repo.GetCategory(客戶資料.篩選分類, client);
            }
            if (!string.IsNullOrEmpty(客戶資料.sort_col))
            {
                bool sort = 客戶資料.isSort;
                if (sort == false)
                {
                    client = client.OrderByField(客戶資料.sort_col, true);
                }
                else
                {
                    client = client.OrderByField(客戶資料.sort_col, false);
                }
                if (ViewBag.isSort != sort)
                {
                    ViewBag.isSort = sort;
                }
            }
            else
            {
                client         = client.OrderBy(c => c.Id);
                ViewBag.isSort = true;
            }

            var orderClient = client.ToPagedList(客戶資料.page == 0 ? 1 : 客戶資料.page, pageSize);

            ViewBag.currentPage  = 客戶資料.page == 0 ? 1 : 客戶資料.page;
            ViewBag.搜尋客戶名稱       = 客戶資料.搜尋客戶名稱;
            ViewBag.篩選分類         = 客戶資料.篩選分類;
            ViewBag.CategoryList = GetCategorySelect();
            ViewBag.sort_col     = 客戶資料.sort_col;
            return(View(orderClient));
        }