Esempio n. 1
0
        /// <summary>The manage definition.</summary>
        /// <param name="definition">The definition.</param>
        private void ManageDefinition(DbConnectionDefinition definition)
        {
            ConnectionStringBuilderForm frm;
            string oldName = null;

            if (definition == null)
            {
                frm = new ConnectionStringBuilderForm(_hostWindow, _services);                 // new blank form
            }
            else
            {
                oldName = definition.Name;
                frm     = new ConnectionStringBuilderForm(_hostWindow, definition, _services);
            }

            frm.ShowDialog(this);

            if (frm.DialogResult == DialogResult.OK)
            {
                SetDirty();

                if (lstConnections.Items.Contains(frm.ConnectionDefinition) && definition != null)
                {
                    if (definition.Name != oldName)
                    {
                        // want the list text to update due to name change
                        UpdateListView();
                        lstConnections.SelectedItem = definition;
                    }
                    else
                    {
                        UpdateDetailsPanel(lstConnections.SelectedItem as DbConnectionDefinition);
                    }
                }
                else
                {
                    _definitionList.AddDefinition(frm.ConnectionDefinition);
                    AddToList(frm.ConnectionDefinition);
                    lstConnections.SelectedItem = frm.ConnectionDefinition;
                }
            }
        }
        /// <summary>The manage definition.</summary>
        /// <param name="definition">The definition.</param>
        private void ManageDefinition(DbConnectionDefinition definition)
        {
            ConnectionStringBuilderForm frm;
            string oldName = null;

            if (definition == null)
            {
                frm = new ConnectionStringBuilderForm(_hostWindow, _services); // new blank form
            }
            else
            {
                oldName = definition.Name;
                frm = new ConnectionStringBuilderForm(_hostWindow, definition, _services);
            }

            frm.ShowDialog(this);

            if (frm.DialogResult == DialogResult.OK)
            {
                if (lstConnections.Items.Contains(frm.ConnectionDefinition) && definition != null)
                {
                    if (definition.Name != oldName)
                    {
                        // want the list text to update due to name change
                        UpdateListView();
                        lstConnections.SelectedItem = definition;
                    }
                    else
                    {
                        UpdateDetailsPanel(lstConnections.SelectedItem as DbConnectionDefinition);
                    }
                }
                else
                {
                    _definitionList.AddDefinition(frm.ConnectionDefinition);
                    AddToList(frm.ConnectionDefinition);
                    lstConnections.SelectedItem = frm.ConnectionDefinition;
                }
            }
        }