Esempio n. 1
0
        private void treeViewDB_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            if (e.Node.Parent == null)
            {
                return;
            }

            TreeNode tnode = e.Node;

            while (tnode.Parent != null)
            {
                tnode = tnode.Parent;
            }

            DBI.SQLBase dbi = DBI.SQLFactory.GetSqlDBI(tnode.Text);

            if (e.Node.Text == "Tables")
            {
                dataGridViewDB.DataSource = dbi.GetTableNames();
            }
            else if (e.Node.Text == "Views")
            {
                ;
            }
            else if (e.Node.Text == "Indexes")
            {
                dataGridViewDB.DataSource = dbi.GetIndexes();
            }
            else if (e.Node.Text == "Procedures")
            {
                dataGridViewDB.DataSource = dbi.GetStoredProcedures();
            }
            else if (e.Node.Text == "Functions")
            {
                dataGridViewDB.DataSource = dbi.GetFunctions();
            }
            else if (e.Node.Text == "Triggers")
            {
                dataGridViewDB.DataSource = dbi.GetTriggers();
            }
            else if (e.Node.Parent.Text == "Tables")
            {
                dataGridViewDB.DataSource = dbi.GetTableData(e.Node.Text);
            }
            else if (e.Node.Parent.Text == "Views")
            {
                dataGridViewDB.DataSource = dbi.GetViewData(e.Node.Text);
            }
            else if (e.Node.Parent.Text == "Indexes")
            {
                dataGridViewDB.DataSource = dbi.GetIndex(e.Node.Text);
            }
            else if (e.Node.Parent.Text == "Procedures")
            {
                dataGridViewDB.DataSource = dbi.GetStoredProcedure(e.Node.Text);
            }
            else if (e.Node.Parent.Text == "Functions")
            {
                dataGridViewDB.DataSource = dbi.GetFunction(e.Node.Text);
            }
            else if (e.Node.Parent.Text == "Triggers")
            {
                dataGridViewDB.DataSource = dbi.GetTrigger(e.Node.Text);
            }
        }
Esempio n. 2
0
        private void LoadDB(String dbConnName)
        {
            DBI.SQLBase dbi = DBI.SQLFactory.GetSqlDBI(dbConnName);

            // Get tables
            DataTable dt     = dbi.GetTableNames();
            TreeNode  tnode1 = treeViewDB.Nodes.Add(dbConnName);

            tnode1.Name             = dbConnName;
            tnode1.ContextMenuStrip = contextMenuStrip1;
            TreeNode tnode2 = tnode1.Nodes.Add("Tables");

            foreach (DataRow row in dt.Rows)
            {
                tnode2.Nodes.Add(
                    String.Format("{0}.{1}", row[0].ToString(), row[1].ToString()));
            }

            // Get views
            dt.Clear();
            dt     = dbi.GetViews();
            tnode2 = tnode1.Nodes.Add("Views");
            foreach (DataRow row in dt.Rows)
            {
                tnode2.Nodes.Add(
                    String.Format("{0}.{1}", row[0].ToString(), row[1].ToString()));
            }

            // Get indexes
            dt.Clear();
            dt     = dbi.GetIndexes();
            tnode2 = tnode1.Nodes.Add("Indexes");
            foreach (DataRow row in dt.Rows)
            {
                tnode2.Nodes.Add(
                    String.Format("{0}.{1}.{2}", row[0].ToString(), row[1].ToString(), row[2].ToString()));
            }

            // Get stored procedures
            dt.Clear();
            dt     = dbi.GetStoredProcedures();
            tnode2 = tnode1.Nodes.Add("Procedures");
            foreach (DataRow row in dt.Rows)
            {
                tnode2.Nodes.Add(
                    String.Format("{0}.{1}", row[0].ToString(), row[1].ToString()));
            }

            // Get functions
            dt.Clear();
            dt     = dbi.GetFunctions();
            tnode2 = tnode1.Nodes.Add("Functions");
            foreach (DataRow row in dt.Rows)
            {
                tnode2.Nodes.Add(
                    String.Format("{0}.{1}", row[0].ToString(), row[1].ToString()));
            }

            // Get triggers
            dt.Clear();
            dt     = dbi.GetTriggers();
            tnode2 = tnode1.Nodes.Add("Triggers");
            foreach (DataRow row in dt.Rows)
            {
                tnode2.Nodes.Add(
                    String.Format("{0}.{1}", row[0].ToString(), row[1].ToString()));
            }
        }