Ejemplo n.º 1
0
        public static Bamboo.Mssql.ViewCollection ReadViews(System.Data.SqlClient.SqlConnection connection)
        {
            Bamboo.Mssql.ViewCollection views = new Bamboo.Mssql.ViewCollection();

            string query = "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'VIEW' AND TABLE_NAME NOT LIKE 'sys%' ORDER BY TABLE_NAME";

            System.Data.SqlClient.SqlCommand command = new System.Data.SqlClient.SqlCommand(query, connection);

            System.Data.SqlClient.SqlDataReader dataReader = command.ExecuteReader();

            while (dataReader.Read())
            {
                Bamboo.Mssql.View view = new Bamboo.Mssql.View();

                if (!dataReader.IsDBNull(dataReader.GetOrdinal("TABLE_NAME")))
                {
                    view.Name = dataReader.GetString(dataReader.GetOrdinal("TABLE_NAME"));
                }

                views.Add(view);
            }

            dataReader.Close();

            foreach (Bamboo.Mssql.View view in views)
            {
                view.Columns = ReadViewColumns(view.Name, connection);
            }

            return(views);
        }
Ejemplo n.º 2
0
        public ViewTreeNode(Bamboo.Mssql.View view)
        {
            this.Text = view.Name;
            this.Tag  = view;

            this.ImageIndex         = Images.View;
            this.SelectedImageIndex = Images.View;

            ViewColumnsTreeNode viewColumnsTreeNode = new ViewColumnsTreeNode(view.Columns);

            this.Nodes.Add(viewColumnsTreeNode);
        }
Ejemplo n.º 3
0
        private void sqlDatabaseTreeView_SelectionChanged(object sender, System.EventArgs e)
        {
            System.Windows.Forms.TreeNode selectedNode = this.sqlDatabaseTreeView.SelectedNode;
            if (selectedNode != null)
            {
                if (selectedNode is TablesTreeNode)
                {
                    this.listView.View = System.Windows.Forms.View.List;
                    this.listView.Columns.Clear();
                    this.listView.Clear();

                    TablesTreeNode tablesTreeNode       = (TablesTreeNode)selectedNode;
                    Bamboo.Mssql.TableCollection tables = (Bamboo.Mssql.TableCollection)tablesTreeNode.Tag;
                    this.ShowTables(tables);
                }
                else if (selectedNode is TableTreeNode)
                {
                    this.listView.View = System.Windows.Forms.View.List;
                    this.listView.Columns.Clear();
                    this.listView.Clear();

                    TableTreeNode      tableTreeNode = (TableTreeNode)selectedNode;
                    Bamboo.Mssql.Table table         = (Bamboo.Mssql.Table)tableTreeNode.Tag;
                    this.ShowTableColumns(table.Columns);
                }
                else if (selectedNode is ColumnsTreeNode)
                {
                    this.listView.View = System.Windows.Forms.View.List;
                    this.listView.Columns.Clear();
                    this.listView.Clear();

                    ColumnsTreeNode columnsTreeNode            = (ColumnsTreeNode)selectedNode;
                    Bamboo.Mssql.TableColumnCollection columns = (Bamboo.Mssql.TableColumnCollection)columnsTreeNode.Tag;
                    this.ShowTableColumns(columns);
                }
                else if (selectedNode is ColumnTreeNode)
                {
                    this.listView.Clear();
                    this.listView.View = System.Windows.Forms.View.Details;

                    ColumnTreeNode           columnTreeNode = (ColumnTreeNode)selectedNode;
                    Bamboo.Mssql.TableColumn column         = (Bamboo.Mssql.TableColumn)columnTreeNode.Tag;
                    this.ShowTableColumn(column);
                }
                else if (selectedNode is ViewsTreeNode)
                {
                    this.listView.View = System.Windows.Forms.View.List;
                    this.listView.Columns.Clear();
                    this.listView.Clear();

                    ViewsTreeNode viewsTreeNode       = (ViewsTreeNode)selectedNode;
                    Bamboo.Mssql.ViewCollection views = (Bamboo.Mssql.ViewCollection)viewsTreeNode.Tag;
                    this.ShowViews(views);
                }
                else if (selectedNode is ViewTreeNode)
                {
                    this.listView.View = System.Windows.Forms.View.List;
                    this.listView.Columns.Clear();
                    this.listView.Clear();

                    ViewTreeNode      viewTreeNode = (ViewTreeNode)selectedNode;
                    Bamboo.Mssql.View view         = (Bamboo.Mssql.View)viewTreeNode.Tag;
                    this.ShowViewColumns(view.Columns);
                }
                else if (selectedNode is ViewColumnsTreeNode)
                {
                    this.listView.View = System.Windows.Forms.View.List;
                    this.listView.Columns.Clear();
                    this.listView.Clear();

                    ViewColumnsTreeNode viewColumnsTreeNode   = (ViewColumnsTreeNode)selectedNode;
                    Bamboo.Mssql.ViewColumnCollection columns = (Bamboo.Mssql.ViewColumnCollection)viewColumnsTreeNode.Tag;
                    this.ShowViewColumns(columns);
                }
                else if (selectedNode is ViewColumnTreeNode)
                {
                    this.listView.Clear();
                    this.listView.View = System.Windows.Forms.View.Details;

                    ViewColumnTreeNode      viewColumnTreeNode = (ViewColumnTreeNode)selectedNode;
                    Bamboo.Mssql.ViewColumn column             = (Bamboo.Mssql.ViewColumn)viewColumnTreeNode.Tag;
                    this.ShowViewColumn(column);
                }
                else if (selectedNode is ProceduresTreeNode)
                {
                    this.listView.View = System.Windows.Forms.View.List;
                    this.listView.Columns.Clear();
                    this.listView.Clear();

                    ProceduresTreeNode proceduresTreeNode       = (ProceduresTreeNode)selectedNode;
                    Bamboo.Mssql.ProcedureCollection procedures = (Bamboo.Mssql.ProcedureCollection)proceduresTreeNode.Tag;
                    this.ShowProcudures(procedures);
                }
                else if (selectedNode is ProcedureTreeNode)
                {
                    this.listView.Clear();
                    this.listView.View = System.Windows.Forms.View.Details;

                    ProcedureTreeNode      procedureTreeNode = (ProcedureTreeNode)selectedNode;
                    Bamboo.Mssql.Procedure procedure         = (Bamboo.Mssql.Procedure)procedureTreeNode.Tag;
                    this.ShowProcudure(procedure);
                }
                else
                {
                    this.listView.Clear();
                }
            }
        }