Ejemplo n.º 1
0
        public void ResetViews(IEnumerable tableTypes, string connectionString)
        {
            this.Children.Clear();
            foreach (TableType tableType in tableTypes)
            {
                ViewNode tableNode = new ViewNode();
                tableNode.DataInfo = tableType;
                //tableNode.ConncetionString = connectionString;

                tableNode.Parent = this;
            }
        }
Ejemplo n.º 2
0
        public void Reset(List<TableType> tableTypes, string connectionString)
        {
            this.Children.Clear();

            //排序
            var orderTables = tableTypes.OrderBy(x => x.Name).ToList();

            foreach (TableType tableType in orderTables)
            {
                ViewNode tableNode = new ViewNode();
                tableNode.DataInfo = tableType;
                //tableNode.ConncetionString = connectionString;

                tableNode.Parent = this;
            }
        }
Ejemplo n.º 3
0
        protected override void OnRefresh(object sender, EventArgs args)
        {
            //获取最新的表
            try
            {
                DbSchema.DatabaseSchema db = DatabaseSchema.CreateInstance(this.DbType);
                db.ConnectionString = this.ConncetionString;
                //db.Provider = new DbSchema.DbSchemaProvider.SqlSchemaProvider();
                var tables = db.Tables;

                TablePackageNode tablePkgNode = null;
                foreach (BaseNode n in this.Children)
                {
                    if (n is TablePackageNode)
                    {
                        tablePkgNode = (TablePackageNode)n;
                    }
                }
                this.TreeNode.TreeView.BeginUpdate();
                foreach (DbSchema.TableSchema table in tables)
                {
                    if (table.IsView)
                    {
                        bool exsited = false;

                        foreach (ViewNode each in this._viewPackageNode.Children)
                        {
                            if (each.Name.Equals(table.Name))
                            {
                                exsited    = true;
                                each.Table = table;
                                break;
                            }
                        }

                        if (!exsited)
                        {
                            ViewNode tableNode = new ViewNode();

                            tableNode.Text   = tableNode.Name = table.Name;
                            tableNode.Parent = _viewPackageNode;
                            tableNode.Table  = table;
                        }
                    }
                    else
                    {
                        bool exsited = false;

                        foreach (TableNode each in tablePkgNode.Children)
                        {
                            if (each.Name.Equals(table.Name))
                            {
                                exsited    = true;
                                each.Table = table;
                                break;
                            }
                        }

                        if (!exsited)
                        {
                            TableNode tableNode = new TableNode();

                            tableNode.Text   = tableNode.Name = table.Name;
                            tableNode.Parent = tablePkgNode;
                            tableNode.Table  = table;
                        }
                    }
                }

                this.sortTables();
                this.TreeNode.TreeView.EndUpdate();
                //检查EF
            }
            catch (Exception ex)
            {
                MessageBox.Show("失败:" + ex.Message);
            }

            base.OnRefresh(sender, args);
        }
Ejemplo n.º 4
0
        protected override void OnRefresh(object sender, EventArgs args)
        {
            //获取最新的表
            try
            {
                DbSchema.DatabaseSchema db = DatabaseSchema.CreateInstance(this.DbType);
                db.ConnectionString = this.ConncetionString;
                //db.Provider = new DbSchema.DbSchemaProvider.SqlSchemaProvider();
                var tables = db.Tables;

                TablePackageNode tablePkgNode = null;
                foreach (BaseNode n in this.Children)
                {
                    if (n is TablePackageNode)
                    {
                        tablePkgNode = (TablePackageNode)n;
                    }
                }
                this.TreeNode.TreeView.BeginUpdate();
                foreach (DbSchema.TableSchema table in tables)
                {

                    if (table.IsView)
                    {
                        bool exsited = false;

                        foreach (ViewNode each in this._viewPackageNode.Children)
                        {
                            if (each.Name.Equals(table.Name))
                            {
                                exsited = true;
                                each.Table = table;
                                break;
                            }
                        }

                        if (!exsited)
                        {
                            ViewNode tableNode = new ViewNode();

                            tableNode.Text = tableNode.Name = table.Name;
                            tableNode.Parent = _viewPackageNode;
                            tableNode.Table = table;
                        }
                    }
                    else
                    {
                        bool exsited = false;

                        foreach (TableNode each in tablePkgNode.Children)
                        {
                            if (each.Name.Equals(table.Name))
                            {
                                exsited = true;
                                each.Table = table;
                                break;
                            }
                        }

                        if (!exsited)
                        {
                            TableNode tableNode = new TableNode();

                            tableNode.Text = tableNode.Name = table.Name;
                            tableNode.Parent = tablePkgNode;
                            tableNode.Table = table;
                        }
                    }
                }

                this.sortTables();
                this.TreeNode.TreeView.EndUpdate();
                //检查EF

            }
            catch (Exception ex)
            {
                MessageBox.Show("失败:" + ex.Message);
            }

            base.OnRefresh(sender, args);
        }