예제 #1
0
        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
        {
            var strSql = new StringBuilder();

            strSql.Append("SELECT * FROM ( ");
            strSql.Append(" SELECT ROW_NUMBER() OVER (");
            if (!string.IsNullOrEmpty(orderby.Trim()))
            {
                strSql.Append("order by T." + orderby);
            }
            else
            {
                strSql.Append("order by T.Id desc");
            }
            strSql.Append(")AS Row, T.*  from T_ESHour T ");
            if (!string.IsNullOrEmpty(strWhere.Trim()))
            {
                strSql.Append(" WHERE " + strWhere);
            }
            strSql.Append(" ) TT");
            strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
            return(DbHelperSql.Query(strSql.ToString()));
        }
예제 #2
0
        /// <summary>
        /// 获取用户名、用户名称集合
        /// </summary>
        /// <param name="strWhere"></param>
        /// <returns></returns>
        public List <string> GetUsesList(string strWhere)
        {
            var list   = new List <string>();
            var strSql = new StringBuilder();

            strSql.Append("select UserId,UserName FROM T_Users");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }

            var ds = DbHelperSql.Query(strSql.ToString());

            if (ds != null)
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    list.Add(dr["UserId"] + "," + dr["UserName"]);
                }
            }

            return(list);
        }