/* * public ConnectionParams FindByServerName(string name) * { * foreach (ConnectionParams cp in this) * { * if (cp.Server.ToLowerInvariant() == name.ToLowerInvariant()) * return cp; * } * return null; * } */ public void Delete(ConnectionParams cp) { int index = 0; foreach (ConnectionParams d in this) { if (d.ID == cp.ID) { this.RemoveAt(index); ConnectionParamsFactory.Save(this); return; } index++; } }
private void AddNewConnectionSpec() { #if PERSONAL_EDITION if (lvConnections.Items.Count >= _maxPersonalEditionConnCnt) { throw new PersonalEditionLimitation(String.Format("Personal Edition does not support more than {0} saved connections.", _maxPersonalEditionConnCnt)); } #endif frmConnectionParams frm = new frmConnectionParams(); if (frm.ShowDialog() == DialogResult.OK) { AddConnectionSpecToList(frm.GetCurrentConnectionSpec()); ConnectionParamsFactory.Save(_connParams); InvalidateButtons(); } }
private void EditSelectedConnectionSpec() { if (lvConnections.SelectedItems.Count == 0) { return; } frmConnectionParams frm = new frmConnectionParams(this.SelectedDataSource, true, false); if (frm.ShowDialog() == DialogResult.OK) { _connParams.Delete(this.SelectedDataSource); lvConnections.Items.Remove(lvConnections.SelectedItems[0]); AddConnectionSpecToList(frm.GetCurrentConnectionSpec()); ConnectionParamsFactory.Save(_connParams); InvalidateButtons(); } }