Пример #1
0
        private void EditConnection()
        {
            var connection = ConnectionItems.FirstOrDefault(c => c.ConnectionString == cboConnection.SelectedValue.ToString());

            if (connection == null)
            {
                MessageBox.Show("There is no connection to edit", "Edit", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            var f = new Connection {
                ConnectionString = connection.ConnectionString
            };
            var dialogResult = f.ShowDialog();

            if (dialogResult == DialogResult.OK)
            {
                connection.ConnectionString = f.ConnectionString;
                // Reload datasource seems to be the easiest way to refresh data ...
                ConnectionItems          = new BindingList <ConnectionItem>(ConnectionItems.OrderBy(c => c.DisplayName).ToList());
                SelectedConnectionString = f.ConnectionString;
                SaveSettings();
                LoadTables();
            }
        }
Пример #2
0
        private void RemoveConnection()
        {
            var connection = ConnectionItems.FirstOrDefault(c => c.ConnectionString == cboConnection.SelectedValue.ToString());

            if (connection == null)
            {
                MessageBox.Show("There is no connection to remove", "Remove", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            ConnectionItems.Remove(connection);
            SaveSettings();
            LoadTables();
        }