private void LoadTablesToCombobox() { cmbSchemasCreate.Items.Clear(); cmbSchemasDelete.Items.Clear(); cmbDeleteProcedureName.Items.Clear(); var listProcedures = dbHandler.GetSchemaProcedures(DatabaseHandler.currentSchema); var listSchemas = dbHandler.GetConnectionSchemas(""); foreach (String str in listProcedures) { cmbDeleteProcedureName.Items.Add(str); } foreach (String str in listSchemas) { if (str != "SYSTEM") { cmbSchemasDelete.Items.Add(str); } cmbSchemasCreate.Items.Add(str); } cmbSchemasCreate.SelectedIndex = cmbSchemasDelete.SelectedIndex = 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); } }