Ejemplo n.º 1
0
        private void columnsPage_CloseFromNext(object sender, Gui.Wizard.PageEventArgs e)
        {
            // Ensure ID column has been defined
            string idColumnName = (idColumnComboBox.SelectedItem == null ? String.Empty : idColumnComboBox.SelectedItem.ToString());

            if (idColumnName.Length == 0)
            {
                MessageBox.Show("You must specify the name of the column that holds the feature ID");
                idColumnComboBox.Focus();
                e.Page = columnsPage;
                return;
            }

            m_Edit.IdColumnName = idColumnName;

            // Ensure column domains are up to date.
            // For the time being, we do NOT establish or remove foreign keys in the
            // database - if that is considered desirable, bear in mind that the changes
            // being saved here may ultimately be discarded by the user (on exit from the
            // application).

            List <IColumnDomain> cds     = new List <IColumnDomain>();
            IEnvironmentFactory  factory = EnvironmentContainer.Factory;

            foreach (DataGridViewRow row in columnsGrid.Rows)
            {
                IDomainTable dt = (row.Cells["dgcDomain"].Value as IDomainTable);

                if (dt != null)
                {
                    IEditColumnDomain cd = factory.CreateColumnDomain();
                    cd.ParentTable = m_Edit;
                    cd.ColumnName  = row.Cells["dgcColumnName"].FormattedValue.ToString();
                    cd.Domain      = dt;

                    cds.Add(cd);
                }
            }

            m_Edit.ColumnDomains = cds.ToArray();
            m_Edit.FinishEdit();
            this.DialogResult = DialogResult.OK;
            Close();
        }