Пример #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (blnEditmode == false)
            {   // When saving a new item, we only need to add it to the listbox and update the registry
                lstServers.Items.Add(txtServerName.Text + "-" + txtDefaultDB.Text);
            }
            else
            {   // When editing a connection, we have to allow for a changed servername and delete the old entry
                var selectedServer = lstServers.SelectedIndex;

                if (selectedServer > 0)
                {
                    if (serverList.Count > 0)
                    {
                        var thisServer      = serverList[selectedServer - 1];
                        var dummyServerName = thisServer.ServerNameorIp;
                        var dummyDefaultDb  = thisServer.DatabaseName;

                        // Delete the old connection from the registry
                        ProgSettings.DeleteConnection(dummyServerName + "-" + dummyDefaultDb);
                    }
                }
            }
            ProgSettings.DbName     = txtDefaultDB.Text;
            ProgSettings.ServerName = txtServerName.Text;
            ProgSettings.UserName   = txtUsername.Text;
            ProgSettings.Password   = txtPassword.Text;
            ProgSettings.Port       = txtPort.Text;

            ProgSettings.WriteRegistry();

            // Repopulate from datastore
            frmServerSelect_Load(sender, e);

            // Set the screen to 'Normal' Mode
            ToggleControls(false);

            btnConnect.Enabled = false;
        }