public ActionResult Index(Users Users, EFPagingInfo<Users> p, bool? IsShowSupAgent, int IsFirst = 0) { #region 条件 if (IsShowSupAgent == null) { IsShowSupAgent = false; } if (Users.CardStae.IsNullOrEmpty()) { Users.CardStae = 2; } if (!Users.UserName.IsNullOrEmpty()) { p.SqlWhere.Add(f => f.UserName == Users.UserName); } if (!Users.TrueName.IsNullOrEmpty()) { p.SqlWhere.Add(f => f.TrueName.Contains(Users.TrueName) || f.NeekName.Contains(Users.TrueName)); } if (!Users.Mobile.IsNullOrEmpty()) { p.SqlWhere.Add(f => f.Mobile == Users.Mobile); } if (!Users.State.IsNullOrEmpty()) { p.SqlWhere.Add(f => f.State == (Users.State == 99 ? 0 : Users.State)); } if (!Users.CardNum.IsNullOrEmpty()) { p.SqlWhere.Add(f => f.CardNum == Users.CardNum); } if (!Users.Agent.IsNullOrEmpty()) { //是否要显示下级 if ((bool)IsShowSupAgent) { SysAgent LowerLevelAgent = Entity.SysAgent.Where(s => s.Id == Users.Agent).FirstOrNew(); IList<SysAgent> SysAgentList = LowerLevelAgent.GetSupAgent(Entity, true); IList<int> UID = SysAgentList.Select(o => o.Id).ToList(); p.SqlWhere.Add(f => UID.Contains(f.Agent)); } else { p.SqlWhere.Add(f => f.Agent == Users.Agent); } } if (!Users.CardId.IsNullOrEmpty()) { p.SqlWhere.Add(f => f.CardId == Users.CardId); } if (!Users.MyPId.IsNullOrEmpty()) { p.SqlWhere.Add(f => f.MyPId == Users.MyPId && f.ShareType == 1); } if (!Users.RegAddress.IsNullOrEmpty()) { p.SqlWhere.Add(f => f.RegAddress.Contains(Users.RegAddress)); } if (!Users.CardStae.IsNullOrEmpty()) { int CardStae = Users.CardStae; if (CardStae == 99) { CardStae = 0; } if (CardStae != 88) { p.SqlWhere.Add(f => f.CardStae == CardStae); } } if (!Users.HasT0.IsNullOrEmpty()) { int HasT0 = Users.HasT0; if (HasT0 == 2) { HasT0 = 0; } p.SqlWhere.Add(f => f.HasT0 == HasT0); } #endregion p.OrderByList.Add("Id", "DESC"); IPageOfItems<Users> UsersList = null; if (IsFirst == 0) { UsersList = new PageOfItems<Users>(new List<Users>(), 0, 10, 0, new Hashtable()); } else { UsersList = Entity.Selects<Users>(p); } ViewBag.UsersList = UsersList; ViewBag.Users = Users; ViewBag.SysAgentList = Entity.SysAgent.Where(n => n.State==1).ToList(); //显示上级名字 var ulids = UsersList.Select(o => o.Id).Distinct().ToArray(); ViewBag.PName = Entity.Users.Select(o => new { o.Id, o.TrueName }).ToDictionary(o => o.Id, o => o.TrueName); ViewBag.IsShowSupAgent = IsShowSupAgent;//是否显示下级 ViewBag.Edit = this.checkPower("Edit"); ViewBag.DeductMoney = this.checkPower("DeductMoney"); ViewBag.MyUsers = this.checkPower("MyUsers"); ViewBag.Save = this.checkPower("Save"); ViewBag.ClearPId = this.checkPower("ClearPId"); ViewBag.StopPay = this.checkPower("StopPay"); ViewBag.StopPaySave = this.checkPower("StopPaySave"); ViewBag.UnFrozenList = this.checkPower("UnFrozenList"); ViewBag.UnFrozenAudit = this.checkPower("UnFrozenAudit"); ViewBag.Clear = this.checkPower("Clear"); ViewBag.ClearRZ = this.checkPower("ClearRZ"); ViewBag.UserTrail = this.checkPower("UserTrail", "Index"); ViewBag.UserMaillist = this.checkPower("UserMaillist", "Index"); ViewBag.UserIdCard = this.checkPower("UserIdCard", "Index"); ViewBag.UserIdLog = this.checkPower("UserIdCard", "Log"); ViewBag.UserLog = this.checkPower("UserLog", "Index"); ViewBag.ChangeT0BlackList = this.checkPower("Users", "ChangeT0BlackList"); ViewBag.ExcelInport = this.checkPower("ExcelInport"); ViewBag.Download = this.checkPower("Download"); return View(); }