void IPgConnectionStash.RemoveConnection(IPgConnection connection)
 {
     if (_DbSettings.ContainsKey(connection.Name))
     {
         _DbSettings.Remove(connection.Name);
     }
 }
Exemple #2
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            string txt = "You're about to remove Cinco connections from your application." + Environment.NewLine + Environment.NewLine +
                "Do you really want to do this";

            DialogResult = MessageBox.Show(txt, "Trash", 
                MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2);

            if (DialogResult == System.Windows.Forms.DialogResult.OK)
            {
                if (dt != null)
                    for (int row = 0; row < dgConnections.Rows.Count; row++)
                    {
                        DataGridViewRow dr = dgConnections.Rows[row];
                        if (dr.Cells["selected"].Value.ToString() == true.ToString())
                        {
                            IPgConnection con = dt.Rows[row]["cinco"] as IPgConnection;
                            if (con != null)
                            {
                                log.Debug(string.Format("Removing connection {0}", con.Name));
                                stash.RemoveConnection(con);

                            }
                        }
                    }
            }
        }
Exemple #3
0
        // callbacks/events
        private void ucDatabase_OnDatabaseChanged(object sender, pgDatabase.DatabaseEventArgs e)
        {
            _currentConnection = e.PgConnection;
            ucDatabase.SaveConfiguration();
            conf.Save();

            dbStructure.Nodes.Clear();
            InitTree();
            dbStructure.Refresh();
        }
 void IPgConnectionStash.AddConnection(IPgConnection connection)
 {
     if (_DbSettings.ContainsKey(connection.Name))
     {
         _DbSettings[connection.Name] = connection;
     }
     else
     {
         _DbSettings.Add(connection.Name, connection);
     }
 }
Exemple #5
0
 private void cbxDatabase_TextChanged(object sender, EventArgs e)
 {
     if (OnDatabaseChanged != null)
     {
         IPgConnection connection = _stash.GetConnection(cbxDatabase.Text);
         if (connection != null && !connection.Equals(_SelectedDatabase))
         {
             _SelectedDatabase = connection;
             OnDatabaseChanged(this, new DatabaseEventArgs(connection));
         }
     }
 }
Exemple #6
0
 private IPgConnection findConnection(string name = "last-database")
 {
     if (_currentConnection == null)
     {
         if (hasConnection())
         {
             IPgConnection con = ucDatabase.Stash.GetConnection(name);
             return(con);
         }
     }
     return(_currentConnection);
 }
Exemple #7
0
        public void AddConnection(IPgConnection connection)
        {
            _stash.AddConnection(connection);

            cbxDatabase.Items.Clear();
            cbxDatabase.Items.AddRange(_stash.PgConnections.ToArray());
            string lastDatabase = conf.GetConfigurationValue(_PersistanceLastValue);

            if (cbxDatabase.Items.Contains(lastDatabase))
            {
                cbxDatabase.Text = lastDatabase;
            }
        }
Exemple #8
0
        bool IPgConnection.Equals(IPgConnection input)
        {
            if (input == null)
            {
                return(false);
            }

            return(input.Name == _Name &&
                   input.Server == _Server &&
                   input.Port == _Port &&
                   input.Database == _Database &&
                   input.User == _User &&
                   input.Password == _Password);
        }
Exemple #9
0
        private void picEdit_Click(object sender, EventArgs e)
        {
            EditPgConnection frm = new EditPgConnection();

            frm.CincoConnection      = _stash.GetConnection(cbxDatabase.Text);
            frm.CincoConnectionStash = _stash;

            if (frm.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
            {
                IPgConnection dbCon = frm.CincoConnection;
                _stash.AddConnection(dbCon);
                cbxDatabase.Text = dbCon.Name;

                log.Debug("Adding: " + dbCon.ToString());
            }

            cbxDatabase.Items.Clear();
            cbxDatabase.Items.AddRange(_stash.PgConnections.ToArray());
        }
        private void picTest_Click(object sender, EventArgs e)
        {
            Cursor = Cursors.WaitCursor;

            IPgDatabase   db  = PgDatabase.Interface;
            IPgConnection tmp = db.PgConnection;

            db.PgConnection = CincoConnection;

            if (db.IsConnectionLife)
            {
                picTest.Image = imageList.Images[2];
            }
            else
            {
                picTest.Image = imageList.Images[1];
            }

            _OrgConnection  = CincoConnection;
            db.PgConnection = tmp;

            Cursor = Cursors.Default;
        }
Exemple #11
0
 public DatabaseEventArgs(IPgConnection connection)
 {
     _PgConnection = connection;
 }
 bool IPgConnectionStash.Contains(IPgConnection connection)
 {
     return(_DbSettings.Keys.Contains <string>(connection.Name));
 }