Example #1
0
        private void AddSearch()
        {
            if (Table == null)
            {
                return;
            }
            var search = new Search()
            {
                Rank = 2, Id = "{0}Search".FormatTo(ListPageName), PageId = ListPageName, ParentId = ListPageName, TargetId = "Right", TargetControlId = tableListTemplate.FormatTo(ListPageName)
            };

            foreach (var field in Table.Columns.Where(o => o.Searchable).OrderBy(o => o.Rank))
            {
                var f = ControlDefaultSetting.GetFormControl(field);
                f.Id       = field.Name;
                f.Name     = field.Name;
                f.Label    = field.Comment;
                f.Rank     = field.Rank;
                f.Enable   = true;
                f.Visiable = true;
                search.Fields.Add(f);
            }
            foreach (var btn in ControlDefaultSetting.GetDefaultSearchButton())
            {
                search.Buttons.Add(btn);
            }
            ComponentHelper.RecSave(search);
        }
Example #2
0
        private void AddTable()
        {
            if (Table == null)
            {
                return;
            }
            var table = new FoxOne.Controls.Table()
            {
                ShowCheckBox = true, ShowIndex = true, Rank = 2, Id = tableListTemplate.FormatTo(ListPageName), PageId = ListPageName, ParentId = ListPageName, TargetId = "Right"
            };

            if (Type != null)
            {
                table.DataSource = new EntityDataSource()
                {
                    EntityTypeFullName = Type.FullName
                };
            }
            else
            {
                table.DataSource = new CRUDDataSource()
                {
                    CRUDName = this.CRUDName
                };
            }
            var key = Table.Columns.FirstOrDefault(o => o.IsKey);

            table.KeyFieldName = key == null ? "Id" : key.Name;
            table.EditUrl      = "/Page/" + EditPageName;
            table.InsertUrl    = table.EditUrl;
            table.DeleteUrl    = "/Entity/Delete";
            foreach (var c in Table.Columns)
            {
                if (c.Showable)
                {
                    table.Columns.Add(new TableColumn()
                    {
                        Rank = c.Rank, FieldName = c.Name, Id = "column{0}".FormatTo(c.Name), ColumnName = c.Comment
                    });
                }
            }
            foreach (var btn in ControlDefaultSetting.GetDefaultTableButton())
            {
                table.Buttons.Add(btn);
            }
            ComponentHelper.RecSave(table);
        }
Example #3
0
        private void AddToolbar()
        {
            if (Table == null)
            {
                return;
            }
            var toolbar = new Toolbar()
            {
                Rank = 1, Id = toolbarTemplate.FormatTo(ListPageName), PageId = ListPageName, ParentId = ListPageName, TargetId = "Right", TargetControlId = tableListTemplate.FormatTo(ListPageName)
            };

            foreach (var btn in ControlDefaultSetting.GetDefaultToolbarButton())
            {
                toolbar.Buttons.Add(btn);
            }
            ComponentHelper.RecSave(toolbar);
        }
        public JsonResult GetFormField()
        {
            string id        = Request.Form[NamingCenter.PARAM_PARENT_ID];
            string pageId    = Request.Form[NamingCenter.PARAM_PAGE_ID];
            var    component = PageBuilder.BuildPage(pageId).FindControl(id);

            if (component is Form)
            {
                var form = component as Form;
                if (form.FormService == null)
                {
                    throw new FoxOneException("Need_DataSource", form.Id);
                }
                if (form.FormService is EntityDataSource)
                {
                    var tempForm = ComponentHelper.GetFormComponent((form.FormService as EntityDataSource).EntityType);
                    foreach (var field in tempForm.Fields)
                    {
                        field.PageId   = pageId;
                        field.ParentId = id;
                        field.TargetId = "Fields";
                        ComponentHelper.RecSave(field);
                    }
                    return(Json(true));
                }
                if (form.FormService is DataTableDataSource)
                {
                    var tableName = (form.FormService as DataTableDataSource).TableName;
                    var table     = FoxOne.Data.Mapping.TableMapper.Tables[Dao.Get().ConnectionString].FirstOrDefault(o => o.Name.Equals(tableName, StringComparison.OrdinalIgnoreCase));
                    foreach (var f in table.Columns.Where(o => o.Editable).OrderBy(o => o.Rank))
                    {
                        var field = ControlDefaultSetting.GetFormControl(f);
                        field.PageId   = pageId;
                        field.ParentId = id;
                        field.TargetId = "Fields";
                        ComponentHelper.RecSave(field);
                    }
                    return(Json(true));
                }
            }
            throw new FoxOneException("Only_Suppost_Form_Ctrl");
        }
Example #5
0
        private void AddForm()
        {
            Form form = null;

            if (Type != null)
            {
                form = ComponentHelper.GetFormComponent(Type);
            }
            else
            {
                if (Table == null)
                {
                    return;
                }
                form = new Form()
                {
                    Rank = 1, Id = "{0}Form".FormatTo(EditPageName)
                };
                form.PostUrl           = "/Entity/Edit";
                form.FormMode          = FormMode.Insert;
                form.AppendQueryString = true;
                form.FormService       = new CRUDDataSource()
                {
                    CRUDName = CRUDName, Id = form.Id + "Ds"
                };
                foreach (var field in Table.Columns.Where(o => o.Editable).OrderBy(o => o.Rank))
                {
                    var f = ControlDefaultSetting.GetFormControl(field);
                    form.Fields.Add(f);
                }
                foreach (var btn in ControlDefaultSetting.GetDefaultFormButton())
                {
                    form.Buttons.Add(btn);
                }
            }
            form.PageId   = EditPageName;
            form.ParentId = EditPageName;
            form.TargetId = "Right";
            ComponentHelper.RecSave(form);
        }