Ejemplo n.º 1
0
        public ActionResult GetCustomerList()
        {
            int    pageIndex = WebUtil.GetFormValue <int>("pageIndex", 1);
            int    pageSize  = WebUtil.GetFormValue <int>("pageSize", 15);
            string CusNum    = WebUtil.GetFormValue <string>("CusNum", string.Empty);
            int    CusType   = WebUtil.GetFormValue <int>("CusType", 0);

            CustomerProvider provider = new CustomerProvider();
            CustomerEntity   entity   = new CustomerEntity();
            PageInfo         pageInfo = new PageInfo()
            {
                PageIndex = pageIndex, PageSize = pageSize
            };

            if (!CusNum.IsEmpty())
            {
                entity.Begin <CustomerEntity>()
                .Where <CustomerEntity>("CusNum", ECondition.Like, "%" + CusNum + "%")
                .Or <CustomerEntity>("CusName", ECondition.Like, "%" + CusNum + "%")
                .End <CustomerEntity>();
            }
            if (CusType != 0)
            {
                entity.Where <CustomerEntity>(a => a.CusType == CusType);
            }

            List <CustomerEntity> listResult = provider.GetCustomerList(entity, ref pageInfo);
            string json = ConvertJson.ListToJson <CustomerEntity>(listResult, "List");

            this.ReturnJson.AddProperty("Data", new JsonObject(json));
            this.ReturnJson.AddProperty("RowCount", pageInfo.RowCount);
            return(Content(this.ReturnJson.ToString()));
        }