Пример #1
0
        private void OnBeforeExpand(object o, System.Windows.Forms.TreeViewCancelEventArgs e)
        {
            if (DoubleClicked)
            {
                e.Cancel      = true;
                DoubleClicked = false;
                e.Node.Collapse();
            }
            else
            {
                DatabaseNode dbn = e.Node as DatabaseNode;
                if (dbn != null)
                {
                    if (dbn.Nodes.Count == 1)
                    {
                        HiddenNode hn = dbn.Nodes[0] as HiddenNode;
                        if (hn != null)
                        {
                            dbn.Nodes.Clear();

                            // build tables
                            TablesNode TableRoot = new TablesNode("Tables");

                            Collection <TableInfo> tables = DatabaseCtrl.GetTables(dbn.DbInfo);

                            foreach (TableInfo tbl in tables)
                            {
                                TableNode tNode = new TableNode(tbl);
                                foreach (ColumnInfo column in tbl.Columns)
                                {
                                    ColumnNode cNode = new ColumnNode(column.ColumnName);
                                    tNode.Nodes.Add(cNode);
                                }
                                TableRoot.Nodes.Add(tNode);
                            }

                            dbn.Nodes.Add(TableRoot);

                            // build views
                            TableRoot = new TablesNode("Views");

                            Collection <ViewInfo> views = DatabaseCtrl.GetViews(dbn.DbInfo);

                            foreach (ViewInfo view in views)
                            {
                                ViewNode vNode = new ViewNode(view.ViewName);
                                foreach (ColumnInfo column in view.Columns)
                                {
                                    ColumnNode cNode = new ColumnNode(column.ColumnName);
                                    vNode.Nodes.Add(cNode);
                                }
                                TableRoot.Nodes.Add(vNode);
                            }

                            dbn.Nodes.Add(TableRoot);
                        }
                    }
                }
            }
        }
Пример #2
0
        private void OnBeforeExpand(object o, System.Windows.Forms.TreeViewCancelEventArgs e)
        {
            if (DoubleClicked)
            {
                e.Cancel = true;
                DoubleClicked = false;
                e.Node.Collapse();
            }
            else
            {
                DatabaseNode dbn = e.Node as DatabaseNode;
                if (dbn != null)
                {
                    if (dbn.Nodes.Count == 1)
                    { 
                        HiddenNode hn = dbn.Nodes[0] as HiddenNode;
                        if (hn != null)
                        {
                            dbn.Nodes.Clear();

                            // build tables
                            TablesNode TableRoot = new TablesNode("Tables");

                            Collection<TableInfo> tables = DatabaseCtrl.GetTables(dbn.DbInfo);

                            foreach (TableInfo tbl in tables)
                            {
                                TableNode tNode = new TableNode(tbl);
                                foreach (ColumnInfo column in tbl.Columns)
                                {
                                    ColumnNode cNode = new ColumnNode(column.ColumnName);
                                    tNode.Nodes.Add(cNode);
                                }
                                TableRoot.Nodes.Add(tNode);
                            }

                            dbn.Nodes.Add(TableRoot);

                            // build views
                            TableRoot = new TablesNode("Views");

                            Collection<ViewInfo> views = DatabaseCtrl.GetViews(dbn.DbInfo);

                            foreach (ViewInfo view in views)
                            {
                                ViewNode vNode = new ViewNode(view.ViewName);
                                foreach (ColumnInfo column in view.Columns)
                                {
                                    ColumnNode cNode = new ColumnNode(column.ColumnName);
                                    vNode.Nodes.Add(cNode);
                                }
                                TableRoot.Nodes.Add(vNode);
                            }

                            dbn.Nodes.Add(TableRoot);
                        }
                    }
                }                
            }
        }