Example #1
0
        /// <summary>
        /// Updates a DDLColumnOfLegalValues saved in the database.
        /// </summary>
        /// <param name="column">Column to be updated</param>
        public void UpdateGridColumn(DDLColumnOfLegalValues column)
        {
            #region InputValidation
            if (column == null)
            {
                throw new ArgumentNullException("DDLColumnOfLegalValues");
            }
            #endregion
            try
            {
                Query updateQuery = db.CreateQuery("update [metaGridColumns] set [Name] = @Name, [TextColumnName] = @TextColumnName, [SourceTableName] = @SourceTableName, [Width] = @Width, [Position] = @Position, " +
                    "[FieldTypeId] = @FieldTypeId, [Text] = @Text, [ShouldRepeatLast] = @ShouldRepeatLast, [IsExclusiveTable] = @IsExclusiveTable, [IsRequired] = @IsRequired, [IsReadOnly] = @IsReadOnly, [Sort] = @Sort " +
                    "where [GridColumnId] = @GridColumnId");

                updateQuery.Parameters.Add(new QueryParameter("@Name", DbType.String, column.Name));
                updateQuery.Parameters.Add(new QueryParameter("@TextColumnName", DbType.String, column.TextColumnName));
                updateQuery.Parameters.Add(new QueryParameter("@SourceTableName", DbType.String, column.SourceTableName));
                updateQuery.Parameters.Add(new QueryParameter("@Width", DbType.Int32, column.Width));
                updateQuery.Parameters.Add(new QueryParameter("@Position", DbType.Int32, column.Position));
                updateQuery.Parameters.Add(new QueryParameter("@FieldTypeId", DbType.Int32, (int)column.GridColumnType));
                updateQuery.Parameters.Add(new QueryParameter("@Text", DbType.String, column.Text));
                updateQuery.Parameters.Add(new QueryParameter("@ShouldRepeatLast", DbType.Boolean, column.ShouldRepeatLast));
                updateQuery.Parameters.Add(new QueryParameter("@IsExclusiveTable", DbType.Boolean, column.IsExclusiveTable));
                updateQuery.Parameters.Add(new QueryParameter("@IsReadOnly", DbType.Boolean, column.IsReadOnly));
                updateQuery.Parameters.Add(new QueryParameter("@IsRequired", DbType.Boolean, column.IsRequired));
                updateQuery.Parameters.Add(new QueryParameter("@Sort", DbType.Boolean, column.ShouldSort));

                updateQuery.Parameters.Add(new QueryParameter("@GridColumnId", DbType.Int32, column.Id));

                db.ExecuteNonQuery(updateQuery);
            }
            catch (Exception ex)
            {
                throw new GeneralException("Could not update grid column in the database", ex);
            }
            finally
            {

            }
        }
