Ejemplo n.º 1
0
        public ActionResult Index()
        {
            var pageCurrent = RequestHelper.GetFormInt("pageCurrent", 1);
            var pageSize    = RequestHelper.GetFormInt("pageSize", 30);
            var total       = 0;

            var where = new Where <Manager>();
            //获取排序字段
            var orderField = RequestHelper.GetFormString("orderField");
            Expression <Func <Manager, object> > orderEx;

            switch (orderField)
            {
            case "Id":
                orderEx = p => p.Id;
                break;

            case "Username":
                orderEx = p => p.Username;
                break;

            case "Password":
                orderEx = p => p.Password;
                break;

            case "Nickname":
                orderEx = p => p.Nickname;
                break;

            case "Description":
                orderEx = p => p.Description;
                break;

            case "IsSystem":
                orderEx = p => p.IsSystem;
                break;

            case "RoleId":
                orderEx = p => p.RoleId;
                break;

            case "AddTime":
                orderEx = p => p.AddTime;
                break;

            case "LastLoginTime":
                orderEx = p => p.LastLoginTime;
                break;

            case "IsLock":
                orderEx = p => p.IsLock;
                break;

            default:
                orderEx = p => p.Id;
                break;
            }
            //设置方式
            var orderDirection = RequestHelper.GetFormString("orderDirection");

            EnumHelper.OrderBy orderby = EnumHelper.OrderBy.Asc;
            if (orderDirection == "desc")
            {
                orderby = EnumHelper.OrderBy.Desc;
            }
            //查询筛选
            var Id = RequestHelper.GetFormInt("Id", 0);

            if (Id > 0)
            {
                where.And(p => p.Id == Id);
            }
            ViewBag.Id = Id;

            var Username = RequestHelper.GetFormString("Username");

            if (!string.IsNullOrEmpty(Username))
            {
                where.And(p => p.Username == Username);
            }
            ViewBag.Username = Username;

            var Password = RequestHelper.GetFormString("Password");

            if (!string.IsNullOrEmpty(Password))
            {
                where.And(p => p.Password == Password);
            }
            ViewBag.Password = Password;

            var Nickname = RequestHelper.GetFormString("Nickname");

            if (!string.IsNullOrEmpty(Nickname))
            {
                where.And(p => p.Nickname == Nickname);
            }
            ViewBag.Nickname = Nickname;

            var Description = RequestHelper.GetFormString("Description");

            if (!string.IsNullOrEmpty(Description))
            {
                where.And(p => p.Description == Description);
            }
            ViewBag.Description = Description;

            var IsSystem = RequestHelper.GetFormString("IsSystem");

            if (!string.IsNullOrEmpty(IsSystem) && IsSystem == "true")
            {
                where.And(p => p.IsSystem == true);
            }
            else if (!string.IsNullOrEmpty(IsSystem) && IsSystem == "false")
            {
                where.And(p => p.IsSystem == false);
            }
            ViewBag.IsSystem = IsSystem;

            var RoleId = RequestHelper.GetFormInt("RoleId", 0);

            if (RoleId > 0)
            {
                where.And(p => p.RoleId == RoleId);
            }
            ViewBag.RoleId = RoleId;

            var AddTime = RequestHelper.GetFormString("AddTime");

            if (!string.IsNullOrEmpty(AddTime))
            {
                var dtAddTime = ToolsHelper.StrToDateTime(AddTime);
                where.And(p => p.AddTime > dtAddTime);
            }
            ViewBag.AddTime = AddTime;

            var LastLoginTime = RequestHelper.GetFormString("LastLoginTime");

            if (!string.IsNullOrEmpty(LastLoginTime))
            {
                var dtLastLoginTime = ToolsHelper.StrToDateTime(LastLoginTime);
                where.And(p => p.AddTime > dtLastLoginTime);
            }
            ViewBag.LastLoginTime = LastLoginTime;

            var IsLock = RequestHelper.GetFormString("IsLock");

            if (!string.IsNullOrEmpty(IsLock) && IsLock == "true")
            {
                where.And(p => p.IsLock == true);
            }
            else if (!string.IsNullOrEmpty(IsLock) && IsLock == "false")
            {
                where.And(p => p.IsLock == false);
            }
            ViewBag.IsLock = IsLock;


            //获取数据
            var list = _bll.QueryPageList(pageCurrent, pageSize, out total, where, orderEx, orderby);

            //缓存数据
            ViewBag.pageCurrent = pageCurrent;
            ViewBag.pageSize    = pageSize;
            ViewBag.total       = total;

            ViewBag.orderDirection = orderDirection;
            ViewBag.orderField     = orderField;

            ViewBag.ManagerRoleList = new Dal.ManagerRole().FindList();

            return(View(list));
        }
