Exemple #1
0
        private void grid_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (grid.CurrentRow == null)
            {
                return;
            }

            if (e.ColumnIndex == colAdd.Index)
            {
                var connection = grid.CurrentRow.DataBoundItem as DbConnection;
                if (connection != null)
                {
                    if (FrmConnection.ShowDialog(connection) == DialogResult.OK)
                    {
                        Settings.Save(connections);
                        grid.DataSource = null;
                        grid.DataSource = connections;
                    }
                }
            }
            else if (e.ColumnIndex == colDelete.Index)
            {
                var connection = grid.CurrentRow.DataBoundItem as DbConnection;
                if (connection != null)
                {
                    if (Program.Confirm("Excluir a conexão '" + connection.Name + "'?"))
                    {
                        grid.DataSource = null;
                        connections.Remove(connection);
                        Settings.Save(connections);
                        grid.DataSource = connections;
                    }
                }
            }
        }
Exemple #2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            var connection = new DbConnection {
                Name = "Nome da conexão"
            };

            if (FrmConnection.ShowDialog(connection) == DialogResult.OK)
            {
                connections.Add(connection);
                Settings.Save(connections);
                grid.DataSource = null;
                grid.DataSource = connections;
            }
        }
Exemple #3
0
        public static DialogResult ShowDialog(DbConnection connection)
        {
            using (var f = new FrmConnection())
            {
                f.LoadData();
                f.Connection = connection;
                f.SetValues();

                if (f.ShowDialog() == DialogResult.OK)
                {
                    f.GetValues();
                    f.DialogResult = DialogResult.OK;
                }
                return(f.DialogResult);
            }
        }