public DataTable GetPagedTable(DataTable dt, int PageIndex, int PageSize, string moduleCode)
        {
            if (PageIndex == 0)
                return null;
            DataTable newdt = dt.Clone();

            #region 获取字典相关信息
            //获取列表字段的配置信息
            Bll_Sys_Config_Fieled filedInstance = new Bll_Sys_Config_Fieled();
            Bll_Bse_Dict DictInstance = new Bll_Bse_Dict();
            List<Sys_Config_Fieled> listField = filedInstance.GetListByCode(" AND D_ModuleCode='" + moduleCode + "'");
            string dictKeyList = "''";
            foreach (var field in listField)
            {
                if (!string.IsNullOrEmpty(field.D_DictKey))
                {
                    dictKeyList += ",'" + field.D_DictKey + "'";
                }
            }
            //获取配置信息中所有的字典表关键字里拥有的字典信息
            List<Bse_Dict> listDictionary = DictInstance.GetListByCode("  and (dict_key in (" + dictKeyList + "))");

            #endregion

            //newdt.Clear();
            int rowbegin = (PageIndex - 1) * PageSize;
            int rowend = PageIndex * PageSize;

            if (rowbegin >= dt.Rows.Count)//如果开始列数大于所拥有的列数
                rowbegin = 0;

            if (rowend > dt.Rows.Count)
                rowend = dt.Rows.Count;
            for (int i = rowbegin; i <= rowend - 1; i++)
            {
                DataRow newdr = newdt.NewRow();
                DataRow dr = dt.Rows[i];
                foreach (DataColumn column in dt.Columns)
                {
                    newdr[column.ColumnName] = dr[column.ColumnName];
                    //更新字典信息
                    var field = listField.Where(o => o.D_Index == column.ColumnName).FirstOrDefault();
                    if (field!=null&&!string.IsNullOrEmpty(field.D_DictKey))
                    {
                        Bse_Dict dict = listDictionary.Where(o => o.Dict_Code == dr[column.ColumnName].ToString()).FirstOrDefault();
                        if (dict != null)
                        {
                            newdr[column.ColumnName] = dict.Dict_Name;
                        }
                    }

                    //对编码进行转换
                    //if (field!=null && !string.IsNullOrEmpty(field.D_UDEF1))
                    //{
                    //    string[] Converts = field.D_UDEF1.Split(',');
                    //    if (Converts.Count()==3)
                    //    {
                    //        if (dr[column.ColumnName]!=null && !string.IsNullOrEmpty(dr[column.ColumnName].ToString()))
                    //        {
                    //            var data = instance.ListDataByCode(Converts[0], Converts[1] + "='" + dr[column.ColumnName].ToString() + "'");
                    //            if (data.Rows.Count>0)
                    //            {
                    //                newdr[column.ColumnName] = data.Rows[0][Converts[2]].ToString();
                    //            }
                    //        }
                    //    }
                    //}

                }
                newdt.Rows.Add(newdr);
            }
            return newdt;
        }
        /// <summary>
        /// 初始化Grid
        /// </summary>
        /// <param name="ModuleCode"></param>
        /// <param name="Namespace"></param>
        /// <param name="param"></param>
        /// <returns></returns>
        public DataTable GetListPageAllRecords(string ModuleCode, string Namespace, Dictionary <string, string> param)
        {
            //读出配置存储过程及参数
            Bll_Sys_Config_ListPage ConfigMInstance = new Bll_Sys_Config_ListPage();
            Bll_Bse_Dict            DictInstance    = new Bll_Bse_Dict();
            Bll_Sys_Config_Fieled   FieldInstance   = new Bll_Sys_Config_Fieled();

            Sys_Config_ListPage      config    = ConfigMInstance.GetListByCode(" AND M_ModuleCode='" + ModuleCode + "' ")[0];
            List <Sys_Config_Fieled> ListField = FieldInstance.GetListByCode(" AND D_ModuleCode='" + ModuleCode + "'");


            List <SqlParameter> list   = new List <SqlParameter>();
            SqlParameter        search = new SqlParameter("@Search", param["@Search"]);

            list.Add(search);
            SqlParameter sidx = new SqlParameter("@Sidx", param["@Sidx"]);

            list.Add(sidx);
            SqlParameter sord = new SqlParameter("@Sord", param["@Sord"]);

            list.Add(sord);
            SqlParameter userid = new SqlParameter("@Userid", param["@Userid"]);

            list.Add(userid);
            SqlParameter deptid = new SqlParameter("@Deptid", param["@Deptid"]);

            list.Add(deptid);
            SqlParameter modulecode = new SqlParameter("@ModuleCode", ModuleCode);

            list.Add(modulecode);
            SqlParameter _namespace = new SqlParameter("@NameSpace", Namespace);

            list.Add(_namespace);
            SqlParameter InlineType = new SqlParameter("@InlineType", param["@InlineType"]);

            list.Add(InlineType);
            SqlParameter GeneralType = new SqlParameter("@GeneralType", param["@GeneralType"]);

            list.Add(GeneralType);
            DataTable newDt = instance.idb.RunProcReturnDatatable(config.M_SQL, list.ToArray());


            #region Old,已被废弃掉的代码片段 By Ye Fei  2011-01-30
            //首先获取config_filed表中有数据字典的列及相关数据字典标示
            //var newList = ListField.Where(o => !string.IsNullOrEmpty(o.D_DictKey) && o.D_EditType.ToLower()=="dict" && o.D_Hidden!="true" );
            //if (newList.Count()>0)
            //{
            //    for (int i = 0; i < newDt.Rows.Count; i++)
            //    {
            //        foreach (Sys_Config_Fieled item in newList)
            //        {
            //            var DictResult = DictInstance.GetListByCode(" AND Dict_Code='" +
            //                                                          newDt.Rows[i][item.D_Index].ToString()
            //                                                          + "' AND Dict_Key='"+item.D_DictKey+"' ");
            //            if (DictResult.Count > 0)
            //            {
            //                newDt.Rows[i][item.D_Index] = DictResult.FirstOrDefault().Dict_Name;
            //            }

            //            if (param["@InlineType"].Length > 0)
            //            {
            //                //物料动态字典取值
            //                string dynKey = param["@InlineType"] + "TYPE";
            //                var Result = DictInstance.GetListByCode(" AND Dict_Code='" +
            //                                                         newDt.Rows[i][item.D_Index].ToString()
            //                                                         + "' AND Dict_Key='" + dynKey.ToUpper() + "' ");
            //                if (Result.Count > 0)
            //                {
            //                    newDt.Rows[i][item.D_Index] = Result.FirstOrDefault().Dict_Name;
            //                }
            //            }

            //        }
            //    }
            //}

            ///排序
            //if (!string.IsNullOrEmpty(config.M_TableName))
            //{
            //    Bll_Comm commInstance = new Bll_Comm();
            //    DataSet ds = commInstance.GetTableInfo(config.M_TableName);
            //    string TableKey = commInstance.GetTableKey(ds);
            //    if (!string.IsNullOrEmpty(TableKey))
            //    {
            //        DataView dv = newDt.DefaultView;
            //        dv.Sort = TableKey + " desc";
            //        newDt = dv.ToTable();
            //    }
            //}
            #endregion
            return(newDt);
        }
        /// <summary>
        /// 初始化Grid
        /// </summary>
        /// <param name="ModuleCode"></param>
        /// <param name="Namespace"></param>
        /// <param name="param"></param>
        /// <returns></returns>
        public DataTable GetListPageAllRecords(string ModuleCode,string Namespace,Dictionary<string,string> param)
        {
            //读出配置存储过程及参数
            Bll_Sys_Config_ListPage ConfigMInstance = new Bll_Sys_Config_ListPage();
            Bll_Bse_Dict DictInstance = new Bll_Bse_Dict();
            Bll_Sys_Config_Fieled FieldInstance = new Bll_Sys_Config_Fieled();

            Sys_Config_ListPage config = ConfigMInstance.GetListByCode(" AND M_ModuleCode='" + ModuleCode + "' ")[0];
            List<Sys_Config_Fieled> ListField = FieldInstance.GetListByCode(" AND D_ModuleCode='" + ModuleCode + "'");

            List<SqlParameter> list = new List<SqlParameter>();
            SqlParameter search = new SqlParameter("@Search",param["@Search"]);
            list.Add(search);
            SqlParameter sidx = new SqlParameter("@Sidx", param["@Sidx"]);
            list.Add(sidx);
            SqlParameter sord = new SqlParameter("@Sord", param["@Sord"]);
            list.Add(sord);
            SqlParameter userid = new SqlParameter("@Userid", param["@Userid"]);
            list.Add(userid);
            SqlParameter deptid = new SqlParameter("@Deptid", param["@Deptid"]);
            list.Add(deptid);
            SqlParameter modulecode = new SqlParameter("@ModuleCode", ModuleCode);
            list.Add(modulecode);
            SqlParameter _namespace = new SqlParameter("@NameSpace", Namespace);
            list.Add(_namespace);
            SqlParameter InlineType = new SqlParameter("@InlineType", param["@InlineType"]);
            list.Add(InlineType);
            SqlParameter GeneralType = new SqlParameter("@GeneralType", param["@GeneralType"]);
            list.Add(GeneralType);
            DataTable newDt=instance.idb.RunProcReturnDatatable(config.M_SQL,list.ToArray());

            #region Old,已被废弃掉的代码片段 By Ye Fei  2011-01-30
            //首先获取config_filed表中有数据字典的列及相关数据字典标示
            //var newList = ListField.Where(o => !string.IsNullOrEmpty(o.D_DictKey) && o.D_EditType.ToLower()=="dict" && o.D_Hidden!="true" );
            //if (newList.Count()>0)
            //{
            //    for (int i = 0; i < newDt.Rows.Count; i++)
            //    {
            //        foreach (Sys_Config_Fieled item in newList)
            //        {
            //            var DictResult = DictInstance.GetListByCode(" AND Dict_Code='" +
            //                                                          newDt.Rows[i][item.D_Index].ToString()
            //                                                          + "' AND Dict_Key='"+item.D_DictKey+"' ");
            //            if (DictResult.Count > 0)
            //            {
            //                newDt.Rows[i][item.D_Index] = DictResult.FirstOrDefault().Dict_Name;
            //            }

            //            if (param["@InlineType"].Length > 0)
            //            {
            //                //物料动态字典取值
            //                string dynKey = param["@InlineType"] + "TYPE";
            //                var Result = DictInstance.GetListByCode(" AND Dict_Code='" +
            //                                                         newDt.Rows[i][item.D_Index].ToString()
            //                                                         + "' AND Dict_Key='" + dynKey.ToUpper() + "' ");
            //                if (Result.Count > 0)
            //                {
            //                    newDt.Rows[i][item.D_Index] = Result.FirstOrDefault().Dict_Name;
            //                }
            //            }

            //        }
            //    }
            //}

            ///排序
            //if (!string.IsNullOrEmpty(config.M_TableName))
            //{
            //    Bll_Comm commInstance = new Bll_Comm();
            //    DataSet ds = commInstance.GetTableInfo(config.M_TableName);
            //    string TableKey = commInstance.GetTableKey(ds);
            //    if (!string.IsNullOrEmpty(TableKey))
            //    {
            //        DataView dv = newDt.DefaultView;
            //        dv.Sort = TableKey + " desc";
            //        newDt = dv.ToTable();
            //    }
            //}
            #endregion
            return newDt;
        }