Ejemplo n.º 1
0
 void IPgConnectionStash.RemoveConnection(IPgConnection connection)
 {
     if (_DbSettings.ContainsKey(connection.Name))
     {
         _DbSettings.Remove(connection.Name);
     }
 }
Ejemplo n.º 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);

                            }
                        }
                    }
            }
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 4
0
 void IPgConnectionStash.AddConnection(IPgConnection connection)
 {
     if (_DbSettings.ContainsKey(connection.Name))
     {
         _DbSettings[connection.Name] = connection;
     }
     else
     {
         _DbSettings.Add(connection.Name, connection);
     }
 }
Ejemplo n.º 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));
         }
     }
 }
Ejemplo n.º 6
0
 private IPgConnection findConnection(string name = "last-database")
 {
     if (_currentConnection == null)
     {
         if (hasConnection())
         {
             IPgConnection con = ucDatabase.Stash.GetConnection(name);
             return(con);
         }
     }
     return(_currentConnection);
 }
Ejemplo n.º 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;
            }
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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());
        }
Ejemplo n.º 10
0
        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;
        }
Ejemplo n.º 11
0
 public DatabaseEventArgs(IPgConnection connection)
 {
     _PgConnection = connection;
 }
Ejemplo n.º 12
0
 bool IPgConnectionStash.Contains(IPgConnection connection)
 {
     return(_DbSettings.Keys.Contains <string>(connection.Name));
 }