Beispiel #1
0
        public Form BuildForm(RowData Data, FormLayouts FormLayout = FormLayouts.Vertical, SectionLayouts SectionLayout = SectionLayouts.Vertical, MetadataTable Table = null)
        {
            if (Table == null)
            {
                Table = Data.Metadata;
                if (Table == null)
                {
                    throw new ArgumentException("The Metadata Table argument is null, and metadata cannot be retrieved from the RowData object", "Table");
                }
            }
            Form form = new Form();

            form.FormLayout  = FormLayout;
            form.TitleColumn = Table.GuessTitleColumn();

            FormSection section = new FormSection();

            section.SectionLayout = SectionLayout;
            List <string> Columns   = Data.Columns;
            string        TableName = Table.Fullname;

            foreach (string s in Columns)
            {
                MetadataColumn mc;
                if (Table.Columns.TryGetValue(s, out mc))
                {
                    BuildField(mc, TableName, null, section, null, false);
                }
            }
            form.Sections.Add(section);
            form.Initialize(Data, Table);
            return(form);
        }
Beispiel #2
0
        public Form GetForm(MetadataTable Table, FormTypes FormType, FormLayouts FormLayout = FormLayouts.Vertical, SectionLayouts SectionLayout = SectionLayouts.VerticalTwoColumns)
        {
            if (FormType == FormTypes.Mobile)
            {
                throw new NotSupportedException("Mobile forms are not supported");
            }
            Form f;

            if (PrimaryForms.TryGetValue(Table.Fullname, out f))
            {
                return(f);
            }
            else
            {
                f = BuildForm(Table, FormType, FormLayout, SectionLayout);
                if (PrimaryForms.TryAdd(Table.Fullname, f))
                {
                    return(f);
                }
                else
                {
                    throw new InvalidOperationException("The default form for " + Table.Fullname + " could not be cached");
                }
            }
        }
Beispiel #3
0
 public Form BuildForm(SqlBuilder Builder, FormLayouts FormLayout = FormLayouts.Vertical, SectionLayouts SectionLayout = SectionLayouts.VerticalTwoColumns)
 {
     Form form = new Form();
     form.FormLayout = FormLayout;
     for (int i = 0; i < Builder.Tables.Count; i++)
     {
         FormSection section = new FormSection() { SectionLayout = SectionLayout };
         Table table = Builder.Tables[i];
         MetadataTable mt = Builder.Metadata.FindTable(table.FullName);
         // section.Legend = StringMap.Default.GetText(SqlBuilder.DefaultCulture.LCID, mt.Fullname, mt.Name);
         section.Legend = mt.DisplayName;
         string TableName = mt.Fullname;
         if (i == 0)
         {
             form.TitleColumn = mt.GuessTitleColumn();
         }
         foreach (Field field in table.FieldList)
         {
             string name = field.Name;
             MetadataColumn mc;
             if (mt.Columns.TryGetValue(name, out mc))
             {
                 MetadataColumn includedFrom = mt.Columns.Values.FirstOrDefault(x => x.IncludeColumns != null && x.IncludeColumns.Contains(field.Alias ?? field.Name));
                 BuildField(mc, TableName, field.Alias, section, includedFrom, i > 0);
             }
         }
         if (section.Fields.Count > 0)
         {
             form.Sections.Add(section);
         }
     }
     form.Sections[0].Fields.Insert(0, new FormField() { Name = "__TABLE", ID = "__TABLE", FieldType = FieldTypes.Input, InputType = InputTypes.text, IsHidden = true });
     return form;
 }
