Пример #1
0
        private void cmbMethod_SelectedIndexChanged(object sender, EventArgs e)
        {
            txtConnStr.Text = txtConnectionStatus.Text = string.Empty;
            OdbcConnectionMethod method      = (OdbcConnectionMethod)cmbMethod.SelectedItem;
            IOdbcSubEditor       childEditor = null;

            switch (method)
            {
            case OdbcConnectionMethod.DSN:
                childEditor = new DSNCtrl();
                break;

            case OdbcConnectionMethod.KnownDriver:
                childEditor = new KnownDriversCtrl();
                break;

            case OdbcConnectionMethod.ManagedFile:
                childEditor = new ManagedCtrl();
                break;

            case OdbcConnectionMethod.RawConnectionString:
                childEditor = new ConnectionStringCtrl();
                break;

            case OdbcConnectionMethod.Unmanaged:
                childEditor = new UnmanagedCtrl();
                break;
            }

            if (childEditor != null)
            {
                childEditor.Bind(_service);
                //See if the current connection settings apply
                try
                {
                    childEditor.ConnectionProperties = _fs.GetConnectionProperties();
                }
                catch { }

                childEditor.ConnectionChanged    += InternalConnectionChanged;
                childEditor.RequestDocumentReset += RequestedDocumentReset;
                pnlMethod.Controls.Clear();
                childEditor.Content.Dock = DockStyle.Fill;
                pnlMethod.Controls.Add(childEditor.Content);
            }

            if (this.ChildEditor != null)
            {
                this.ChildEditor.ConnectionChanged    -= InternalConnectionChanged;
                this.ChildEditor.RequestDocumentReset -= RequestedDocumentReset;
            }

            this.ChildEditor = childEditor;

            if (this.ChildEditor != null)
            {
                if (!_init)
                {
                    _fs.ApplyConnectionProperties(this.ChildEditor.ConnectionProperties);
                }

                btnTest.Enabled = true;
            }
            else
            {
                btnTest.Enabled = false;
            }
        }