コード例 #1
0
        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));
        }
コード例 #2
0
        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));
        }
コード例 #3
0
        // 根据指定的查询关键词及分页参数,获取客户列表.
        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));
        }
コード例 #4
0
        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));
        }
コード例 #5
0
        public List <Customer> SearchCustomers(CustomerSearchInfo searchinfo)
        {
            _searchResults = null;

            if (searchinfo.SearchTerm != null)
            {
                var genreSearchQuery = "SELECT * " +
                                       $"FROM {DatabaseUtils.Databasename}.customers " +
                                       $"WHERE CUST_Name_First " +
                                       $"LIKE \"%{searchinfo.SearchTerm}%\";";

                var tempSearchResults = SqlGetCustomersBySearch(genreSearchQuery);

                CompareResults(tempSearchResults);
            }

            if (searchinfo.SearchTerm != null)
            {
                var yearSearchQuery = "SELECT * " +
                                      $"FROM {DatabaseUtils.Databasename}.customers " +
                                      $"WHERE CUST_Name_Last " +
                                      $"LIKE \"%{searchinfo.SearchTerm}%\";";

                var tempSearchResults = SqlGetCustomersBySearch(yearSearchQuery);

                CompareResults(tempSearchResults);
            }

            if (searchinfo.PhoneNumber != null && searchinfo.PhoneNumber != "")
            {
                var titleSearchQuery = "SELECT * " +
                                       $"FROM {DatabaseUtils.Databasename}.customers " +
                                       $"WHERE CUST_PhoneNumber " +
                                       $"LIKE \"%{searchinfo.PhoneNumber}%\";";

                var tempSearchResults = SqlGetCustomersBySearch(titleSearchQuery);

                CompareResults(tempSearchResults);
            }
            return(_searchResults);
        }
コード例 #6
0
 // 根据指定的查询关键词及分页参数,获取客户列表.
 public List <Customer> GetList(CustomerSearchInfo info)
 {
     return(DbHelper.FillListPaged <Customer>("GetCustomerList", info));
 }