public void AddColumn(DMSNewColumn newColumn, DMSColumn colBefore, string defaultValue) { /* Update DMSRecord metadata */ Metadata.FieldCount++; /* Add the field metadata */ var colIndex = Columns.IndexOf(colBefore) + 1; var newFieldMeta = new DMSRecordFieldMetadata(newColumn, this); Metadata.FieldMetadata.Insert(colIndex, newFieldMeta); /* Add the DMSColumn */ var newDMSCol = new DMSColumn(); newDMSCol.Name = newColumn.FieldName; if (newColumn.DecimalPositions > 0) { newDMSCol.Size = newColumn.FieldLength + "," + newColumn.DecimalPositions; } newDMSCol.Size = newColumn.FieldLength.ToString(); newDMSCol.Type = "CHAR"; Columns.Insert(colIndex, newDMSCol); foreach (var row in Rows) { row.InsertValueString(colIndex, defaultValue); } }
public DMSRecordFieldMetadata(DMSNewColumn newColumn, DMSTable table) { FieldName = newColumn.FieldName; RecordName = table.Name; Unknown1 = 0; VersionNumber = newColumn.VersionNumber; DecimalPositions = newColumn.DecimalPositions; UseEditMask = newColumn.UseEditMask; Unknown2 = 0; FieldType = newColumn.FieldType; FieldFormat = newColumn.FieldFormat; FieldLength = newColumn.FieldLength; DefaultGUIControl = newColumn.DefaultGUIControl; Unknown5 = 0; Unknown6 = 0; }