Example #2
0
        /// <summary>
        /// Creates a new <see cref="Epi.Fields.DDLColumnOfLegalValues"/> in <see cref="Epi.Fields.GridField"/>.
        /// </summary>
        /// <param name="column"><see cref="Epi.Fields.DDLColumnOfLegalValues"/></param>
        /// <returns>Id of the newly created column.</returns>
        public int CreateGridColumn(DDLColumnOfLegalValues column)
        {
            try
            {
                Query insertQuery = db.CreateQuery("insert into metaGridColumns([Name], [TextColumnName], [SourceTableName], [Width], [Position], [FieldTypeId], [Text], [ShouldRepeatLast], [IsExclusiveTable], [IsReadOnly], [IsRequired], [FieldId], [Sort]) " +
                    "values (@Name, @TextColumnName, @SourceTableName, @Width, @Position, @FieldTypeId, @Text, @ShouldRepeatLast, @IsExclusiveTable, @IsReadOnly, @IsRequired, @FieldId, @Sort)");

                insertQuery.Parameters.Add(new QueryParameter("@Name", DbType.String, column.Name));
                insertQuery.Parameters.Add(new QueryParameter("@TextColumnName", DbType.String, column.TextColumnName));
                insertQuery.Parameters.Add(new QueryParameter("@SourceTableName", DbType.String, column.SourceTableName));
                insertQuery.Parameters.Add(new QueryParameter("@Width", DbType.Int32, column.Width));
                insertQuery.Parameters.Add(new QueryParameter("@Position", DbType.Int32, column.Position));
                insertQuery.Parameters.Add(new QueryParameter("@FieldTypeId", DbType.Int32, (int)column.GridColumnType));
                insertQuery.Parameters.Add(new QueryParameter("@Text", DbType.String, column.Text));
                insertQuery.Parameters.Add(new QueryParameter("@ShouldRepeatLast", DbType.Boolean, column.ShouldRepeatLast));
                insertQuery.Parameters.Add(new QueryParameter("@IsExclusiveTable", DbType.Boolean, column.IsExclusiveTable));
                insertQuery.Parameters.Add(new QueryParameter("@IsReadOnly", DbType.Boolean, column.IsReadOnly));
                insertQuery.Parameters.Add(new QueryParameter("@IsRequired", DbType.Boolean, column.IsRequired));
                insertQuery.Parameters.Add(new QueryParameter("@FieldId", DbType.Int32, column.Grid.Id));
                insertQuery.Parameters.Add(new QueryParameter("@Sort", DbType.Boolean, column.ShouldSort));

                db.ExecuteNonQuery(insertQuery);
                return GetMaxGridColumnId(column.Grid.Id);
            }
            catch (Exception ex)
            {
                throw new GeneralException("Could not create grid column in the database", ex);
            }
            finally
            {

            }
        }
