private void btnSave_Click(object sender, EventArgs e)
        {
            if (!IsValidTFSConfiguration())
            {
                return;
            }

            try
            {
                TFSConnectionString newtfsConnectionString = new TFSConnectionString
                {
                    ServerName = this.txtServerName.Text,
                    PortNumber = int.Parse(this.txtPortNumber.Text),
                    DefaultCollection = this.txtDefaultCollection.Text
                };

                newtfsConnectionString.Validate();
                newtfsConnectionString.SaveOrUpdateTFSConnectionStringToDB();
                this.Close();
            }
            catch (ArgumentNullException argumentex)
            {
                MessageBox.Show(argumentex.Message, "Invalid TFS connection parameters", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (FormatException formatException)
            {
                MessageBox.Show(formatException.Message, "Invalid TFS connection parameters", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Invalid TFS connection parameters", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 public TFSConnectionEditor(TFSConnectionString tfsConectionString)
     : this()
 {
     tfsConectionString.Validate();
     this.txtServerName.Text = tfsConectionString.ServerName;
     this.txtPortNumber.Text = tfsConectionString.PortNumber.ToString();
     this.txtDefaultCollection.Text = tfsConectionString.DefaultCollection;
 }
 /// <summary>
 /// Handles the SelectionChanged event of the dgvTFSsettings control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
 private void dgvTFSsettings_SelectionChanged(object sender, EventArgs e)
 {
     if (this.dgvTFSsettings.SelectedRows.Count > 0)
     {
         this.selectedTFSConnectionString = new TFSConnectionString
         {
             ServerName = this.dgvTFSsettings.SelectedRows[0].Cells[0].Value.ToString(),
             PortNumber = int.Parse(this.dgvTFSsettings.SelectedRows[0].Cells[1].Value.ToString()),
             DefaultCollection = this.dgvTFSsettings.SelectedRows[0].Cells[2].Value.ToString()
         };
     }
 }