// Protected methods. /// <summary> /// An event handler called when a new field has been set. /// </summary> /// <param name="oldField">The old field.</param> /// <param name="newField">The new field.</param> protected virtual void OnFieldSet(DbField oldField, DbField newField) { // If the field has not changed, do nothing. if (oldField == newField) return; if (null != newField) { this.labelTitle.Text = "No field selected"; this.tabControl.Visible = false; } else { this.labelTitle.Text = newField.DisplayName; this.textBoxNameLocal.Text = newField.LocalName; this.textBoxNameDatabase.Text = newField.HasName ? newField.GetDatabaseName() : string.Empty; this.textBoxNameDisplay.Text = newField.DisplayName; this.textBoxTypeLocal.Text = newField.LocalType; this.textBoxTypeDatabase.Text = newField.DatabaseType; this.textBoxDescription.Text = newField.Description; this.checkBoxNullable.Checked = newField.IsNullable; this.checkBoxConfigured.Checked = newField.HasName; this.pictureBox.Image = newField.HasName ? Resources.FieldSuccess_32 : Resources.FieldWarning_32; this.tabControl.Visible = true; } this.tabControl.SelectedTab = this.tabPageGeneral; if (this.Focused) { this.textBoxNameLocal.Select(); this.textBoxNameLocal.SelectionStart = 0; this.textBoxNameLocal.SelectionLength = 0; } }
/// <summary> /// Returns the full database field name for the given table, local field name and default database. /// </summary> /// <param name="field">The field.</param> /// <param name="tableName">The table name.</param> /// <returns>The field name as a string.</returns> private static string GetFieldName(DbField field, string tableName) { // Return the field name made of the database name, schema name, table name, and field name. return "{0}.[{1}]".FormatWith(tableName, field.GetDatabaseName()); }