Example #3
0
        /// <summary>
        /// Updates column data 
        /// </summary>
        private void UpdateColumnData()
        {
            currentGridColumn = hti.Column + iColumnOffset;
            MetaFieldType metaFieldTypeEnum = (MetaFieldType)cmbFieldType.SelectedValue;

            switch (metaFieldTypeEnum)
            {
                case MetaFieldType.Text:
                    TextColumn textColumn;
                    textColumn = new TextColumn(grid);
                    textColumn.Name = txtFieldName.Text;
                    textColumn.Text = txtColumnName.Text;
                    textColumn.ShouldRepeatLast = cbxRepeatLast.Checked;
                    textColumn.IsRequired = cbxRequired.Checked;
                    textColumn.IsReadOnly = cbxReadOnly.Checked;
                    textColumn.Position = hti.Column;
                    textColumn.Width = this.dgColumns.TableStyles["GridColumns"].GridColumnStyles[hti.Column].Width;

                    if (!string.IsNullOrEmpty(cmbSize.Text))
                    {
                        textColumn.Size = int.Parse(cmbSize.Text);
                    }
                    textColumn.Grid = grid;
                    gridColumns.RemoveAt(currentGridColumn);
                    gridColumns.Insert(currentGridColumn, textColumn);
                    UpdateColumnStyle(currentGridColumn, textColumn);
                    break;

                case MetaFieldType.Number:
                    NumberColumn numberColumn;
                    numberColumn = new NumberColumn(grid);
                    numberColumn.Name = txtFieldName.Text;
                    numberColumn.Text = txtColumnName.Text;
                    numberColumn.ShouldRepeatLast = cbxRepeatLast.Checked;
                    numberColumn.IsRequired = cbxRequired.Checked;
                    numberColumn.IsReadOnly = cbxReadOnly.Checked;
                    numberColumn.Position = hti.Column;
                    numberColumn.Width = this.dgColumns.TableStyles["GridColumns"].GridColumnStyles[hti.Column].Width; // 500;
                    numberColumn.Pattern = cmbPattern.Text;
                    if (cbxRange.Checked)
                    {
                        numberColumn.Lower = txtLower.Text;
                        numberColumn.Upper = txtUpper.Text;
                    }

                    gridColumns.RemoveAt(currentGridColumn);
                    gridColumns.Insert(currentGridColumn, numberColumn);
                    UpdateColumnStyle(currentGridColumn, numberColumn);
                    break;

                case MetaFieldType.PhoneNumber:
                    PhoneNumberColumn phoneNumberColumn;
                    phoneNumberColumn = new PhoneNumberColumn(grid);
                    phoneNumberColumn.Name = txtFieldName.Text;
                    phoneNumberColumn.Text = txtColumnName.Text;
                    phoneNumberColumn.ShouldRepeatLast = cbxRepeatLast.Checked;
                    phoneNumberColumn.IsRequired = cbxRequired.Checked;
                    phoneNumberColumn.IsReadOnly = cbxReadOnly.Checked;
                    phoneNumberColumn.Position = hti.Column;
                    phoneNumberColumn.Width = this.dgColumns.TableStyles["GridColumns"].GridColumnStyles[hti.Column].Width;
                    phoneNumberColumn.Pattern = cmbPattern.Text;
                    gridColumns.RemoveAt(currentGridColumn);
                    gridColumns.Insert(currentGridColumn, phoneNumberColumn);
                    UpdateColumnStyle(currentGridColumn, phoneNumberColumn);
                    break;

                case MetaFieldType.Date:
                case MetaFieldType.Time:
                case MetaFieldType.DateTime:

                    ContiguousColumn column;
                    switch (metaFieldTypeEnum)
                    {
                        case MetaFieldType.Date:
                            column = new DateColumn(grid);
                            break;
                        case MetaFieldType.Time:
                            column = new TimeColumn(grid);
                            break;
                        case MetaFieldType.DateTime:
                            column = new DateTimeColumn(grid);
                            break;
                        default:
                            column = new DateColumn(grid);
                            break;
                    }

                    column.Name = txtFieldName.Text;
                    column.Text = txtColumnName.Text;
                    column.ShouldRepeatLast = cbxRepeatLast.Checked;
                    column.IsRequired = cbxRequired.Checked;
                    column.IsReadOnly = cbxReadOnly.Checked;
                    column.Position = hti.Column;
                    column.Width = this.dgColumns.TableStyles["GridColumns"].GridColumnStyles[hti.Column].Width; // 500;
                    column.Pattern = cmbPattern.Text;
                    if (cbxRange.Checked)
                    {
                        column.Lower = txtLower.Text;
                        column.Upper = txtUpper.Text;
                    }
                    gridColumns.RemoveAt(currentGridColumn);
                    gridColumns.Insert(currentGridColumn, column);
                    UpdateColumnStyle(currentGridColumn, column);
                    break;

                case MetaFieldType.CommentLegal:
                    DDLColumnOfCommentLegal commentLegalColumn;
                    commentLegalColumn = new DDLColumnOfCommentLegal(grid);

                    commentLegalColumn.Name = txtFieldName.Text;
                    commentLegalColumn.Text = txtColumnName.Text;
                    commentLegalColumn.ShouldRepeatLast = cbxRepeatLast.Checked;
                    commentLegalColumn.IsRequired = cbxRequired.Checked;
                    commentLegalColumn.IsReadOnly = cbxReadOnly.Checked;
                    commentLegalColumn.IsUniqueField = cbxUniqueField.Checked;
                    commentLegalColumn.Position = hti.Column;
                    commentLegalColumn.Width = this.dgColumns.TableStyles["GridColumns"].GridColumnStyles[hti.Column].Width;
                    if (txtDataSource.Text.Length > 4)
                    {
                        commentLegalColumn.SourceTableName = txtDataSource.Text.Split(new string[] { "::" }, StringSplitOptions.RemoveEmptyEntries)[0].Trim();
                        commentLegalColumn.TextColumnName = txtDataSource.Text.Split(new string[] { "::" }, StringSplitOptions.RemoveEmptyEntries)[1].Trim();
                    }
                    commentLegalColumn.Grid = grid;
                    gridColumns.RemoveAt(currentGridColumn);
                    gridColumns.Insert(currentGridColumn, commentLegalColumn);
                    UpdateColumnStyle(currentGridColumn, commentLegalColumn);
                    btnDataSource.Enabled = true;
                    cbxUniqueField.Enabled = true;
                    break;

                case MetaFieldType.LegalValues:
                    DDLColumnOfLegalValues legalValuesColumn;
                    legalValuesColumn = new DDLColumnOfLegalValues(grid);
                    legalValuesColumn.Name = txtFieldName.Text;
                    legalValuesColumn.Text = txtColumnName.Text;
                    legalValuesColumn.ShouldRepeatLast = cbxRepeatLast.Checked;
                    legalValuesColumn.IsRequired = cbxRequired.Checked;
                    legalValuesColumn.IsReadOnly = cbxReadOnly.Checked;
                    legalValuesColumn.IsUniqueField = cbxUniqueField.Checked;
                    legalValuesColumn.Position = hti.Column;
                    legalValuesColumn.Width = this.dgColumns.TableStyles["GridColumns"].GridColumnStyles[hti.Column].Width;
                    if (txtDataSource.Text.Length > 4)
                    {
                        legalValuesColumn.SourceTableName = txtDataSource.Text.Split(new string[] { "::" }, StringSplitOptions.RemoveEmptyEntries)[0].Trim();
                        legalValuesColumn.TextColumnName = txtDataSource.Text.Split(new string[] { "::" }, StringSplitOptions.RemoveEmptyEntries)[1].Trim();
                    }
                    legalValuesColumn.Grid = grid;
                    gridColumns.RemoveAt(currentGridColumn);
                    gridColumns.Insert(currentGridColumn, legalValuesColumn);
                    UpdateColumnStyle(currentGridColumn, legalValuesColumn);
                    btnDataSource.Enabled = true;
                    cbxUniqueField.Enabled = true;
                    break;

                case MetaFieldType.Checkbox:
                    CheckboxColumn checkboxColumn = new CheckboxColumn(grid);
                    checkboxColumn.Name = txtFieldName.Text;
                    checkboxColumn.Text = txtColumnName.Text;
                    checkboxColumn.ShouldRepeatLast = cbxRepeatLast.Checked;
                    checkboxColumn.IsRequired = cbxRequired.Checked;
                    checkboxColumn.IsReadOnly = cbxReadOnly.Checked;
                    checkboxColumn.Position = gridColumnsTable.Columns[txtFieldName.Text].Ordinal;
                    checkboxColumn.Width = this.dgColumns.TableStyles["GridColumns"].PreferredColumnWidth;
                    checkboxColumn.Grid = grid;
                    gridColumns.RemoveAt(currentGridColumn);
                    gridColumns.Insert(currentGridColumn, checkboxColumn);
                    UpdateColumnStyle(currentGridColumn, checkboxColumn);
                    btnDataSource.Enabled = true;
                    cbxUniqueField.Enabled = true;
                    break;

                case MetaFieldType.YesNo:
                    YesNoColumn yesNoColumn;
                    yesNoColumn = new YesNoColumn(grid);
                    yesNoColumn.Name = txtFieldName.Text;
                    yesNoColumn.Text = txtColumnName.Text;
                    yesNoColumn.ShouldRepeatLast = cbxRepeatLast.Checked;
                    yesNoColumn.IsRequired = cbxRequired.Checked;
                    yesNoColumn.IsReadOnly = cbxReadOnly.Checked;
                    yesNoColumn.IsUniqueField = cbxUniqueField.Checked;
                    yesNoColumn.Position = hti.Column;
                    yesNoColumn.Width = this.dgColumns.TableStyles["GridColumns"].GridColumnStyles[hti.Column].Width;

                    if (txtDataSource.Text.Length > 4)
                    {
                        yesNoColumn.SourceTableName = txtDataSource.Text.Split(new string[] { "::" }, StringSplitOptions.RemoveEmptyEntries)[0].Trim();
                        yesNoColumn.TextColumnName = txtDataSource.Text.Split(new string[] { "::" }, StringSplitOptions.RemoveEmptyEntries)[1].Trim();
                    }

                    yesNoColumn.Grid = grid;
                    gridColumns.RemoveAt(currentGridColumn);
                    gridColumns.Insert(currentGridColumn, yesNoColumn);
                    UpdateColumnStyle(currentGridColumn, yesNoColumn);
                    btnDataSource.Enabled = true;
                    cbxUniqueField.Enabled = true;
                    break;
            }
        }
