Ejemplo n.º 1
0
        private void PopulateDBConnections()
        {
            _connParams = ConnectionParamsFactory.GetConnections();
            lvConnections.Items.Clear();

            foreach (ConnectionParams connSpec in _connParams)
            {
                ListViewItem item;
                if (connSpec.FriendlyName == null || connSpec.FriendlyName.Length == 0)
                {
                    item = new ListViewItem(connSpec.Name);
                }
                else
                {
                    item = new ListViewItem(connSpec.Name + "  { " + connSpec.FriendlyName + " } ");
                }

                item.SubItems.Add(connSpec.InitialCatalog);
                item.Checked = connSpec.IsConnected;
                item.Tag     = connSpec.ID;
                lvConnections.Items.Add(item);
            }

            if (_connParams.Count > 0)
            {
                lvConnections.Items[0].Selected = true;
            }

            InvalidateButtons();
        }
Ejemplo n.º 2
0
        private void PopulateServers(string defaultServerName)
        {
            cmbServers.Items.Clear();

            if (_conn.State != ConnectionState.Open)
            {
                return;
            }

            int serverIndex = -1;

            _connParamsCollection = ConnectionParamsFactory.GetConnections();
            foreach (ConnectionParams cp in _connParamsCollection)
            {
                cmbServers.Items.Add(cp.Name);
                if (defaultServerName.ToLowerInvariant() == cp.Name.ToLowerInvariant())
                {
                    cmbServers.SelectedIndex = cmbServers.Items.Count - 1;
                    serverIndex = cmbServers.SelectedIndex;
                }
            }

            if (serverIndex == -1)
            {
                cmbServers.Items.Add(defaultServerName);
                cmbServers.SelectedIndex = cmbServers.Items.Count - 1;
            }
        }
Ejemplo n.º 3
0
        private void AddNewConnectionSpec()
        {
            frmConnectionParams frm = new frmConnectionParams();

            frm.TopMost = true;
            if (frm.ShowDialog() == DialogResult.OK)
            {
                AddConnectionSpecToList(frm.GetCurrentConnectionSpec());
                ConnectionParamsFactory.Save(_connParams);
                InvalidateButtons();
            }
        }
Ejemplo n.º 4
0
        private void EditSelectedConnectionSpec()
        {
            if (lvConnections.SelectedItems.Count == 0)
            {
                return;
            }

            frmConnectionParams frm = new frmConnectionParams(this.SelectedDataSource, true);

            frm.TopMost = true;
            if (frm.ShowDialog() == DialogResult.OK)
            {
                _connParams.Delete(this.SelectedDataSource);
                lvConnections.Items.Remove(lvConnections.SelectedItems[0]);
                AddConnectionSpecToList(frm.GetCurrentConnectionSpec());
                ConnectionParamsFactory.Save(_connParams);
                InvalidateButtons();
            }
        }
Ejemplo n.º 5
0
 public frmRecoverContent()
 {
     InitializeComponent();
     _connRep = ConnectionParamsFactory.EnumerateConnections();
 }
Ejemplo n.º 6
0
 public static MSSQLConnection CreateMssqlConnection(string server, string database, string username = null, string password = null)
 {
     return(new MSSQLConnection(ConnectionParamsFactory.CreateMssqlConnectionParams(server, database, username, password)));
 }