Exemplo n.º 1
0
        public static SortedDictionary <string, int> GetRelativeItemsSource(string tableName, string columnName, bool addNullItem)
        {
            var relation = TableKeys.GetColumnRelation(tableName, columnName);
            var result   = new SortedDictionary <string, int>();

            if (string.IsNullOrEmpty(relation.tableName) == false)
            {
                var       table        = TableManager.GetTable(relation.tableName);
                string    valueColName = GetValueColumnName(table, relation.columnName);
                DataRow[] rows         = table.Select();
                foreach (DataRow row in rows)
                {
                    var key   = (int)row[relation.columnName];
                    var value = GetRowStringView(row, relation.columnName, valueColName);
                    result.Add(value, key);
                }
            }
            if (addNullItem)
            {
                result.Add("", -1);
            }
            return(result);
        }
Exemplo n.º 2
0
        public static SortedSet <string> GetTableItems(string tableName, string columnName)
        {
            DataTable tab        = TableManager.GetTable(tableName);
            bool      isFk       = TableKeys.CheckColumnKeyType(tableName, columnName, TableKeys.KeyType.ForeignKey);
            var       keysList   = GetUniqueSet(tab, columnName);
            var       valuesList = new SortedSet <string>();

            foreach (var value in keysList)
            {
                if (isFk)
                {
                    valuesList.Add(GetValueByKey(tableName, columnName, value, true));
                }
                else
                {
                    valuesList.Add(value.ToString());
                }
            }
            if (valuesList.Contains("") == false)
            {
                valuesList.Add("");
            }
            return(valuesList);
        }
Exemplo n.º 3
0
        public static SortedDictionary <string, int> GetTableKeyItems(string tableName, string columnName, bool addNullItem = true)
        {
            DataTable tab    = TableManager.GetTable(tableName);
            bool      isFk   = TableKeys.CheckColumnKeyType(tableName, columnName, TableKeys.KeyType.ForeignKey);
            var       result = new SortedDictionary <string, int>();

            if (isFk)
            {
                var keysList = GetUniqueSet(tab, columnName);
                foreach (var key in keysList)
                {
                    var value = GetValueByKey(tableName, columnName, key, true);
                    if (result.ContainsKey(value) == false)
                    {
                        result.Add(value, (int)key);
                    }
                }
                if (result.ContainsKey("") == false && addNullItem)
                {
                    result.Add("", -1);
                }
            }
            return(result);
        }
Exemplo n.º 4
0
        public static DataRow DecodeRow(DataRow sourceRow, string tableName)
        {
            var destTable = TableManager.GetTable(tableName);

            return(DecodeRow(sourceRow, destTable));
        }