Example #4
0
 /// <summary>
 /// Save column data 
 /// </summary>
 private void SaveColumnData()
 {
     switch ((MetaFieldType)cmbFieldType.SelectedValue)
     {
         case MetaFieldType.Text:
             TextColumn textColumn = new TextColumn(grid);
             textColumn.Name = txtFieldName.Text;
             textColumn.Text = txtColumnName.Text;
             textColumn.ShouldRepeatLast = cbxRepeatLast.Checked;
             textColumn.IsRequired = cbxRequired.Checked;
             textColumn.IsReadOnly = cbxReadOnly.Checked;
             textColumn.Position = gridColumnsTable.Columns[txtFieldName.Text].Ordinal;//gridColumnsTable.Columns.Count;
             textColumn.Width = this.dgColumns.TableStyles["GridColumns"].PreferredColumnWidth;
             if (!string.IsNullOrEmpty(cmbSize.Text))
             {
                 textColumn.Size = int.Parse(cmbSize.Text);
             }
             textColumn.Grid = grid;
             gridColumns.Add(textColumn);
             SetColumnStyle(textColumn);
             break;
         case MetaFieldType.Number:
             NumberColumn numberColumn = new NumberColumn(grid);
             numberColumn.Name = txtFieldName.Text;
             numberColumn.Text = txtColumnName.Text;
             numberColumn.ShouldRepeatLast = cbxRepeatLast.Checked;
             numberColumn.IsRequired = cbxRequired.Checked;
             numberColumn.IsReadOnly = cbxReadOnly.Checked;
             numberColumn.Position = gridColumnsTable.Columns[txtFieldName.Text].Ordinal;
             numberColumn.Width = this.dgColumns.TableStyles["GridColumns"].PreferredColumnWidth;
             numberColumn.Pattern = cmbPattern.Text;
             if (cbxRange.Checked)
             {
                 numberColumn.Lower = txtLower.Text;
                 numberColumn.Upper = txtUpper.Text;
             }
             gridColumns.Add(numberColumn);
             SetColumnStyle(numberColumn);
             break;
         case MetaFieldType.PhoneNumber:
             PhoneNumberColumn phoneNumberColumn = new PhoneNumberColumn(grid);
             phoneNumberColumn.Name = txtFieldName.Text;
             phoneNumberColumn.Text = txtColumnName.Text;
             phoneNumberColumn.ShouldRepeatLast = cbxRepeatLast.Checked;
             phoneNumberColumn.IsRequired = cbxRequired.Checked;
             phoneNumberColumn.IsReadOnly = cbxReadOnly.Checked;
             phoneNumberColumn.Position = gridColumnsTable.Columns[txtFieldName.Text].Ordinal;
             phoneNumberColumn.Width = this.dgColumns.TableStyles["GridColumns"].PreferredColumnWidth;
             phoneNumberColumn.Pattern = cmbPattern.Text;
             gridColumns.Add(phoneNumberColumn);
             SetColumnStyle(phoneNumberColumn);
             break;
         case MetaFieldType.Date:
             SetContiguousColumnProperties(new DateColumn(grid));
             break;
         case MetaFieldType.Time:
             SetContiguousColumnProperties(new TimeColumn(grid));
             break;
         case MetaFieldType.DateTime:
             SetContiguousColumnProperties(new DateTimeColumn(grid));
             break;
         case MetaFieldType.CommentLegal:
             DDLColumnOfCommentLegal commentLegalColumn = new DDLColumnOfCommentLegal(grid);
             commentLegalColumn.ShouldSort = shouldSort;
             commentLegalColumn.SourceTableName = sourceTableName;
             commentLegalColumn.TextColumnName = textColumnName;
             commentLegalColumn.IsExclusiveTable = isExclusiveTable;
             commentLegalColumn.Name = txtFieldName.Text;
             commentLegalColumn.Text = txtColumnName.Text;
             commentLegalColumn.ShouldRepeatLast = cbxRepeatLast.Checked;
             commentLegalColumn.IsRequired = cbxRequired.Checked;
             commentLegalColumn.IsReadOnly = cbxReadOnly.Checked;
             commentLegalColumn.IsUniqueField = cbxUniqueField.Checked;
             commentLegalColumn.Position = gridColumnsTable.Columns[txtFieldName.Text].Ordinal;
             commentLegalColumn.Width = this.dgColumns.TableStyles["GridColumns"].PreferredColumnWidth;
             commentLegalColumn.Grid = grid;
             gridColumns.Add(commentLegalColumn);
             SetColumnStyle(commentLegalColumn);
             break;
         case MetaFieldType.LegalValues:
             DDLColumnOfLegalValues legalValuesColumn = new DDLColumnOfLegalValues(grid);
             legalValuesColumn.ShouldSort = shouldSort;
             legalValuesColumn.SourceTableName = sourceTableName;
             legalValuesColumn.TextColumnName = textColumnName;
             legalValuesColumn.IsExclusiveTable = isExclusiveTable;
             legalValuesColumn.Name = txtFieldName.Text;
             legalValuesColumn.Text = txtColumnName.Text;
             legalValuesColumn.ShouldRepeatLast = cbxRepeatLast.Checked;
             legalValuesColumn.IsRequired = cbxRequired.Checked;
             legalValuesColumn.IsReadOnly = cbxReadOnly.Checked;
             legalValuesColumn.IsUniqueField = cbxUniqueField.Checked;
             legalValuesColumn.Position = gridColumnsTable.Columns[txtFieldName.Text].Ordinal;
             legalValuesColumn.Width = this.dgColumns.TableStyles["GridColumns"].PreferredColumnWidth; ;
             legalValuesColumn.Grid = grid;
             gridColumns.Add(legalValuesColumn);
             SetColumnStyle(legalValuesColumn);
             break;
         case MetaFieldType.Checkbox:
             CheckboxColumn checkboxColumn = new CheckboxColumn(grid);
             checkboxColumn.Name = txtFieldName.Text;
             checkboxColumn.Text = txtColumnName.Text;
             checkboxColumn.ShouldRepeatLast = cbxRepeatLast.Checked;
             checkboxColumn.IsRequired = cbxRequired.Checked;
             checkboxColumn.IsReadOnly = cbxReadOnly.Checked;
             checkboxColumn.Position = gridColumnsTable.Columns[txtFieldName.Text].Ordinal;//gridColumnsTable.Columns.Count;
             checkboxColumn.Width = this.dgColumns.TableStyles["GridColumns"].PreferredColumnWidth;
             checkboxColumn.Grid = grid;
             gridColumns.Add(checkboxColumn);
             SetColumnStyle(checkboxColumn);
             break;
         case MetaFieldType.YesNo:
             YesNoColumn yesNoColumn = new YesNoColumn(grid);
             yesNoColumn.ShouldSort = shouldSort;
             yesNoColumn.SourceTableName = sourceTableName;
             yesNoColumn.TextColumnName = textColumnName;
             yesNoColumn.IsExclusiveTable = isExclusiveTable;
             yesNoColumn.Name = txtFieldName.Text;
             yesNoColumn.Text = txtColumnName.Text;
             yesNoColumn.ShouldRepeatLast = cbxRepeatLast.Checked;
             yesNoColumn.IsRequired = cbxRequired.Checked;
             yesNoColumn.IsReadOnly = cbxReadOnly.Checked;
             yesNoColumn.IsUniqueField = cbxUniqueField.Checked;
             yesNoColumn.Position = gridColumnsTable.Columns[txtFieldName.Text].Ordinal;
             yesNoColumn.Width = this.dgColumns.TableStyles["GridColumns"].PreferredColumnWidth; ;
             yesNoColumn.Grid = grid;
             gridColumns.Add(yesNoColumn);
             SetColumnStyle(yesNoColumn);
             break;
     }
 }
