public object LoadModel(int? page) { // 说明:参数page表示分页数,方法名LoadModel其实可以【随便取】。 // 根据用户选择的界面风格,计算实现要呈现的页面路径。 string papeUrl = this.GetTargetPageUrl("Customers.aspx"); if( this.IsStyle2 ) // Style2 风格下,页面不需要绑定数据。数据由JS通过AJAX方式获取 return new PageResult(papeUrl, null); // 为Style1 风格获取数据。 CustomerSearchInfo info = new CustomerSearchInfo(); info.SearchWord = string.Empty; info.PageIndex = page.HasValue ? page.Value - 1 : 0; info.PageSize = AppHelper.DefaultPageSize; CustomersPageModel result = new CustomersPageModel(); result.PagingInfo = info; result.List = BllFactory.GetCustomerBLL().GetList(info); result.RequestUrlEncodeRawUrl = HttpUtility.UrlEncode(this.HttpContext.Request.RawUrl); return new PageResult(papeUrl, result); }
public object List(CustomerSearchInfo pagingInfo) { pagingInfo.CheckPagingInfoState(); List<Customer> List = BllFactory.GetCustomerBLL().GetList(pagingInfo); var result = new GridResult<Customer>(List, pagingInfo.TotalRecords); return new JsonResult(result); }
// 根据指定的查询关键词及分页参数,获取客户列表. public List<Customer> GetList(CustomerSearchInfo info) { var query = from customer in WebSiteDB.MyNorthwind.Customers.AsQueryable() select customer; if( string.IsNullOrEmpty(info.SearchWord) == false ) query = query.Where( c => c.CustomerName.Contains(info.SearchWord) || c.Address.Contains(info.SearchWord)); return query.OrderBy(x => x.CustomerName).GetPagingList<Customer>(info); }
public object ShowCustomerPicker(string searchWord, int? page) { CustomerSearchInfo info = new CustomerSearchInfo(); info.SearchWord = searchWord ?? string.Empty; info.PageIndex = page.HasValue ? page.Value - 1 : 0; info.PageSize = AppHelper.DefaultPageSize; CustomerPickerModel data = new CustomerPickerModel(); data.SearchInfo = info; data.List = BllFactory.GetCustomerBLL().GetList(info); return new PageResult("/Pages/Style1/Controls/CustomerPicker.cshtml", data); }
// 根据指定的查询关键词及分页参数,获取客户列表. public List<Customer> GetList(CustomerSearchInfo info) { return DbHelper.FillListPaged<Customer>("GetCustomerList", info); }