Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 3
0
        public object Show(int id)
        {
            Customer customer = BllFactory.GetCustomerBLL().GetById(id);

            if (customer == null)
            {
                throw new MyMessageException("指定的ID值无效。不能找到对应的记录。");
            }

            return(new PageResult("/Pages/Style1/Controls/CustomerInfo.cshtml", customer));
        }
Ejemplo n.º 4
0
        public object GetById(int id)
        {
            Customer customer = BllFactory.GetCustomerBLL().GetById(id);

            if (customer == null)
            {
                throw new MyMessageException("指定的ID值无效。不能找到对应的记录。");
            }

            return(new JsonResult(customer));
        }
Ejemplo n.º 5
0
        public object Delete(int id, string returnUrl)
        {
            BllFactory.GetCustomerBLL().Delete(id);

            if (string.IsNullOrEmpty(returnUrl))
            {
                return(null);
            }
            else
            {
                return(new RedirectResult(returnUrl));
            }
        }
Ejemplo n.º 6
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));
        }
Ejemplo n.º 7
0
        public void Update(Customer customer)
        {
            customer.EnsureItemIsOK();

            BllFactory.GetCustomerBLL().Update(customer);
        }
Ejemplo n.º 8
0
        public void Insert(Customer customer)
        {
            customer.EnsureItemIsOK();

            BllFactory.GetCustomerBLL().Insert(customer);
        }