コード例 #1
0
        public JsonResult SearchList()
        {
            #region 权限控制
            int[] iRangePage         = { ListPageNodeId };
            int   iCurrentPageNodeId = RequestParameters.Pint("NodeId");
            var   tempAuth           = Utits.IsNodePageAuth(iRangePage, iCurrentPageNodeId);
            if (tempAuth.ErrorType != 1)
            {
                return(Json(tempAuth));
            }
            #endregion

            //当前页
            int iCurrentPage = RequestParameters.Pint("currentPage");
            iCurrentPage = iCurrentPage <= 0 ? 1 : iCurrentPage;
            //索引页
            int iPageIndex = iCurrentPage - 1;
            //一页的数量
            int iPageSize = RequestParameters.Pint("pageSize");
            iPageSize = iPageSize <= 0 ? 5 : iPageSize;
            iPageSize = iPageSize > 100 ? 100 : iPageSize;
            //总记录数量
            int iTotalRecord = 0;

            #region 查询条件
            var searchCondition = new ConditionModel();

            var WhereList = new List <WhereCondition>();

            int[] Stage = { (int)ECustomerType.Rzspb, (int)ECustomerType.RuYuan };
            for (int i = 0; i < Stage.Length; i++)
            {
                var whereCondition = new WhereCondition();
                whereCondition.FieldName     = "Stage";
                whereCondition.FieldValue    = Stage[i];
                whereCondition.Relation      = "OR";
                whereCondition.FieldOperator = EnumOper.Equal;
                WhereList.Add(whereCondition);
            }
            string CustomerName = RequestParameters.Pstring("CustomerName");
            if (CustomerName.Length > 0)
            {
                var whereCondition = new WhereCondition();
                whereCondition.FieldName     = "CustomerName";
                whereCondition.FieldValue    = CustomerName;
                whereCondition.FieldOperator = EnumOper.Contains;
                WhereList.Add(whereCondition);
            }
            var welfareCentreId = Utits.WelfareCentreID;
            if (welfareCentreId != null)
            {
                var whereCondition = new WhereCondition();
                whereCondition.FieldName     = "WelfareCentreID";
                whereCondition.FieldValue    = welfareCentreId;
                whereCondition.FieldOperator = EnumOper.Equal;
                WhereList.Add(whereCondition);
            }
            Guid userId = RequestParameters.PGuid("userId");
            if (userId != Guid.Empty)
            {
                var whereCondition = new WhereCondition();
                whereCondition.FieldName     = "OperatorUserID";
                whereCondition.FieldValue    = userId;
                whereCondition.FieldOperator = EnumOper.Equal;
                WhereList.Add(whereCondition);
            }
            var CustomerGender = RequestParameters.PintNull("CustomerGender");//性别
            if (CustomerGender != null)
            {
                var whereCondition = new WhereCondition();
                whereCondition.FieldName     = "CustomerGender";
                whereCondition.FieldValue    = CustomerGender;
                whereCondition.FieldOperator = EnumOper.Equal;
                WhereList.Add(whereCondition);
            }
            var CustomerHJDQBySearch = RequestParameters.Pstring("CustomerHJDQBySearch");//
            if (CustomerHJDQBySearch.Length > 0)
            {
                var whereCondition = new WhereCondition();
                whereCondition.FieldName     = "CustomerHJDQ_dic";
                whereCondition.FieldValue    = CustomerHJDQBySearch;
                whereCondition.FieldOperator = EnumOper.Equal;
                WhereList.Add(whereCondition);
            }
            var AgeBySearch = RequestParameters.Pstring("AgeBySearch");
            if (AgeBySearch.Length > 0)
            {
                var ageList = AgeBySearch.Split('-');
                if (ageList.Count() == 2)
                {
                    if (ageList[0] != null)
                    {
                        var whereCondition = new WhereCondition();
                        whereCondition.FieldName     = "CustomerAge";
                        whereCondition.FieldValue    = ageList[0];
                        whereCondition.FieldOperator = EnumOper.GreaterThanEqual;
                        WhereList.Add(whereCondition);
                    }
                    if (ageList[1] != null)
                    {
                        var whereCondition = new WhereCondition();
                        whereCondition.FieldName     = "CustomerAge";
                        whereCondition.FieldValue    = ageList[1];
                        whereCondition.FieldOperator = EnumOper.LessThanEqual;
                        WhereList.Add(whereCondition);
                    }
                }
            }


            int?IsValid = RequestParameters.PintNull("IsValid");
            if (IsValid != null)
            {
                var whereCondition = new WhereCondition();
                whereCondition.FieldName     = "IsValid";
                whereCondition.FieldValue    = IsValid;
                whereCondition.FieldOperator = EnumOper.Equal;
                WhereList.Add(whereCondition);
            }
            string Remark = RequestParameters.Pstring("RemarkBySearch");
            if (Remark.Length > 0)
            {
                var whereCondition = new WhereCondition();
                whereCondition.FieldName     = "Remark";
                whereCondition.FieldValue    = Remark;
                whereCondition.FieldOperator = EnumOper.Contains;
                WhereList.Add(whereCondition);
            }

            Guid CustomerID = RequestParameters.PGuid("CustomerID");
            if (CustomerID != Guid.Empty)
            {
                var whereCondition = new WhereCondition();
                whereCondition.FieldName     = "ID";
                whereCondition.FieldValue    = CustomerID;
                whereCondition.FieldOperator = EnumOper.DoubleEqual;
                WhereList.Add(whereCondition);
            }
            searchCondition.WhereList = WhereList;

            var    OrderList = new List <OrderCondition>();
            string sortfield = RequestParameters.Pstring("sortfield");
            if (sortfield.Length <= 0)
            {
                sortfield = "ID";
            }
            var orderCondition = new OrderCondition();
            orderCondition.FiledOrder = sortfield;
            orderCondition.Ascending  = true;
            OrderList.Add(orderCondition);

            searchCondition.OrderList = OrderList;
            #endregion

            var cBll = new CustomerBll();
            var list = cBll.SearchVByPageCondition(iPageIndex, iPageSize, ref iTotalRecord, searchCondition);
            iPageSize = iPageSize == 0 ? iTotalRecord : iPageSize;
            int pageCount    = iTotalRecord % iPageSize == 0 ? iTotalRecord / iPageSize : iTotalRecord / iPageSize + 1;
            var sReturnModel = new ResultList();
            sReturnModel.ErrorType   = 1;
            sReturnModel.CurrentPage = iCurrentPage;
            sReturnModel.PageSize    = iPageSize;
            sReturnModel.TotalRecord = iTotalRecord;
            sReturnModel.PageCount   = pageCount;
            sReturnModel.Data        = list;
            return(Json(sReturnModel, JsonRequestBehavior.AllowGet));
        }