From 42db6fc0dc37c2a2f6b73f8742c352e93ff3a5ea Mon Sep 17 00:00:00 2001 From: "Valeriano A.R." Date: Sun, 11 May 2025 18:15:24 +0200 Subject: [PATCH] Initialize issues branch --- .gitignore | 9 - VAR.DatabaseExplorer.sln | 22 -- .../Code/BusinessLogic/DatabaseBL.cs | 205 ---------- .../Code/BusinessLogic/ProcedureBL.cs | 137 ------- .../Code/BusinessLogic/TableBL.cs | 205 ---------- .../Code/DataAccess/ColumnDA.cs | 93 ----- .../Code/DataAccess/DatabaseDA.cs | 137 ------- .../Code/DataAccess/ProcedureDA.cs | 157 -------- .../Code/DataAccess/ServerDA.cs | 32 -- .../Code/DataAccess/TableDA.cs | 114 ------ VAR.DatabaseExplorer/Code/DataTableHelper.cs | 104 ----- .../Code/DataTransfer/Column.cs | 36 -- .../Code/DataTransfer/Database.cs | 22 -- .../Code/DataTransfer/Procedure.cs | 31 -- .../Code/DataTransfer/ProcedureDefinition.cs | 9 - .../Code/DataTransfer/Server.cs | 25 -- .../Code/DataTransfer/Table.cs | 25 -- .../Code/DataTransfer/TableRow.cs | 17 - .../Code/DataTransfer/User.cs | 18 - .../Code/DataTransfer/ViewDefinition.cs | 9 - .../Code/SplittingStreamWriter.cs | 65 --- VAR.DatabaseExplorer/Code/TableRowHelper.cs | 117 ------ .../Controls/CustomListView.cs | 85 ---- .../Controls/CustomTextBox.cs | 37 -- VAR.DatabaseExplorer/Controls/WindowButton.cs | 54 --- VAR.DatabaseExplorer/Program.cs | 20 - .../Properties/AssemblyInfo.cs | 14 - VAR.DatabaseExplorer/UI/FrmData.Designer.cs | 84 ---- VAR.DatabaseExplorer/UI/FrmData.cs | 78 ---- VAR.DatabaseExplorer/UI/FrmData.resx | 120 ------ .../UI/FrmDatabase.Designer.cs | 370 ------------------ VAR.DatabaseExplorer/UI/FrmDatabase.cs | 194 --------- VAR.DatabaseExplorer/UI/FrmDatabase.resx | 126 ------ VAR.DatabaseExplorer/UI/FrmExec.Designer.cs | 153 -------- VAR.DatabaseExplorer/UI/FrmExec.cs | 102 ----- VAR.DatabaseExplorer/UI/FrmExec.resx | 120 ------ VAR.DatabaseExplorer/UI/FrmMain.Designer.cs | 110 ------ VAR.DatabaseExplorer/UI/FrmMain.cs | 98 ----- VAR.DatabaseExplorer/UI/FrmMain.resx | 126 ------ .../UI/FrmRoutines.Designer.cs | 160 -------- VAR.DatabaseExplorer/UI/FrmRoutines.cs | 75 ---- VAR.DatabaseExplorer/UI/FrmRoutines.resx | 120 ------ .../UI/FrmSQLServerSearch.Designer.cs | 264 ------------- VAR.DatabaseExplorer/UI/FrmSQLServerSearch.cs | 85 ---- .../UI/FrmSQLServerSearch.resx | 120 ------ .../VAR.DatabaseExplorer.csproj | 201 ---------- VAR.DatabaseExplorer/app.manifest | 76 ---- VAR.DatabaseExplorer/packages.config | 4 - issues/.keep | 0 49 files changed, 4585 deletions(-) delete mode 100644 .gitignore delete mode 100644 VAR.DatabaseExplorer.sln delete mode 100644 VAR.DatabaseExplorer/Code/BusinessLogic/DatabaseBL.cs delete mode 100644 VAR.DatabaseExplorer/Code/BusinessLogic/ProcedureBL.cs delete mode 100644 VAR.DatabaseExplorer/Code/BusinessLogic/TableBL.cs delete mode 100644 VAR.DatabaseExplorer/Code/DataAccess/ColumnDA.cs delete mode 100644 VAR.DatabaseExplorer/Code/DataAccess/DatabaseDA.cs delete mode 100644 VAR.DatabaseExplorer/Code/DataAccess/ProcedureDA.cs delete mode 100644 VAR.DatabaseExplorer/Code/DataAccess/ServerDA.cs delete mode 100644 VAR.DatabaseExplorer/Code/DataAccess/TableDA.cs delete mode 100644 VAR.DatabaseExplorer/Code/DataTableHelper.cs delete mode 100644 VAR.DatabaseExplorer/Code/DataTransfer/Column.cs delete mode 100644 VAR.DatabaseExplorer/Code/DataTransfer/Database.cs delete mode 100644 VAR.DatabaseExplorer/Code/DataTransfer/Procedure.cs delete mode 100644 VAR.DatabaseExplorer/Code/DataTransfer/ProcedureDefinition.cs delete mode 100644 VAR.DatabaseExplorer/Code/DataTransfer/Server.cs delete mode 100644 VAR.DatabaseExplorer/Code/DataTransfer/Table.cs delete mode 100644 VAR.DatabaseExplorer/Code/DataTransfer/TableRow.cs delete mode 100644 VAR.DatabaseExplorer/Code/DataTransfer/User.cs delete mode 100644 VAR.DatabaseExplorer/Code/DataTransfer/ViewDefinition.cs delete mode 100644 VAR.DatabaseExplorer/Code/SplittingStreamWriter.cs delete mode 100644 VAR.DatabaseExplorer/Code/TableRowHelper.cs delete mode 100644 VAR.DatabaseExplorer/Controls/CustomListView.cs delete mode 100644 VAR.DatabaseExplorer/Controls/CustomTextBox.cs delete mode 100644 VAR.DatabaseExplorer/Controls/WindowButton.cs delete mode 100644 VAR.DatabaseExplorer/Program.cs delete mode 100644 VAR.DatabaseExplorer/Properties/AssemblyInfo.cs delete mode 100644 VAR.DatabaseExplorer/UI/FrmData.Designer.cs delete mode 100644 VAR.DatabaseExplorer/UI/FrmData.cs delete mode 100644 VAR.DatabaseExplorer/UI/FrmData.resx delete mode 100644 VAR.DatabaseExplorer/UI/FrmDatabase.Designer.cs delete mode 100644 VAR.DatabaseExplorer/UI/FrmDatabase.cs delete mode 100644 VAR.DatabaseExplorer/UI/FrmDatabase.resx delete mode 100644 VAR.DatabaseExplorer/UI/FrmExec.Designer.cs delete mode 100644 VAR.DatabaseExplorer/UI/FrmExec.cs delete mode 100644 VAR.DatabaseExplorer/UI/FrmExec.resx delete mode 100644 VAR.DatabaseExplorer/UI/FrmMain.Designer.cs delete mode 100644 VAR.DatabaseExplorer/UI/FrmMain.cs delete mode 100644 VAR.DatabaseExplorer/UI/FrmMain.resx delete mode 100644 VAR.DatabaseExplorer/UI/FrmRoutines.Designer.cs delete mode 100644 VAR.DatabaseExplorer/UI/FrmRoutines.cs delete mode 100644 VAR.DatabaseExplorer/UI/FrmRoutines.resx delete mode 100644 VAR.DatabaseExplorer/UI/FrmSQLServerSearch.Designer.cs delete mode 100644 VAR.DatabaseExplorer/UI/FrmSQLServerSearch.cs delete mode 100644 VAR.DatabaseExplorer/UI/FrmSQLServerSearch.resx delete mode 100644 VAR.DatabaseExplorer/VAR.DatabaseExplorer.csproj delete mode 100644 VAR.DatabaseExplorer/app.manifest delete mode 100644 VAR.DatabaseExplorer/packages.config create mode 100644 issues/.keep diff --git a/.gitignore b/.gitignore deleted file mode 100644 index fada17e..0000000 --- a/.gitignore +++ /dev/null @@ -1,9 +0,0 @@ -*.suo -*.exe -*.dll -*.pdb -*.user -*/bin/* -*/obj/* -/.vs/* -/packages/ diff --git a/VAR.DatabaseExplorer.sln b/VAR.DatabaseExplorer.sln deleted file mode 100644 index 4976765..0000000 --- a/VAR.DatabaseExplorer.sln +++ /dev/null @@ -1,22 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.25420.1 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VAR.DatabaseExplorer", "VAR.DatabaseExplorer\VAR.DatabaseExplorer.csproj", "{79531B74-3062-4A71-9953-5702BEBDEC0E}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {79531B74-3062-4A71-9953-5702BEBDEC0E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {79531B74-3062-4A71-9953-5702BEBDEC0E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {79531B74-3062-4A71-9953-5702BEBDEC0E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {79531B74-3062-4A71-9953-5702BEBDEC0E}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/VAR.DatabaseExplorer/Code/BusinessLogic/DatabaseBL.cs b/VAR.DatabaseExplorer/Code/BusinessLogic/DatabaseBL.cs deleted file mode 100644 index 864d8f1..0000000 --- a/VAR.DatabaseExplorer/Code/BusinessLogic/DatabaseBL.cs +++ /dev/null @@ -1,205 +0,0 @@ -using System.Collections.Generic; -using System.IO; -using System.Linq; -using VAR.DatabaseExplorer.Code.DataAccess; -using VAR.DatabaseExplorer.Code.DataTransfer; - -namespace VAR.DatabaseExplorer.Code.BusinessLogic -{ - public class DatabaseBL - { - internal static Database Database_Get(string connectionString) - { - Database database = DatabaseDA.GetInfo(connectionString); - return database; - } - - public static Database Database_GetSchema(string connectionString, bool fillTableDefinitions = false, bool fillProcDefinitions = false, bool fillViewDefinitions = false) - { - Database database = DatabaseDA.GetInfo(connectionString); - database.Tables = TableBL.Table_GetAll(connectionString, fillTableDefinitions, fillViewDefinitions); - database.Procedures = ProcedureBL.Procedure_GetAll(connectionString, fillProcDefinitions); - return database; - } - - public static void Database_GenerateDocumentation(TextWriter txtWriter, Database database) - { - // Poner cabecera de la documentacion - txtWriter.WriteLine(""); - txtWriter.WriteLine("" + database.Name + ""); - txtWriter.WriteLine(""); - - // Iterar cada tabla - foreach (Table table in database.Tables) - { - // Cabecera de la info de tabla - txtWriter.WriteLine("

" + table.Schema + "." + table.Name + "

"); - - // Iterar las columnas - txtWriter.WriteLine(""); - txtWriter.WriteLine(""); - txtWriter.WriteLine(""); - foreach (Column c in table.Columns) - { - txtWriter.WriteLine(""); - } - txtWriter.WriteLine("
NombreTipoTamañoPrimaria
" + - c.Name + "" + - c.Type + "" + - c.Size + "" + - c.PK + "
"); - } - - // Iterar cada procedimiento - foreach (Procedure proc in database.Procedures) - { - // Cabecera de la info del procedimiento - txtWriter.WriteLine("

" + proc.Schema + "." + proc.Name + "

"); - - txtWriter.WriteLine("
");
-                txtWriter.WriteLine(proc.Definition);
-                txtWriter.WriteLine("
"); - } - - // Poner pie y cerrar fichero - txtWriter.WriteLine(""); - } - - public static void Database_ExportData(TextWriter txtWriter, string connectionString, Database database, List tablesToExportData) - { - const int OneMegaByte = 1 * 1024 * 1024; - const int MaxSizePerBatch = OneMegaByte; - const int MaxSizePerFile = OneMegaByte * 32; - - // Preparar cabecera del script - txtWriter.WriteLine("SET NOCOUNT ON;"); - txtWriter.WriteLine(string.Empty); - - List
tables = database.Tables; - if (tablesToExportData.Any()) - { - tables = tables.Where(t => - tablesToExportData.Select(tted => tted.Schema).Contains(t.Schema) && - tablesToExportData.Select(tted => tted.Name).Contains(t.Name) && - tablesToExportData.Select(tted => tted.Type).Contains(t.Type)).ToList(); - } - - // Desactivar todas las FKs - txtWriter.WriteLine("-- Disable all constraints"); - foreach (Table table in tables) - { - if (table.Type != "BASE TABLE") { continue; } - - string tableName = string.Format("[{0}].[{1}]", table.Schema, table.Name); - txtWriter.WriteLine(string.Format("ALTER TABLE {0} NOCHECK CONSTRAINT all;", tableName)); - } - txtWriter.WriteLine("GO"); - txtWriter.WriteLine(string.Empty); - - // Prepara información a exportar - long batchLength = 0; - long fileLength = 0; - foreach (Table table in tables) - { - TableBL.Table_ExportData(table, txtWriter, connectionString, (lenght, onSplit) => - { - batchLength += lenght; - fileLength += lenght; - - if (batchLength > MaxSizePerBatch) - { - txtWriter.WriteLine("PRINT '...';"); - txtWriter.WriteLine("GO"); - batchLength = 0; - onSplit?.Invoke(txtWriter); - } - if (fileLength > MaxSizePerFile) - { - txtWriter.WriteLine("PRINT '...';"); - txtWriter.WriteLine("GO"); - SplittingStreamWriter.Split(txtWriter); - fileLength = 0; - batchLength = 0; - onSplit?.Invoke(txtWriter); - } - }); - } - - // Activar todas las FKs - txtWriter.WriteLine("-- Enable all constraints"); - foreach (Table table in tables) - { - if (table.Type != "BASE TABLE") { continue; } - - string tableName = string.Format("[{0}].[{1}]", table.Schema, table.Name); - txtWriter.WriteLine(string.Format("ALTER TABLE {0} WITH CHECK CHECK CONSTRAINT all;", tableName)); - } - txtWriter.WriteLine("GO"); - txtWriter.WriteLine(string.Empty); - } - - public static void Database_ExportTables(TextWriter txtWriter, string connectionString, Database database) - { - foreach (Table table in database.Tables) - { - TableBL.Table_GenerateCreate(table, txtWriter); - } - } - - public static void Database_ExportFunctions(StreamWriter txtWriter, Database database) - { - List exportedRoutines = new List(); - - int exportedOnLoopCount = 0; - do - { - exportedOnLoopCount = 0; - foreach (Procedure routine in database.Procedures) - { - if (exportedRoutines.Any(er => er.Schema == routine.Schema && er.Name == routine.Name)) { continue; } - if (routine.Dependencies.Count > 0) - { - if (routine.Dependencies.Any(pd => exportedRoutines.Any(er => er.Schema == pd.Schema && er.Name == pd.Name) == false)) - { - continue; - } - } - - ProcedureBL.Procedure_GenerateCreate(routine, txtWriter); - exportedRoutines.Add(routine); - exportedOnLoopCount++; - } - } while (exportedOnLoopCount > 0); - } - - public static void Database_ExportSchemas(StreamWriter txtWriter, string connectionString, Database database) - { - // Preparar cabecera del script - txtWriter.WriteLine("SET NOCOUNT ON;"); - txtWriter.WriteLine("GO"); - txtWriter.WriteLine(string.Empty); - - List schemas = DatabaseDA.GetSchemas(connectionString); - foreach (string schema in schemas) - { - txtWriter.WriteLine(string.Format("CREATE SCHEMA [{0}];", schema)); - txtWriter.WriteLine("GO"); - txtWriter.WriteLine(string.Empty); - } - } - - public static void Database_ExportViews(StreamWriter txtWriter, Database database) - { - // Preparar cabecera del script - txtWriter.WriteLine("SET NOCOUNT ON;"); - txtWriter.WriteLine("GO"); - txtWriter.WriteLine(string.Empty); - - foreach (Table table in database.Tables) - { - if (table.Type != "VIEW") { continue; } - TableBL.View_GenerateCreate(table, txtWriter); - } - } - } -} \ No newline at end of file diff --git a/VAR.DatabaseExplorer/Code/BusinessLogic/ProcedureBL.cs b/VAR.DatabaseExplorer/Code/BusinessLogic/ProcedureBL.cs deleted file mode 100644 index 2b84dce..0000000 --- a/VAR.DatabaseExplorer/Code/BusinessLogic/ProcedureBL.cs +++ /dev/null @@ -1,137 +0,0 @@ -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using VAR.DatabaseExplorer.Code.DataAccess; -using VAR.DatabaseExplorer.Code.DataTransfer; - -namespace VAR.DatabaseExplorer.Code.BusinessLogic -{ - public class ProcedureBL - { - public static List Procedure_GetAll(string connectionString, bool fillDefinition = false) - { - List procedures = ProcedureDA.GetAllProcedures(connectionString); - if (fillDefinition) - { - // Get all definitions - List definitions = ProcedureDA.GetProcedureDefinitions(connectionString, null, null); - foreach (Procedure procedure in procedures) - { - var sbDefinition = new StringBuilder(); - foreach (ProcedureDefinition definition in definitions) - { - if (procedure.Schema == definition.ProcedureSchema && procedure.Name == definition.ProcedureName) - { - sbDefinition.Append(definition.Definition); - } - } - procedure.Definition = sbDefinition.ToString(); - } - Procedure_AssingDependencies(procedures); - } - return procedures; - } - - private static void Procedure_AssignDependency(Procedure procedure, Procedure procedureDep) - { - if (procedure.Dependencies.Any(pd => procedureDep.Schema == pd.Schema && procedureDep.Name == pd.Name)) { return; } - procedure.Dependencies.Add(procedureDep); - } - - private static void Procedure_CheckDependencies(IEnumerable procedures, Procedure procedureDep, string strProcFullName) - { - foreach (Procedure procedure in procedures) - { - if (procedure.Schema == procedureDep.Schema && procedure.Name == procedureDep.Name) { continue; } - - if (string.IsNullOrEmpty(procedure.DefinitionLowercase)) - { - procedure.DefinitionLowercase = procedure.Definition.ToLower(); - } - if (procedure.DefinitionLowercase.Contains(strProcFullName)) - { - Procedure_AssignDependency(procedure, procedureDep); - } - } - } - - private static void Procedure_AssingDependencies(IEnumerable procedures) - { - foreach (Procedure procedureDep in procedures) - { - string strProcFullName; - string strProcedureSchema = procedureDep.Schema.ToLower(); - string strProcedureName = procedureDep.Name.ToLower(); - - strProcFullName = string.Format("{0}.{1} ", strProcedureSchema, strProcedureName); - Procedure_CheckDependencies(procedures, procedureDep, strProcFullName); - strProcFullName = string.Format("{0}.{1}(", strProcedureSchema, strProcedureName); - Procedure_CheckDependencies(procedures, procedureDep, strProcFullName); - - strProcFullName = string.Format("[{0}].{1} ", strProcedureSchema, strProcedureName); - Procedure_CheckDependencies(procedures, procedureDep, strProcFullName); - strProcFullName = string.Format("[{0}].{1}(", strProcedureSchema, strProcedureName); - Procedure_CheckDependencies(procedures, procedureDep, strProcFullName); - strProcFullName = string.Format("{0}.[{1}]", strProcedureSchema, strProcedureName); - Procedure_CheckDependencies(procedures, procedureDep, strProcFullName); - strProcFullName = string.Format("[{0}].[{1}]", strProcedureSchema, strProcedureName); - Procedure_CheckDependencies(procedures, procedureDep, strProcFullName); - - strProcFullName = string.Format("\"{0}\".{1} ", strProcedureSchema, strProcedureName); - Procedure_CheckDependencies(procedures, procedureDep, strProcFullName); - strProcFullName = string.Format("\"{0}\".{1}(", strProcedureSchema, strProcedureName); - Procedure_CheckDependencies(procedures, procedureDep, strProcFullName); - strProcFullName = string.Format("{0}.\"{1}\"", strProcedureSchema, strProcedureName); - Procedure_CheckDependencies(procedures, procedureDep, strProcFullName); - strProcFullName = string.Format("\"{0}\".\"{1}\"", strProcedureSchema, strProcedureName); - Procedure_CheckDependencies(procedures, procedureDep, strProcFullName); - } - } - - public static void Procedure_GenerateCreate(Procedure routine, StreamWriter txtWriter) - { - string routineName = string.Format("[{0}].[{1}]", routine.Schema, routine.Name); - if (routine.Type.ToUpper() == "PROCEDURE") - { - txtWriter.WriteLine(string.Format("PRINT '*** Creating procedure {0}....';", routineName)); - txtWriter.WriteLine(string.Format("IF EXISTS (SELECT TOP 1 1 FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_SCHEMA = '{0}' AND ROUTINE_NAME = '{1}')", routine.Schema, routine.Name)); - txtWriter.WriteLine("BEGIN"); - txtWriter.WriteLine(string.Format(" DROP PROCEDURE {0};", routineName)); - txtWriter.WriteLine("END"); - } - if (routine.Type.ToUpper() == "FUNCTION") - { - txtWriter.WriteLine(string.Format("PRINT '*** Creating function {0}....';", routineName)); - txtWriter.WriteLine(string.Format("IF EXISTS (SELECT TOP 1 1 FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_SCHEMA = '{0}' AND ROUTINE_NAME = '{1}')", routine.Schema, routine.Name)); - txtWriter.WriteLine("BEGIN"); - txtWriter.WriteLine(string.Format(" DROP FUNCTION {0};", routineName)); - txtWriter.WriteLine("END"); - } - - txtWriter.WriteLine("GO"); - txtWriter.WriteLine(routine.Definition); - txtWriter.WriteLine("GO"); - txtWriter.WriteLine(); - } - - public static List Procedure_VerifyAndGetInvalidProcedures(string connectionString) - { - List procedures = ProcedureDA.GetAllProcedures(connectionString); - List invalidProcedures = new List(); - foreach (Procedure procedure in procedures) - { - if (DatabaseDA.VerifyModule(connectionString, procedure.Schema, procedure.Name) == false) - { - invalidProcedures.Add(procedure); - } - } - return invalidProcedures; - } - - public static void Procedure_DeleteProcedures(string connectionString, List procedures) - { - ProcedureDA.Procedure_DeleteProcedures(connectionString, procedures); - } - } -} \ No newline at end of file diff --git a/VAR.DatabaseExplorer/Code/BusinessLogic/TableBL.cs b/VAR.DatabaseExplorer/Code/BusinessLogic/TableBL.cs deleted file mode 100644 index 3f88f0e..0000000 --- a/VAR.DatabaseExplorer/Code/BusinessLogic/TableBL.cs +++ /dev/null @@ -1,205 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Data; -using System.IO; -using System.Linq; -using System.Text; -using VAR.DatabaseExplorer.Code.DataAccess; -using VAR.DatabaseExplorer.Code.DataTransfer; - -namespace VAR.DatabaseExplorer.Code.BusinessLogic -{ - public class TableBL - { - public static List
Table_GetAll(string connectionString, bool fillColumns = false, bool fillViewDefinitions = false) - { - List
tables = TableDA.GetAllTables(connectionString); - if (fillColumns) - { - List allColumns = ColumnDA.GetColumns(connectionString, null, null); - foreach (Table table in tables) - { - table.Columns = allColumns.Where(c => c.TableName == table.Name && c.TableSchema == table.Schema).ToList(); - } - } - if (fillViewDefinitions) - { - // Get all view definitions - List definitions = TableDA.GetViewDefinitions(connectionString, null, null); - foreach (Table table in tables) - { - var sbDefinition = new StringBuilder(); - foreach (ViewDefinition definition in definitions) - { - if (table.Schema == definition.ViewSchema && table.Name == definition.ViewName) - { - sbDefinition.Append(definition.Definition); - } - } - table.ViewDefinition = sbDefinition.ToString(); - } - } - return tables; - } - - public static void Table_ExportData(Table t, TextWriter txtWriter, string conectionString, Action> notifyLenght = null) - { - if (t.Type != "BASE TABLE") { return; } - - string tableName = string.Format("[{0}].[{1}]", t.Schema, t.Name); - txtWriter.WriteLine(string.Format("PRINT '*** Importing data of {0}....';", tableName)); - IEnumerable rows = TableDA.GetData(conectionString, tableName); - if (t.Columns.Any(c => c.Indentity)) - { - txtWriter.WriteLine(string.Format("-- {0}", tableName)); - txtWriter.WriteLine(string.Format("DELETE FROM {0};", tableName)); - txtWriter.WriteLine(string.Format("DBCC CHECKIDENT ('{0}', RESEED, 0);", tableName)); - txtWriter.WriteLine("GO"); - txtWriter.WriteLine(string.Format("SET IDENTITY_INSERT {0} ON;", tableName)); - foreach (TableRow row in rows) - { - int lenght = TableRowHelper.TableRow_GenerateInsert(txtWriter, row, tableName); - notifyLenght?.Invoke(lenght, (txt) => - { - txtWriter.WriteLine("GO"); - txtWriter.WriteLine(string.Format("SET IDENTITY_INSERT {0} ON;", tableName)); - }); - } - txtWriter.WriteLine("GO"); - txtWriter.WriteLine(string.Format("SET IDENTITY_INSERT {0} OFF;", tableName)); - txtWriter.WriteLine("GO"); - txtWriter.WriteLine(string.Empty); - } - else - { - txtWriter.WriteLine(string.Format("-- {0}", tableName)); - txtWriter.WriteLine(string.Format("DELETE FROM {0};", tableName)); - txtWriter.WriteLine("GO"); - foreach (TableRow row in rows) - { - int lenght = TableRowHelper.TableRow_GenerateInsert(txtWriter, row, tableName); - notifyLenght?.Invoke(lenght, null); - } - txtWriter.WriteLine("GO"); - txtWriter.WriteLine(string.Empty); - } - } - - public static void Table_GenerateCreate(Table table, TextWriter txtWriter) - { - if (table.Type != "BASE TABLE") { return; } - - string tableName = string.Format("[{0}].[{1}]", table.Schema, table.Name); - txtWriter.WriteLine(string.Format("PRINT '*** Creating tabla {0}....';", tableName)); - txtWriter.WriteLine(string.Format("IF EXISTS (SELECT TOP 1 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '{0}' AND TABLE_NAME = '{1}')", table.Schema, table.Name)); - txtWriter.WriteLine("BEGIN"); - txtWriter.WriteLine(string.Format(" DROP TABLE {0};", tableName)); - txtWriter.WriteLine("END"); - - txtWriter.WriteLine("GO"); - txtWriter.WriteLine(string.Format("CREATE TABLE {0} (", tableName)); - bool firstColumn = true; - foreach (Column c in table.Columns) - { - if (firstColumn == false) - { - txtWriter.WriteLine(","); - } - txtWriter.Write(" ["); - txtWriter.Write(c.Name); - txtWriter.Write("] "); - if ( - c.Type == "nvarchar" || - c.Type == "varchar" || - c.Type == "char" || - c.Type == "nchar" || - c.Type == "binary" || - c.Type == "varbinary" || - false) - { - if (c.Size < 0) - { - txtWriter.Write(string.Format("{0}(MAX)", c.Type)); - } - else - { - txtWriter.Write(string.Format("{0}({1})", c.Type, c.Size)); - } - } - else - { - txtWriter.Write(c.Type); - } - if (string.IsNullOrEmpty(c.Colation) == false && ( - c.Type == "nvarchar" || - c.Type == "varchar" || - c.Type == "char" || - c.Type == "nchar" || - false - )) - { - txtWriter.Write(string.Format(" COLLATE {0}", c.Colation)); - } - if (c.Nullable) - { - txtWriter.Write(" NULL"); - } - else - { - txtWriter.Write(" NOT NULL"); - } - if (c.PK) - { - txtWriter.Write(" PRIMARY KEY"); - } - if (c.Indentity) - { - txtWriter.Write(" IDENTITY(1,1)"); - } - firstColumn = false; - - } - txtWriter.WriteLine(); - txtWriter.WriteLine(string.Format(");")); - txtWriter.WriteLine("GO"); - txtWriter.WriteLine(); - } - - public static void View_GenerateCreate(Table table, StreamWriter txtWriter) - { - if (table.Type != "VIEW") { return; } - - string viewName = string.Format("[{0}].[{1}]", table.Schema, table.Name); - txtWriter.WriteLine(string.Format("PRINT '*** Creating view {0}....';", viewName)); - txtWriter.WriteLine(string.Format("IF EXISTS (SELECT TOP 1 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '{0}' AND TABLE_NAME = '{1}')", table.Schema, table.Name)); - txtWriter.WriteLine("BEGIN"); - txtWriter.WriteLine(string.Format(" DROP VIEW {0};", viewName)); - txtWriter.WriteLine("END"); - - txtWriter.WriteLine("GO"); - txtWriter.WriteLine(table.ViewDefinition); - txtWriter.WriteLine("GO"); - txtWriter.WriteLine(); - } - - public static List
View_VerifyAndGetInvalidViews(string connectionString) - { - List
tables = TableDA.GetAllTables(connectionString); - List
invalidViews = new List
(); - foreach (Table table in tables) - { - if (table.Type != "VIEW") { continue; } - if (DatabaseDA.VerifyModule(connectionString, table.Schema, table.Name) == false) - { - invalidViews.Add(table); - } - } - return invalidViews; - } - - public static void View_DeleteViews(string connectionString, List
views) - { - TableDA.View_DeleteViews(connectionString, views); - } - } -} \ No newline at end of file diff --git a/VAR.DatabaseExplorer/Code/DataAccess/ColumnDA.cs b/VAR.DatabaseExplorer/Code/DataAccess/ColumnDA.cs deleted file mode 100644 index 43d4b68..0000000 --- a/VAR.DatabaseExplorer/Code/DataAccess/ColumnDA.cs +++ /dev/null @@ -1,93 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Data; -using System.Data.SqlClient; -using VAR.DatabaseExplorer.Code.DataTransfer; - -namespace VAR.DatabaseExplorer.Code.DataAccess -{ - public class ColumnDA - { - public static List GetColumns(string conexionString, string tableSchema, string tableName) - { - var columns = new List(); - var cnx = new SqlConnection(conexionString); - - // Preparar comando y parametros - var da = new SqlDataAdapter(@" - SELECT - col.TABLE_SCHEMA TableSchema, - col.TABLE_NAME TableName, - col.COLUMN_NAME AS ColumnName, - col.DATA_TYPE AS Type, - col.CHARACTER_MAXIMUM_LENGTH AS Size, - c.KeyType AS KeyType, - col.IS_NULLABLE AS Nullable, - CASE WHEN (COLUMNPROPERTY(object_id(col.TABLE_SCHEMA+'.'+col.TABLE_NAME), col.COLUMN_NAME, 'IsIdentity') = 1) THEN 1 ELSE 0 END IsIdentity, - col.COLLATION_NAME Colation, - NULL EmptyColumn - FROM INFORMATION_SCHEMA.COLUMNS AS col - LEFT JOIN ( - SELECT - k.TABLE_SCHEMA TableSchema, - k.TABLE_NAME TableName, - k.COLUMN_NAME ColumnName, - c.CONSTRAINT_TYPE KeyType - FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS k - LEFT JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS AS c - ON k.CONSTRAINT_NAME=c.CONSTRAINT_NAME AND - k.TABLE_NAME=c.TABLE_NAME AND - k.TABLE_SCHEMA=c.TABLE_SCHEMA - ) c ON col.COLUMN_NAME=c.ColumnName AND - col.TABLE_NAME=c.TableName AND - col.TABLE_SCHEMA=c.TableSchema AND - c.KeyType = 'PRIMARY KEY' - WHERE (@TableName IS NULL OR col.TABLE_NAME=@TableName) AND - (@TableSchema IS NULL OR col.TABLE_SCHEMA=@TableSchema) - ORDER BY col.TABLE_SCHEMA, col.TABLE_NAME, col.ORDINAL_POSITION - ", cnx); - var prm = new SqlParameter("@TableName", SqlDbType.VarChar, 100) { Value = (object)tableName ?? DBNull.Value }; - da.SelectCommand.Parameters.Add(prm); - prm = new SqlParameter("@TableSchema", SqlDbType.VarChar, 100) { Value = (object)tableSchema ?? DBNull.Value }; - da.SelectCommand.Parameters.Add(prm); - - // Obtener datatable con las columnas - var dt = new DataTable(); - cnx.Open(); - da.Fill(dt); - cnx.Close(); - - // Recorrer datatable estableciendo la lista de columnas - foreach (DataRow dr in dt.Rows) - { - Column col = new Column(); - - col.TableSchema = Convert.ToString(dr["TableSchema"]); - col.TableName = Convert.ToString(dr["TableName"]); - col.Name = Convert.ToString(dr["ColumnName"]); - - col.Type = Convert.ToString(dr["Type"]); - - if ((dr["Size"] is DBNull) == false) - { - col.Size = Convert.ToInt32(dr["Size"]); - } - - string strNullable = (Convert.ToString(dr["Nullable"])).ToLower(); - col.Nullable = (strNullable == "yes") || (strNullable == "1") || (strNullable == "true"); - - string KeyType = Convert.ToString(dr["KeyType"]).ToLower(); - if (KeyType.Contains("primary")) - { - col.PK = true; - } - col.Indentity = Convert.ToBoolean(dr["IsIdentity"]); - col.Colation = Convert.ToString(dr["Colation"]); - - columns.Add(col); - } - - return columns; - } - } -} \ No newline at end of file diff --git a/VAR.DatabaseExplorer/Code/DataAccess/DatabaseDA.cs b/VAR.DatabaseExplorer/Code/DataAccess/DatabaseDA.cs deleted file mode 100644 index fd7c49a..0000000 --- a/VAR.DatabaseExplorer/Code/DataAccess/DatabaseDA.cs +++ /dev/null @@ -1,137 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Data; -using System.Data.SqlClient; -using System.Linq; -using VAR.DatabaseExplorer.Code.DataTransfer; - -namespace VAR.DatabaseExplorer.Code.DataAccess -{ - public class DatabaseDA - { - public static List GetAllDatabases(string connectionString) - { - var databases = new List(); - var cnx = new SqlConnection(connectionString); - - cnx.Open(); - DataTable dt = cnx.GetSchema("Databases"); - cnx.Close(); - dt.DefaultView.Sort = "database_name ASC, create_date ASC"; - dt = dt.DefaultView.ToTable(); - - foreach (DataRow dr in dt.Rows) - { - databases.Add(new Database - { - Name = (string)dr["database_name"], - CreateDate = (DateTime)dr["create_date"] - }); - } - return databases; - } - - public static Database GetInfo(string connectionString) - { - string databaseName = null; - var cnx = new SqlConnection(connectionString); - string strCmd = string.Format(@" - SELECT - [name] DatabaseName, - [create_date] CreateDate - FROM sys.databases - WHERE database_id = DB_ID(); - "); - var da = new SqlDataAdapter(strCmd, cnx); - var dt = new DataTable(); - cnx.Open(); - databaseName = cnx.Database; - da.Fill(dt); - cnx.Close(); - - if(dt.Rows.Count == 0) - { - return new Database - { - Name = databaseName, - CreateDate = DateTime.UtcNow, - }; - } - - var database = new Database - { - Name = Convert.ToString(dt.Rows[0]["DatabaseName"]), - CreateDate = Convert.ToDateTime(dt.Rows[0]["CreateDate"]), - }; - return database; - } - - public static List GetSchemas(string connectionString) - { - var cnx = new SqlConnection(connectionString); - string strCmd = string.Format(@" - select s.name as schema_name - from sys.schemas s - where s.principal_id = 1 AND schema_id != 1 - order by s.name - "); - var da = new SqlDataAdapter(strCmd, cnx); - var dt = new DataTable(); - cnx.Open(); - da.Fill(dt); - cnx.Close(); - - List schemas = dt.AsEnumerable().Select(dr => Convert.ToString(dr["schema_name"])).ToList(); - return schemas; - } - - public static bool SupportedSqlServerVersion(string serverVersion) - { - return - serverVersion.StartsWith("10.") || - serverVersion.StartsWith("11.") || - serverVersion.StartsWith("12.") || - serverVersion.StartsWith("13.") || - serverVersion.StartsWith("14.") || - serverVersion.StartsWith("15.") || - serverVersion.StartsWith("16.") || - false; - } - - public static bool VerifyModule(string connectionString, string schema, string name) - { - SqlDataAdapter dataAdapter; - var cnx = new SqlConnection(connectionString); - cnx.Open(); - - string procedureName = string.Format("[{0}].[{1}]", schema, name); - - if (SupportedSqlServerVersion(cnx.ServerVersion)) - { - dataAdapter = new SqlDataAdapter(@" - BEGIN TRY - EXECUTE sys.sp_refreshsqlmodule @Name; - SELECT 1 'OK'; - END TRY - BEGIN CATCH - SELECT 0 'OK'; - END CATCH - ", cnx); - dataAdapter.SelectCommand.Parameters.AddWithValue("@Name", (object)procedureName ?? DBNull.Value); - } - else - { - cnx.Close(); - return true; - } - - var dt = new DataTable(); - dataAdapter.Fill(dt); - cnx.Close(); - - int isOK = Convert.ToInt32(dt.Rows[0][0]); - - return isOK != 0; - } - } -} \ No newline at end of file diff --git a/VAR.DatabaseExplorer/Code/DataAccess/ProcedureDA.cs b/VAR.DatabaseExplorer/Code/DataAccess/ProcedureDA.cs deleted file mode 100644 index 7fa8f26..0000000 --- a/VAR.DatabaseExplorer/Code/DataAccess/ProcedureDA.cs +++ /dev/null @@ -1,157 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Data; -using System.Data.SqlClient; -using System.Text; -using VAR.DatabaseExplorer.Code.DataTransfer; - -namespace VAR.DatabaseExplorer.Code.DataAccess -{ - public class ProcedureDA - { - public static List GetAllProcedures(string connectionString) - { - var procedures = new List(); - var cnx = new SqlConnection(connectionString); - - var da = new SqlDataAdapter( - "SELECT ROUTINE_NAME Name, ROUTINE_SCHEMA [Schema], CREATED CreateDate, ROUTINE_TYPE [Type] FROM INFORMATION_SCHEMA.ROUTINES", - cnx); - var dt = new DataTable(); - cnx.Open(); - da.Fill(dt); - cnx.Close(); - - foreach (DataRow dr in dt.Rows) - { - procedures.Add(new Procedure - { - Schema = Convert.ToString(dr["Schema"]), - Name = Convert.ToString(dr["Name"]), - Type = Convert.ToString(dr["Type"]), - CreateDate = Convert.ToDateTime(dr["CreateDate"]), - }); - } - return procedures; - } - - public static string GetProcedureDefinition(string connectionString, string schema, string name) - { - SqlDataAdapter dataAdapter; - var cnx = new SqlConnection(connectionString); - cnx.Open(); - - if (DatabaseDA.SupportedSqlServerVersion(cnx.ServerVersion)) - { - dataAdapter = new SqlDataAdapter(@" - SELECT - sn.name ProcedureSchema, - sp.name ProcedureName, - ISNULL(smsp.definition, ssmsp.definition) AS [Definition] - FROM sys.all_objects AS sp - INNER JOIN sys.schemas sn ON sp.schema_id = sn.schema_id - LEFT OUTER JOIN sys.sql_modules AS smsp ON smsp.object_id = sp.object_id - LEFT OUTER JOIN sys.system_sql_modules AS ssmsp ON ssmsp.object_id = sp.object_id - WHERE - (sp.type = N'P' OR sp.type = N'RF' OR sp.type = N'PC' OR sp.type = N'IF' OR sp.type = N'FN' OR sp.type = N'TF') - AND - (@name IS NULL OR sp.name = @name) AND - (@schema IS NULL OR sn.name = @schema) - ", cnx); - dataAdapter.SelectCommand.Parameters.AddWithValue("@Name", name); - dataAdapter.SelectCommand.Parameters.AddWithValue("@Schema", schema); - } - else - { - cnx.Close(); - return null; - } - - var dt = new DataTable(); - dataAdapter.Fill(dt); - cnx.Close(); - - var sbProc = new StringBuilder(); - foreach (DataRow dr in dt.Rows) - { - string strProcBlock = Convert.ToString(dr["Definition"]); - strProcBlock = strProcBlock.Replace("\r", "").Replace("\n", "\r\n"); - sbProc.Append(strProcBlock); - } - - return sbProc.ToString(); - } - - public static List GetProcedureDefinitions(string connectionString, string schema, string name) - { - SqlDataAdapter dataAdapter; - var cnx = new SqlConnection(connectionString); - cnx.Open(); - - if (DatabaseDA.SupportedSqlServerVersion(cnx.ServerVersion)) - { - dataAdapter = new SqlDataAdapter(@" - SELECT - sn.name ProcedureSchema, - sp.name ProcedureName, - ISNULL(smsp.definition, ssmsp.definition) AS [Definition] - FROM sys.all_objects AS sp - INNER JOIN sys.schemas sn ON sp.schema_id = sn.schema_id - LEFT OUTER JOIN sys.sql_modules AS smsp ON smsp.object_id = sp.object_id - LEFT OUTER JOIN sys.system_sql_modules AS ssmsp ON ssmsp.object_id = sp.object_id - WHERE - (sp.type = N'P' OR sp.type = N'RF' OR sp.type = N'PC' OR sp.type = N'IF' OR sp.type = N'FN' OR sp.type = N'TF') - AND - (@name IS NULL OR sp.name = @name) AND - (@schema IS NULL OR sn.name = @schema) - ", cnx); - dataAdapter.SelectCommand.Parameters.AddWithValue("@Name", (object)name ?? DBNull.Value); - dataAdapter.SelectCommand.Parameters.AddWithValue("@Schema", (object)schema ?? DBNull.Value); - } - else - { - cnx.Close(); - return null; - } - - var dt = new DataTable(); - dataAdapter.Fill(dt); - cnx.Close(); - - var definitions = new List(); - foreach (DataRow dr in dt.Rows) - { - string strProcSchema = Convert.ToString(dr["ProcedureSchema"]); - string strProcName = Convert.ToString(dr["ProcedureName"]); - string strProcBlock = Convert.ToString(dr["Definition"]); - strProcBlock = strProcBlock.Replace("\r", "").Replace("\n", "\r\n"); - definitions.Add(new ProcedureDefinition { ProcedureSchema = strProcSchema, ProcedureName = strProcName, Definition = strProcBlock }); - } - - return definitions; - } - - public static void Procedure_DeleteProcedures(string connectionString, List procedures) - { - var cnx = new SqlConnection(connectionString); - cnx.Open(); - - foreach (Procedure procedure in procedures) - { - string strCmd = null; - if (procedure.Type == "FUNCTION") - { - strCmd = string.Format("DROP FUNCTION [{0}].[{1}]", procedure.Schema, procedure.Name); - } - else - { - strCmd = string.Format("DROP PROCEDURE [{0}].[{1}]", procedure.Schema, procedure.Name); - } - var cmd = new SqlCommand(strCmd, cnx); - cmd.ExecuteNonQuery(); - } - - cnx.Close(); - } - } -} \ No newline at end of file diff --git a/VAR.DatabaseExplorer/Code/DataAccess/ServerDA.cs b/VAR.DatabaseExplorer/Code/DataAccess/ServerDA.cs deleted file mode 100644 index e403b28..0000000 --- a/VAR.DatabaseExplorer/Code/DataAccess/ServerDA.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Data; -using System.Data.Sql; -using VAR.DatabaseExplorer.Code.DataTransfer; - -namespace VAR.DatabaseExplorer.Code.DataAccess -{ - public class ServerDA - { - public static List GetAllServers() - { - var servers = new List(); - SqlDataSourceEnumerator enumerador = SqlDataSourceEnumerator.Instance; - - DataTable dtServers = enumerador.GetDataSources(); - dtServers.DefaultView.Sort = "ServerName ASC, InstanceName ASC, Version ASC"; - dtServers = dtServers.DefaultView.ToTable(); - - foreach (DataRow dr in dtServers.Rows) - { - servers.Add(new Server - { - Name = (dr["ServerName"] == DBNull.Value) ? string.Empty : (string)dr["ServerName"], - Instance = (dr["InstanceName"] == DBNull.Value) ? string.Empty : (string)dr["InstanceName"], - Version = (dr["Version"] == DBNull.Value) ? "???" : (string)dr["Version"] - }); - } - return servers; - } - } -} \ No newline at end of file diff --git a/VAR.DatabaseExplorer/Code/DataAccess/TableDA.cs b/VAR.DatabaseExplorer/Code/DataAccess/TableDA.cs deleted file mode 100644 index b5eacf4..0000000 --- a/VAR.DatabaseExplorer/Code/DataAccess/TableDA.cs +++ /dev/null @@ -1,114 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Data; -using System.Data.SqlClient; -using VAR.DatabaseExplorer.Code.DataTransfer; - -namespace VAR.DatabaseExplorer.Code.DataAccess -{ - public class TableDA - { - public static List
GetAllTables(string connectionString) - { - var tables = new List
(); - var cnx = new SqlConnection(connectionString); - - cnx.Open(); - DataTable dt = cnx.GetSchema("Tables"); - cnx.Close(); - dt.DefaultView.Sort = "TABLE_SCHEMA ASC, TABLE_NAME ASC, TABLE_TYPE ASC"; - dt = dt.DefaultView.ToTable(); - - foreach (DataRow dr in dt.Rows) - { - Table table = new Table - { - Schema = (string)dr["TABLE_SCHEMA"], - Name = (string)dr["TABLE_NAME"], - Type = (string)dr["TABLE_TYPE"] - }; - - tables.Add(table); - } - - return tables; - } - - public static List GetViewDefinitions(string connectionString, string schema = null, string name = null) - { - SqlDataAdapter dataAdapter; - var cnx = new SqlConnection(connectionString); - cnx.Open(); - - if (DatabaseDA.SupportedSqlServerVersion(cnx.ServerVersion)) - { - dataAdapter = new SqlDataAdapter(@" - SELECT - sn.name ViewSchema, - SO.name ViewName, - ISNULL(SM.definition, SM.definition) AS [Definition] - FROM sys.sql_modules SM - INNER JOIN sys.Objects SO ON SM.Object_id = SO.Object_id - INNER JOIN sys.schemas sn ON SO.schema_id = sn.schema_id - WHERE SO.type = 'v' - AND - (@name IS NULL OR SO.name = @name) AND - (@schema IS NULL OR sn.name = @schema) - ", cnx); - dataAdapter.SelectCommand.Parameters.AddWithValue("@Name", (object)name ?? DBNull.Value); - dataAdapter.SelectCommand.Parameters.AddWithValue("@Schema", (object)schema ?? DBNull.Value); - } - else - { - cnx.Close(); - return null; - } - - var dt = new DataTable(); - dataAdapter.Fill(dt); - cnx.Close(); - - var definitions = new List(); - foreach (DataRow dr in dt.Rows) - { - string strViewSchema = Convert.ToString(dr["ViewSchema"]); - string strViewName = Convert.ToString(dr["ViewName"]); - string strDefinition = Convert.ToString(dr["Definition"]); - strDefinition = strDefinition.Replace("\r", "").Replace("\n", "\r\n"); - definitions.Add(new ViewDefinition { ViewSchema = strViewSchema, ViewName = strViewName, Definition = strDefinition }); - } - - return definitions; - } - - public static IEnumerable GetData(string connectionString, string tableFullName) - { - var cnx = new SqlConnection(connectionString); - string strCmd = string.Format("SELECT * FROM {0}", tableFullName); - var cmd = new SqlCommand(strCmd, cnx); - cnx.Open(); - SqlDataReader reader = cmd.ExecuteReader(); - while (reader.Read()) - { - TableRow row = TableRowHelper.ConvertFromDataRecord(reader); - yield return row; - } - cnx.Close(); - } - - public static void View_DeleteViews(string connectionString, List
views) - { - var cnx = new SqlConnection(connectionString); - cnx.Open(); - - foreach (Table view in views) - { - string strCmd = string.Format("DROP VIEW [{0}].[{1}]", view.Schema, view.Name); - var cmd = new SqlCommand(strCmd, cnx); - cmd.ExecuteNonQuery(); - } - - cnx.Close(); - } - } -} \ No newline at end of file diff --git a/VAR.DatabaseExplorer/Code/DataTableHelper.cs b/VAR.DatabaseExplorer/Code/DataTableHelper.cs deleted file mode 100644 index 595f7af..0000000 --- a/VAR.DatabaseExplorer/Code/DataTableHelper.cs +++ /dev/null @@ -1,104 +0,0 @@ -using System; -using System.Data; -using System.Globalization; -using System.IO; -using System.Text; - -namespace VAR.DatabaseExplorer.Code -{ - public static class DataTableHelper - { - public static void DataTable_GenerateInserts(TextWriter txtWriter, DataTable dataTable, string destTable) - { - const int OneMegaByte = 1 * 1024 * 1024; - const int MaxSizePerBatch = OneMegaByte; - var nfi = new NumberFormatInfo { NumberDecimalSeparator = "." }; - - var sbColumns = new StringBuilder(); - foreach (DataColumn dc in dataTable.Columns) - { - // El nombre de la columna - if (sbColumns.Length > 0) { sbColumns.Append(", "); } - sbColumns.AppendFormat("[{0}]", dc.ColumnName); - } - int size = 0; - // Recorrer la tabla de datos - foreach (DataRow dr in dataTable.Rows) - { - var sbValues = new StringBuilder(); - foreach (DataColumn dc in dataTable.Columns) - { - // El valor de la columna - if (sbValues.Length > 0) { sbValues.Append(", "); } - object valor = dr[dc]; - if (valor == DBNull.Value || valor == null) - { - // NULOS - sbValues.Append("NULL"); - } - else - { - string type = dc.DataType.Name.ToLower(); - if (type == "string") - { - // Cadenas - sbValues.AppendFormat("N'{0}'", ((string)valor).Replace("'", "''")); - } - else if (type == "short" || type == "int16") - { - // short - sbValues.Append(((short)valor).ToString(nfi)); - } - else if (type == "int" || type == "int32") - { - // int - sbValues.Append(((int)valor).ToString(nfi)); - } - else if (type == "long" || type == "int64") - { - // long - sbValues.Append(((long)valor).ToString(nfi)); - } - else if (type == "decimal") - { - // Decimales - sbValues.Append(((decimal)valor).ToString(nfi)); - } - else if (type == "bit" || type == "bool" || type == "boolean") - { - // Booleanos - sbValues.Append(((bool)valor) ? "1" : "0"); - } - else if (type == "byte[]") - { - // Arrays de bytes (imágenes, archivos etc) - sbValues.AppendFormat("0x{0}", BitConverter.ToString(((byte[])valor)).Replace("-", "")); - } - else if (type == "datetime") - { - // DateTime - sbValues.AppendFormat("'{0}'", ((DateTime)valor).ToString("yyyy-MM-dd HH:mm:ss")); - } - else - { - // Otros - sbValues.AppendFormat("'{0}'", valor.ToString()); - } - } - } - - // Insertar fila a la datatable destino - string strLine = string.Format("INSERT INTO {0} ({1}) VALUES ({2});", - destTable, sbColumns.ToString(), sbValues.ToString()); - if ((size + strLine.Length) >= MaxSizePerBatch) - { - txtWriter.WriteLine("PRINT '...';"); - txtWriter.WriteLine("GO"); - size = 0; - } - size += strLine.Length; - txtWriter.WriteLine(strLine); - } - } - } -} \ No newline at end of file diff --git a/VAR.DatabaseExplorer/Code/DataTransfer/Column.cs b/VAR.DatabaseExplorer/Code/DataTransfer/Column.cs deleted file mode 100644 index e092fb1..0000000 --- a/VAR.DatabaseExplorer/Code/DataTransfer/Column.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; -using System.Xml.Serialization; - -namespace VAR.DatabaseExplorer.Code.DataTransfer -{ - [Serializable] - public class Column - { - [XmlAttribute] - public string TableSchema { get; set; } - - [XmlAttribute] - public string TableName { get; set; } - - [XmlAttribute] - public string Name { get; set; } - - [XmlAttribute] - public string Type { get; set; } - - [XmlAttribute] - public int Size { get; set; } - - [XmlAttribute] - public bool Nullable { get; set; } - - [XmlAttribute] - public bool PK { get; set; } - - [XmlAttribute] - public bool Indentity { get; set; } - - [XmlAttribute] - public string Colation { get; set; } - } -} \ No newline at end of file diff --git a/VAR.DatabaseExplorer/Code/DataTransfer/Database.cs b/VAR.DatabaseExplorer/Code/DataTransfer/Database.cs deleted file mode 100644 index 8c3bfb3..0000000 --- a/VAR.DatabaseExplorer/Code/DataTransfer/Database.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Xml.Serialization; - -namespace VAR.DatabaseExplorer.Code.DataTransfer -{ - [Serializable] - public class Database - { - [XmlAttribute] - public string Name { get; set; } - - [XmlAttribute] - public DateTime CreateDate { get; set; } - - [XmlArray] - public List
Tables { get; set; } - - [XmlArray] - public List Procedures { get; set; } - } -} \ No newline at end of file diff --git a/VAR.DatabaseExplorer/Code/DataTransfer/Procedure.cs b/VAR.DatabaseExplorer/Code/DataTransfer/Procedure.cs deleted file mode 100644 index d7d9006..0000000 --- a/VAR.DatabaseExplorer/Code/DataTransfer/Procedure.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Xml.Serialization; - -namespace VAR.DatabaseExplorer.Code.DataTransfer -{ - [Serializable] - public class Procedure - { - [XmlAttribute] - public string Schema { get; set; } - - [XmlAttribute] - public string Name { get; set; } - - [XmlAttribute] - public string Type { get; set; } - - [XmlAttribute] - public DateTime CreateDate { get; set; } - - [XmlElement] - public string Definition { get; set; } - - [XmlIgnore] - public string DefinitionLowercase { get; set; } - - [XmlIgnore] - public List Dependencies { get; } = new List(); - } -} \ No newline at end of file diff --git a/VAR.DatabaseExplorer/Code/DataTransfer/ProcedureDefinition.cs b/VAR.DatabaseExplorer/Code/DataTransfer/ProcedureDefinition.cs deleted file mode 100644 index 9d06da2..0000000 --- a/VAR.DatabaseExplorer/Code/DataTransfer/ProcedureDefinition.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace VAR.DatabaseExplorer.Code.DataTransfer -{ - public class ProcedureDefinition - { - public string ProcedureSchema { get; set; } - public string ProcedureName { get; set; } - public string Definition { get; set; } - } -} diff --git a/VAR.DatabaseExplorer/Code/DataTransfer/Server.cs b/VAR.DatabaseExplorer/Code/DataTransfer/Server.cs deleted file mode 100644 index 98cc77c..0000000 --- a/VAR.DatabaseExplorer/Code/DataTransfer/Server.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Xml.Serialization; - -namespace VAR.DatabaseExplorer.Code.DataTransfer -{ - [Serializable] - public class Server - { - [XmlAttribute] - public string Name { get; set; } - - [XmlAttribute] - public string Instance { get; set; } - - [XmlAttribute] - public string Version { get; set; } - - [XmlArray] - public List Users { get; set; } - - [XmlArray] - public List Databases { get; set; } - } -} \ No newline at end of file diff --git a/VAR.DatabaseExplorer/Code/DataTransfer/Table.cs b/VAR.DatabaseExplorer/Code/DataTransfer/Table.cs deleted file mode 100644 index 22ce175..0000000 --- a/VAR.DatabaseExplorer/Code/DataTransfer/Table.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Xml.Serialization; - -namespace VAR.DatabaseExplorer.Code.DataTransfer -{ - [Serializable] - public class Table - { - [XmlAttribute] - public string Schema { get; set; } - - [XmlAttribute] - public string Name { get; set; } - - [XmlAttribute] - public string Type { get; set; } - - [XmlArray] - public List Columns { get; set; } - - [XmlElement] - public string ViewDefinition { get; set; } - } -} \ No newline at end of file diff --git a/VAR.DatabaseExplorer/Code/DataTransfer/TableRow.cs b/VAR.DatabaseExplorer/Code/DataTransfer/TableRow.cs deleted file mode 100644 index 39791a2..0000000 --- a/VAR.DatabaseExplorer/Code/DataTransfer/TableRow.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace VAR.DatabaseExplorer.Code.DataTransfer -{ - public class TableRow - { - public List Cells { get; } = new List(); - } - - public class TableCell - { - public string Name { get; set; } - public object Data { get; set; } - public Type DataType { get; set; } - } -} diff --git a/VAR.DatabaseExplorer/Code/DataTransfer/User.cs b/VAR.DatabaseExplorer/Code/DataTransfer/User.cs deleted file mode 100644 index 0b5f12d..0000000 --- a/VAR.DatabaseExplorer/Code/DataTransfer/User.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Xml.Serialization; - -namespace VAR.DatabaseExplorer.Code.DataTransfer -{ - [Serializable] - public class User - { - [XmlAttribute] - public bool ImplicitUser { get; set; } - - [XmlAttribute] - public string UserName { get; set; } - - [XmlAttribute] - public string Password { get; set; } - } -} \ No newline at end of file diff --git a/VAR.DatabaseExplorer/Code/DataTransfer/ViewDefinition.cs b/VAR.DatabaseExplorer/Code/DataTransfer/ViewDefinition.cs deleted file mode 100644 index 4d50485..0000000 --- a/VAR.DatabaseExplorer/Code/DataTransfer/ViewDefinition.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace VAR.DatabaseExplorer.Code.DataTransfer -{ - public class ViewDefinition - { - public string ViewSchema { get; set; } - public string ViewName { get; set; } - public string Definition { get; set; } - } -} diff --git a/VAR.DatabaseExplorer/Code/SplittingStreamWriter.cs b/VAR.DatabaseExplorer/Code/SplittingStreamWriter.cs deleted file mode 100644 index a7eea46..0000000 --- a/VAR.DatabaseExplorer/Code/SplittingStreamWriter.cs +++ /dev/null @@ -1,65 +0,0 @@ -using System.IO; -using System.Text; - -namespace VAR.DatabaseExplorer.Code -{ - class SplittingStreamWriter : TextWriter - { - private string _baseFileName = null; - private int _fileNumber = 0; - - private StreamWriter _currentStreamWriter = null; - - public SplittingStreamWriter(string baseFileName) - { - _baseFileName = baseFileName; - _currentStreamWriter = new StreamWriter(string.Format(_baseFileName, _fileNumber)); - } - - public override void Write(char value) - { - _currentStreamWriter.Write(value); - } - - public override void Write(string value) - { - _currentStreamWriter.Write(value); - } - - public override void WriteLine() - { - _currentStreamWriter.WriteLine(); - } - - public override void WriteLine(string value) - { - _currentStreamWriter.WriteLine(value); - } - - public override Encoding Encoding - { - get { return Encoding.Default; } - } - - public void Split() - { - _currentStreamWriter.Close(); - _fileNumber++; - _currentStreamWriter = new StreamWriter(string.Format(_baseFileName, _fileNumber)); - } - - public static void Split(object obj) - { - SplittingStreamWriter splittingStreamWriter = obj as SplittingStreamWriter; - if (obj == null) { return; } - splittingStreamWriter.Split(); - } - - public override void Close() - { - _currentStreamWriter.Close(); - _currentStreamWriter = null; - _fileNumber = 0; - } - } -} diff --git a/VAR.DatabaseExplorer/Code/TableRowHelper.cs b/VAR.DatabaseExplorer/Code/TableRowHelper.cs deleted file mode 100644 index a98b20e..0000000 --- a/VAR.DatabaseExplorer/Code/TableRowHelper.cs +++ /dev/null @@ -1,117 +0,0 @@ -using System; -using System.Data; -using System.Globalization; -using System.IO; -using System.Text; -using VAR.DatabaseExplorer.Code.DataTransfer; - -namespace VAR.DatabaseExplorer.Code -{ - public class TableRowHelper - { - public static TableRow ConvertFromDataRecord(IDataRecord record) - { - var row = new TableRow(); - int columnNumber = record.FieldCount; - for (int i = 0; i < columnNumber; i++) - { - TableCell cell = new TableCell - { - Name = record.GetName(i), - Data = record.GetValue(i), - DataType = record.GetFieldType(i), - }; - row.Cells.Add(cell); - } - return row; - } - - public static int TableRow_GenerateInsert(TextWriter txtWriter, TableRow row, string destTable) - { - var nfi = new NumberFormatInfo { NumberDecimalSeparator = "." }; - - var sbColumns = new StringBuilder(); - foreach (TableCell cell in row.Cells) - { - // El nombre de la columna - if (sbColumns.Length > 0) { sbColumns.Append(", "); } - sbColumns.AppendFormat("[{0}]", cell.Name); - } - var sbValues = new StringBuilder(); - foreach (TableCell cell in row.Cells) - { - // El valor de la columna - if (sbValues.Length > 0) { sbValues.Append(", "); } - object valor = cell.Data; - if (valor == DBNull.Value || valor == null) - { - // NULOS - sbValues.Append("NULL"); - } - else - { - string type = cell.DataType.Name.ToLower(); - if (type == "string") - { - // Cadenas - sbValues.AppendFormat("N'{0}'", ((string)valor).Replace("'", "''")); - } - else if (type == "short" || type == "int16") - { - // short - sbValues.Append(((short)valor).ToString(nfi)); - } - else if (type == "int" || type == "int32") - { - // int - sbValues.Append(((int)valor).ToString(nfi)); - } - else if (type == "long" || type == "int64") - { - // long - sbValues.Append(((long)valor).ToString(nfi)); - } - else if (type == "decimal") - { - // Decimales - sbValues.Append(((decimal)valor).ToString(nfi)); - } - else if (type == "float") - { - // Float - sbValues.Append(((float)valor).ToString(nfi)); - } - else if (type == "double") - { - // Double - sbValues.Append(((double)valor).ToString(nfi)); - } - else if (type == "bit" || type == "bool" || type == "boolean") - { - // Booleanos - sbValues.Append(((bool)valor) ? "1" : "0"); - } - else if (type == "byte[]") - { - // Arrays de bytes (imágenes, archivos etc) - sbValues.AppendFormat("0x{0}", BitConverter.ToString(((byte[])valor)).Replace("-", "")); - } - else if (type == "datetime") - { - // DateTime - sbValues.AppendFormat("'{0}'", ((DateTime)valor).ToString("yyyy-MM-ddTHH:mm:ss.fff")); - } - else - { - // Otros - sbValues.AppendFormat("'{0}'", valor.ToString()); - } - } - } - string strLine = string.Format("INSERT INTO {0} ({1}) VALUES ({2});", - destTable, sbColumns.ToString(), sbValues.ToString()); - txtWriter.WriteLine(strLine); - return strLine.Length; - } - } -} diff --git a/VAR.DatabaseExplorer/Controls/CustomListView.cs b/VAR.DatabaseExplorer/Controls/CustomListView.cs deleted file mode 100644 index 3194e78..0000000 --- a/VAR.DatabaseExplorer/Controls/CustomListView.cs +++ /dev/null @@ -1,85 +0,0 @@ -using System; -using System.Collections; -using System.ComponentModel; -using System.Runtime.InteropServices; -using System.Windows.Forms; - -namespace VAR.DatabaseExplorer.Controls -{ - [DefaultProperty("Items")] - [DefaultEvent("SelectedIndexChanged")] - [ComVisible(true)] - [ClassInterface(ClassInterfaceType.AutoDispatch)] - [Docking(DockingBehavior.Ask)] - public class CustomListView : ListView - { - #region Declarations - - private ListViewItemComparer itemComparer = new ListViewItemComparer(); - - #endregion Declarations - - #region Properties - - private bool allowSorting = false; - - public bool AllowSorting - { - get { return allowSorting; } - set { allowSorting = value; } - } - - #endregion Properties - - #region Control life cicle - - public CustomListView() - { - ColumnClick += CustomListView_ColumnClick; - } - - #endregion Control life cicle - - #region Events - - private void CustomListView_ColumnClick(object sender, ColumnClickEventArgs e) - { - if (!allowSorting) { return; } - itemComparer.SetColumn(e.Column); - ListViewItemSorter = itemComparer; - Sort(); - } - - #endregion Events - } - - #region ListViewItemComparer - - internal class ListViewItemComparer : IComparer - { - private int _col; - private bool _ascending; - - public void SetColumn(int col) - { - _col = col; - _ascending = _col != col || !_ascending; - } - - public int Compare(object x, object y) - { - var itemA = (ListViewItem)x; - var itemB = (ListViewItem)y; - - if (itemA.SubItems.Count <= _col || itemB.SubItems.Count <= _col) - { - return -1; - } - return _ascending - ? String.CompareOrdinal(itemA.SubItems[_col].Text, itemB.SubItems[_col].Text) - : String.CompareOrdinal(itemB.SubItems[_col].Text, itemA.SubItems[_col].Text); - } - } - - #endregion ListViewItemComparer -} \ No newline at end of file diff --git a/VAR.DatabaseExplorer/Controls/CustomTextBox.cs b/VAR.DatabaseExplorer/Controls/CustomTextBox.cs deleted file mode 100644 index 69d5378..0000000 --- a/VAR.DatabaseExplorer/Controls/CustomTextBox.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using System.Windows.Forms; - -namespace VAR.DatabaseExplorer.Controls -{ - [ComVisible(true)] - [ClassInterface(ClassInterfaceType.AutoDispatch)] - public class CustomTextBox : TextBox - { - #region SetTabWidth - - private const int EM_SETTABSTOPS = 0x00CB; - - [DllImport("User32.dll", CharSet = CharSet.Auto)] - private static extern IntPtr SendMessage(IntPtr h, int msg, int wParam, int[] lParam); - - protected void SetTabWidth(int tabWidth) - { - SendMessage(Handle, EM_SETTABSTOPS, 1, new int[] { tabWidth * 4 }); - } - - #endregion SetTabWidth - - private int _tabWidth = 8; - - public int TabWidth - { - get { return _tabWidth; } - set - { - _tabWidth = value; - SetTabWidth(value); - } - } - } -} \ No newline at end of file diff --git a/VAR.DatabaseExplorer/Controls/WindowButton.cs b/VAR.DatabaseExplorer/Controls/WindowButton.cs deleted file mode 100644 index 0206031..0000000 --- a/VAR.DatabaseExplorer/Controls/WindowButton.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System; -using System.Drawing; -using System.Windows.Forms; - -namespace VAR.DatabaseExplorer.Controls -{ - public class WindowButton : Button - { - #region Properties - - private Form _window = null; - - public Form Window - { - get { return _window; } - set { _window = value; } - } - - private bool _active = false; - - public bool Active - { - get { return _active; } - set - { - _active = value; - ForeColor = _active ? Color.Black : Color.Gray; - } - } - - #endregion Properties - - #region Creator - - public WindowButton() - { - AutoSize = true; - AutoSizeMode = AutoSizeMode.GrowAndShrink; - Click += WindowButton_Click; - } - - #endregion Creator - - #region Events - - private void WindowButton_Click(object sender, EventArgs e) - { - if (_window == null) { return; } - _window.Activate(); - } - - #endregion Events - } -} \ No newline at end of file diff --git a/VAR.DatabaseExplorer/Program.cs b/VAR.DatabaseExplorer/Program.cs deleted file mode 100644 index 0a12c68..0000000 --- a/VAR.DatabaseExplorer/Program.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Windows.Forms; -using VAR.DatabaseExplorer.UI; - -namespace VAR.DatabaseExplorer -{ - internal static class Program - { - /// - /// The main entry point for the application. - /// - [STAThread] - private static void Main() - { - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); - Application.Run(new FrmMain()); - } - } -} \ No newline at end of file diff --git a/VAR.DatabaseExplorer/Properties/AssemblyInfo.cs b/VAR.DatabaseExplorer/Properties/AssemblyInfo.cs deleted file mode 100644 index 03c5780..0000000 --- a/VAR.DatabaseExplorer/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; - -[assembly: AssemblyTitle("DatabaseExplorer")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("VAR")] -[assembly: AssemblyProduct("DatabaseExplorer")] -[assembly: AssemblyCopyright("Copyright © VAR 2012-2018")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] -[assembly: ComVisible(false)] -[assembly: Guid("31f76805-336c-471c-8af2-a4c1364e97b9")] -[assembly: AssemblyVersion("1.0.0.*")] \ No newline at end of file diff --git a/VAR.DatabaseExplorer/UI/FrmData.Designer.cs b/VAR.DatabaseExplorer/UI/FrmData.Designer.cs deleted file mode 100644 index 05259c3..0000000 --- a/VAR.DatabaseExplorer/UI/FrmData.Designer.cs +++ /dev/null @@ -1,84 +0,0 @@ -namespace VAR.DatabaseExplorer.UI -{ - partial class FrmData - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.dgvDatos = new System.Windows.Forms.DataGridView(); - this.btnRefresh = new System.Windows.Forms.Button(); - ((System.ComponentModel.ISupportInitialize)(this.dgvDatos)).BeginInit(); - this.SuspendLayout(); - // - // dgvDatos - // - this.dgvDatos.AllowUserToAddRows = false; - this.dgvDatos.AllowUserToDeleteRows = false; - this.dgvDatos.AllowUserToOrderColumns = true; - this.dgvDatos.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.dgvDatos.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.dgvDatos.Location = new System.Drawing.Point(12, 18); - this.dgvDatos.Name = "dgvDatos"; - this.dgvDatos.ReadOnly = true; - this.dgvDatos.Size = new System.Drawing.Size(347, 273); - this.dgvDatos.TabIndex = 0; - this.dgvDatos.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgvDatos_CellDoubleClick); - this.dgvDatos.CellFormatting += new System.Windows.Forms.DataGridViewCellFormattingEventHandler(this.dgvDatos_CellFormatting); - // - // btnRefresh - // - this.btnRefresh.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.btnRefresh.Location = new System.Drawing.Point(12, 297); - this.btnRefresh.Name = "btnRefresh"; - this.btnRefresh.Size = new System.Drawing.Size(75, 23); - this.btnRefresh.TabIndex = 1; - this.btnRefresh.Text = "Refresh"; - this.btnRefresh.UseVisualStyleBackColor = true; - this.btnRefresh.Click += new System.EventHandler(this.btnRefresh_Click); - // - // FrmDatos - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(371, 332); - this.Controls.Add(this.btnRefresh); - this.Controls.Add(this.dgvDatos); - this.Name = "FrmDatos"; - this.Text = "frmDatos"; - this.Load += new System.EventHandler(this.frmDatos_Load); - ((System.ComponentModel.ISupportInitialize)(this.dgvDatos)).EndInit(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.DataGridView dgvDatos; - private System.Windows.Forms.Button btnRefresh; - } -} \ No newline at end of file diff --git a/VAR.DatabaseExplorer/UI/FrmData.cs b/VAR.DatabaseExplorer/UI/FrmData.cs deleted file mode 100644 index 1644b38..0000000 --- a/VAR.DatabaseExplorer/UI/FrmData.cs +++ /dev/null @@ -1,78 +0,0 @@ -using System; -using System.Data; -using System.Data.SqlClient; -using System.Drawing; -using System.Windows.Forms; - -namespace VAR.DatabaseExplorer.UI -{ - public partial class FrmData : Form - { - #region Declarations - - private readonly string _conexionString = string.Empty; - private readonly string _tableSchema = string.Empty; - private readonly string _tableName = string.Empty; - - #endregion Declarations - - #region Form life cycle - - public FrmData(string conexionString, string tableSchema, string tableName) - { - InitializeComponent(); - _conexionString = conexionString; - _tableSchema = tableSchema; - _tableName = tableName; - _conexionString = conexionString; - LoadDataFromTable(); - } - - private void frmDatos_Load(object sender, EventArgs e) - { - } - - #endregion Form life cycle - - #region Events - - private void dgvDatos_CellDoubleClick(object sender, DataGridViewCellEventArgs e) - { - } - - private void dgvDatos_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) - { - if (e.DesiredType == typeof(Image)) - { - if (e.Value is DBNull || (e.Value is byte[] && ((byte[])e.Value).Length <= 0)) - { - e.Value = new Bitmap(1, 1); - } - } - } - - private void btnRefresh_Click(object sender, EventArgs e) - { - LoadDataFromTable(); - } - - #endregion Events - - #region Private methods - - private void LoadDataFromTable() - { - Text = _tableSchema + @"." + _tableName; - string tableFullName = "[" + _tableSchema + "].[" + _tableName + "]"; - var dt = new DataTable(); - var cnx = new SqlConnection(_conexionString); - var da = new SqlDataAdapter("select * from " + tableFullName, cnx); - cnx.Open(); - da.Fill(dt); - cnx.Close(); - dgvDatos.DataSource = dt; - } - - #endregion Private methods - } -} \ No newline at end of file diff --git a/VAR.DatabaseExplorer/UI/FrmData.resx b/VAR.DatabaseExplorer/UI/FrmData.resx deleted file mode 100644 index 7080a7d..0000000 --- a/VAR.DatabaseExplorer/UI/FrmData.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/VAR.DatabaseExplorer/UI/FrmDatabase.Designer.cs b/VAR.DatabaseExplorer/UI/FrmDatabase.Designer.cs deleted file mode 100644 index c561e1d..0000000 --- a/VAR.DatabaseExplorer/UI/FrmDatabase.Designer.cs +++ /dev/null @@ -1,370 +0,0 @@ -namespace VAR.DatabaseExplorer.UI -{ - partial class FrmDatabase - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.lblConString = new System.Windows.Forms.Label(); - this.btnCopiarConString = new System.Windows.Forms.Button(); - this.menuBaseDatos = new System.Windows.Forms.MenuStrip(); - this.btnVerDatos = new System.Windows.Forms.Button(); - this.lblTituloTabla = new System.Windows.Forms.Label(); - this.lblTituloDB = new System.Windows.Forms.Label(); - this.btnDocGen = new System.Windows.Forms.Button(); - this.btnProcs = new System.Windows.Forms.Button(); - this.btnExec = new System.Windows.Forms.Button(); - this.splitContainer1 = new System.Windows.Forms.SplitContainer(); - this.btnRefresh = new System.Windows.Forms.Button(); - this.lsvTablas = new VAR.DatabaseExplorer.Controls.CustomListView(); - this.colEsquema = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.colNombreTabla = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.colTipo = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.btnVerify = new System.Windows.Forms.Button(); - this.btnExportSchema = new System.Windows.Forms.Button(); - this.btnExportData = new System.Windows.Forms.Button(); - this.lsvColumnas = new VAR.DatabaseExplorer.Controls.CustomListView(); - this.colNombreColumna = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.colTipoDatos = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.colClave = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.colNullable = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.txtConString = new VAR.DatabaseExplorer.Controls.CustomTextBox(); - ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); - this.splitContainer1.Panel1.SuspendLayout(); - this.splitContainer1.Panel2.SuspendLayout(); - this.splitContainer1.SuspendLayout(); - this.SuspendLayout(); - // - // lblConString - // - this.lblConString.AutoSize = true; - this.lblConString.Location = new System.Drawing.Point(9, 9); - this.lblConString.Name = "lblConString"; - this.lblConString.Size = new System.Drawing.Size(105, 13); - this.lblConString.TabIndex = 1; - this.lblConString.Text = "Cadena de conexion"; - // - // btnCopiarConString - // - this.btnCopiarConString.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.btnCopiarConString.Location = new System.Drawing.Point(742, 4); - this.btnCopiarConString.Name = "btnCopiarConString"; - this.btnCopiarConString.Size = new System.Drawing.Size(52, 23); - this.btnCopiarConString.TabIndex = 3; - this.btnCopiarConString.Text = "Copiar"; - this.btnCopiarConString.UseVisualStyleBackColor = true; - this.btnCopiarConString.Click += new System.EventHandler(this.btnCopiarConString_Click); - // - // menuBaseDatos - // - this.menuBaseDatos.Location = new System.Drawing.Point(0, 0); - this.menuBaseDatos.Name = "menuBaseDatos"; - this.menuBaseDatos.Size = new System.Drawing.Size(806, 24); - this.menuBaseDatos.TabIndex = 18; - // - // btnVerDatos - // - this.btnVerDatos.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.btnVerDatos.Location = new System.Drawing.Point(392, 485); - this.btnVerDatos.Name = "btnVerDatos"; - this.btnVerDatos.Size = new System.Drawing.Size(75, 23); - this.btnVerDatos.TabIndex = 11; - this.btnVerDatos.Text = "Ver Datos"; - this.btnVerDatos.UseVisualStyleBackColor = true; - this.btnVerDatos.Click += new System.EventHandler(this.btnVerDatos_Click); - // - // lblTituloTabla - // - this.lblTituloTabla.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.lblTituloTabla.BackColor = System.Drawing.SystemColors.ControlDarkDark; - this.lblTituloTabla.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblTituloTabla.ForeColor = System.Drawing.SystemColors.ControlLightLight; - this.lblTituloTabla.Location = new System.Drawing.Point(3, 0); - this.lblTituloTabla.Name = "lblTituloTabla"; - this.lblTituloTabla.Size = new System.Drawing.Size(464, 37); - this.lblTituloTabla.TabIndex = 12; - this.lblTituloTabla.Text = "lblTituloTabla"; - this.lblTituloTabla.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // lblTituloDB - // - this.lblTituloDB.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.lblTituloDB.BackColor = System.Drawing.SystemColors.ControlDarkDark; - this.lblTituloDB.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblTituloDB.ForeColor = System.Drawing.SystemColors.ControlLightLight; - this.lblTituloDB.Location = new System.Drawing.Point(3, 0); - this.lblTituloDB.Name = "lblTituloDB"; - this.lblTituloDB.Size = new System.Drawing.Size(326, 37); - this.lblTituloDB.TabIndex = 13; - this.lblTituloDB.Text = "lblTituloDB"; - this.lblTituloDB.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // btnDocGen - // - this.btnDocGen.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.btnDocGen.Location = new System.Drawing.Point(181, 485); - this.btnDocGen.Name = "btnDocGen"; - this.btnDocGen.Size = new System.Drawing.Size(75, 23); - this.btnDocGen.TabIndex = 14; - this.btnDocGen.Text = "Doc"; - this.btnDocGen.UseVisualStyleBackColor = true; - this.btnDocGen.Click += new System.EventHandler(this.btnDocGen_Click); - // - // btnProcs - // - this.btnProcs.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.btnProcs.Location = new System.Drawing.Point(84, 485); - this.btnProcs.Name = "btnProcs"; - this.btnProcs.Size = new System.Drawing.Size(87, 23); - this.btnProcs.TabIndex = 15; - this.btnProcs.Text = "Procedimientos"; - this.btnProcs.UseVisualStyleBackColor = true; - this.btnProcs.Click += new System.EventHandler(this.btnProcs_Click); - // - // btnExec - // - this.btnExec.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.btnExec.Location = new System.Drawing.Point(177, 485); - this.btnExec.Name = "btnExec"; - this.btnExec.Size = new System.Drawing.Size(45, 23); - this.btnExec.TabIndex = 16; - this.btnExec.Text = "Exec"; - this.btnExec.UseVisualStyleBackColor = true; - this.btnExec.Click += new System.EventHandler(this.btnExec_Click); - // - // splitContainer1 - // - this.splitContainer1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel1; - this.splitContainer1.Location = new System.Drawing.Point(1, 32); - this.splitContainer1.Name = "splitContainer1"; - // - // splitContainer1.Panel1 - // - this.splitContainer1.Panel1.Controls.Add(this.btnRefresh); - this.splitContainer1.Panel1.Controls.Add(this.lblTituloDB); - this.splitContainer1.Panel1.Controls.Add(this.btnExec); - this.splitContainer1.Panel1.Controls.Add(this.lsvTablas); - this.splitContainer1.Panel1.Controls.Add(this.btnProcs); - // - // splitContainer1.Panel2 - // - this.splitContainer1.Panel2.Controls.Add(this.btnVerify); - this.splitContainer1.Panel2.Controls.Add(this.btnExportSchema); - this.splitContainer1.Panel2.Controls.Add(this.btnExportData); - this.splitContainer1.Panel2.Controls.Add(this.lblTituloTabla); - this.splitContainer1.Panel2.Controls.Add(this.btnDocGen); - this.splitContainer1.Panel2.Controls.Add(this.lsvColumnas); - this.splitContainer1.Panel2.Controls.Add(this.btnVerDatos); - this.splitContainer1.Size = new System.Drawing.Size(806, 511); - this.splitContainer1.SplitterDistance = 332; - this.splitContainer1.TabIndex = 17; - // - // btnRefresh - // - this.btnRefresh.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.btnRefresh.Location = new System.Drawing.Point(3, 485); - this.btnRefresh.Name = "btnRefresh"; - this.btnRefresh.Size = new System.Drawing.Size(75, 23); - this.btnRefresh.TabIndex = 14; - this.btnRefresh.Text = "Refresh"; - this.btnRefresh.UseVisualStyleBackColor = true; - this.btnRefresh.Click += new System.EventHandler(this.btnRefresh_Click); - // - // lsvTablas - // - this.lsvTablas.AllowSorting = true; - this.lsvTablas.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.lsvTablas.CheckBoxes = true; - this.lsvTablas.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.colEsquema, - this.colNombreTabla, - this.colTipo}); - this.lsvTablas.FullRowSelect = true; - this.lsvTablas.HideSelection = false; - this.lsvTablas.Location = new System.Drawing.Point(3, 40); - this.lsvTablas.Name = "lsvTablas"; - this.lsvTablas.Size = new System.Drawing.Size(326, 439); - this.lsvTablas.Sorting = System.Windows.Forms.SortOrder.Ascending; - this.lsvTablas.TabIndex = 4; - this.lsvTablas.UseCompatibleStateImageBehavior = false; - this.lsvTablas.View = System.Windows.Forms.View.Details; - this.lsvTablas.SelectedIndexChanged += new System.EventHandler(this.lsvTablas_SelectedIndexChanged); - // - // colEsquema - // - this.colEsquema.Text = "Esquema"; - // - // colNombreTabla - // - this.colNombreTabla.Text = "Tabla"; - this.colNombreTabla.Width = 169; - // - // colTipo - // - this.colTipo.Text = "Tipo"; - this.colTipo.Width = 71; - // - // btnVerify - // - this.btnVerify.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.btnVerify.Location = new System.Drawing.Point(262, 485); - this.btnVerify.Name = "btnVerify"; - this.btnVerify.Size = new System.Drawing.Size(75, 23); - this.btnVerify.TabIndex = 17; - this.btnVerify.Text = "Verify"; - this.btnVerify.UseVisualStyleBackColor = true; - this.btnVerify.Click += new System.EventHandler(this.btnVerify_Click); - // - // btnExportSchema - // - this.btnExportSchema.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.btnExportSchema.Location = new System.Drawing.Point(84, 485); - this.btnExportSchema.Name = "btnExportSchema"; - this.btnExportSchema.Size = new System.Drawing.Size(91, 23); - this.btnExportSchema.TabIndex = 16; - this.btnExportSchema.Text = "ExportSchema"; - this.btnExportSchema.UseVisualStyleBackColor = true; - this.btnExportSchema.Click += new System.EventHandler(this.BtnExportSchema_Click); - // - // btnExportData - // - this.btnExportData.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.btnExportData.Location = new System.Drawing.Point(3, 485); - this.btnExportData.Name = "btnExportData"; - this.btnExportData.Size = new System.Drawing.Size(75, 23); - this.btnExportData.TabIndex = 15; - this.btnExportData.Text = "ExportData"; - this.btnExportData.UseVisualStyleBackColor = true; - this.btnExportData.Click += new System.EventHandler(this.btnExportData_Click); - // - // lsvColumnas - // - this.lsvColumnas.AllowSorting = false; - this.lsvColumnas.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.lsvColumnas.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.colNombreColumna, - this.colTipoDatos, - this.colClave, - this.colNullable}); - this.lsvColumnas.FullRowSelect = true; - this.lsvColumnas.HideSelection = false; - this.lsvColumnas.Location = new System.Drawing.Point(3, 40); - this.lsvColumnas.Name = "lsvColumnas"; - this.lsvColumnas.Size = new System.Drawing.Size(464, 439); - this.lsvColumnas.TabIndex = 6; - this.lsvColumnas.UseCompatibleStateImageBehavior = false; - this.lsvColumnas.View = System.Windows.Forms.View.Details; - // - // colNombreColumna - // - this.colNombreColumna.Text = "Columna"; - this.colNombreColumna.Width = 122; - // - // colTipoDatos - // - this.colTipoDatos.Text = "Tipo de Datos"; - this.colTipoDatos.Width = 81; - // - // colClave - // - this.colClave.Text = "Clave"; - this.colClave.Width = 71; - // - // colNullable - // - this.colNullable.Text = "Nullable"; - // - // txtConString - // - this.txtConString.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.txtConString.Location = new System.Drawing.Point(120, 6); - this.txtConString.Name = "txtConString"; - this.txtConString.ReadOnly = true; - this.txtConString.Size = new System.Drawing.Size(616, 20); - this.txtConString.TabIndex = 0; - this.txtConString.TabWidth = 8; - // - // FrmDatabase - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(806, 543); - this.Controls.Add(this.splitContainer1); - this.Controls.Add(this.btnCopiarConString); - this.Controls.Add(this.lblConString); - this.Controls.Add(this.txtConString); - this.Controls.Add(this.menuBaseDatos); - this.MainMenuStrip = this.menuBaseDatos; - this.Name = "FrmDatabase"; - this.Text = "Base de Datos"; - this.Load += new System.EventHandler(this.frmBaseDatos_Load); - this.splitContainer1.Panel1.ResumeLayout(false); - this.splitContainer1.Panel2.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); - this.splitContainer1.ResumeLayout(false); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private VAR.DatabaseExplorer.Controls.CustomTextBox txtConString; - private System.Windows.Forms.Label lblConString; - private System.Windows.Forms.Button btnCopiarConString; - private VAR.DatabaseExplorer.Controls.CustomListView lsvTablas; - private System.Windows.Forms.ColumnHeader colNombreTabla; - private System.Windows.Forms.ColumnHeader colEsquema; - private System.Windows.Forms.ColumnHeader colTipo; - private VAR.DatabaseExplorer.Controls.CustomListView lsvColumnas; - private System.Windows.Forms.ColumnHeader colNombreColumna; - private System.Windows.Forms.ColumnHeader colTipoDatos; - private System.Windows.Forms.MenuStrip menuBaseDatos; - private System.Windows.Forms.ColumnHeader colClave; - private System.Windows.Forms.Button btnVerDatos; - private System.Windows.Forms.Label lblTituloTabla; - private System.Windows.Forms.Label lblTituloDB; - private System.Windows.Forms.Button btnDocGen; - private System.Windows.Forms.Button btnProcs; - private System.Windows.Forms.Button btnExec; - private System.Windows.Forms.SplitContainer splitContainer1; - private System.Windows.Forms.ColumnHeader colNullable; - private System.Windows.Forms.Button btnRefresh; - private System.Windows.Forms.Button btnExportData; - private System.Windows.Forms.Button btnExportSchema; - private System.Windows.Forms.Button btnVerify; - } -} \ No newline at end of file diff --git a/VAR.DatabaseExplorer/UI/FrmDatabase.cs b/VAR.DatabaseExplorer/UI/FrmDatabase.cs deleted file mode 100644 index ccfdc9b..0000000 --- a/VAR.DatabaseExplorer/UI/FrmDatabase.cs +++ /dev/null @@ -1,194 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Windows.Forms; -using VAR.DatabaseExplorer.Code; -using VAR.DatabaseExplorer.Code.BusinessLogic; -using VAR.DatabaseExplorer.Code.DataAccess; -using VAR.DatabaseExplorer.Code.DataTransfer; - -namespace VAR.DatabaseExplorer.UI -{ - public partial class FrmDatabase : Form - { - private string _connectionString; - - private string _tableSchema; - private string _tableName; - - private void Initialize() - { - List
tables = TableBL.Table_GetAll(_connectionString); - lsvTablas.Items.Clear(); - foreach (Table table in tables) - { - ListViewItem item = lsvTablas.Items.Add(table.Schema); - item.SubItems.Add(table.Name); - item.SubItems.Add(table.Type); - } - - lsvColumnas.Items.Clear(); - } - - public FrmDatabase(string connectionString) - { - InitializeComponent(); - _connectionString = connectionString; - txtConString.Text = connectionString; - } - - private void frmBaseDatos_Load(object sender, EventArgs e) - { - Initialize(); - Database database = DatabaseBL.Database_Get(_connectionString); - Text = database.Name; - lblTituloDB.Text = database.Name; - lblTituloTabla.Text = ""; - } - - private void btnCopiarConString_Click(object sender, EventArgs e) - { - Clipboard.SetText(txtConString.Text); - } - - private void lsvTablas_SelectedIndexChanged(object sender, EventArgs e) - { - if (lsvTablas.SelectedItems.Count != 1) { return; } - - ListViewItem item = lsvTablas.SelectedItems[0]; - _tableSchema = item.SubItems[0].Text; - _tableName = item.SubItems[1].Text; - - lblTituloTabla.Text = _tableSchema + @"." + _tableName; - - List columns = ColumnDA.GetColumns(_connectionString, _tableSchema, _tableName); - lsvColumnas.Items.Clear(); - foreach (Column col in columns) - { - ListViewItem subitem = lsvColumnas.Items.Add(col.Name); - string type = string.Format("{0}{1}", col.Type, col.Size > 0 ? string.Format("({0})", col.Size) : string.Empty); - subitem.SubItems.Add(type); - subitem.SubItems.Add(col.PK ? "PK" : string.Empty); - subitem.SubItems.Add(col.Nullable ? "Null" : "NotNull"); - } - } - - private void btnVerDatos_Click(object sender, EventArgs e) - { - if (string.IsNullOrEmpty(_tableSchema) || string.IsNullOrEmpty(_tableName)) { return; } - - var form = new FrmData(_connectionString, _tableSchema, _tableName); - FrmMain.AddForm(form); - } - - private void btnProcs_Click(object sender, EventArgs e) - { - var form = new FrmRoutines(_connectionString); - FrmMain.AddForm(form); - } - - private void btnExec_Click(object sender, EventArgs e) - { - var form = new FrmExec(_connectionString); - FrmMain.AddForm(form); - } - - private void btnDocGen_Click(object sender, EventArgs e) - { - Parent.Enabled = false; - - Database database = DatabaseBL.Database_GetSchema(connectionString: _connectionString, fillTableDefinitions: true, fillProcDefinitions: true); - - string fixedDatabaseName = database.Name.Replace(' ', '_'); - var streamWriter = new StreamWriter(fixedDatabaseName + ".documentation.html"); - DatabaseBL.Database_GenerateDocumentation(streamWriter, database); - streamWriter.Close(); - - Parent.Enabled = true; - } - - private void btnRefresh_Click(object sender, EventArgs e) - { - Initialize(); - } - - private void btnExportData_Click(object sender, EventArgs e) - { - Parent.Enabled = false; - - List
tablesToExportData = new List
(); - foreach (ListViewItem checkedItem in lsvTablas.CheckedItems) - { - Table tableToExportData = new Table() - { - Schema = checkedItem.SubItems[0].Text.ToString(), //Schema - Name = checkedItem.SubItems[1].Text.ToString(), //Name - Type = checkedItem.SubItems[2].Text.ToString(), //Type - }; - tablesToExportData.Add(tableToExportData); - } - - Database database = DatabaseBL.Database_GetSchema(connectionString: _connectionString, fillTableDefinitions: true); - string fixedDatabaseName = database.Name.Replace(' ', '_'); - var streamWriter = new SplittingStreamWriter("05." + fixedDatabaseName + ".{0:000}.Data.sql"); - DatabaseBL.Database_ExportData(streamWriter, _connectionString, database, tablesToExportData); - streamWriter.Close(); - - Parent.Enabled = true; - } - - private void BtnExportSchema_Click(object sender, EventArgs e) - { - Parent.Enabled = false; - - Database database = DatabaseBL.Database_GetSchema(connectionString: _connectionString, fillTableDefinitions: true, fillProcDefinitions: true, fillViewDefinitions: true); - string fixedDatabaseName = database.Name.Replace(' ', '_'); - - // Schemas - var streamWriterSchemas = new StreamWriter("01." + fixedDatabaseName + ".Schemas.sql"); - DatabaseBL.Database_ExportSchemas(streamWriterSchemas, _connectionString, database); - streamWriterSchemas.Close(); - - // Tables - var streamWriterTables = new StreamWriter("02." + fixedDatabaseName + ".Tables.sql"); - DatabaseBL.Database_ExportTables(streamWriterTables, _connectionString, database); - streamWriterTables.Close(); - - // Routines - var streamWriterRoutines = new StreamWriter("03." + fixedDatabaseName + ".Routines.sql"); - DatabaseBL.Database_ExportFunctions(streamWriterRoutines, database); - streamWriterRoutines.Close(); - - // Views - var streamWriterViews = new StreamWriter("04." + fixedDatabaseName + ".Views.sql"); - DatabaseBL.Database_ExportViews(streamWriterViews, database); - streamWriterViews.Close(); - - Parent.Enabled = true; - } - - private void btnVerify_Click(object sender, EventArgs e) - { - List invalidProcedures = ProcedureBL.Procedure_VerifyAndGetInvalidProcedures(connectionString: _connectionString); - List
invalidViews = TableBL.View_VerifyAndGetInvalidViews(connectionString: _connectionString); - - if (invalidProcedures.Count != 0) - { - string message = string.Format("Delete {0} Procedures?", invalidProcedures.Count); - if (MessageBox.Show(this, message, "Delete Procedures?", MessageBoxButtons.OKCancel) == DialogResult.OK) - { - ProcedureBL.Procedure_DeleteProcedures(_connectionString, invalidProcedures); - } - } - - if (invalidViews.Count != 0) - { - string message = string.Format("Delete {0} Views?", invalidViews.Count); - if (MessageBox.Show(this, message, "Delete Views?", MessageBoxButtons.OKCancel) == DialogResult.OK) - { - TableBL.View_DeleteViews(_connectionString, invalidViews); - } - } - } - } -} \ No newline at end of file diff --git a/VAR.DatabaseExplorer/UI/FrmDatabase.resx b/VAR.DatabaseExplorer/UI/FrmDatabase.resx deleted file mode 100644 index 39ba7d0..0000000 --- a/VAR.DatabaseExplorer/UI/FrmDatabase.resx +++ /dev/null @@ -1,126 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - - - 41 - - \ No newline at end of file diff --git a/VAR.DatabaseExplorer/UI/FrmExec.Designer.cs b/VAR.DatabaseExplorer/UI/FrmExec.Designer.cs deleted file mode 100644 index ccc8399..0000000 --- a/VAR.DatabaseExplorer/UI/FrmExec.Designer.cs +++ /dev/null @@ -1,153 +0,0 @@ -namespace VAR.DatabaseExplorer.UI -{ - partial class FrmExec - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.btnExec = new System.Windows.Forms.Button(); - this.dgvDatos = new System.Windows.Forms.DataGridView(); - this.splitContainer1 = new System.Windows.Forms.SplitContainer(); - this.btnGenInserts = new System.Windows.Forms.Button(); - this.txtCommand = new VAR.DatabaseExplorer.Controls.CustomTextBox(); - this.txtDestTable = new System.Windows.Forms.TextBox(); - ((System.ComponentModel.ISupportInitialize)(this.dgvDatos)).BeginInit(); - this.splitContainer1.Panel1.SuspendLayout(); - this.splitContainer1.Panel2.SuspendLayout(); - this.splitContainer1.SuspendLayout(); - this.SuspendLayout(); - // - // btnExec - // - this.btnExec.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.btnExec.Location = new System.Drawing.Point(532, 66); - this.btnExec.Name = "btnExec"; - this.btnExec.Size = new System.Drawing.Size(75, 23); - this.btnExec.TabIndex = 0; - this.btnExec.Text = "Exec"; - this.btnExec.UseVisualStyleBackColor = true; - this.btnExec.Click += new System.EventHandler(this.btnExec_Click); - // - // dgvDatos - // - this.dgvDatos.AllowUserToAddRows = false; - this.dgvDatos.AllowUserToDeleteRows = false; - this.dgvDatos.AllowUserToOrderColumns = true; - this.dgvDatos.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.dgvDatos.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.dgvDatos.Location = new System.Drawing.Point(3, 3); - this.dgvDatos.Name = "dgvDatos"; - this.dgvDatos.ReadOnly = true; - this.dgvDatos.Size = new System.Drawing.Size(604, 338); - this.dgvDatos.TabIndex = 2; - this.dgvDatos.CellFormatting += new System.Windows.Forms.DataGridViewCellFormattingEventHandler(this.dgvDatos_CellFormatting); - // - // splitContainer1 - // - this.splitContainer1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel1; - this.splitContainer1.Location = new System.Drawing.Point(12, 12); - this.splitContainer1.Name = "splitContainer1"; - this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal; - // - // splitContainer1.Panel1 - // - this.splitContainer1.Panel1.Controls.Add(this.txtDestTable); - this.splitContainer1.Panel1.Controls.Add(this.btnGenInserts); - this.splitContainer1.Panel1.Controls.Add(this.txtCommand); - this.splitContainer1.Panel1.Controls.Add(this.btnExec); - // - // splitContainer1.Panel2 - // - this.splitContainer1.Panel2.Controls.Add(this.dgvDatos); - this.splitContainer1.Size = new System.Drawing.Size(610, 440); - this.splitContainer1.SplitterDistance = 92; - this.splitContainer1.TabIndex = 3; - // - // btnGenInserts - // - this.btnGenInserts.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.btnGenInserts.Location = new System.Drawing.Point(3, 66); - this.btnGenInserts.Name = "btnGenInserts"; - this.btnGenInserts.Size = new System.Drawing.Size(102, 23); - this.btnGenInserts.TabIndex = 2; - this.btnGenInserts.Text = "Genera INSERTs"; - this.btnGenInserts.UseVisualStyleBackColor = true; - this.btnGenInserts.Click += new System.EventHandler(this.btnGenInserts_Click); - // - // txtCommand - // - this.txtCommand.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.txtCommand.Font = new System.Drawing.Font("Lucida Console", 8.25F); - this.txtCommand.Location = new System.Drawing.Point(3, 3); - this.txtCommand.Multiline = true; - this.txtCommand.Name = "txtCommand"; - this.txtCommand.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; - this.txtCommand.Size = new System.Drawing.Size(604, 57); - this.txtCommand.TabIndex = 1; - this.txtCommand.TabWidth = 8; - // - // txtDestTable - // - this.txtDestTable.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.txtDestTable.Location = new System.Drawing.Point(111, 68); - this.txtDestTable.Name = "txtDestTable"; - this.txtDestTable.Size = new System.Drawing.Size(126, 20); - this.txtDestTable.TabIndex = 3; - // - // FrmExec - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(634, 464); - this.Controls.Add(this.splitContainer1); - this.Name = "FrmExec"; - this.Text = "Exec"; - ((System.ComponentModel.ISupportInitialize)(this.dgvDatos)).EndInit(); - this.splitContainer1.Panel1.ResumeLayout(false); - this.splitContainer1.Panel1.PerformLayout(); - this.splitContainer1.Panel2.ResumeLayout(false); - this.splitContainer1.ResumeLayout(false); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.Button btnExec; - private VAR.DatabaseExplorer.Controls.CustomTextBox txtCommand; - private System.Windows.Forms.DataGridView dgvDatos; - private System.Windows.Forms.SplitContainer splitContainer1; - private System.Windows.Forms.Button btnGenInserts; - private System.Windows.Forms.TextBox txtDestTable; - } -} \ No newline at end of file diff --git a/VAR.DatabaseExplorer/UI/FrmExec.cs b/VAR.DatabaseExplorer/UI/FrmExec.cs deleted file mode 100644 index d9d6d7b..0000000 --- a/VAR.DatabaseExplorer/UI/FrmExec.cs +++ /dev/null @@ -1,102 +0,0 @@ -using System; -using System.Data; -using System.Data.SqlClient; -using System.Drawing; -using System.IO; -using System.Windows.Forms; -using VAR.DatabaseExplorer.Code; - -namespace VAR.DatabaseExplorer.UI -{ - public partial class FrmExec : Form - { - #region Declarations - - private readonly string _cnxString; - - #endregion Declarations - - #region Form life cycle - - public FrmExec(string cnxString) - { - InitializeComponent(); - - _cnxString = cnxString; - } - - #endregion Form life cycle - - #region Events - - private void btnExec_Click(object sender, EventArgs e) - { - try - { - DataTable dt = Exec(); - dgvDatos.DataSource = dt; - } - catch (Exception ex) - { - MessageBox.Show(ex.Message); - } - } - - private void btnGenInserts_Click(object sender, EventArgs e) - { - try - { - DataTable dataTable = Exec(); - - StringWriter stringWriter = new StringWriter(); - DataTableHelper.DataTable_GenerateInserts(stringWriter, dataTable, txtDestTable.Text); - - // Preparar la datatable destino - var destDataTable = new DataTable(); - destDataTable.Columns.Add("Cmd", typeof(String)); - foreach (string cmd in stringWriter.GetStringBuilder().ToString().Split('\n')) - { - destDataTable.Rows.Add(new object[] { cmd }); - } - - dgvDatos.DataSource = destDataTable; - } - catch (Exception ex) - { - MessageBox.Show(ex.Message); - } - } - - private void dgvDatos_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) - { - if (e.DesiredType == typeof(Image)) - { - if (e.Value is DBNull || (e.Value is byte[] && ((byte[])e.Value).Length <= 0)) - { - e.Value = new Bitmap(1, 1); - } - } - } - - #endregion Events - - #region Private methods - - private DataTable Exec() - { - // Establecer conexion - var cnx = new SqlConnection(_cnxString); - - // Obtener resultado en un datatable. - var da = new SqlDataAdapter(txtCommand.Text, cnx); - var dt = new DataTable(); - cnx.Open(); - da.Fill(dt); - cnx.Close(); - - return dt; - } - - #endregion Private methods - } -} \ No newline at end of file diff --git a/VAR.DatabaseExplorer/UI/FrmExec.resx b/VAR.DatabaseExplorer/UI/FrmExec.resx deleted file mode 100644 index 7080a7d..0000000 --- a/VAR.DatabaseExplorer/UI/FrmExec.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/VAR.DatabaseExplorer/UI/FrmMain.Designer.cs b/VAR.DatabaseExplorer/UI/FrmMain.Designer.cs deleted file mode 100644 index 84afa48..0000000 --- a/VAR.DatabaseExplorer/UI/FrmMain.Designer.cs +++ /dev/null @@ -1,110 +0,0 @@ -namespace VAR.DatabaseExplorer.UI -{ - partial class FrmMain - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.menuPrincipal = new System.Windows.Forms.MenuStrip(); - this.menuServidor = new System.Windows.Forms.ToolStripMenuItem(); - this.menuSQLServerSearch = new System.Windows.Forms.ToolStripMenuItem(); - this.flowpnlWindows = new System.Windows.Forms.FlowLayoutPanel(); - this.menuConectionString = new System.Windows.Forms.ToolStripMenuItem(); - this.menuPrincipal.SuspendLayout(); - this.SuspendLayout(); - // - // menuPrincipal - // - this.menuPrincipal.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.menuServidor}); - this.menuPrincipal.Location = new System.Drawing.Point(0, 0); - this.menuPrincipal.Name = "menuPrincipal"; - this.menuPrincipal.Size = new System.Drawing.Size(800, 24); - this.menuPrincipal.TabIndex = 4; - this.menuPrincipal.Text = "menuPrincipal"; - // - // menuServidor - // - this.menuServidor.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.menuSQLServerSearch, - this.menuConectionString}); - this.menuServidor.Name = "menuServidor"; - this.menuServidor.Size = new System.Drawing.Size(62, 20); - this.menuServidor.Text = "Servidor"; - // - // menuSQLServerSearch - // - this.menuSQLServerSearch.Name = "menuSQLServerSearch"; - this.menuSQLServerSearch.Size = new System.Drawing.Size(180, 22); - this.menuSQLServerSearch.Text = "SQL Server Search"; - this.menuSQLServerSearch.Click += new System.EventHandler(this.menuSQLServerSearch_Click); - // - // flowpnlWindows - // - this.flowpnlWindows.AutoSize = true; - this.flowpnlWindows.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.flowpnlWindows.Dock = System.Windows.Forms.DockStyle.Top; - this.flowpnlWindows.Location = new System.Drawing.Point(0, 24); - this.flowpnlWindows.Name = "flowpnlWindows"; - this.flowpnlWindows.Size = new System.Drawing.Size(800, 0); - this.flowpnlWindows.TabIndex = 6; - // - // menuConectionString - // - this.menuConectionString.Name = "menuConectionString"; - this.menuConectionString.Size = new System.Drawing.Size(180, 22); - this.menuConectionString.Text = "Conection String"; - this.menuConectionString.Click += new System.EventHandler(this.menuConectionString_Click); - // - // FrmMain - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 601); - this.Controls.Add(this.flowpnlWindows); - this.Controls.Add(this.menuPrincipal); - this.IsMdiContainer = true; - this.MainMenuStrip = this.menuPrincipal; - this.Name = "FrmMain"; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; - this.Text = "Explorador de Servidores"; - this.MdiChildActivate += new System.EventHandler(this.FrmPrincipal_MdiChildActivate); - this.menuPrincipal.ResumeLayout(false); - this.menuPrincipal.PerformLayout(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.MenuStrip menuPrincipal; - private System.Windows.Forms.ToolStripMenuItem menuServidor; - private System.Windows.Forms.ToolStripMenuItem menuSQLServerSearch; - private System.Windows.Forms.FlowLayoutPanel flowpnlWindows; - private System.Windows.Forms.ToolStripMenuItem menuConectionString; - } -} \ No newline at end of file diff --git a/VAR.DatabaseExplorer/UI/FrmMain.cs b/VAR.DatabaseExplorer/UI/FrmMain.cs deleted file mode 100644 index e691e00..0000000 --- a/VAR.DatabaseExplorer/UI/FrmMain.cs +++ /dev/null @@ -1,98 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Windows.Forms; -using VAR.DatabaseExplorer.Controls; - -namespace VAR.DatabaseExplorer.UI -{ - public partial class FrmMain : Form - { - #region Declarations - - private static FrmMain _currentInstance; - - #endregion Declarations - - #region Creator - - public FrmMain() - { - _currentInstance = this; - InitializeComponent(); - } - - #endregion Creator - - #region WindowList - - private List listChilds = new List(); - - public static void AddForm(Form frm) - { - frm.MdiParent = _currentInstance; - frm.WindowState = FormWindowState.Maximized; - frm.Show(); - _currentInstance.listChilds.Add(frm); - frm.FormClosed += _currentInstance.FrmPrincipal_OnChildClose; - _currentInstance.RefreshWindowButtons(); - } - - protected void FrmPrincipal_OnChildClose(object sender, FormClosedEventArgs e) - { - listChilds.Remove((Form)sender); - RefreshWindowButtons(); - } - - private void FrmPrincipal_MdiChildActivate(object sender, EventArgs e) - { - RefreshWindowButtons(); - } - - private void RefreshWindowButtons() - { - int childCount = listChilds.Count; - int delta = childCount - flowpnlWindows.Controls.Count; - if (delta < 0) - { - int dest = flowpnlWindows.Controls.Count + delta; - for (int i = flowpnlWindows.Controls.Count - 1; i >= dest; i--) - { - flowpnlWindows.Controls.RemoveAt(i); - } - } - else if (delta > 0) - { - for (int i = 0; i < delta; i++) - { - flowpnlWindows.Controls.Add(new WindowButton()); - } - } - for (int i = 0; i < childCount; i++) - { - WindowButton btn = (WindowButton)flowpnlWindows.Controls[i]; - Form frm = listChilds[i]; - btn.Text = frm.Text; - btn.Window = frm; - btn.Active = (frm == ActiveMdiChild); - } - } - - #endregion WindowList - - #region Menus - - private void menuSQLServerSearch_Click(object sender, EventArgs e) - { - var frm = new FrmSQLServerSearch(); - FrmMain.AddForm(frm); - } - - private void menuConectionString_Click(object sender, EventArgs e) - { - - } - - #endregion Menus - - } -} \ No newline at end of file diff --git a/VAR.DatabaseExplorer/UI/FrmMain.resx b/VAR.DatabaseExplorer/UI/FrmMain.resx deleted file mode 100644 index 3bdf2c2..0000000 --- a/VAR.DatabaseExplorer/UI/FrmMain.resx +++ /dev/null @@ -1,126 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 14, 6 - - - 32 - - \ No newline at end of file diff --git a/VAR.DatabaseExplorer/UI/FrmRoutines.Designer.cs b/VAR.DatabaseExplorer/UI/FrmRoutines.Designer.cs deleted file mode 100644 index a24723e..0000000 --- a/VAR.DatabaseExplorer/UI/FrmRoutines.Designer.cs +++ /dev/null @@ -1,160 +0,0 @@ -namespace VAR.DatabaseExplorer.UI -{ - partial class FrmRoutines - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.lsvProcs = new VAR.DatabaseExplorer.Controls.CustomListView(); - this.colNombre = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.colSchema = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.colFecha = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.colTipo = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.txtProc = new VAR.DatabaseExplorer.Controls.CustomTextBox(); - this.splitContainer1 = new System.Windows.Forms.SplitContainer(); - this.btnRefresh = new System.Windows.Forms.Button(); - this.splitContainer1.Panel1.SuspendLayout(); - this.splitContainer1.Panel2.SuspendLayout(); - this.splitContainer1.SuspendLayout(); - this.SuspendLayout(); - // - // lsvProcs - // - this.lsvProcs.Activation = System.Windows.Forms.ItemActivation.OneClick; - this.lsvProcs.AllowSorting = true; - this.lsvProcs.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.lsvProcs.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.colNombre, - this.colSchema, - this.colFecha, - this.colTipo}); - this.lsvProcs.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lsvProcs.FullRowSelect = true; - this.lsvProcs.GridLines = true; - this.lsvProcs.Location = new System.Drawing.Point(0, 0); - this.lsvProcs.Name = "lsvProcs"; - this.lsvProcs.Size = new System.Drawing.Size(352, 449); - this.lsvProcs.TabIndex = 0; - this.lsvProcs.UseCompatibleStateImageBehavior = false; - this.lsvProcs.View = System.Windows.Forms.View.Details; - this.lsvProcs.SelectedIndexChanged += new System.EventHandler(this.lsvProcs_SelectedIndexChanged); - // - // colNombre - // - this.colNombre.Text = "Nombre"; - this.colNombre.Width = 120; - // - // colSchema - // - this.colSchema.Text = "Schema"; - // - // colFecha - // - this.colFecha.Text = "Fecha"; - this.colFecha.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; - this.colFecha.Width = 84; - // - // colTipo - // - this.colTipo.Text = "Tipo"; - // - // txtProc - // - this.txtProc.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.txtProc.Font = new System.Drawing.Font("Lucida Console", 8.25F); - this.txtProc.Location = new System.Drawing.Point(3, 3); - this.txtProc.Multiline = true; - this.txtProc.Name = "txtProc"; - this.txtProc.ScrollBars = System.Windows.Forms.ScrollBars.Both; - this.txtProc.Size = new System.Drawing.Size(352, 475); - this.txtProc.TabIndex = 1; - this.txtProc.TabWidth = 4; - // - // splitContainer1 - // - this.splitContainer1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel1; - this.splitContainer1.Location = new System.Drawing.Point(12, 12); - this.splitContainer1.Name = "splitContainer1"; - // - // splitContainer1.Panel1 - // - this.splitContainer1.Panel1.Controls.Add(this.btnRefresh); - this.splitContainer1.Panel1.Controls.Add(this.lsvProcs); - // - // splitContainer1.Panel2 - // - this.splitContainer1.Panel2.Controls.Add(this.txtProc); - this.splitContainer1.Size = new System.Drawing.Size(717, 481); - this.splitContainer1.SplitterDistance = 355; - this.splitContainer1.TabIndex = 2; - // - // btnRefresh - // - this.btnRefresh.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.btnRefresh.Location = new System.Drawing.Point(3, 455); - this.btnRefresh.Name = "btnRefresh"; - this.btnRefresh.Size = new System.Drawing.Size(75, 23); - this.btnRefresh.TabIndex = 1; - this.btnRefresh.Text = "Refresh"; - this.btnRefresh.UseVisualStyleBackColor = true; - this.btnRefresh.Click += new System.EventHandler(this.btnRefresh_Click); - // - // FrmProcedimientos - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(741, 505); - this.Controls.Add(this.splitContainer1); - this.Name = "FrmProcedimientos"; - this.Text = "frmProcedimientos"; - this.Load += new System.EventHandler(this.frmProcedimientos_Load); - this.splitContainer1.Panel1.ResumeLayout(false); - this.splitContainer1.Panel2.ResumeLayout(false); - this.splitContainer1.Panel2.PerformLayout(); - this.splitContainer1.ResumeLayout(false); - this.ResumeLayout(false); - - } - - #endregion - - private VAR.DatabaseExplorer.Controls.CustomListView lsvProcs; - private System.Windows.Forms.ColumnHeader colNombre; - private System.Windows.Forms.ColumnHeader colFecha; - private VAR.DatabaseExplorer.Controls.CustomTextBox txtProc; - private System.Windows.Forms.SplitContainer splitContainer1; - private System.Windows.Forms.ColumnHeader colTipo; - private System.Windows.Forms.ColumnHeader colSchema; - private System.Windows.Forms.Button btnRefresh; - } -} \ No newline at end of file diff --git a/VAR.DatabaseExplorer/UI/FrmRoutines.cs b/VAR.DatabaseExplorer/UI/FrmRoutines.cs deleted file mode 100644 index fd731aa..0000000 --- a/VAR.DatabaseExplorer/UI/FrmRoutines.cs +++ /dev/null @@ -1,75 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Data.SqlClient; -using System.Windows.Forms; -using VAR.DatabaseExplorer.Code.DataAccess; -using VAR.DatabaseExplorer.Code.DataTransfer; - -namespace VAR.DatabaseExplorer.UI -{ - public partial class FrmRoutines : Form - { - #region Declarations - - private string _connectionString; - - private readonly SqlConnection _cnx; - - #endregion Declarations - - #region Form life cycle - - public FrmRoutines(string cnxString) - { - InitializeComponent(); - - _connectionString = cnxString; - _cnx = new SqlConnection(cnxString); - } - - private void frmProcedimientos_Load(object sender, EventArgs e) - { - lsvProcs_LoadData(); - } - - #endregion Form life cycle - - #region Events - - private void lsvProcs_SelectedIndexChanged(object sender, EventArgs e) - { - if (lsvProcs.SelectedItems.Count <= 0) { return; } - - string name = lsvProcs.SelectedItems[0].SubItems[0].Text; - string schema = lsvProcs.SelectedItems[0].SubItems[1].Text; - - string procDefinition = ProcedureDA.GetProcedureDefinition(_connectionString, schema, name); - txtProc.Text = procDefinition; - } - - private void btnRefresh_Click(object sender, EventArgs e) - { - lsvProcs_LoadData(); - } - - #endregion Events - - #region Private methods - - private void lsvProcs_LoadData() - { - List procs = ProcedureDA.GetAllProcedures(_connectionString); - - lsvProcs.Items.Clear(); - foreach (Procedure proc in procs) - { - ListViewItem item = lsvProcs.Items.Add(proc.Name); - item.SubItems.Add(proc.Schema); - item.SubItems.Add(proc.CreateDate.ToShortDateString()); - item.SubItems.Add(proc.Type); - } - } - - #endregion Private methods - } -} \ No newline at end of file diff --git a/VAR.DatabaseExplorer/UI/FrmRoutines.resx b/VAR.DatabaseExplorer/UI/FrmRoutines.resx deleted file mode 100644 index 7080a7d..0000000 --- a/VAR.DatabaseExplorer/UI/FrmRoutines.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/VAR.DatabaseExplorer/UI/FrmSQLServerSearch.Designer.cs b/VAR.DatabaseExplorer/UI/FrmSQLServerSearch.Designer.cs deleted file mode 100644 index 51110c6..0000000 --- a/VAR.DatabaseExplorer/UI/FrmSQLServerSearch.Designer.cs +++ /dev/null @@ -1,264 +0,0 @@ -namespace VAR.DatabaseExplorer.UI -{ - partial class FrmSQLServerSearch - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.lsvServidores = new VAR.DatabaseExplorer.Controls.CustomListView(); - this.colNombreServidor = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.colInstancia = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.colVersion = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.btnListarServidores = new System.Windows.Forms.Button(); - this.lblServidor = new System.Windows.Forms.Label(); - this.txtServidor = new VAR.DatabaseExplorer.Controls.CustomTextBox(); - this.lblUsuario = new System.Windows.Forms.Label(); - this.lblContrasenha = new System.Windows.Forms.Label(); - this.txtUsuario = new VAR.DatabaseExplorer.Controls.CustomTextBox(); - this.TxtContrasenha = new VAR.DatabaseExplorer.Controls.CustomTextBox(); - this.btnListarBBDD = new System.Windows.Forms.Button(); - this.lsvBBDD = new VAR.DatabaseExplorer.Controls.CustomListView(); - this.colDBName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.colFechaCreacion = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.splitContainer1 = new System.Windows.Forms.SplitContainer(); - ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); - this.splitContainer1.Panel1.SuspendLayout(); - this.splitContainer1.Panel2.SuspendLayout(); - this.splitContainer1.SuspendLayout(); - this.SuspendLayout(); - // - // lsvServidores - // - this.lsvServidores.AllowSorting = true; - this.lsvServidores.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.lsvServidores.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.colNombreServidor, - this.colInstancia, - this.colVersion}); - this.lsvServidores.FullRowSelect = true; - this.lsvServidores.HideSelection = false; - this.lsvServidores.Location = new System.Drawing.Point(3, 32); - this.lsvServidores.Name = "lsvServidores"; - this.lsvServidores.Size = new System.Drawing.Size(306, 386); - this.lsvServidores.TabIndex = 1; - this.lsvServidores.UseCompatibleStateImageBehavior = false; - this.lsvServidores.View = System.Windows.Forms.View.Details; - this.lsvServidores.SelectedIndexChanged += new System.EventHandler(this.lsvServidores_SelectedIndexChanged); - // - // colNombreServidor - // - this.colNombreServidor.Text = "Servidor"; - this.colNombreServidor.Width = 110; - // - // colInstancia - // - this.colInstancia.Text = "Instancia"; - this.colInstancia.Width = 94; - // - // colVersion - // - this.colVersion.Text = "Version"; - this.colVersion.Width = 73; - // - // btnListarServidores - // - this.btnListarServidores.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.btnListarServidores.Location = new System.Drawing.Point(3, 3); - this.btnListarServidores.Name = "btnListarServidores"; - this.btnListarServidores.Size = new System.Drawing.Size(306, 23); - this.btnListarServidores.TabIndex = 2; - this.btnListarServidores.Text = "Listar Servidores"; - this.btnListarServidores.UseVisualStyleBackColor = true; - this.btnListarServidores.Click += new System.EventHandler(this.btnListarServidores_Click); - // - // lblServidor - // - this.lblServidor.AutoSize = true; - this.lblServidor.Location = new System.Drawing.Point(3, 8); - this.lblServidor.Name = "lblServidor"; - this.lblServidor.Size = new System.Drawing.Size(46, 13); - this.lblServidor.TabIndex = 3; - this.lblServidor.Text = "Servidor"; - // - // txtServidor - // - this.txtServidor.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.txtServidor.Location = new System.Drawing.Point(70, 6); - this.txtServidor.Name = "txtServidor"; - this.txtServidor.Size = new System.Drawing.Size(218, 20); - this.txtServidor.TabIndex = 4; - this.txtServidor.TabWidth = 8; - // - // lblUsuario - // - this.lblUsuario.AutoSize = true; - this.lblUsuario.Location = new System.Drawing.Point(3, 35); - this.lblUsuario.Name = "lblUsuario"; - this.lblUsuario.Size = new System.Drawing.Size(43, 13); - this.lblUsuario.TabIndex = 5; - this.lblUsuario.Text = "Usuario"; - // - // lblContrasenha - // - this.lblContrasenha.AutoSize = true; - this.lblContrasenha.Location = new System.Drawing.Point(3, 61); - this.lblContrasenha.Name = "lblContrasenha"; - this.lblContrasenha.Size = new System.Drawing.Size(61, 13); - this.lblContrasenha.TabIndex = 6; - this.lblContrasenha.Text = "Contraseña"; - // - // txtUsuario - // - this.txtUsuario.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.txtUsuario.Location = new System.Drawing.Point(70, 32); - this.txtUsuario.Name = "txtUsuario"; - this.txtUsuario.Size = new System.Drawing.Size(218, 20); - this.txtUsuario.TabIndex = 7; - this.txtUsuario.TabWidth = 8; - // - // TxtContrasenha - // - this.TxtContrasenha.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.TxtContrasenha.Location = new System.Drawing.Point(70, 58); - this.TxtContrasenha.Name = "TxtContrasenha"; - this.TxtContrasenha.Size = new System.Drawing.Size(218, 20); - this.TxtContrasenha.TabIndex = 8; - this.TxtContrasenha.TabWidth = 8; - this.TxtContrasenha.UseSystemPasswordChar = true; - // - // btnListarBBDD - // - this.btnListarBBDD.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.btnListarBBDD.Location = new System.Drawing.Point(6, 84); - this.btnListarBBDD.Name = "btnListarBBDD"; - this.btnListarBBDD.Size = new System.Drawing.Size(282, 23); - this.btnListarBBDD.TabIndex = 9; - this.btnListarBBDD.Text = "Listar BBDD"; - this.btnListarBBDD.UseVisualStyleBackColor = true; - this.btnListarBBDD.Click += new System.EventHandler(this.btnListarBBDD_Click); - // - // lsvBBDD - // - this.lsvBBDD.AllowSorting = true; - this.lsvBBDD.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.lsvBBDD.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.colDBName, - this.colFechaCreacion}); - this.lsvBBDD.FullRowSelect = true; - this.lsvBBDD.HideSelection = false; - this.lsvBBDD.Location = new System.Drawing.Point(6, 113); - this.lsvBBDD.Name = "lsvBBDD"; - this.lsvBBDD.Size = new System.Drawing.Size(282, 305); - this.lsvBBDD.TabIndex = 11; - this.lsvBBDD.UseCompatibleStateImageBehavior = false; - this.lsvBBDD.View = System.Windows.Forms.View.Details; - this.lsvBBDD.DoubleClick += new System.EventHandler(this.lsvBBDD_DoubleClick); - // - // colDBName - // - this.colDBName.Text = "Base de Datos"; - this.colDBName.Width = 165; - // - // colFechaCreacion - // - this.colFechaCreacion.Text = "Fecha de Creacion"; - this.colFechaCreacion.Width = 107; - // - // splitContainer1 - // - this.splitContainer1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.splitContainer1.Location = new System.Drawing.Point(12, 12); - this.splitContainer1.Name = "splitContainer1"; - // - // splitContainer1.Panel1 - // - this.splitContainer1.Panel1.Controls.Add(this.lsvServidores); - this.splitContainer1.Panel1.Controls.Add(this.btnListarServidores); - // - // splitContainer1.Panel2 - // - this.splitContainer1.Panel2.Controls.Add(this.lblServidor); - this.splitContainer1.Panel2.Controls.Add(this.lsvBBDD); - this.splitContainer1.Panel2.Controls.Add(this.txtServidor); - this.splitContainer1.Panel2.Controls.Add(this.btnListarBBDD); - this.splitContainer1.Panel2.Controls.Add(this.lblUsuario); - this.splitContainer1.Panel2.Controls.Add(this.lblContrasenha); - this.splitContainer1.Panel2.Controls.Add(this.TxtContrasenha); - this.splitContainer1.Panel2.Controls.Add(this.txtUsuario); - this.splitContainer1.Size = new System.Drawing.Size(607, 421); - this.splitContainer1.SplitterDistance = 312; - this.splitContainer1.TabIndex = 12; - // - // FrmSQLServerSearch - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(631, 445); - this.Controls.Add(this.splitContainer1); - this.Name = "FrmSQLServerSearch"; - this.Text = "SQL Server Search"; - this.splitContainer1.Panel1.ResumeLayout(false); - this.splitContainer1.Panel2.ResumeLayout(false); - this.splitContainer1.Panel2.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); - this.splitContainer1.ResumeLayout(false); - this.ResumeLayout(false); - - } - - #endregion - - private VAR.DatabaseExplorer.Controls.CustomListView lsvServidores; - private System.Windows.Forms.Button btnListarServidores; - private System.Windows.Forms.ColumnHeader colNombreServidor; - private System.Windows.Forms.ColumnHeader colInstancia; - private System.Windows.Forms.ColumnHeader colVersion; - private System.Windows.Forms.Label lblServidor; - private VAR.DatabaseExplorer.Controls.CustomTextBox txtServidor; - private System.Windows.Forms.Label lblUsuario; - private System.Windows.Forms.Label lblContrasenha; - private VAR.DatabaseExplorer.Controls.CustomTextBox txtUsuario; - private VAR.DatabaseExplorer.Controls.CustomTextBox TxtContrasenha; - private System.Windows.Forms.Button btnListarBBDD; - private VAR.DatabaseExplorer.Controls.CustomListView lsvBBDD; - private System.Windows.Forms.ColumnHeader colDBName; - private System.Windows.Forms.ColumnHeader colFechaCreacion; - private System.Windows.Forms.SplitContainer splitContainer1; - - } -} - diff --git a/VAR.DatabaseExplorer/UI/FrmSQLServerSearch.cs b/VAR.DatabaseExplorer/UI/FrmSQLServerSearch.cs deleted file mode 100644 index 22abbe5..0000000 --- a/VAR.DatabaseExplorer/UI/FrmSQLServerSearch.cs +++ /dev/null @@ -1,85 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Data.SqlClient; -using System.Windows.Forms; -using VAR.DatabaseExplorer.Code.DataAccess; -using VAR.DatabaseExplorer.Code.DataTransfer; - -namespace VAR.DatabaseExplorer.UI -{ - public partial class FrmSQLServerSearch : Form - { - public FrmSQLServerSearch() - { - InitializeComponent(); - } - - private void btnListarServidores_Click(object sender, EventArgs e) - { - List servers = ServerDA.GetAllServers(); - - lsvServidores.Items.Clear(); - lsvBBDD.Items.Clear(); - foreach (Server server in servers) - { - ListViewItem item = lsvServidores.Items.Add(server.Name); - item.SubItems.Add(server.Instance); - item.SubItems.Add(server.Version); - } - } - - private void lsvServidores_SelectedIndexChanged(object sender, EventArgs e) - { - if (lsvServidores.SelectedItems.Count > 0) - { - ListViewItem item = lsvServidores.SelectedItems[0]; - txtServidor.Text = string.IsNullOrEmpty(item.SubItems[1].Text) - ? item.SubItems[0].Text - : string.Format("{0}/{1}", item.SubItems[0].Text, item.SubItems[1].Text); - } - } - - private void btnListarBBDD_Click(object sender, EventArgs e) - { - string connectionString = BuildConnectionString(txtServidor.Text, null, txtUsuario.Text, TxtContrasenha.Text); - List databases = DatabaseDA.GetAllDatabases(connectionString); - - lsvBBDD.Items.Clear(); - foreach (Database database in databases) - { - ListViewItem item = lsvBBDD.Items.Add(database.Name); - item.SubItems.Add(database.CreateDate.ToShortDateString()); - } - } - - private void lsvBBDD_DoubleClick(object sender, EventArgs e) - { - if (lsvBBDD.SelectedItems.Count != 1) return; - string databaseName = lsvBBDD.SelectedItems[0].SubItems[0].Text; - // Llamar a la venta de la base de datos - string connectionStirng = BuildConnectionString(txtServidor.Text, databaseName, txtUsuario.Text, TxtContrasenha.Text); - var frm = new FrmDatabase(connectionStirng); - FrmMain.AddForm(frm); - } - - private string BuildConnectionString(string server, string database, string user, string password) - { - var constructor = new SqlConnectionStringBuilder(); - constructor.DataSource = string.IsNullOrEmpty(server) ? "localhost" : server; - if (string.IsNullOrEmpty(database) == false) - { - constructor.InitialCatalog = database; - } - if (string.IsNullOrEmpty(user)) - { - constructor.IntegratedSecurity = true; - } - else - { - constructor.UserID = user; - constructor.Password = password; - } - return constructor.ConnectionString; - } - } -} \ No newline at end of file diff --git a/VAR.DatabaseExplorer/UI/FrmSQLServerSearch.resx b/VAR.DatabaseExplorer/UI/FrmSQLServerSearch.resx deleted file mode 100644 index d58980a..0000000 --- a/VAR.DatabaseExplorer/UI/FrmSQLServerSearch.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/VAR.DatabaseExplorer/VAR.DatabaseExplorer.csproj b/VAR.DatabaseExplorer/VAR.DatabaseExplorer.csproj deleted file mode 100644 index 76a8352..0000000 --- a/VAR.DatabaseExplorer/VAR.DatabaseExplorer.csproj +++ /dev/null @@ -1,201 +0,0 @@ - - - - Debug - AnyCPU - 9.0.30729 - 2.0 - {79531B74-3062-4A71-9953-5702BEBDEC0E} - WinExe - Properties - VAR.DatabaseExplorer - VAR.DatabaseExplorer - v4.6.1 - 512 - - - - - 3.5 - false - - publish\ - true - Disk - false - Foreground - 7 - Days - false - false - true - 0 - 1.0.0.%2a - false - true - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - false - true - - - pdbonly - true - bin\Release\ - - - prompt - 4 - false - - - VAR.DatabaseExplorer.Program - - - app.manifest - - - - ..\packages\Oracle.ManagedDataAccess.19.7.0\lib\net40\Oracle.ManagedDataAccess.dll - - - - 3.5 - - - 3.5 - - - 3.5 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Component - - - Component - - - Component - - - Form - - - FrmDatabase.cs - - - Form - - - FrmData.cs - - - Form - - - FrmExec.cs - - - Form - - - FrmMain.cs - - - Form - - - FrmRoutines.cs - - - Form - - - FrmSQLServerSearch.cs - - - - - - FrmDatabase.cs - - - FrmData.cs - - - FrmExec.cs - - - FrmMain.cs - - - FrmRoutines.cs - - - FrmSQLServerSearch.cs - - - - - False - .NET Framework 3.5 SP1 Client Profile - false - - - False - .NET Framework 3.5 SP1 - true - - - False - Windows Installer 3.1 - true - - - - - - - - - - \ No newline at end of file diff --git a/VAR.DatabaseExplorer/app.manifest b/VAR.DatabaseExplorer/app.manifest deleted file mode 100644 index 2a43f52..0000000 --- a/VAR.DatabaseExplorer/app.manifest +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - - - - - - - - diff --git a/VAR.DatabaseExplorer/packages.config b/VAR.DatabaseExplorer/packages.config deleted file mode 100644 index e6bfa2d..0000000 --- a/VAR.DatabaseExplorer/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/issues/.keep b/issues/.keep new file mode 100644 index 0000000..e69de29