Beispiel #1
0
        private void LoadTablesToCombobox()
        {
            cmbSchemasCreate.Items.Clear();
            cmbSchemasDelete.Items.Clear();
            cmbDeleteIndexName.Items.Clear();
            cmbTableName.Items.Clear();

            //cmbDeleteFunctionName.Items.Clear();

            var listIndexes = dbHandler.GetSchemaIndexes(DatabaseHandler.currentSchema);
            var listSchemas = dbHandler.GetConnectionSchemas("");

            foreach (String str in listIndexes)
            {
                cmbDeleteIndexName.Items.Add(str);
            }

            foreach (String str in listSchemas)
            {
                if (str != "SYSTEM")
                {
                    cmbSchemasDelete.Items.Add(str);
                }

                cmbSchemasCreate.Items.Add(str);
            }

            cmbSchemasCreate.SelectedIndex = cmbSchemasDelete.SelectedIndex = 0;
        }
Beispiel #2
0
        private void btnLoadScript_Click(object sender, EventArgs e)
        {
            var tables = dbHandler.GetTableDDL(cmbTables.SelectedItem.ToString(), cmbSchemasDelete.SelectedItem.ToString());

            richTextBox1.Text = "Table " + cmbTables.SelectedItem.ToString() + "\n";
            foreach (String str in tables)
            {
                richTextBox1.Text += "\t" + str + "\n";
            }

            richTextBox1.Text += "\n\t ------ INDEXES ------\n\n";

            //VERY SMART CODE!!!!!!!!!!!  I managed to use an existing code, adding a part of the query and eliminating the rest of the query by using comments
            var indexes = dbHandler.GetSchemaIndexes(cmbSchemasDelete.SelectedItem.ToString() + "' and Tablename = '" + cmbTables.SelectedItem.ToString() + "';//");

            foreach (String str in indexes)
            {
                richTextBox1.Text += "\t" + str + "\n";

                var indexFields = dbHandler.GetIndexFields(str, cmbSchemasDelete.SelectedItem.ToString());

                richTextBox1.Text += "\t-----ON FIELDS------ \n";

                foreach (string strField in indexFields)
                {
                    richTextBox1.Text += "\t\t" + strField + "\n";
                }

                richTextBox1.Text += "\t-----END------ \n\n";
            }
        }
Beispiel #3
0
        private void PopulateTreeViewWithKey(TreeView selectedNode)
        {
            /* Function will get the data according to the level of the node in the treeview
             * 0 level = Get Schemas
             * 1 level = Get Tables, Functions, Views and Procedures
             * 2 level = Get Table Fields (Just a string which may be Table, Procedure, Functions and Views)
             * 3 level = Get, according to the treenode text, return its data (for example, if the user clicked table, get the tables of that schema and displayed it and so on)
             * 4 level = depends it is a tbale or stored procedure or function*/

            //Given the level of the selected node and the text of the selected node, its possible to get its data
            string nodeText = selectedNode.SelectedNode.Text;

            int           level    = selectedNode.SelectedNode.Level;
            List <String> listData = new List <string>();

            switch (level)
            {
            case 0:
                listData = dbHandler.GetConnectionSchemas(nodeText);
                break;

            case 1:
                listData      = dbHandler.GetSchemaStringObjects(nodeText);
                currentSchema = nodeText;
                DatabaseHandler.currentSchema = currentSchema;
                break;

            case 2:

                /*Given the text of the node, if the text of the node is equal to "Table" then call the function
                 * that returns the tables of the given schema */

                switch (nodeText)
                {
                case "Tables":
                    listData            = dbHandler.GetSchemaTables(currentSchema);
                    currentSchemaObject = "Tables";
                    break;

                case "Functions":
                    listData            = dbHandler.GetSchemaFunctions(currentSchema);
                    currentSchemaObject = "Functions";
                    break;

                case "Procedures":
                    listData            = dbHandler.GetSchemaProcedures(currentSchema);
                    currentSchemaObject = "Procedures";
                    break;

                case "Views":
                    listData            = dbHandler.GetSchemaViews(currentSchema);
                    currentSchemaObject = "Views";
                    break;

                case "Indexes":
                    listData            = dbHandler.GetSchemaIndexes(currentSchema);
                    currentSchemaObject = "Indexes";
                    break;
                }

                break;

            case 3:
                /* If the current schema object is table, call the function that brings the data of that table ( the table name is the selected node text )
                 * and so on */

                switch (currentSchemaObject)
                {
                case "Tables":
                    PopulateDataGridView(nodeText);
                    break;

                case "Functions":

                    break;

                case "Procedures":

                    break;

                case "Views":
                    GetViewData(nodeText);
                    break;
                }
                break;

            default:
                return;
            }

            selectedNode.SelectedNode.Nodes.Clear();

            foreach (String data in listData)
            {
                selectedNode.SelectedNode.Nodes.Add(data);
            }
        }