Example #1
0
        public TreeNode[] GetSubObjectHierarchy(TreeNode node)
        {
            // Show the column breakdown for the selected table

            if (node is OracleNode)
            {
                OracleNode on = (OracleNode)node;
                if (on.type == "T" || on.type == "V")
                {
                    DataSet ds = dbClient.Execute("select COLUMN_NAME name, DATA_TYPE type, DATA_LENGTH clength, DATA_PRECISION nprecision, DATA_SCALE nscale, NULLABLE nullable from USER_TAB_COLUMNS where TABLE_NAME = '"
                                                  + on.Text + "'", timeout);
                    if (ds == null || ds.Tables.Count == 0)
                    {
                        return(null);
                    }

                    TreeNode[] tn    = new OracleNode [ds.Tables[0].Rows.Count];
                    int        count = 0;

                    foreach (DataRow row in ds.Tables[0].Rows)
                    {
                        string length;
                        if (row ["clength"].ToString() != "")
                        {
                            length = "(" + row ["clength"].ToString() + ")";
                        }
                        else if (row ["nprecision"].ToString() != "")
                        {
                            length = "(" + row ["nprecision"].ToString() + "," + row ["nscale"].ToString() + ")";
                        }
                        else
                        {
                            length = "";
                        }

                        string nullable = row ["nullable"].ToString().StartsWith("Y") ? "null" : "not null";

                        OracleNode column = new OracleNode(row ["name"].ToString() + " ("
                                                           + row ["type"].ToString() + length + ", " + nullable + ")");

                        column.dragText = row ["name"].ToString();

                        tn [count++] = column;
                    }
                    return(tn);
                }
            }
            return(null);
        }
Example #2
0
        public DataSet  GetSubObjectDataSet(TreeNode thenode)
        {
            if (thenode is OracleNode)
            {
                OracleNode on = (OracleNode)thenode;

                this.DbClient.Database = on.database;
                if (on.type == "U" || on.type == "V")                                           // break down columns for user tables and views
                {
                    DataSet ds = dbClient.Execute("select COLUMN_NAME name, DATA_TYPE type, DATA_LENGTH clength, DATA_PRECISION nprecision, DATA_SCALE nscale, NULLABLE nullable from USER_TAB_COLUMNS where TABLE_NAME = '"
                                                  + on.Text + "'", timeout);
                    return(ds);
                }
            }
            return(null);
        }
Example #3
0
        public string GetActionText(TreeNode node, string action)
        {
            if (!(node is OracleNode))
            {
                return(null);
            }
            OracleNode on = (OracleNode)node;

            if (action.StartsWith("select * from "))
            {
                return(action);
            }
            else
            {
                return(null);
            }
        }
Example #4
0
        public StringCollection GetActionList(TreeNode node)
        {
            if (!(node is OracleNode))
            {
                return(null);
            }

            OracleNode       on     = (OracleNode)node;
            StringCollection output = new StringCollection();

            if (on.type == "T" || on.type == "V")
            {
                output.Add("select * from " + on.dragText);
            }

            return(output.Count == 0 ? null : output);
        }
Example #5
0
        public TreeNode[] GetObjectHierarchy()
        {
            TreeNode[] top = new TreeNode[]
            {
                new TreeNode("User Tables"),
                new TreeNode("User Views"),
            };

            DataSet ds = dbClient.Execute("select TABLE_NAME from USER_TABLES", timeout);

            if (ds == null || ds.Tables.Count == 0)
            {
                return(null);
            }

            foreach (DataRow row in ds.Tables[0].Rows)
            {
                OracleNode node = new OracleNode(row [0].ToString());
                node.type     = "T";
                node.dragText = node.Text;
                top [0].Nodes.Add(node);
                // Add a dummy sub-node to user tables and views so they'll have a clickable expand sign
                // allowing us to have GetSubObjectHierarchy called so the user can view the columns
                node.Nodes.Add(new TreeNode());
            }

            ds = dbClient.Execute("select VIEW_NAME from USER_VIEWS", timeout);
            if (ds == null || ds.Tables.Count == 0)
            {
                return(top);
            }

            foreach (DataRow row in ds.Tables[0].Rows)
            {
                OracleNode node = new OracleNode(row [0].ToString());
                node.type     = "V";
                node.dragText = node.Text;
                top [1].Nodes.Add(node);
                // Add a dummy sub-node to user tables and views so they'll have a clickable expand sign
                // allowing us to have GetSubObjectHierarchy called so the user can view the columns
                node.Nodes.Add(new TreeNode());
            }

            return(top);
        }