Beispiel #1
0
        private void AddField(FieldBaseType field, Table tb)
        {
            if (field.GetType() == typeof(TextField))
            {
                AddTextCol(field, tb);
                return;
            }

            if (field.GetType() == typeof(LookupField))
            {
                AddTextCol(field, tb);
                return;
            }

            if (field.GetType() == typeof(DateField))
            {
                AddDateCol(field, tb);
                return;
            }

            if (field.GetType() == typeof(NumberField))
            {
                AddNumberCol(field, tb);
                return;
            }

            if (field.GetType() == typeof(BoolField))
            {
                AddBoolCol(field, tb);
                return;
            }
            if (field.GetType() == typeof(EnumField))
            {
                AddEnumCol(field, tb);
                return;
            }
            if (field.GetType() == typeof(StatusField))
            {
                AddEnumCol(field, tb);
                return;
            }
        }
Beispiel #2
0
        private Element CreateFieldElement(FieldBaseType obj)
        {
            if (obj.GetType() == typeof(EnumField))
            {
                EnumField field     = obj as EnumField;
                Element   enumField = new Element
                {
                    ctrlType           = ctlEnum,
                    label              = field.Label,
                    enumOptions        = field.Options,
                    defaultValue       = field.DefaultValue ?? "",
                    defaultSearchValue = field.DefaultSearchValue ?? "",
                    readOnly           = field.ReadOnly,
                    required           = field.Required,
                    columnName         = field.ColumnName,
                    searchable         = field.Searchable,
                    modifyEnable       = field.ModifyEnabled,
                    hiddenField        = field.HiddenField,
                    clientId           = field.ClientId,
                    resultVisibility   = field.ResultVisibility,
                    resultPosition     = field.ResultPosition,
                    multipleValues     = field.MultipleValues
                };
                if (field.Layout != null)
                {
                    enumField.rows    = field.Layout.RowNumber;
                    enumField.columns = field.Layout.ColNumber;
                }

                return(enumField);
            }

            if (obj.GetType() == typeof(StatusField))
            {
                StatusField field       = obj as StatusField;
                Element     statusField = new Element
                {
                    ctrlType           = ctlStatus,
                    label              = field.Label,
                    statusType         = field.Options,
                    defaultValue       = field.DefaultValue ?? "",
                    defaultSearchValue = field.DefaultSearchValue ?? "",
                    readOnly           = field.ReadOnly,
                    required           = field.Required,
                    columnName         = field.ColumnName,
                    searchable         = field.Searchable,
                    modifyEnable       = field.ModifyEnabled,
                    hiddenField        = field.HiddenField,
                    clientId           = field.ClientId,
                    resultVisibility   = field.ResultVisibility,
                    resultPosition     = field.ResultPosition
                };
                if (field.Layout != null)
                {
                    statusField.rows    = field.Layout.RowNumber;
                    statusField.columns = field.Layout.ColNumber;
                }

                return(statusField);
            }

            if (obj.GetType() == typeof(TextField))
            {
                TextField field     = obj as TextField;
                Element   textField = new Element
                {
                    ctrlType           = ctlText,
                    label              = field.Label,
                    multiLine          = field.Multiline,
                    HTMLEnable         = field.HTMLEnable,
                    defaultValue       = field.DefaultValue ?? "",
                    defaultSearchValue = field.DefaultSearchValue ?? "",
                    readOnly           = field.ReadOnly,
                    required           = field.Required,
                    columnName         = field.ColumnName,
                    searchable         = field.Searchable,
                    modifyEnable       = field.ModifyEnabled,
                    hiddenField        = field.HiddenField,
                    clientId           = field.ClientId,
                    resultVisibility   = field.ResultVisibility,
                    resultPosition     = field.ResultPosition
                };
                if (field.Layout != null)
                {
                    textField.rows    = field.Layout.RowNumber;
                    textField.columns = field.Layout.ColNumber;
                }

                return(textField);
            }

            if (obj.GetType() == typeof(DateField))
            {
                DateField field   = obj as DateField;
                Element   element = new Element
                {
                    ctrlType           = ctlDate,
                    label              = field.Label,
                    defaultSearchValue = field.DefaultSearchValue.ToString("dd/MM/yyyy") ?? "",
                    restrictedYear     = field.RestrictedYear,
                    enableDefaultDate  = field.DefaultTodayEnabled,
                    readOnly           = field.ReadOnly,
                    required           = field.Required,
                    columnName         = field.ColumnName,
                    searchable         = field.Searchable,
                    modifyEnable       = field.ModifyEnabled,
                    hiddenField        = field.HiddenField,
                    clientId           = field.ClientId,
                    resultVisibility   = field.ResultVisibility,
                    resultPosition     = field.ResultPosition
                };

                element.defaultValue = "";
                if (field.DefaultValueSpecified && field.DefaultValue != DateTime.MinValue)
                {
                    element.defaultValue = field.DefaultValue.ToString("dd/MM/yyyy");
                }

                if (field.Layout != null)
                {
                    element.rows    = field.Layout.RowNumber;
                    element.columns = field.Layout.ColNumber;
                }

                return(element);
            }

            if (obj.GetType() == typeof(NumberField))
            {
                NumberField field       = obj as NumberField;
                Element     numberField = new Element
                {
                    ctrlType     = ctlNumber,
                    label        = field.Label,
                    defaultValue = field.DefaultValueSpecified == true?field.DefaultValue.ToString() : "",
                                       readOnly         = field.ReadOnly,
                                       required         = field.Required,
                                       columnName       = field.ColumnName,
                                       searchable       = field.Searchable,
                                       modifyEnable     = field.ModifyEnabled,
                                       hiddenField      = field.HiddenField,
                                       clientId         = field.ClientId,
                                       resultVisibility = field.ResultVisibility,
                                       resultPosition   = field.ResultPosition,
                                       format           = field.Format
                };
                if (field.MinValueSpecified)
                {
                    numberField.minValue = field.MinValue;
                }
                if (field.MaxValueSpecified)
                {
                    numberField.maxValue = field.MaxValue;
                }
                if (field.Layout != null)
                {
                    numberField.rows    = field.Layout.RowNumber;
                    numberField.columns = field.Layout.ColNumber;
                }
                return(numberField);
            }

            if (obj.GetType() == typeof(BoolField))
            {
                BoolField field     = obj as BoolField;
                Element   boolField = new Element
                {
                    ctrlType         = ctlCheckbox,
                    label            = field.Label,
                    defaultValue     = field.DefaultValue == true && field.DefaultValueSpecified ? "True" : "",
                    readOnly         = field.ReadOnly,
                    required         = field.Required,
                    columnName       = field.ColumnName,
                    searchable       = field.Searchable,
                    modifyEnable     = field.ModifyEnabled,
                    hiddenField      = field.HiddenField,
                    clientId         = field.ClientId,
                    resultVisibility = field.ResultVisibility,
                    resultPosition   = field.ResultPosition
                };
                if (field.Layout != null)
                {
                    boolField.rows    = field.Layout.RowNumber;
                    boolField.columns = field.Layout.ColNumber;
                }
                return(boolField);
            }

            if (obj.GetType() == typeof(LookupField))
            {
                LookupField field  = obj as LookupField;
                Element     lookup = new Element
                {
                    ctrlType             = ctlLookup,
                    label                = field.Label,
                    required             = field.Required,
                    columnName           = field.ColumnName,
                    lookupRepositoryName = field.LookupArchiveName,
                    lookupFieldName      = field.LookupArchiveColumnName == "_subject" ? "Oggetto" : field.LookupArchiveColumnName,
                    searchable           = field.Searchable,
                    modifyEnable         = field.ModifyEnabled,
                    hiddenField          = field.HiddenField,
                    clientId             = field.ClientId,
                    resultVisibility     = field.ResultVisibility,
                    resultPosition       = field.ResultPosition,
                    multipleValues       = field.MultipleValues
                };
                if (field.Layout != null)
                {
                    lookup.rows    = field.Layout.RowNumber;
                    lookup.columns = field.Layout.ColNumber;
                }
                return(lookup);
            }

            return(null);
        }