Beispiel #4
0
        public Form BuildForm(SqlBuilder Builder, FormLayouts FormLayout = FormLayouts.Vertical, SectionLayouts SectionLayout = SectionLayouts.VerticalTwoColumns)
        {
            Form form = new Form();

            form.FormLayout = FormLayout;
            for (int i = 0; i < Builder.Tables.Count; i++)
            {
                FormSection section = new FormSection()
                {
                    SectionLayout = SectionLayout
                };
                Table         table = Builder.Tables[i];
                MetadataTable mt    = Builder.Metadata.FindTable(table.FullName);
                // section.Legend = StringMap.Default.GetText(SqlBuilder.DefaultCulture.LCID, mt.Fullname, mt.Name);
                section.Legend = mt.DisplayName;
                string TableName = mt.Fullname;
                if (i == 0)
                {
                    form.TitleColumn = mt.GuessTitleColumn();
                }
                foreach (Field field in table.FieldList)
                {
                    string         name = field.Name;
                    MetadataColumn mc;
                    if (mt.Columns.TryGetValue(name, out mc))
                    {
                        MetadataColumn includedFrom = mt.Columns.Values.FirstOrDefault(x => x.IncludeColumns != null && x.IncludeColumns.Contains(field.Alias ?? field.Name));
                        BuildField(mc, TableName, field.Alias, section, includedFrom, i > 0);
                    }
                }
                if (section.Fields.Count > 0)
                {
                    form.Sections.Add(section);
                }
            }
            form.Sections[0].Fields.Insert(0, new FormField()
            {
                Name = "__TABLE", ID = "__TABLE", FieldType = FieldTypes.Input, InputType = InputTypes.text, IsHidden = true
            });
            return(form);
        }
Beispiel #5
0
        public Form BuildForm(MetadataTable Table, FormTypes FormType, FormLayouts FormLayout = FormLayouts.Vertical, SectionLayouts SectionLayout = SectionLayouts.VerticalTwoColumns)
        {
            Form form = new Form();

            form.FormLayout  = FormLayout;
            form.TitleColumn = Table.GuessTitleColumn();
            if (form.TitleColumn == null)
            {
                form.TitleColumn = Table.PrimaryKey.Columns.First().Name;
            }
            FormSection section = new FormSection()
            {
                SectionLayout = SectionLayout
            };
            string TableName = Table.Fullname;

            foreach (MetadataColumn col in Table.Columns.Values)
            {
                BuildField(col, TableName, null, section, null, false);
            }
            form.Sections.Add(section);
            return(form);
        }
Beispiel #6
0
 public Form GetForm(MetadataTable Table, FormTypes FormType, FormLayouts FormLayout = FormLayouts.Vertical, SectionLayouts SectionLayout = SectionLayouts.VerticalTwoColumns)
 {
     if (FormType == FormTypes.Mobile)
     {
         throw new NotSupportedException("Mobile forms are not supported");
     }
     Form f;
     if (PrimaryForms.TryGetValue(Table.Fullname, out f))
     {
         return f;
     }
     else
     {
         f = BuildForm(Table, FormType, FormLayout, SectionLayout);
         if (PrimaryForms.TryAdd(Table.Fullname, f))
         {
             return f;
         }
         else
         {
             throw new InvalidOperationException("The default form for " + Table.Fullname + " could not be cached");
         }
     }
 }
Beispiel #7
0
        public Form BuildForm(RowData Data, FormLayouts FormLayout = FormLayouts.Vertical, SectionLayouts SectionLayout = SectionLayouts.Vertical, MetadataTable Table = null)
        {
            if (Table == null)
            {
                Table = Data.Metadata;
                if (Table == null)
                {
                    throw new ArgumentException("The Metadata Table argument is null, and metadata cannot be retrieved from the RowData object", "Table");
                }
            }
            Form form = new Form();
            form.FormLayout = FormLayout;
            form.TitleColumn = Table.GuessTitleColumn();

            FormSection section = new FormSection();
            section.SectionLayout = SectionLayout;
            List<string> Columns = Data.Columns;
            string TableName = Table.Fullname;
            foreach (string s in Columns)
            {
                MetadataColumn mc;
                if (Table.Columns.TryGetValue(s, out mc))
                {
                    BuildField(mc, TableName, null, section, null, false);
                }
            }
            form.Sections.Add(section);
            form.Initialize(Data, Table);
            return form;
        }
Beispiel #8
0
 public Form BuildForm(MetadataTable Table, FormTypes FormType, FormLayouts FormLayout = FormLayouts.Vertical, SectionLayouts SectionLayout = SectionLayouts.VerticalTwoColumns)
 {
     Form form = new Form();
     form.FormLayout = FormLayout;
     form.TitleColumn = Table.GuessTitleColumn();
     if (form.TitleColumn == null)
     {
         form.TitleColumn = Table.PrimaryKey.Columns.First().Name;
     }
     FormSection section = new FormSection() { SectionLayout = SectionLayout };
     string TableName = Table.Fullname;
     foreach (MetadataColumn col in Table.Columns.Values)
     {
         BuildField(col, TableName, null, section, null, false);
     }
     form.Sections.Add(section);
     return form;
 }