Exemplo n.º 1
0
        private void FieldGrid_CellEndEdit(Object sender, DataGridViewCellEventArgs e)
        {
            DataEntityField field = this.FieldGrid.Rows[e.RowIndex].DataBoundItem as DataEntityField;

            if (field != null)
            {
                field.Save();
            }
        }
Exemplo n.º 2
0
        private void FieldGrid_CellContentClick(Object sender, DataGridViewCellEventArgs e)
        {
            DataEntityField field = this.FieldGrid.Rows[e.RowIndex].DataBoundItem as DataEntityField;

            if (e.RowIndex >= 0 && e.ColumnIndex == this.FieldEllipsisColumn.Index && !field.IsPrimaryKey)
            {
                FieldSettings fieldSettings = new FieldSettings();
                fieldSettings.RelatedEntityDropdown.Items.Add(new { CodeName = "" });
                fieldSettings.RelatedEntityDropdown.Items.AddRange(this.CurrentDatabase.Domains.SelectMany(domain => domain.Entities).OrderBy(ent => ent.ObjectName).ToArray());
                fieldSettings.RelatedEntityDropdown.DisplayMember = "CodeName";

                // Display the current settings in the UI
                fieldSettings.FieldType                          = field.CodeType;
                fieldSettings.FieldNameTextbox.Text              = field.ObjectName;
                fieldSettings.ExposureDropdown.SelectedIndex     = (Int32)field.CodeExposure;
                fieldSettings.RelatedEntityDropdown.SelectedItem = field.RelatedEntity;
                fieldSettings.RelatedFieldDropdown.SelectedItem  = field.RelatedField;
                fieldSettings.RelatedFieldTextbox.Text           = field.CodeHeader;
                fieldSettings.IsUniqueCheckbox.Checked           = field.IsUnique;

                if (fieldSettings.ShowDialog() == DialogResult.OK)
                {
                    field.CodeExposure  = (DataEntityField.Exposure)fieldSettings.ExposureDropdown.SelectedIndex;
                    field.IsUnique      = fieldSettings.IsUniqueCheckbox.Checked;
                    field.RelatedEntity = fieldSettings.RelatedEntityDropdown.SelectedIndex < 1 ? null : fieldSettings.RelatedEntityDropdown.SelectedItem as DataEntity;
                    if (field.RelatedEntity == null)
                    {
                        field.RelatedField = null;
                        field.CodeHeader   = null;
                    }
                    else if (String.Equals(field.RelatedEntity.ObjectName, "Code", StringComparison.OrdinalIgnoreCase))
                    {
                        field.RelatedField = null;
                        field.CodeHeader   = fieldSettings.RelatedFieldTextbox.Text;
                    }
                    else
                    {
                        field.RelatedField = fieldSettings.RelatedEntityDropdown.SelectedIndex < 1 ? null : fieldSettings.RelatedFieldDropdown.SelectedItem as DataEntityField;
                        field.CodeHeader   = null;
                    }
                    field.Save();
                }
            }
        }