Exemplo n.º 1
0
        /// <summary>
        /// (分页查询)从数据库中获取用户列表
        /// </summary>
        /// <param name="queryModel">查询条件</param>
        /// <returns>返回用户列表</returns>
        public DataTable GetUsersList(Entity.System.view.QueryModelUser queryModel)
        {
            try
            {
                var userName   = queryModel.userName ?? "";
                var pageNumber = queryModel.offset / queryModel.limit + 1;
                var pageSize   = queryModel.limit;

                var strSql = new StringBuilder();
                strSql.Append("select t.*,COUNT(*) OVER () RESULT_COUNT from userinfo t where t.f_name like '%'||:userName||'%'");

                OracleParameter[] parameters =
                {
                    new OracleParameter(":userName", userName)
                };
                var dbapi = new DbAPI();
                dbapi.OpenConn("");
                var rst = dbapi.GetDataTable(DbAPI.GeneratePagingSql(strSql.ToString(), pageNumber, pageSize), parameters);
                dbapi.CloseConn();
                return(rst);
            }
            catch (Exception ex)
            {
                LogBN.WriteLog(typeof(USERINFO_BN), "(分页查询)从数据库中获取用户列表GetUsersList 程序段的异常" + ex);
                return(null);
            }
        }
        public Entity.MonitorLog.BootstrapTableDataModel GetUserList([FromUri] Entity.System.view.QueryModelUser queryModel)
        {
            var bn   = new USERINFO_BN();
            var rows = bn.GetUsersList(queryModel);
            var rst  = new Entity.MonitorLog.BootstrapTableDataModel
            {
                rows  = rows,
                total = rows.Rows.Count > 0 ? Convert.ToInt32(rows.Rows[0]["RESULT_COUNT"]) : 0
            };

            return(rst);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 导出用户列表到Excel
        /// </summary>
        /// <param name="queryModel">查询参数</param>
        public DataTable GetExcelListUsers(Entity.System.view.QueryModelUser queryModel)
        {
            try
            {
                var userName = string.IsNullOrWhiteSpace(queryModel.userName) ? "" : queryModel.userName;
                var strSql   = "SELECT f_name \"用户名\", f_realname \"真实姓名\", f_email \"邮箱\", f_phone \"固话\", f_tel \"手机\", f_description \"说明\", f_address \"住址\" FROM userinfo where f_name like '%' || :userName || '%'";

                OracleParameter[] parameters =
                {
                    new OracleParameter(":userName", userName)
                };
                var dbapi = new DbAPI();
                dbapi.OpenConn("");
                var rst = dbapi.GetDataTable(strSql, parameters);
                dbapi.CloseConn();
                return(rst);
            }
            catch (Exception ex)
            {
                LogBN.WriteLog(typeof(MonitorLog), "导出用户列表到Excel方法GetExcelList 程序段的异常" + ex);
                return(null);
            }
        }