private void DeleteConnection() { if (lstConnections.SelectedIndex >= 0) { ConnectionItem connectionDetails = lstConnections.SelectedItem as ConnectionItem; if (connectionDetails.ConnectionID == -1) { // user was adding a new connection this._addConnection = false; } else { this._connSettings.DeleteConnection(connectionDetails.ConnectionID); this.queryTree.RemoveUserItems(connectionDetails.ConnectionID); } lstConnections.Items.RemoveAt(lstConnections.SelectedIndex); if (lstConnections.Items.Count > 0) { lstConnections.SelectedIndex = 0; } } lstConnections.Enabled = true; btnAddConn.Enabled = true; }
private void LoadDefinedConnections(int selectedIndex) { try { lstConnections.Items.Clear(); foreach (MyZillaSettingsDataSet.ConnectionRow cConnection in _connSettings.Connection.Rows) { ConnectionItem ci = new ConnectionItem(cConnection.ConnectionId, cConnection.ConnectionName); lstConnections.Items.Add(ci); } lstConnections.DisplayMember = "ConnectionInfo"; lstConnections.ValueMember = "ConnectionID"; if (lstConnections.Items.Count >= selectedIndex + 1) { lstConnections.SelectedIndex = selectedIndex; } } catch (Exception ex) { MyLogger.Write(ex, "LoadDefinedConnections", LoggingCategory.Exception); MessageBox.Show(this, ex.Message, Messages.Error, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void FormConnectionSettings_FormClosing(object sender, FormClosingEventArgs e) { ConnectionItem selConnection = lstConnections.SelectedItem as ConnectionItem; if (selConnection != null) { bool isModified = this.CheckForModifications(selConnection.ConnectionID); if (isModified) { DialogResult dr = MessageBox.Show(this, Messages.MsgExistModifications, Messages.Info, MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.Yes) { e.Cancel = false; } else { e.Cancel = true; } } else { e.Cancel = false; } } }
private void lstConnections_SelectedIndexChanged(object sender, EventArgs e) { try { if (lstConnections.SelectedIndex >= 0) { ConnectionItem ci = lstConnections.SelectedItem as ConnectionItem; lblTestResult.Visible = false; if (ci != null) { TDSettings.ConnectionRow conn = _connSettings.GetConnectionById(ci.ConnectionID); if (conn != null) { txtUrl.Text = conn.URL; txtConnectionName.Text = conn.ConnectionName; txtUserName.Text = conn.UserName; txtPassword.Text = conn.Password; chkActiveUser.Checked = conn.ActiveUser; //chkRemember.Checked = conn.RememberPassword; } else { if (this._addConnection == true) { txtConnectionName.Text = Messages.NewConnection; txtUrl.Text = string.Empty; txtUserName.Text = string.Empty; txtPassword.Text = string.Empty; chkActiveUser.Checked = false; //chkRemember.Checked = false; } } } } } catch (Exception ex) { MyLogger.Write(ex, "lstConnections_SelectedIndexChanged", LoggingCategory.Exception); MessageBox.Show(this, ex.Message, Messages.Error, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void AddConnection() { this._addConnection = true; lstConnections.Enabled = false; ConnectionItem ci = new ConnectionItem(-1, Messages.NewConnection ); lstConnections.Items.Add(ci); lstConnections.SelectedIndex = lstConnections.Items.Count - 1; btnAddConn.Enabled = false; }
private void AddConnection() { this._addConnection = true; lstConnections.Enabled = false; ConnectionItem ci = new ConnectionItem(-1, Messages.NewConnection); lstConnections.Items.Add(ci); lstConnections.SelectedIndex = lstConnections.Items.Count - 1; btnAddConn.Enabled = false; }
private bool ConnectionNameAlreadyInUse(string ConnName) { bool result = false; for (int i = 0; i < lstConnections.Items.Count; i++) { if (i != lstConnections.SelectedIndex) { ConnectionItem item = (ConnectionItem)lstConnections.Items[i]; if (item != null && item.ConnectionInfo == ConnName) { result = true; break; } } } return(result); }
private void LoadDefinedConnections( int selectedIndex) { try { lstConnections.Items.Clear(); foreach (MyZillaSettingsDataSet.ConnectionRow cConnection in _connSettings.Connection.Rows) { ConnectionItem ci = new ConnectionItem(cConnection.ConnectionId , cConnection.ConnectionName ); lstConnections.Items.Add(ci); } lstConnections.DisplayMember = "ConnectionInfo"; lstConnections.ValueMember = "ConnectionID"; if (lstConnections.Items.Count >= selectedIndex+ 1 ) { lstConnections.SelectedIndex = selectedIndex ; } } catch (Exception ex) { MyLogger.Write(ex, "LoadDefinedConnections", LoggingCategory.Exception); MessageBox.Show(this, ex.Message, Messages.Error , MessageBoxButtons.OK, MessageBoxIcon.Error ); } }
private void btnSave_Click(object sender, EventArgs e) { try { ep.Clear(); // save connections bool isValid = CheckConditionsForSave(); if (isValid == true) { if (this._addConnection == true) { // get connection information int connectionID = _connSettings.AddConnection(txtConnectionName.Text.Trim(), this.FullConnectionURL(txtUrl.Text), cmbType.Text, txtUserName.Text.Trim(), txtPassword.Text.Trim(), true, chkActiveUser.Checked); // get version of the connection (async thread) this.GetVersionForConnection(connectionID, txtUrl.Text.Trim()); lstConnections.Enabled = true; LoadDefinedConnections(lstConnections.SelectedIndex); this._addConnection = false; btnAddConn.Enabled = true; } else { ConnectionItem ci = lstConnections.SelectedItem as ConnectionItem; if (ci != null) { string oldURL = _connSettings.GetConnectionById(ci.ConnectionID).URL; _connSettings.EditConnection(ci.ConnectionID , txtConnectionName.Text.Trim() , this.FullConnectionURL(txtUrl.Text) , cmbType.Text , txtUserName.Text.Trim() , txtPassword.Text.Trim() , true , chkActiveUser.Checked ); if (oldURL != txtUrl.Text.Trim()) { // get version of the connection (async thread) this.GetVersionForConnection(ci.ConnectionID, txtUrl.Text.Trim()); } } } MessageBox.Show(this, Messages.SaveGlSettingsOK, Messages.Info, MessageBoxButtons.OK, MessageBoxIcon.Information); LoadDefinedConnections(lstConnections.SelectedIndex); }// is valid = true } catch (Exception ex) { MyLogger.Write(ex, "btnSave_Click", LoggingCategory.Exception); MessageBox.Show(this, ex.Message, Messages.Error, MessageBoxButtons.OK, MessageBoxIcon.Error); } }