Ejemplo n.º 2
0
        public ActionResult Index()
        {
            var pageCurrent = RequestHelper.GetFormInt("pageCurrent", 1);
            var pageSize    = RequestHelper.GetFormInt("pageSize", 30);
            int total;

            var where = new Where <ManagerRole>();
            //获取排序字段
            var orderField = RequestHelper.GetFormString("orderField");
            Expression <Func <ManagerRole, object> > orderEx;

            switch (orderField)
            {
            case "Id":
                orderEx = p => p.Id;
                break;

            case "RoleName":
                orderEx = p => p.RoleName;
                break;

            case "IsSystem":
                orderEx = p => p.IsSystem;
                break;

            case "SortId":
                orderEx = p => p.SortId;
                break;

            case "DepartmentID":
                orderEx = p => p.DepartmentID;
                break;

            default:
                orderEx = p => p.Id;
                break;
            }
            //设置方式
            var orderDirection = RequestHelper.GetFormString("orderDirection");

            EnumHelper.OrderBy orderby = EnumHelper.OrderBy.Asc;
            if (orderDirection == "desc")
            {
                orderby = EnumHelper.OrderBy.Desc;
            }
            //查询筛选

            var Id = RequestHelper.GetFormInt("Id", 0);

            if (Id > 0)
            {
                where.And(p => p.Id == Id);
            }
            ViewBag.Id = Id;

            var RoleName = RequestHelper.GetFormString("RoleName");

            if (!string.IsNullOrEmpty(RoleName))
            {
                where.And(p => p.RoleName == RoleName);
            }
            ViewBag.RoleName = RoleName;

            var IsSystem = RequestHelper.GetFormString("IsSystem");

            if (!string.IsNullOrEmpty(IsSystem) && IsSystem == "true")
            {
                where.And(p => p.IsSystem == true);
            }
            else if (!string.IsNullOrEmpty(IsSystem) && IsSystem == "false")
            {
                where.And(p => p.IsSystem == false);
            }
            ViewBag.IsSystem = IsSystem;

            var SortId = RequestHelper.GetFormInt("SortId", 0);

            if (SortId > 0)
            {
                where.And(p => p.SortId == SortId);
            }
            ViewBag.SortId = SortId;

            var DepartmentID = RequestHelper.GetFormInt("DepartmentID", 0);

            if (DepartmentID > 0)
            {
                where.And(p => p.DepartmentID == DepartmentID);
            }
            ViewBag.DepartmentID = DepartmentID;

            //获取数据
            var list = _bll.QueryPageList(pageCurrent, pageSize, out total, where, orderEx, orderby);

            //缓存数据
            ViewBag.pageCurrent = pageCurrent;
            ViewBag.pageSize    = pageSize;
            ViewBag.total       = total;

            ViewBag.orderDirection = orderDirection;
            ViewBag.orderField     = orderField;

            return(View(list));
        }
