示例#1
0
        public MySearchUtil ToSearchUtil()
        {
            var util = MySearchUtil.New().AndEqual("IsDel", false).OrderByDesc("Id");

            if (!string.IsNullOrWhiteSpace(Key))
            {
                util.AndContains(new[] { "Name", "Mobile", "Phone", "Email" }, Key.Trim());
            }

            if (Dept <= 0)
            {
                return(util);
            }

            if (!IsStrict)
            {
                var deptIds = DeptUtil.GetSelfAndChildrenIds(Dept);
                util.AndIn("DeptId", deptIds);
            }
            else
            {
                util.AndEqual("DeptId", Dept);
            }

            return(util);
        }
示例#2
0
        public MySearchUtil ToSearchUtil()
        {
            var util = MySearchUtil.New().AndEqual("IsDel", false);

            if (!string.IsNullOrWhiteSpace(Key))
            {
                util.AndContains(new[] { "Name", "Code", "FinancialCode", "Band", "Imei", "Model", "Source", "Remark", "Position", "DeptName", "AccountName" }, Key.Trim());
            }

            if (!string.IsNullOrWhiteSpace(Position))
            {
                util.AndContains("Position", Position.Trim());
            }

            if (!string.IsNullOrWhiteSpace(State))
            {
                util.AndEqual("State", State.Trim());
            }

            if (DeptId.HasValue)
            {
                if (!IsContainSubDept)
                {
                    util.AndEqual("DeptId", (int)DeptId);
                }
                else
                {
                    var depts = DeptUtil.GetSelfAndChildrenIds((int)DeptId);
                    util.AndIn("DeptId", depts);
                }
            }

            if (CateId.HasValue && CateId > 0)
            {
                var cate = AssetCateUtil.Get((int)CateId);
                if (cate == null)
                {
                    util.And("1=2");
                }
                else
                {
                    var ids = AssetCateUtil.GetSelfAndChildrenIds(cate.Id);
                    util.AndIn("AssetCateId", ids);
                }
            }

            if (AccountId.HasValue && AccountId > 0)
            {
                util.AndEqual("AccountId", (int)AccountId);
            }

            if (!IncludeScrap)
            {
                util.AndNotEqual("State", "报废");
            }

            if (!string.IsNullOrWhiteSpace(Healthy))
            {
                util.AndEqual("Healthy", Healthy);
            }

            if (Sort.HasValue)
            {
                switch (Sort)
                {
                case 1:
                    util.OrderBy("Code");
                    break;

                case 2:
                    util.OrderBy("Name");
                    break;

                case 3:
                    util.OrderBy("DeptName");
                    break;

                case 4:
                    util.OrderBy("AccountName");
                    break;

                default:
                    util.OrderByDesc("UpdateAt");
                    break;
                }
            }
            else
            {
                util.OrderByDesc("UpdateAt");
            }

            return(util);
        }