Example #5
0
        /// <summary>
        /// Opens Dialog for Legal Values or Comment Legal column.
        /// </summary>
        /// <param name="sender">Object that fired the event</param>
        /// <param name="e">.NET supplied event args</param>
        private void btnDataSource_Click(object sender, EventArgs e)
        {
            if (hti != null)
            {
                if (hti.Type == DataGrid.HitTestType.ColumnHeader)
                {
                    object currentColumn = gridColumns[currentGridColumn];
                    currentGridColumn = hti.Column + iColumnOffset;

                    LegalValuesDialog sourceTableDialog = null;

                    switch ((int)cmbFieldType.SelectedValue)
                    {
                        case ((int)MetaFieldType.CommentLegal):
                            DDLColumnOfCommentLegal dDLColumnOfCommentLegal = new Epi.Fields.DDLColumnOfCommentLegal((GridField)Grid);
                            if (currentColumn is DDLColumnOfCommentLegal)  dDLColumnOfCommentLegal = (DDLColumnOfCommentLegal)currentColumn;
                            sourceTableDialog = new CommentLegalDialog(dDLColumnOfCommentLegal, form, txtFieldName.Text, page);

                            break;

                        case ((int)MetaFieldType.LegalValues):
                            DDLColumnOfLegalValues dDLColumnOfLegalValues = new Epi.Fields.DDLColumnOfLegalValues((GridField)Grid);
                            if (currentColumn is DDLColumnOfLegalValues) dDLColumnOfLegalValues = (DDLColumnOfLegalValues)currentColumn;
                            sourceTableDialog = new LegalValuesDialog(dDLColumnOfLegalValues, form, txtFieldName.Text, page);
                            break;
                    }

                    if (sourceTableDialog != null)
                    {
                        ShowDDLFieldDialog(sourceTableDialog);
                        currentColumn = ((LegalValuesDialog)sourceTableDialog).DdlColumn;
                    }
                }
                else
                {
                    if (cmbFieldType.SelectedValue.Equals((int)MetaFieldType.CommentLegal))
                    {
                        TableBasedDropDownColumn column = new DDLColumnOfCommentLegal(grid);
                        CommentLegalDialog commentLegal = new CommentLegalDialog(column, form, txtFieldName.Text, page);
                        ShowDDLFieldDialog(commentLegal);
                    }

                    if (cmbFieldType.SelectedValue.Equals((int)MetaFieldType.LegalValues))
                    {
                        TableBasedDropDownColumn column = new DDLColumnOfLegalValues(grid);
                        LegalValuesDialog legalValues = new LegalValuesDialog(column, form, txtFieldName.Text, page);
                        ShowDDLFieldDialog(legalValues);
                    }
                }
            }
            else
            {
                if (cmbFieldType.SelectedValue.Equals((int)MetaFieldType.CommentLegal))
                {
                    TableBasedDropDownColumn column = new DDLColumnOfCommentLegal(grid);
                    CommentLegalDialog commentLegal = new CommentLegalDialog(column, form, txtFieldName.Text, page);
                    ShowDDLFieldDialog(commentLegal);
                }

                if (cmbFieldType.SelectedValue.Equals((int)MetaFieldType.LegalValues))
                {
                    TableBasedDropDownColumn column = new DDLColumnOfLegalValues(grid);
                    LegalValuesDialog legalValues = new LegalValuesDialog(column, form, txtFieldName.Text, page);
                    ShowDDLFieldDialog(legalValues);
                }
            }
            btnSaveColumn.Enabled = (!String.IsNullOrEmpty(txtDataSource.Text));
        }