Ejemplo n.º 3
0
        public ActionResult Index()
        {
            var pageCurrent = RequestHelper.GetFormInt("pageCurrent", 1);
            var pageSize    = RequestHelper.GetFormInt("pageSize", 30);
            int total;

            var where = new Where <ManagerLog>();
            //获取排序字段
            var orderField = RequestHelper.GetFormString("orderField");
            Expression <Func <ManagerLog, object> > orderEx;

            switch (orderField)
            {
            case "Id":
                orderEx = p => p.Id;
                break;

            case "UserId":
                orderEx = p => p.UserId;
                break;

            case "UserName":
                orderEx = p => p.UserName;
                break;

            case "ActionType":
                orderEx = p => p.ActionType;
                break;

            case "Remark":
                orderEx = p => p.Remark;
                break;

            case "UserIp":
                orderEx = p => p.UserIp;
                break;

            case "AddTime":
                orderEx = p => p.AddTime;
                break;

            case "ControllerName":
                orderEx = p => p.ControllerName;
                break;

            case "ActionName":
                orderEx = p => p.ActionName;
                break;

            default:
                orderEx = p => p.Id;
                break;
            }
            //设置方式
            var orderDirection = RequestHelper.GetFormString("orderDirection");

            EnumHelper.OrderBy orderby = EnumHelper.OrderBy.Asc;
            if (orderDirection == "desc")
            {
                orderby = EnumHelper.OrderBy.Desc;
            }
            //查询筛选

            var Id = RequestHelper.GetFormInt("Id", 0);

            if (Id > 0)
            {
                where.And(p => p.Id == Id);
            }
            ViewBag.Id = Id;

            var UserId = RequestHelper.GetFormInt("UserId", 0);

            if (UserId > 0)
            {
                where.And(p => p.UserId == UserId);
            }
            ViewBag.UserId = UserId;

            var UserName = RequestHelper.GetFormString("UserName");

            if (!string.IsNullOrEmpty(UserName))
            {
                where.And(p => p.UserName == UserName);
            }
            ViewBag.UserName = UserName;

            var ActionType = RequestHelper.GetFormString("ActionType");

            if (!string.IsNullOrEmpty(ActionType))
            {
                where.And(p => p.ActionType == ActionType);
            }
            ViewBag.ActionType = ActionType;

            var Remark = RequestHelper.GetFormString("Remark");

            if (!string.IsNullOrEmpty(Remark))
            {
                where.And(p => p.Remark == Remark);
            }
            ViewBag.Remark = Remark;

            var UserIp = RequestHelper.GetFormString("UserIp");

            if (!string.IsNullOrEmpty(UserIp))
            {
                where.And(p => p.UserIp == UserIp);
            }
            ViewBag.UserIp = UserIp;

            var AddTime = RequestHelper.GetFormString("AddTime");

            if (!string.IsNullOrEmpty(AddTime))
            {
                var dtAddTime = ToolsHelper.StrToDateTime(AddTime);
                where.And(p => p.AddTime > dtAddTime);
            }
            ViewBag.AddTime = AddTime;

            var ControllerName = RequestHelper.GetFormString("ControllerName");

            if (!string.IsNullOrEmpty(ControllerName))
            {
                where.And(p => p.ControllerName == ControllerName);
            }
            ViewBag.ControllerName = ControllerName;

            var ActionName = RequestHelper.GetFormString("ActionName");

            if (!string.IsNullOrEmpty(ActionName))
            {
                where.And(p => p.ActionName == ActionName);
            }
            ViewBag.ActionName = ActionName;

            //获取数据
            var list = _bll.QueryPageList(pageCurrent, pageSize, out total, where, orderEx, orderby);

            //缓存数据
            ViewBag.pageCurrent = pageCurrent;
            ViewBag.pageSize    = pageSize;
            ViewBag.total       = total;

            ViewBag.orderDirection = orderDirection;
            ViewBag.orderField     = orderField;

            return(View(list));
        }
Ejemplo n.º 4
0
 public List <T> QueryPageList(int pageIndex, int pageSize, out int totalRecord, Where <T> where, Expression <Func <T, object> > orderBy, EnumHelper.OrderBy ascDesc)
 {
     totalRecord = Db.From <T>().Where(where).Count();
     if (ascDesc == EnumHelper.OrderBy.Desc)
     {
         return(Db.From <T>().Where(where).OrderByDescending(orderBy).Page(pageSize, pageIndex).ToList());
     }
     return(Db.From <T>().Where(where).OrderBy(orderBy).Page(pageSize, pageIndex).ToList());
 }
Ejemplo n.º 5
0
 /// <summary>
 ///     通用查询
 /// </summary>
 /// <returns></returns>
 public List <T> QueryToList(Expression <Func <T, bool> > where, Expression <Func <T, object> > orderBy, EnumHelper.OrderBy ascDesc)
 {
     if (ascDesc == EnumHelper.OrderBy.Desc)
     {
         return(Db.From <T>().Where(where).OrderByDescending(orderBy).ToList());
     }
     return(QueryToList(where, orderBy));
 }
Ejemplo n.º 6
0
 public List <T> QueryToList(Expression <Func <T, bool> > ep, int topNum, Expression <Func <T, object> > orderBy, EnumHelper.OrderBy ascDesc)
 {
     if (ascDesc == EnumHelper.OrderBy.Desc)
     {
         return(Db.From <T>().Where(ep).Top(topNum).OrderByDescending(orderBy).ToList());
     }
     return(Db.From <T>().Where(ep).Top(topNum).OrderBy(orderBy).ToList());
 }