Esempio n. 1
0
        /// <summary>
        /// 执行查询返回表
        /// </summary>
        /// <param name="strTableName">表名</param>
        /// <param name="iTopNumber">TOP N</param>
        /// <param name="queryCondition">查询条件</param>
        /// <param name="queryOrder">排序集合</param>
        /// <param name="conn">数据库连接</param>
        /// <param name="tran">数据库操作事务</param>
        /// <returns>结果集</returns>
        private static DataTable ExcuteQuery(String strTableName, int iTopNumber,
                                             QueryConditionDecorator queryCondition, QueryOrderCollection queryOrder, SqlConnection conn, SqlTransaction tran)
        {
            string strSql = "SELECT";

            if (0 != iTopNumber)
            {
                strSql += " TOP " + iTopNumber;
            }
            strSql += " * FROM " + strTableName;

            // 生成条件
            SqlParameter[] paraQuery = null;
            if (null != queryCondition)
            {
                QueryCondition condition = new QueryCondition();
                condition.ConnectTo(queryCondition);

                ArrayList lstSqlParameter = new ArrayList();
                strSql += condition.MakeCondition(lstSqlParameter);

                paraQuery = new SqlParameter[lstSqlParameter.Count];
                for (int i = 0; i < lstSqlParameter.Count; i++)
                {
                    paraQuery[i] = lstSqlParameter[i] as SqlParameter;
                }
            }

            // 生成排序
            if (null != queryOrder)
            {
                strSql += queryOrder.MakeOrder();
            }

            // 执行查询
            if (null != paraQuery)
            {
                if (null != conn)
                {
                    return(SqlHelper.ExecuteDataTable(conn, CommandType.Text, strSql, paraQuery));
                }
                else
                {
                    return(SqlHelper.ExecuteDataTable(tran, CommandType.Text, strSql, paraQuery));
                }
            }
            else
            {
                if (null != conn)
                {
                    return(SqlHelper.ExecuteDataTable(conn, CommandType.Text, strSql));
                }
                else
                {
                    return(SqlHelper.ExecuteDataTable(tran, CommandType.Text, strSql));
                }
            }
        }
Esempio n. 2
0
 /// <summary>
 /// 执行查询返回表
 /// </summary>
 /// <param name="strTableName">表名</param>
 /// <param name="iTopNumber">TOP N</param>
 /// <param name="queryCondition">查询条件</param>
 /// <param name="queryOrder">排序集合</param>
 /// <param name="tran">数据库操作事务</param>
 /// <returns>结果集</returns>
 public static DataTable ExcuteQuery(String strTableName, int iTopNumber,
                                     QueryConditionDecorator queryCondition, QueryOrderCollection queryOrder, SqlTransaction tran)
 {
     return(ExcuteQuery(strTableName, iTopNumber, queryCondition, queryOrder, null, tran));
 }
Esempio n. 3
0
 /// <summary>
 /// 执行查询返回表
 /// </summary>
 /// <param name="strTableName">表名</param>
 /// <param name="iTopNumber">TOP N</param>
 /// <param name="queryCondition">查询条件</param>
 /// <param name="queryOrder">排序集合</param>
 /// <param name="conn">数据库连接</param>
 /// <returns>结果集</returns>
 public static DataTable ExcuteQuery(String strTableName, int iTopNumber,
                                     QueryConditionDecorator queryCondition, QueryOrderCollection queryOrder, SqlConnection conn)
 {
     return(ExcuteQuery(strTableName, iTopNumber, queryCondition, queryOrder, conn, null));
 }
Esempio n. 4
0
 /// <summary>
 /// 执行查询返回表
 /// </summary>
 /// <param name="strTableName">表名</param>
 /// <param name="queryOrder">排序集合</param>
 /// <param name="tran">数据库操作事务</param>
 /// <returns>结果集</returns>
 public static DataTable ExcuteQuery(String strTableName, QueryOrderCollection queryOrder, SqlTransaction tran)
 {
     return(ExcuteQuery(strTableName, 0, null, queryOrder, null, tran));
 }
Esempio n. 5
0
 /// <summary>
 /// 执行查询返回表
 /// </summary>
 /// <param name="strTableName">表名</param>
 /// <param name="queryOrder">排序集合</param>
 /// <param name="conn">数据库连接</param>
 /// <returns>结果集</returns>
 public static DataTable ExcuteQuery(String strTableName, QueryOrderCollection queryOrder, SqlConnection conn)
 {
     return(ExcuteQuery(strTableName, 0, null, queryOrder, conn, null));
 }
Esempio n. 6
0
 /// <summary>
 /// 执行分页查询返回表
 /// </summary>
 /// <param name="strTableName">表名</param>
 /// <param name="queryCondition">查询条件</param>
 /// <param name="queryOrder">排序集合</param>
 /// <param name="startRecord">开始查询记录</param>
 /// <param name="maxRecords">查询记录数量</param>
 /// <param name="tran">数据库操作事务</param>
 /// <returns>结果集</returns>
 public static DataTable ExcutePage(String strTableName, QueryConditionDecorator queryCondition,
                                    QueryOrderCollection queryOrder, int startRecord, int maxRecords, SqlTransaction tran)
 {
     return(ExcutePage(strTableName, queryCondition, queryOrder, startRecord, maxRecords, null, tran));
 }
Esempio n. 7
0
 /// <summary>
 /// 执行分页查询返回表
 /// </summary>
 /// <param name="strTableName">表名</param>
 /// <param name="queryOrder">排序集合</param>
 /// <param name="startRecord">开始查询记录</param>
 /// <param name="maxRecords">查询记录数量</param>
 /// <param name="conn">数据库连接</param>
 /// <returns>结果集</returns>
 public static DataTable ExcutePage(String strTableName, QueryOrderCollection queryOrder, int startRecord, int maxRecords, SqlConnection conn)
 {
     return(ExcutePage(strTableName, null, queryOrder, startRecord, maxRecords, conn, null));
 }