Exemplo n.º 1
0
        public JsonResult GetTable(string id)
        {
            var tables = FoxOne.Data.Mapping.TableMapper.Tables[Dao.Get().ConnectionString];

            if (id.IsNotNullOrEmpty())
            {
                var dataTable = tables.FirstOrDefault(o => o.Name.Equals(id, StringComparison.OrdinalIgnoreCase));
                var table     = new FoxOne.Controls.Table()
                {
                    AllowPaging = false, ShowCheckBox = false, ShowIndex = false, AutoGenerateColum = false
                };
                table.Columns.Add(new TableColumn()
                {
                    FieldName = "Name", ColumnName = "字段名", TextAlign = CellTextAlign.Left
                });
                table.Columns.Add(new TableColumn()
                {
                    FieldName = "Comment", ColumnName = "注释", TextAlign = CellTextAlign.Left
                });
                table.Columns.Add(new TableColumn()
                {
                    FieldName = "Type", ColumnName = "类型"
                });
                table.Columns.Add(new TableColumn()
                {
                    FieldName = "Length", ColumnName = "长度"
                });
                table.Columns.Add(new TableColumn()
                {
                    FieldName = "IsKey", ColumnName = "主键"
                });
                table.Columns.Add(new TableColumn()
                {
                    FieldName = "IsNullable", ColumnName = "可为空"
                });
                table.Columns.Add(new TableColumn()
                {
                    FieldName = "IsAutoIncrement", ColumnName = "自增"
                });
                table.DataSource = new TableDataSource(dataTable);
                return(Json(table.Render()));
            }
            else
            {
                var result = new List <TreeNode>();
                result.Add(new TreeNode()
                {
                    Value = "Root", Text = tables[0].Schema, Open = true, ParentId = "", Icon = dsIconUrl
                });
                foreach (var table in tables)
                {
                    result.Add(new TreeNode()
                    {
                        Value = table.Name, Icon = tbIconUrl, Open = false, Text = table.Name, ParentId = "Root"
                    });
                }
                return(Json(result));
            }
        }
Exemplo n.º 2
0
        public ActionResult ControlList()
        {
            var table = new FoxOne.Controls.Table()
            {
                ShowIndex         = true,
                ShowCheckBox      = true,
                AllowPaging       = false,
                AutoGenerateColum = false,
                AutoHeight        = true
            };

            table.KeyFieldName = "Id";
            table.Columns.Add(new TableColumn()
            {
                FieldName = "Id"
            });
            table.Columns.Add(new TableColumn()
            {
                FieldName = "Type"
            });
            table.Columns.Add(new TableColumn()
            {
                FieldName = "Rank"
            });
            table.Columns.Add(new TableColumn()
            {
                FieldName = "TargetId"
            });
            table.Columns.Add(new TableColumn()
            {
                FieldName = "LastUpdateTime"
            });
            table.Buttons.Add(new TableButton()
            {
                CssClass = "btn btn-primary btn-sm", Id = "btnEdit", Name = "编辑", OnClick = "editCtrl('{0}','{1}')", DataFields = "PageId,Id"
            });
            table.Buttons.Add(new TableButton()
            {
                CssClass = "btn btn-danger btn-sm", Id = "btnDelete", Name = "删除", OnClick = "deleteCtrl('{0}','{1}')", DataFields = "PageId,Id"
            });
            var ds = new EntityDataSource()
            {
                EntityType = typeof(ComponentEntity)
            };

            ds.DataFilter = new RequestParameterDataFilter()
            {
                ParameterRange = ParameterRange.QueryString
            };
            table.DataSource  = ds;
            ViewData["table"] = table;
            return(View());
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
        public ActionResult ControlList()
        {
            var table = new FoxOne.Controls.Table()
            {
                ShowIndex         = true,
                ShowCheckBox      = true,
                AllowPaging       = false,
                AutoGenerateColum = false,
                AutoHeight        = true
            };

            table.KeyFieldName = "Id";
            table.Columns.Add(new TableColumn()
            {
                FieldName = "Id", ShowLength = 20
            });
            table.Columns.Add(new TableColumn()
            {
                FieldName = "Type"
            });
            //table.Columns.Add(new TableColumn() { FieldName = "Rank" });
            table.Columns.Add(new TableColumn()
            {
                FieldName = "TargetId"
            });
            //table.Columns.Add(new TableColumn() { FieldName = "LastUpdateTime" });
            table.Buttons.Add(new TableButton()
            {
                CssClass = "btn btn-primary btn-sm", Id = "btnEdit", Name = "编辑", OnClick = "editCtrl('{0}','{1}')", DataFields = "PageId,Id"
            });
            table.Buttons.Add(new TableButton()
            {
                CssClass = "btn btn-danger btn-sm", Id = "btnDelete", Name = "删除", OnClick = "deleteCtrl('{0}','{1}')", DataFields = "PageId,Id"
            });
            var ds = new EntityDataSource()
            {
                EntityType = typeof(ComponentEntity)
            };
            var filter = new CompositeDataFilter()
            {
            };

            filter.DataFilters = new List <IDataFilter>();
            filter.DataFilters.Add(new StaticDataFilter()
            {
                ColumnName = "ParentId", Operator = typeof(EqualsOperation).FullName, Value = "$QueryString._PARENT_ID$"
            });
            filter.DataFilters.Add(new StaticDataFilter()
            {
                ColumnName = "PageId", Operator = typeof(EqualsOperation).FullName, Value = "$QueryString._PAGE_ID"
            });
            if (Request.QueryString.AllKeys.Contains("_TARGET_ID"))
            {
                filter.DataFilters.Add(new StaticDataFilter()
                {
                    ColumnName = "TargetId", Operator = typeof(EqualsOperation).FullName, Value = "$QueryString._TARGET_ID"
                });
            }
            filter.OperatorType = OperatorType.And;
            ds.DataFilter       = filter;
            ds.ColumnConverters = new List <IColumnConverter>();
            ds.ColumnConverters.Add(new ControlNameConverter()
            {
                ColumnName = "Type", ConverterType = ColumnConverterType.Replace
            });
            table.DataSource  = ds;
            ViewData["table"] = table;
            return(View());
        }