Esempio n. 1
0
        /// <summary>
        /// 编码转换
        /// </summary>
        /// <returns></returns>
        public static DataTable DictionaryIdToName(DataTable dt)
        {
            Dictionary <string, string> piName = new Dictionary <string, string>();
            var list = new RoadFlow.Platform.DictionaryBLL().GetAll();

            //编码转换
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                for (int j = 0; j < dt.Columns.Count; j++)
                {
                    if (dt.Columns[j].ColumnName == "SW_ZJ" || dt.Columns[j].ColumnName == "SY_ZJ")
                    {
                    }
                    else
                    {
                        if (list.FindAll(x => x.Code == dt.Columns[j].ColumnName).Count > 0)
                        {
                            string temp = Convert.ToString(dt.Rows[i][j]);
                            RoadFlow.Data.Model.DictionaryModel dictionary = list.Find(p => p.ID.ToString().ToUpper() == temp.ToUpper());
                            if (dictionary != null)
                            {
                                dt.Rows[i][j] = dictionary.Title;
                            }
                            else
                            {
                                dt.Rows[i][j] = "已删除";
                            }
                        }
                    }
                }
            }
            return(dt);
        }
Esempio n. 2
0
        /// <summary>
        /// 转换数据编码
        /// </summary>
        /// <param name="dt"></param>
        /// <returns></returns>
        public DataTable ConvertType(DataTable dt)
        {
            //取得编码字典
            var list = new RoadFlow.Platform.DictionaryBLL().GetAll();

            //编码转换
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                for (int j = 0; j < dt.Columns.Count; j++)
                {
                    if (list.FindAll(x => x.Code == dt.Columns[j].ColumnName).Count > 0)
                    {
                        string temp = Convert.ToString(dt.Rows[i][j]);
                        dt.Rows[i][j] = list.Find(x => x.ID.ToString() == temp).Title;
                    }
                }
            }
            return(dt);
        }