예제 #1
0
        /// <summary>
        /// 分页查询,返回标准的查询XML
        /// </summary>
        /// <param name="strFieldList">查询字段列表</param>
        /// <param name="strTableList">查询表列表</param>
        /// <param name="strOtherClause">Where条件</param>
        /// <param name="strOrdFld">排序字段 例如:PERSONID DESC</param>
        /// <param name="strDicFieldList">待翻译字典字段列表  例如:SEX,NATION </param>
        /// <param name="strDicNameList">待翻译字典名称列表 例如:DIC_SEX,DIC_NATIVE 注意:strDicFieldList和strDicNameList必须一一对应 </param>
        /// <param name="strDateFieldList">待处理的日期型字段列表 例如:BIRTHDAY,COMEDATE</param>
        /// <param name="intTotalRecords">记录总数</param>
        /// <param name="intTotalPages">总页数</param>
        /// <param name="intPageSize">每页记录数</param>
        /// <param name="intCurrentPage">待查询的页数</param>
        /// <param name="intCountTotal">是否需要统计记录总数</param>
        /// <param name="blnDicInSv">字典翻译方式</param>
        /// <param name="strListName">生成列表名称</param>
        /// <returns>标准的查询 XML 返回结构的字符串</returns>
        public static string basicListQuery(string strFieldList,
                                            string strTableList,
                                            string strOtherClause,
                                            string strOrdFld,
                                            string[] strDicFieldList,
                                            string[] strDicNameList,
                                            string[] strDateFieldList,
                                            int intTotalRecords,
                                            int intTotalPages,
                                            int intPageSize,
                                            int intCurrentPage,
                                            int intCountTotal,
                                            Boolean blnDicInSv,
                                            String strListName)
        {
            OleDbConnection m_Conn = Conn.getConn();

            try
            {
                string str_FieldList = strFieldList.Replace(Common.MARK, Common.QUOTE);
                string str_TableList = strTableList.Replace(Common.MARK, Common.QUOTE);

                string str_OtherClause = null;
                string str_OrdFld      = null;

                if (!General.empty(strOtherClause))
                {
                    str_OtherClause = strOtherClause.Replace(Common.MARK, Common.QUOTE);
                }

                if (!General.empty(strOrdFld))
                {
                    str_OrdFld = strOrdFld.Replace(Common.MARK, Common.QUOTE);
                }

                int int_TotalRecords = intTotalRecords;
                int int_TotalPages   = intTotalPages;

                OleDbDataReader rst = null;

                OleDbCommand m_Command = new OleDbCommand("QueryPagination", m_Conn);

                m_Command.CommandType = CommandType.StoredProcedure;

                OleDbParameter param;

                param           = m_Command.Parameters.Add("t", OleDbType.VarChar, 1000);
                param.Direction = ParameterDirection.Input;
                param.Value     = "";

                param           = m_Command.Parameters.Add("strFieldList", OleDbType.VarChar, 1000);
                param.Direction = ParameterDirection.Input;
                param.Value     = str_FieldList;

                param           = m_Command.Parameters.Add("strTableList", OleDbType.VarChar, 300);
                param.Direction = ParameterDirection.Input;
                param.Value     = str_TableList;

                param           = m_Command.Parameters.Add("strWhereClause", OleDbType.VarChar, 1000);
                param.Direction = ParameterDirection.Input;
                param.Value     = str_OtherClause;

                param           = m_Command.Parameters.Add("strOrderFld", OleDbType.VarChar, 100);
                param.Direction = ParameterDirection.Input;
                param.Value     = str_OrdFld;

                param           = m_Command.Parameters.Add("intCurrentPage", OleDbType.Integer, 4);
                param.Direction = ParameterDirection.Input;
                param.Value     = intCurrentPage;

                param           = m_Command.Parameters.Add("intPageSize", OleDbType.Integer, 4);
                param.Direction = ParameterDirection.Input;
                param.Value     = intPageSize;

                param           = m_Command.Parameters.Add("intCountToto", OleDbType.Integer, 4);
                param.Direction = ParameterDirection.Input;
                param.Value     = intCountTotal;

                param           = m_Command.Parameters.Add("intTotoRecords", OleDbType.Integer, 10);
                param.Direction = ParameterDirection.Output;

                param           = m_Command.Parameters.Add("intTotoPages", OleDbType.Integer, 10);
                param.Direction = ParameterDirection.Output;
                m_Command.ExecuteNonQuery();

                int_TotalRecords = Convert.ToInt32(m_Command.Parameters["intTotoRecords"].Value);
                int_TotalPages   = Convert.ToInt32(m_Command.Parameters["intTotoPages"].Value);

                rst = m_Command.ExecuteReader();

                string strReturnXml = getQueryXml(rst,
                                                  strDicFieldList,
                                                  strDicNameList,
                                                  strDateFieldList,
                                                  int_TotalRecords,
                                                  int_TotalPages,
                                                  blnDicInSv,
                                                  strListName);


                rst.Close();
                return(strReturnXml);
            }
            catch (Exception e)
            {
                return(e.Message);
            }
            finally
            {
                m_Conn.Close();
            }
        }