Previous Topic

How the Instance Is Changed

Clicking the Change button in the application triggers the execution of the changeButton_Click event handler.

The event handler performs the following:

private void changeButton_Click(object sender, EventArgs e)

{

    TargetDetails newSource = new TargetDetails();

 

    if (InstanceCheckItems() == DialogResult.OK)

    {

    if (hostComboBox.SelectedValue != null)

    {

        newSource.host = hostComboBox.SelectedValue.ToString();

    }

    else

    {

        newSource.host = hostComboBox.Text.ToString();

    }

    if (instanceComboBox.SelectedValue != null)

    {

        newSource.port = String.Format(rm.GetString("PortAddress"),

            instanceComboBox.SelectedValue.ToString());

    }

    else

    {

        newSource.port = String.Format(rm.GetString("PortAddress"),

            instanceComboBox.Text.ToString());

    }

    if (useridTextBox != null)

    {

        newSource.user = useridTextBox.Text;

    }

    if (passwordTextBox != null)

    {

        newSource.pwd = passwordTextBox.Text;

    }

    if (databaseComboBox.SelectedValue != null)

    {

        newSource.db = databaseComboBox.SelectedValue.ToString();

    }

    else

    {

        newSource.db = databaseComboBox.Text.ToString();

    }

    savedSource = currentSource;

    currentSource = newSource;

    SetConnection(ingresConnection1,

    currentSource.GetConnectionString());

    if (connectDefaultCheckBox.Checked == true)

    {

        WriteConfiguration(appConfigFile);

        defaultSourceRadioButton.Checked = true;

    }

    if (CheckVersion(1, 0, 0) == true)

    {

                        SetInstanceControls();

                        SetStatus(currentSource);

                        SetStaticControls();

    }

    else

    {

        DialogResult result = MessageBox.Show(rm.GetString("ErrorVersion"),

            rm.GetString("InstanceCaption"),

            MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);

            if (result != DialogResult.Retry)

            {

                currentSource = savedSource;

            }

        }

    }

}


© 2006 Ingres Corporation. All rights reserved.