コード例 #1
0
        public static DataTable GetTableDataHelper(TableFullNameModel tableFullName, out SqlDataAdapter dataAdapterForUpdate)
        {
            if (string.IsNullOrEmpty(tableFullName.DataBaseName) || string.IsNullOrEmpty(tableFullName.TableName))
            {
                dataAdapterForUpdate = null;
                throw new ArgumentException(@"tableFullName should not be empty", nameof(tableFullName));
            }

            var databaseName = tableFullName.DataBaseName;
            var tableName    = tableFullName.TableName;
            var connection   = new SqlConnection(GetDifferentConnectionWithName(databaseName));

            connection.Open();
            var selectAllScript = $"SELECT * FROM [{tableName}]";

            dataAdapterForUpdate = new SqlDataAdapter(selectAllScript, connection);
            var dummy = new SqlCommandBuilder(dataAdapterForUpdate);
            var dataTableForUpdate = new DataTable();

            dataAdapterForUpdate.Fill(dataTableForUpdate);
            connection.Close();
            return(dataTableForUpdate);
        }
コード例 #2
0
        public static void SetElseTabsFalse(this ObservableCollection <OpenedTablesModel> openedTabs, TableFullNameModel tableFullName)
        {
            if (string.IsNullOrEmpty(tableFullName.DataBaseName) || string.IsNullOrEmpty(tableFullName.TableName))
            {
                throw new ArgumentException(@"tableFullName should not be empty", nameof(tableFullName));
            }

            foreach (var tab in openedTabs)
            {
                tab.IsChoosed = (tab.TableFullName == tableFullName);
            }
        }
コード例 #3
0
        public static bool IsThisTabOpened(this ObservableCollection <OpenedTablesModel> openedTabs, TableFullNameModel tableFullName)
        {
            if (string.IsNullOrEmpty(tableFullName.DataBaseName) || string.IsNullOrEmpty(tableFullName.TableName))
            {
                throw new ArgumentException(@"tableFullName should not be empty", nameof(tableFullName));
            }

            return(openedTabs.Any(table => table.TableFullName == tableFullName));
        }