/// <summary>
 /// Shows the form as a dialog with the specified database field.
 /// </summary>
 /// <param name="owner">The owner window.</param>
 /// <param name="field">The database field.</param>
 /// <returns>The dialog result.</returns>
 public DialogResult ShowDialog(IWin32Window owner, DbField field)
 {
     // Select the server an table.
     this.control.Field = field;
     // Set the dialog name.
     this.Text = "{0} Field Properties".FormatWith(field.DisplayName);
     // Open the dialog.
     return base.ShowDialog(owner);
 }
        /// <summary>
        /// Opens the dialog and compares a database field with the information received from a database server.
        /// </summary>
        /// <param name="owner">The owner window.</param>
        /// <param name="field">The database field.</param>
        /// <param name="name">The field name.</param>
        /// <param name="type">The field type.</param>
        /// <param name="length">The field length.</param>
        /// <param name="precision">The field precision.</param>
        /// <param name="scale">The field scale.</param>
        /// <param name="nullable">The field is nullable.</param>
        /// <returns>The dialog result.</returns>
        public DialogResult ShowDialog(
			IWin32Window owner,
			DbField field,
			string name,
			string type,
			int length,
			int precision,
			int scale,
			bool? nullable)
        {
            // Set the control.
            this.control.Compare(field, name, type, length, precision, scale, nullable);
            // Open the dialog.
            return base.ShowDialog(owner);
        }
        /// <summary>
        /// Compares a database field with the information received from a database server.
        /// </summary>
        /// <param name="field">The database field.</param>
        /// <param name="name">The field name.</param>
        /// <param name="type">The field type.</param>
        /// <param name="length">The field length.</param>
        /// <param name="precision">The field precision.</param>
        /// <param name="scale">The field scale.</param>
        /// <param name="nullable">The field is nullable.</param>
        public void Compare(
			DbField field,
			string name,
			string type,
			int length,
			int precision,
			int scale,
			bool? nullable)
        {
            this.rowName.Cells[0].Value = field.DisplayName;
            this.rowName.Cells[1].Value = name;
            this.rowTypeLocal.Cells[0].Value = field.LocalType;
            this.rowTypeDatabase.Cells[0].Value = field.DatabaseType;
            this.rowTypeDatabase.Cells[1].Value = type;
            this.rowLength.Cells[1].Value = length;
            this.rowPrecision.Cells[1].Value = precision;
            this.rowScale.Cells[1].Value = scale;
            this.rowNullable.Cells[0].Value = field.IsNullable ? "Yes" : "No";
            this.rowNullable.Cells[1].Value = nullable.HasValue ? nullable.Value ? "Yes" : "No" : "(unknown)";
        }
        // 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;
            }
        }
Exemplo n.º 5
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());
 }