Esempio n. 1
0
        /// <summary>
        ///
        ///  return TreeNode[].Add("SELECT [COLUMN_NAME] FROM [Columns] WHERE [Tablename] = {filter}")
        ///
        /// </summary>
        public TreeNode[] GetSubObjectHierarchy(TreeNode node)
        {
            // Show the column breakdown for the selected table

            if (node is OleDbNode)
            {
                string table = node.Text;


                string[] fields = GetOleDbBrowserValues("COLUMN_NAME"
                                                        , OleDbSchemaGuid.Columns
                                                        , new object[] { GetDatabaseFilter(), null, table });

                if (fields != null)
                {
                    TreeNode[] tn    = new OleDbNode [fields.Length];
                    int        count = 0;

                    foreach (string name in fields)
                    {
                        OleDbNode column = new OleDbNode(name, -1);
                        tn [count++] = column;
                    }
                    return(tn);
                }
            }
            return(null);
        }
Esempio n. 2
0
        public StringCollection GetActionList(TreeNode node)
        {
            if (!(node is OleDbNode))
            {
                return(null);
            }

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

            if (on.type >= 0)
            {
                output.Add("select * from " + on.dragText);
                output.Add("(insert all fields)");
                output.Add("(insert all fields, table prefixed)");
            }

            return(output.Count == 0 ? null : output);
        }
Esempio n. 3
0
        /// <summary>
        /// top[curNoteType].Add("SELECT [TABLE_NAME] FROM [Tables] WHERE [Tabletyp] = {filter}")
        /// </summary>
        private void CreateNodeHierachy(TreeNode[] top, int curNoteType, string filter)
        {
            string[] result = null;

            result = GetOleDbBrowserValues(
                "TABLE_NAME", OleDbSchemaGuid.Tables
                , new object[] { GetDatabaseFilter(), null, null, filter });

            if (result != null)
            {
                foreach (string str in result)
                {
                    OleDbNode node = new OleDbNode(str, curNoteType);

                    top [curNoteType].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());
                }
            }
        }
Esempio n. 4
0
        public string GetActionText(TreeNode node, string action)
        {
            if (!(node is OleDbNode))
            {
                return(null);
            }

            OleDbNode on = (OleDbNode)node;

            if (action.StartsWith("select * from "))
            {
                return(action);
            }

            if (action.StartsWith("(insert all fields"))
            {
                StringBuilder sb = new StringBuilder();
                // If the table-prefixed option has been selected, add the table name to all the fields
                string prefix = action == "(insert all fields)" ? "" : on.dragText + ".";
                int    chars  = 0;
                foreach (TreeNode subNode in GetSubObjectHierarchy(node))
                {
                    if (chars > 50)
                    {
                        chars = 0;
                        sb.Append("\r\n");
                    }
                    string s = (sb.Length == 0 ? "" : ", ") + prefix + ((OleDbNode)subNode).dragText;
                    chars += s.Length;
                    sb.Append(s);
                }
                return(sb.Length == 0 ? null : sb.ToString());
            }

            return(null);
        }