protected void Form_Load(object sender, EventArgs e) { columnFieldNameTextBox.Text = this.ColumnMapping.FieldName; columnDataTypeTextBox.Text = this.ColumnMapping.DataType; columnPrimaryKeyCheckBox.Checked = this.ColumnMapping.PrimaryKey; columnNullableCheckBox.Checked = this.ColumnMapping.Nullable; columnTreatAsYesNoIndicatorCheckBox.Checked = this.ColumnMapping.TreatAsYesNoIndicator; if (this.ColumnMapping.DataType.Equals(this.ColumnMapping.ContainingProject.FindDataTypeMapping("binary").ApplicationDataType) || this.ColumnMapping.DataType.Equals(this.ColumnMapping.ContainingProject.FindDataTypeMapping("varbinary").ApplicationDataType)) { foreach (ColumnMapping cm in this.ColumnMapping.TableMapping.ColumnMappings) { if (cm.DataType.Equals(this.ColumnMapping.ContainingProject.FindDataTypeMapping("binary").ApplicationDataType) || cm.DataType.Equals(this.ColumnMapping.ContainingProject.FindDataTypeMapping("varbinary").ApplicationDataType)) { encryptionVectorColumnComboBox.Items.Add(cm); } } if (!string.IsNullOrEmpty(this.ColumnMapping.EncryptionVectorColumnName)) { ColumnMapping encryptionVectorColumn = this.ColumnMapping.TableMapping.FindColumnMapping(this.ColumnMapping.EncryptionVectorColumnName); encryptionPropertyNameTextBox.Text = this.ColumnMapping.DecryptionPropertyName; if (encryptionVectorColumnComboBox.Items.Contains(encryptionVectorColumn)) { encryptionVectorColumnComboBox.SelectedItem = encryptionVectorColumn; } else { MessageBox.Show("The encryption vector column for this encrypted column could not be located."); } encryptionCheckBox.Checked = true; } else { encryptionCheckBox.Checked = false; } encryptionCheckBox.Enabled = true; } else { encryptionCheckBox.Enabled = false; } foreach (TableMapping tm in this.ColumnMapping.ContainingProject.TableMappings) { foreach (ColumnMapping cm in tm.ColumnMappings) { if (cm.EnumerationMapping != null) { referencedEnumerationComboBox.Items.Add(cm.EnumerationMapping); } } } if (this.ColumnMapping.EnumerationMapping != null) { if (this.ColumnMapping.EnumerationMapping.IsReference) { EnumerationMapping referencedEnumerationMapping = this.ColumnMapping.EnumerationMapping.GetReferencedEnumerationMapping(); enumerationIsReferenceCheckBox.Checked = true; if (referencedEnumerationMapping != null && referencedEnumerationComboBox.Items.Contains(referencedEnumerationMapping)) { referencedEnumerationComboBox.SelectedItem = referencedEnumerationMapping; } else { MessageBox.Show("The referenced enumeration mapping '" + referencedEnumerationMapping.Name + "' could not be located."); } } else { enumerationIsReferenceCheckBox.Checked = false; enumerationNameTextBox.Text = this.ColumnMapping.EnumerationMapping.Name; foreach (EnumerationValueMapping value in this.ColumnMapping.EnumerationMapping.Values) { AddEnumerationValue(value); } } enumerationCheckBox.Checked = true; } else { enumerationCheckBox.Checked = false; } editAnnotations.Annotations = this.ColumnMapping.Annotations; editAttributes.Attributes = this.ColumnMapping.Attributes; this.IsLoaded = true; }
private void enumTypeComboBox_SelectedIndexChanged(object sender, EventArgs e) { EnumerationMapping enumerationMapping = GetSelectedEnumerationMapping(); nullableDataTypeCheckBox.Checked = (enumerationMapping != null && enumerationMapping.ColumnMapping.Nullable); }
public void SaveOptions() { if (!IsLoaded) { return; } this.ColumnMapping.FieldName = columnFieldNameTextBox.Text; this.ColumnMapping.PrimaryKey = columnPrimaryKeyCheckBox.Checked; this.ColumnMapping.DataType = columnDataTypeTextBox.Text; this.ColumnMapping.Nullable = columnNullableCheckBox.Checked; this.ColumnMapping.TreatAsYesNoIndicator = columnTreatAsYesNoIndicatorCheckBox.Checked; if (encryptionCheckBox.Checked && !string.IsNullOrEmpty(encryptionPropertyNameTextBox.Text) && encryptionVectorColumnComboBox.SelectedItem != null) { this.ColumnMapping.DecryptionPropertyName = encryptionPropertyNameTextBox.Text; this.ColumnMapping.EncryptionVectorColumnName = ((ColumnMapping)encryptionVectorColumnComboBox.SelectedItem).ColumnName; } else { this.ColumnMapping.DecryptionPropertyName = null; this.ColumnMapping.EncryptionVectorColumnName = null; } if (enumerationCheckBox.Checked) { if (enumerationIsReferenceCheckBox.Checked && referencedEnumerationComboBox.SelectedIndex >= 0) { EnumerationMapping referencedEnumerationMapping = (EnumerationMapping)referencedEnumerationComboBox.SelectedItem; this.ColumnMapping.EnumerationMapping = new EnumerationMapping(referencedEnumerationMapping); this.ColumnMapping.EnumerationMapping.JoinToColumnMapping(this.ColumnMapping); } else if (!enumerationIsReferenceCheckBox.Checked) { this.ColumnMapping.EnumerationMapping = new EnumerationMapping(enumerationNameTextBox.Text, null, null, null); foreach (EnumerationValueMapping item in enumerationValuesListBox.Items) { this.ColumnMapping.EnumerationMapping.Values.Add(item); } this.ColumnMapping.EnumerationMapping.JoinToColumnMapping(this.ColumnMapping); //Update any referenced enumerations. foreach (TableMapping tm in this.ColumnMapping.ContainingProject.TableMappings) { foreach (ColumnMapping cm in tm.ColumnMappings) { if (cm.EnumerationMapping != null && cm.EnumerationMapping.References(this.ColumnMapping.EnumerationMapping)) { cm.EnumerationMapping.UpdateReference(this.ColumnMapping.EnumerationMapping); } } } } } else { this.ColumnMapping.EnumerationMapping = null; } this.ColumnMapping.Annotations = new List <Annotation <ColumnMapping> >(editAnnotations.Annotations); this.ColumnMapping.Attributes = new List <Attribute <ColumnMapping> >(editAttributes.Attributes); OnSaved(); }