private SavedConnection GetSelectedItem() { if (lstConnections.SelectedIndices.Count < 1) { return(SavedConnection.Empty); } SavedConnection conn = lstConnections.SelectedItems[0].Tag as SavedConnection; return(conn); }
public void SaveNewConnection(ConnectionStringEntry entry) { string connKey = string.Format("{0}_{1}", entry.ProjectName, entry.ConnectionName); SavedConnection newConn = new SavedConnection() { ConnectionString = entry.ConnectionString, Name = connKey }; SaveNewConnection(newConn); }
private void tsAddNewConnection_Click(object sender, EventArgs e) { SavedConnection newConn = new SavedConnection() { Name = "New Connection", ConnectionString = "DataSource=.;Initial Catalog=;Trusted Connection=true;" }; ListViewItem itm = new ListViewItem(); itm.Text = newConn.Name; itm.SubItems.Add(newConn.ConnectionString); itm.Tag = newConn; lstConnections.Items.Add(itm); SavedConnections.Add(newConn); }
private void tsAddConnection_Click(object sender, EventArgs e) { foreach (var itm in chkLstConfigs.CheckedItems) { ConnectionStringEntry conn = itm as ConnectionStringEntry; if (!string.IsNullOrEmpty(txtConnectionName.Text) && !string.IsNullOrEmpty(txtConnStr.Text)) { NewConnections.Add(new ConnectionStringEntry() { ConnectionName = txtConnectionName.Text, ConnectionString = txtConnStr.Text, ConfigPath = conn.ConfigPath, ConfigFile = conn.ConfigFile, ProjectName = conn.ProjectName, ProjectItem = conn.ProjectItem }); } foreach (var savedIitm in chkLstSavedConnections.CheckedItems) { SavedConnection savedConn = savedIitm as SavedConnection; NewConnections.Add(new ConnectionStringEntry() { ConnectionName = savedConn.Name, ConnectionString = savedConn.ConnectionString, ConfigPath = conn.ConfigPath, ConfigFile = conn.ConfigFile, ProjectName = conn.ProjectName, ProjectItem = conn.ProjectItem }); } } this.DialogResult = System.Windows.Forms.DialogResult.OK; }
public void RemoveConnection(SavedConnection connection) { _connections.Remove(connection); Save(); }
public void SaveNewConnection(SavedConnection newConn) { _connections.Add(newConn); Save(); }
void _view_ChangeConnection(ConnectionStringEntry entry, SavedConnection savedConn, bool silent) { entry.ConnectionString = savedConn.ConnectionString; WriteConfigChanges(entry.ConnectionName, entry); _view.RefreshView(); }