diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8f3472f --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +*.suo +*.exe +*.dll +*.pdb +*.user +ServerExplorer/obj +ServerExplorer/bin diff --git a/ServerExplorer/ServerExplorer.sln b/ServerExplorer.sln similarity index 100% rename from ServerExplorer/ServerExplorer.sln rename to ServerExplorer.sln diff --git a/ServerExplorer/2008 to 2010.bat b/ServerExplorer/2008 to 2010.bat deleted file mode 100644 index 75ef23c..0000000 --- a/ServerExplorer/2008 to 2010.bat +++ /dev/null @@ -1,7 +0,0 @@ -REM Tool from: http://www.programmersheaven.com/download/41236/download.aspx - -for /f "tokens=*" %%a IN ('dir /b /s *.sln') do ssr.exe 0 "Format Version 10.00" "Format Version 11.00" %%a -for /f "tokens=*" %%a IN ('dir /b /s *.sln') do ssr.exe 0 "# Visual Studio 2008" "# Visual Studio 2010" %%a - -for /f "tokens=*" %%a IN ('dir /b /s *.csproj') do ssr.exe 0 "ToolsVersion=''3.5''" "ToolsVersion=''4.0''" %%a -for /f "tokens=*" %%a IN ('dir /b /s *.csproj') do ssr.exe 0 "v9.0" "v10.0" %%a diff --git a/ServerExplorer/2010 to 2008.bat b/ServerExplorer/2010 to 2008.bat deleted file mode 100644 index e0bbca2..0000000 --- a/ServerExplorer/2010 to 2008.bat +++ /dev/null @@ -1,7 +0,0 @@ -REM SSR.EXE tool from: http://www.programmersheaven.com/download/41236/download.aspx - -for /f "tokens=*" %%a IN ('dir /b /s *.sln') do ssr.exe 0 "Format Version 11.00" "Format Version 10.00" %%a -for /f "tokens=*" %%a IN ('dir /b /s *.sln') do ssr.exe 0 "# Visual Studio 2010" "# Visual Studio 2008" %%a - -for /f "tokens=*" %%a IN ('dir /b /s *.csproj') do ssr.exe 0 "ToolsVersion=''4.0''" "ToolsVersion=''3.5''" %%a -for /f "tokens=*" %%a IN ('dir /b /s *.csproj') do ssr.exe 0 "v10.0" "v9.0" %%a \ No newline at end of file diff --git a/ServerExplorer/CodeGen.cs b/ServerExplorer/CodeGen.cs new file mode 100644 index 0000000..eab287e --- /dev/null +++ b/ServerExplorer/CodeGen.cs @@ -0,0 +1,380 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.IO; +using System.Data; + +namespace ServerExplorer +{ + public class CodeGen + { + private static string FixNombre(string strIn){ + return strIn.Replace(' ', '_'); + } + + + public static void GeneraDTO(Config config, TablaDesc t) + { + string nombreObj = FixNombre(t.Esquema) + "_" + FixNombre(t.Nombre); + string nombreFichero = config.PathDTO + "/" + nombreObj + "_DTO.cs"; + EscritorCodigo escritor = new EscritorCodigo(nombreFichero); + + // Cabecera + escritor.Escribe("using System;"); + escritor.Escribe("using System.Data;"); + escritor.Escribe(""); + escritor.EscribeInd("namespace " + config.NamespaceDTO); + + // El objeto de la tabla + escritor.EscribeInd("public partial class " + nombreObj); + foreach (ColumnaDesc c in t.Columnas) + { + string nombre = FixNombre(c.Nombre); + TipoCol tipo = c.GetTipo(); + string sTipo = null; + + // Determinar el tipo a usar + switch (tipo) + { + case TipoCol.Numerico: + sTipo = "int"; break; + case TipoCol.Texto: + sTipo = "string"; break; + case TipoCol.AproxNumerico: + sTipo = "double"; break; + case TipoCol.Tiempo: + sTipo = "DateTime"; break; + case TipoCol.Booleano: + sTipo = "bool"; break; + case TipoCol.Binario: + sTipo = "byte[]"; break; + } + if (sTipo == null) + { + continue; + } + + // El atributo privado para cada columna + escritor.Escribe("private " + sTipo + " _" + nombre + ";"); + + // La propiedad publica para cada columna + escritor.EscribeInd("public " + sTipo + " " + nombre); + escritor.EscribeInd("get"); + escritor.Escribe("return _" + nombre + ";"); + escritor.DeInd(); + escritor.EscribeInd("set"); + escritor.Escribe("_" + nombre + " = value;"); + escritor.DeInd(); + escritor.DeInd(); + escritor.Escribe(""); + } + escritor.DeInd(); + + // El Pie + escritor.DeInd(); + + // Cerrar ficheros + escritor.Cerrar(); + } + + private static void GenerarDALParametrosTabla + (TablaDesc t, String varPrm, String varCmd, String varDTO, bool input, EscritorCodigo escritor) + { + foreach (ColumnaDesc c in t.Columnas) + { + string nombre = FixNombre(c.Nombre); + TipoCol tipo = c.GetTipo(); + + // Establecer el tipo del parametro + switch (tipo) + { + case TipoCol.Numerico: + escritor.Escribe(varPrm + " = new SqlParameter(\"@[" + c.Nombre + "]\",SqlDbType.Int);"); break; + case TipoCol.Texto: + escritor.Escribe(varPrm + " = new SqlParameter(\"@[" + c.Nombre + "]\", " + + "SqlDbType.VarChar, " + c.Tamanho + ");"); break; + case TipoCol.AproxNumerico: + escritor.Escribe(varPrm + " = new SqlParameter(\"@[" + c.Nombre + "]\", SqlDbType.Real);"); break; + case TipoCol.Tiempo: + escritor.Escribe(varPrm + " = new SqlParameter(\"@[" + c.Nombre + "]\", SqlDbType.DateTime);"); break; + case TipoCol.Booleano: + escritor.Escribe(varPrm + " = new SqlParameter(\"@[" + c.Nombre + "]\", SqlDbType.Bit);"); break; + case TipoCol.Binario: + if (c.Tamanho > 0) + { + escritor.Escribe(varPrm + " = new SqlParameter(\"@[" + c.Nombre + "]\", " + + "SqlDbType.VarBinary, " + c.Tamanho + ");"); + } + else + { + escritor.Escribe(varPrm + " = new SqlParameter(\"@[" + c.Nombre + "]\", SqlDbType.Binary);"); + } + break; + default: + continue; + } + if (input) + { + escritor.Escribe(varPrm + ".Direction = ParameterDirection.Input;"); + } + else + { + escritor.Escribe(varPrm + ".Direction = ParameterDirection.Output;"); + } + escritor.Escribe(varPrm + ".Value = " + varDTO + "." + nombre + ";"); + escritor.Escribe(varCmd + ".Parameters.Add(" + varPrm + ");"); + } + escritor.Escribe(""); + } + + private static void GenerarDALInsert(Config config, TablaDesc t, EscritorCodigo escritor) + { + string nombreObj = FixNombre(t.Esquema) + "_" + FixNombre(t.Nombre); + string strInsert1, strInsert2; + + // Cabecera y variables del metodo + escritor.EscribeInd("public bool Insertar(" + nombreObj + " reg)"); + escritor.Escribe("SqlCommand cmd;"); + escritor.Escribe("SqlParameter prm;"); + escritor.Escribe("int nRows;"); + escritor.Escribe(""); + + // Preparacion del comando + strInsert1 = String.Empty; + strInsert2 = String.Empty; + foreach (ColumnaDesc c in t.Columnas) + { + TipoCol tipo = c.GetTipo(); + + if(tipo==TipoCol.Otro) + continue; + + if (strInsert1 == String.Empty) + { + // Primera columna + strInsert1 += "[" + c.Nombre + "]"; + strInsert2 += "@[" + c.Nombre + "]"; + } + else + { + // Cualquier otra columna + strInsert1 += ", [" + c.Nombre + "]"; + strInsert2 += ", @[" + c.Nombre + "]"; + } + } + escritor.Escribe("cmd = new SqlCommand(\"INSERT INTO [" + t.Esquema + "].[" + t.Nombre + "] " + + "(" + strInsert1 + ") " + + "VALUES (" + strInsert2 + "\");"); + escritor.Escribe(""); + + // Preparacion de los parametros + GenerarDALParametrosTabla(t, "prm", "cmd", "reg", true, escritor); + + // Ejecucion + escritor.Escribe("cnx.Open();"); + escritor.Escribe("nRows = cmd.ExecuteNonQuery()"); + escritor.Escribe("cnx.Close();"); + escritor.Escribe(""); + + // Pie + escritor.Escribe("return (nRows>0);"); + escritor.DeInd(); + escritor.Escribe(""); + } + + private static void GenerarDALActualizar(Config config, TablaDesc t, EscritorCodigo escritor) + { + string nombreObj = FixNombre(t.Esquema) + "_" + FixNombre(t.Nombre); + string strActualizar,strFiltroPrimario; + + // Cabecera y variables del metodo + escritor.EscribeInd("public bool Actualizar(" + nombreObj + " reg)"); + escritor.Escribe("SqlCommand cmd;"); + escritor.Escribe("SqlParameter prm;"); + escritor.Escribe("int nRows;"); + escritor.Escribe(""); + + // Preparacion del comando + strActualizar = String.Empty; + foreach (ColumnaDesc c in t.Columnas) + { + TipoCol tipo = c.GetTipo(); + + if (tipo == TipoCol.Otro) + continue; + if (c.Primaria) + continue; + + if (strActualizar != String.Empty) + { + strActualizar += ","; + } + strActualizar += "[" + c.Nombre + "]=@[" + c.Nombre + "]"; + } + strFiltroPrimario = String.Empty; + foreach (ColumnaDesc c in t.Columnas) + { + TipoCol tipo = c.GetTipo(); + + if (!c.Primaria) + continue; + + if (strFiltroPrimario != String.Empty) + { + strFiltroPrimario += " AND "; + } + strFiltroPrimario += "[" + c.Nombre + "]=@[" + c.Nombre + "]"; + } + escritor.Escribe("cmd = new SqlCommand(\"UPDATE [" + t.Esquema + "].[" + t.Nombre + "] " + + "SET " + strActualizar + " " + + "WHERE " + strFiltroPrimario + "\");"); + escritor.Escribe(""); + + // Preparacion de los parametros + GenerarDALParametrosTabla(t, "prm", "cmd", "reg", true, escritor); + + // Ejecucion + escritor.Escribe("cnx.Open();"); + escritor.Escribe("nRows = cmd.ExecuteNonQuery();"); + escritor.Escribe("cnx.Close();"); + escritor.Escribe(""); + + // Pie + escritor.Escribe("return (nRows>0);"); + escritor.DeInd(); + escritor.Escribe(""); + } + + + public static void GeneraDAL(Config config, TablaDesc t) + { + string nombreObj = FixNombre(t.Esquema) + "_" + FixNombre(t.Nombre); + string nombreDAL = FixNombre(t.Esquema) + "_" + FixNombre(t.Nombre) + "_DAL"; + string nombreFichero = config.PathDTO + "/" + nombreDAL + ".cs"; + EscritorCodigo escritor = new EscritorCodigo(nombreFichero); + + // Cabecera. + escritor.Escribe("using System;"); + escritor.Escribe("using System.Data;"); + escritor.Escribe("using System.Data.Sql;"); + escritor.Escribe("using System.Data.SqlClient;"); + escritor.Escribe(""); + escritor.Escribe("using " + config.NamespaceDTO + ";"); + escritor.Escribe(""); + escritor.EscribeInd("namespace " + config.NamespaceDAL); + + // El objeto DAL. + escritor.EscribeInd("public partial class " + nombreDAL); + + // Atributos internos + escritor.Escribe("SqlConnexion cnx;"); + escritor.Escribe(""); + + // Constructor + escritor.EscribeInd("public " + nombreDAL + "(SqlConnexion cnx)"); + escritor.Escribe("this.cnx = cnx;"); + escritor.DeInd(); + escritor.Escribe(""); + + // Metodo Insertar. + GenerarDALInsert(config, t, escritor); + + // Metodo Actualizar. + GenerarDALActualizar(config, t, escritor); + + // FIXME: Metodo Borrar. + + // FIXME: Metodo Leer. + + // FIXME: Metodo LeerTodos + + // Cerrar objeto DAL. + escritor.DeInd(); + + // El Pie + escritor.DeInd(); + + // Cerrar ficheros. + escritor.Cerrar(); + } + + public static Boolean GenerarCodigo(Config config,DatabaseDesc database) + { + // Asegura la existencia de los directorios destinos + if (!System.IO.Directory.Exists(config.PathRaiz)) { Utiles.CrearDirectorio(config.PathRaiz); } + if (!System.IO.Directory.Exists(config.PathDTO)) { Utiles.CrearDirectorio(config.PathDTO); } + if (!System.IO.Directory.Exists(config.PathDAL)) { Utiles.CrearDirectorio(config.PathDAL); } + if (!System.IO.Directory.Exists(config.PathExtra)) { Utiles.CrearDirectorio(config.PathExtra); } + + // Itera por cada tabla para crear sus DTO y DAL + foreach (TablaDesc t in database.Tablas) + { + GeneraDTO(config, t); + GeneraDAL(config, t); + } + + return true; + } + + private class Indentado + { + private int indentado = 0; + private StringBuilder sb = new StringBuilder(); + + public void Inc() + { + indentado++; + } + public void Dec() + { + indentado--; + if (indentado < 0) + { + indentado = 0; + } + } + public string Str() + { + sb.Remove(0, sb.Length); + for (int i=0; i < indentado; i++) + { + sb.Append("\t"); + } + return sb.ToString(); + } + } + + private class EscritorCodigo + { + StreamWriter escritor; + Indentado indentado; + + public EscritorCodigo(string nombreFichero) + { + escritor = new StreamWriter(nombreFichero); + indentado = new Indentado(); + } + public void Cerrar() + { + escritor.Close(); + } + + public void Escribe(String str) + { + escritor.WriteLine(indentado.Str() + str); + } + public void EscribeInd(String str) + { + escritor.WriteLine(indentado.Str() + str); + escritor.WriteLine(indentado.Str() + "{"); + indentado.Inc(); + } + public void DeInd() + { + indentado.Dec(); + escritor.WriteLine(indentado.Str() + "}"); + } + } + } +} diff --git a/ServerExplorer/Config.cs b/ServerExplorer/Config.cs new file mode 100644 index 0000000..b597e4e --- /dev/null +++ b/ServerExplorer/Config.cs @@ -0,0 +1,101 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Xml.Serialization; + +namespace ServerExplorer +{ + public class Config + { + public String ConString = ""; + public String pathRaiz = "."; + public String PathRaiz + { + get { return pathRaiz; } + set { pathRaiz = value; } + } + public String pathDAL="."; + public String PathDAL + { + get + { + if (pathDAL == ".") + { + return pathRaiz; + } + else + { + return pathDAL; + } + } + set { pathDAL = value; } + } + public String pathDTO = "."; + public String PathDTO + { + get { + if (pathDTO == ".") + { + return pathRaiz; + } + else + { + return pathDTO; + } + } + set { pathDTO = value; } + } + public String pathExtra = "."; + public String PathExtra + { + get { + if (pathExtra == ".") + { + return pathRaiz; + } + else + { + return pathExtra; + } + } + set { pathExtra = value; } + } + public String NamespaceDAL = "DAL"; + public String NamespaceDTO = "DTO"; + public List Tablas = new List(); + + public Config() { } + + public void Guardar(String fichero) + { + XmlSerializer seriador = new XmlSerializer(typeof(Config)); + StreamWriter escritor = new StreamWriter(fichero); + seriador.Serialize(escritor, this); + escritor.Close(); + } + + public static Config Cargar(String fichero) + { + XmlSerializer seriador = new XmlSerializer(typeof(Config)); + StreamReader lector = new StreamReader(fichero); + Config config = (Config)seriador.Deserialize(lector); + lector.Close(); + return config; + } + + } + + public class TablaInfo + { + public String Esquema=""; + public String Nombre=""; + + public TablaInfo() { } + public TablaInfo(String esquema, String nombre) + { + Esquema = esquema; + Nombre = nombre; + } + } + +} diff --git a/ServerExplorer/ServerExplorer/DatabaseDesc.cs b/ServerExplorer/DatabaseDesc.cs similarity index 100% rename from ServerExplorer/ServerExplorer/DatabaseDesc.cs rename to ServerExplorer/DatabaseDesc.cs diff --git a/ServerExplorer/DocGen.cs b/ServerExplorer/DocGen.cs new file mode 100644 index 0000000..2aca5c8 --- /dev/null +++ b/ServerExplorer/DocGen.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.IO; + +namespace ServerExplorer +{ + public class DocGen + { + public static void GenerarDocumentacion(Config config, DatabaseDesc database) + { + // Asegura la existencia de los directorios destinos + if (!System.IO.Directory.Exists(config.PathRaiz)) { Utiles.CrearDirectorio(config.PathRaiz); } + if (!System.IO.Directory.Exists(config.PathDTO)) { Utiles.CrearDirectorio(config.PathDTO); } + if (!System.IO.Directory.Exists(config.PathDAL)) { Utiles.CrearDirectorio(config.PathDAL); } + if (!System.IO.Directory.Exists(config.PathExtra)) { Utiles.CrearDirectorio(config.PathExtra); } + + + // Abrir el documento que contendra la documentacion + StreamWriter escritor=new StreamWriter(config.PathExtra+"/documentacion.html"); + + + // Poner cabecera de la documentacion + escritor.WriteLine("" + database.Nombre + ""); + escritor.WriteLine(""); + + // Iterar cada tabla + foreach (TablaDesc t in database.Tablas) + { + // Cabecera de la info de tabla + escritor.WriteLine("

"+t.Esquema+"."+t.Nombre+"

"); + + // Iterar las columnas + escritor.WriteLine(""); + escritor.WriteLine(""); + escritor.WriteLine(""); + foreach (ColumnaDesc c in t.Columnas) + { + escritor.WriteLine(""); + } + escritor.WriteLine("
NombreTipoTamañoPrimaria
" + + c.Nombre + "" + + c.Tipo + "" + + c.Tamanho + "" + + c.Primaria + "
"); + } + + + // Poner pie y cerrar fichero + escritor.WriteLine(""); + escritor.Close(); + + } + } +} diff --git a/ServerExplorer/ServerExplorer/Program.cs b/ServerExplorer/Program.cs similarity index 100% rename from ServerExplorer/ServerExplorer/Program.cs rename to ServerExplorer/Program.cs diff --git a/ServerExplorer/ServerExplorer/Properties/AssemblyInfo.cs b/ServerExplorer/Properties/AssemblyInfo.cs similarity index 93% rename from ServerExplorer/ServerExplorer/Properties/AssemblyInfo.cs rename to ServerExplorer/Properties/AssemblyInfo.cs index 00673fe..a4c1023 100644 --- a/ServerExplorer/ServerExplorer/Properties/AssemblyInfo.cs +++ b/ServerExplorer/Properties/AssemblyInfo.cs @@ -8,9 +8,9 @@ using System.Runtime.InteropServices; [assembly: AssemblyTitle("ServerExplorer")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("cyc")] +[assembly: AssemblyCompany("VAR")] [assembly: AssemblyProduct("ServerExplorer")] -[assembly: AssemblyCopyright("Copyright © cyc 2012")] +[assembly: AssemblyCopyright("Copyright © VAR 2012")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/ServerExplorer/ServerExplorer/Properties/Resources.Designer.cs b/ServerExplorer/Properties/Resources.Designer.cs similarity index 100% rename from ServerExplorer/ServerExplorer/Properties/Resources.Designer.cs rename to ServerExplorer/Properties/Resources.Designer.cs diff --git a/ServerExplorer/ServerExplorer/Properties/Resources.resx b/ServerExplorer/Properties/Resources.resx similarity index 100% rename from ServerExplorer/ServerExplorer/Properties/Resources.resx rename to ServerExplorer/Properties/Resources.resx diff --git a/ServerExplorer/ServerExplorer/Properties/Settings.Designer.cs b/ServerExplorer/Properties/Settings.Designer.cs similarity index 100% rename from ServerExplorer/ServerExplorer/Properties/Settings.Designer.cs rename to ServerExplorer/Properties/Settings.Designer.cs diff --git a/ServerExplorer/ServerExplorer/Properties/Settings.settings b/ServerExplorer/Properties/Settings.settings similarity index 100% rename from ServerExplorer/ServerExplorer/Properties/Settings.settings rename to ServerExplorer/Properties/Settings.settings diff --git a/ServerExplorer/ServerExplorer/ServerExplorer.csproj b/ServerExplorer/ServerExplorer.csproj similarity index 89% rename from ServerExplorer/ServerExplorer/ServerExplorer.csproj rename to ServerExplorer/ServerExplorer.csproj index 4bb5b58..56fb2a3 100644 --- a/ServerExplorer/ServerExplorer/ServerExplorer.csproj +++ b/ServerExplorer/ServerExplorer.csproj @@ -51,6 +51,7 @@ 4 + 3.5 @@ -69,8 +70,9 @@ - + + Form @@ -89,12 +91,24 @@ frmDatos.cs + + Form + + + frmExec.cs + Form frmPrincipal.cs + + Form + + + frmProcedimientos.cs + Form @@ -114,9 +128,15 @@ frmDatos.cs + + frmExec.cs + frmPrincipal.cs + + frmProcedimientos.cs + frmServidores.cs @@ -165,4 +185,4 @@ --> - \ No newline at end of file + diff --git a/ServerExplorer/ServerExplorer.suo b/ServerExplorer/ServerExplorer.suo deleted file mode 100644 index 4453764..0000000 Binary files a/ServerExplorer/ServerExplorer.suo and /dev/null differ diff --git a/ServerExplorer/ServerExplorer/CodeGen.cs b/ServerExplorer/ServerExplorer/CodeGen.cs deleted file mode 100644 index b2c7878..0000000 --- a/ServerExplorer/ServerExplorer/CodeGen.cs +++ /dev/null @@ -1,120 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.IO; - -namespace ServerExplorer -{ - public class CodeGen - { - public static Boolean GenerarCodigo(CodeGenConfig config,DatabaseDesc database) - { - // Asegura la existencia de los directorios destinos - if (!System.IO.Directory.Exists(config.PathDTO)) { Utiles.CrearDirectorio(config.PathDTO); } - if (!System.IO.Directory.Exists(config.PathDAL)) { Utiles.CrearDirectorio(config.PathDAL); } - if (!System.IO.Directory.Exists(config.PathExtra)) { Utiles.CrearDirectorio(config.PathExtra); } - - // Itera por cada tabla para crear sus DTOs - foreach (TablaDesc t in database.Tablas) - { - string nombreObj = t.Esquema + t.Nombre; - string nombreFichero = config.PathDTO + "/" + nombreObj + "_DTO.cs"; - EscritorCodigo escritor = new EscritorCodigo(nombreFichero); - - // Cabecera. - escritor.Escribe("using System;"); - escritor.Escribe("using System.Data;"); - escritor.Escribe(""); - escritor.EscribeInd("namespace namespace"); - - // El objeto de la tabla. - escritor.EscribeInd("public partial class " + nombreObj); - foreach(ColumnaDesc c in t.Columnas){ - // El atributo privado para cada columna. - escritor.Escribe("private Object " + "_" + c.Nombre + ";"); - - // La propiedad publica para cada columna. - escritor.EscribeInd("public Object " + c.Nombre ); - escritor.EscribeInd("get"); - escritor.Escribe("return _" + c.Nombre + ";"); - escritor.DeInd(); - escritor.EscribeInd("set"); - escritor.Escribe("_" + c.Nombre + " = value;"); - escritor.DeInd(); - escritor.DeInd(); - escritor.Escribe(""); - } - escritor.DeInd(); - - // El Pie - escritor.DeInd(); - - // Cerrar ficheros. - escritor.Cerrar(); - } - - return true; - } - - private class Indentado - { - private int indentado = 0; - private StringBuilder sb = new StringBuilder(); - - public void Inc() - { - indentado++; - } - public void Dec() - { - indentado--; - if (indentado < 0) - { - indentado = 0; - } - } - public string Str() - { - sb.Remove(0, sb.Length); - for (int i=0; i < indentado; i++) - { - sb.Append("\t"); - } - return sb.ToString(); - } - } - - private class EscritorCodigo - { - StreamWriter escritor; - Indentado indentado; - - public EscritorCodigo(string nombreFichero) - { - escritor = new StreamWriter(nombreFichero); - indentado = new Indentado(); - } - public void Cerrar() - { - escritor.Close(); - } - - public void Escribe(String str) - { - escritor.WriteLine(indentado.Str() + str); - } - public void EscribeInd(String str) - { - escritor.WriteLine(indentado.Str() + str); - escritor.WriteLine(indentado.Str() + "{"); - indentado.Inc(); - } - public void DeInd() - { - indentado.Dec(); - escritor.WriteLine(indentado.Str() + "}"); - } - } - } -} diff --git a/ServerExplorer/ServerExplorer/CodeGenConfig.cs b/ServerExplorer/ServerExplorer/CodeGenConfig.cs deleted file mode 100644 index 619383b..0000000 --- a/ServerExplorer/ServerExplorer/CodeGenConfig.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Xml.Serialization; - -namespace ServerExplorer -{ - public class CodeGenConfig - { - public String ConString = ""; - public String PathRaiz="."; - public String PathDAL="."; - public String PathDTO="."; - public String PathExtra="."; - public List Tablas = new List(); - - public CodeGenConfig() { } - - public void Guardar(String fichero) - { - XmlSerializer seriador = new XmlSerializer(typeof(CodeGenConfig)); - StreamWriter escritor = new StreamWriter(fichero); - seriador.Serialize(escritor, this); - } - - public static CodeGenConfig Cargar(String fichero) - { - XmlSerializer seriador = new XmlSerializer(typeof(CodeGenConfig)); - StreamReader lector = new StreamReader(fichero); - CodeGenConfig config = (CodeGenConfig)seriador.Deserialize(lector); - return config; - } - - } - - public class CodeGenTablaInfo - { - public String Esquema=""; - public String Nombre=""; - - public CodeGenTablaInfo() { } - public CodeGenTablaInfo(String esquema, String nombre) - { - Esquema = esquema; - Nombre = nombre; - } - } - -} diff --git a/ServerExplorer/ServerExplorer/ServerExplorer.csproj.user b/ServerExplorer/ServerExplorer/ServerExplorer.csproj.user deleted file mode 100644 index 3a19d15..0000000 --- a/ServerExplorer/ServerExplorer/ServerExplorer.csproj.user +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - es-ES - false - - \ No newline at end of file diff --git a/ServerExplorer/ServerExplorer/bin/Debug/ServerExplorer.exe b/ServerExplorer/ServerExplorer/bin/Debug/ServerExplorer.exe deleted file mode 100644 index bc8d12d..0000000 Binary files a/ServerExplorer/ServerExplorer/bin/Debug/ServerExplorer.exe and /dev/null differ diff --git a/ServerExplorer/ServerExplorer/bin/Debug/ServerExplorer.pdb b/ServerExplorer/ServerExplorer/bin/Debug/ServerExplorer.pdb deleted file mode 100644 index 469aba8..0000000 Binary files a/ServerExplorer/ServerExplorer/bin/Debug/ServerExplorer.pdb and /dev/null differ diff --git a/ServerExplorer/ServerExplorer/bin/Debug/ServerExplorer.vshost.exe b/ServerExplorer/ServerExplorer/bin/Debug/ServerExplorer.vshost.exe deleted file mode 100644 index 526b854..0000000 Binary files a/ServerExplorer/ServerExplorer/bin/Debug/ServerExplorer.vshost.exe and /dev/null differ diff --git a/ServerExplorer/ServerExplorer/bin/Debug/ServerExplorer.vshost.exe.manifest b/ServerExplorer/ServerExplorer/bin/Debug/ServerExplorer.vshost.exe.manifest deleted file mode 100644 index 061c9ca..0000000 --- a/ServerExplorer/ServerExplorer/bin/Debug/ServerExplorer.vshost.exe.manifest +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/ServerExplorer/ServerExplorer/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/ServerExplorer/ServerExplorer/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache deleted file mode 100644 index 7610437..0000000 Binary files a/ServerExplorer/ServerExplorer/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache and /dev/null differ diff --git a/ServerExplorer/ServerExplorer/obj/Debug/GenerateResource-ResGen.read.1.tlog b/ServerExplorer/ServerExplorer/obj/Debug/GenerateResource-ResGen.read.1.tlog deleted file mode 100644 index 0d7fbc1..0000000 Binary files a/ServerExplorer/ServerExplorer/obj/Debug/GenerateResource-ResGen.read.1.tlog and /dev/null differ diff --git a/ServerExplorer/ServerExplorer/obj/Debug/GenerateResource-ResGen.write.1.tlog b/ServerExplorer/ServerExplorer/obj/Debug/GenerateResource-ResGen.write.1.tlog deleted file mode 100644 index 822cf12..0000000 Binary files a/ServerExplorer/ServerExplorer/obj/Debug/GenerateResource-ResGen.write.1.tlog and /dev/null differ diff --git a/ServerExplorer/ServerExplorer/obj/Debug/ResGen.read.1.tlog b/ServerExplorer/ServerExplorer/obj/Debug/ResGen.read.1.tlog deleted file mode 100644 index 46b134b..0000000 --- a/ServerExplorer/ServerExplorer/obj/Debug/ResGen.read.1.tlog +++ /dev/null @@ -1 +0,0 @@ -ÿþ \ No newline at end of file diff --git a/ServerExplorer/ServerExplorer/obj/Debug/ResGen.write.1.tlog b/ServerExplorer/ServerExplorer/obj/Debug/ResGen.write.1.tlog deleted file mode 100644 index 46b134b..0000000 --- a/ServerExplorer/ServerExplorer/obj/Debug/ResGen.write.1.tlog +++ /dev/null @@ -1 +0,0 @@ -ÿþ \ No newline at end of file diff --git a/ServerExplorer/ServerExplorer/obj/Debug/ServerExplorer.Properties.Resources.resources b/ServerExplorer/ServerExplorer/obj/Debug/ServerExplorer.Properties.Resources.resources deleted file mode 100644 index 06c24d0..0000000 Binary files a/ServerExplorer/ServerExplorer/obj/Debug/ServerExplorer.Properties.Resources.resources and /dev/null differ diff --git a/ServerExplorer/ServerExplorer/obj/Debug/ServerExplorer.csproj.FileListAbsolute.txt b/ServerExplorer/ServerExplorer/obj/Debug/ServerExplorer.csproj.FileListAbsolute.txt deleted file mode 100644 index 39f754b..0000000 --- a/ServerExplorer/ServerExplorer/obj/Debug/ServerExplorer.csproj.FileListAbsolute.txt +++ /dev/null @@ -1,39 +0,0 @@ -D:\VAR\ServerExplorer\ServerExplorer\bin\Debug\ServerExplorer.exe -D:\VAR\ServerExplorer\ServerExplorer\bin\Debug\ServerExplorer.pdb -D:\VAR\ServerExplorer\ServerExplorer\obj\Debug\ResolveAssemblyReference.cache -D:\VAR\ServerExplorer\ServerExplorer\obj\Debug\ServerExplorer.Properties.Resources.resources -D:\VAR\ServerExplorer\ServerExplorer\obj\Debug\ServerExplorer.exe -D:\VAR\ServerExplorer\ServerExplorer\obj\Debug\ServerExplorer.pdb -D:\VAR\ServerExplorer\ServerExplorer\obj\Debug\ServerExplorer.frmServidores.resources -D:\VAR\ServerExplorer\ServerExplorer\obj\Debug\ServerExplorer.frmBaseDatos.resources -D:\VAR\ServerExplorer\ServerExplorer\obj\Debug\ServerExplorer.frmPrincipal.resources -C:\Users\val\Desktop\ServerExplorer\ServerExplorer\obj\Debug\ServerExplorer.exe -C:\Users\val\Desktop\ServerExplorer\ServerExplorer\obj\Debug\ServerExplorer.pdb -C:\Users\val\Desktop\ServerExplorer\ServerExplorer\bin\Debug\ServerExplorer.exe -C:\Users\val\Desktop\ServerExplorer\ServerExplorer\bin\Debug\ServerExplorer.pdb -C:\Users\val\Desktop\ServerExplorer\ServerExplorer\obj\Debug\ResolveAssemblyReference.cache -C:\Users\val\Desktop\ServerExplorer\ServerExplorer\obj\Debug\ServerExplorer.frmBaseDatos.resources -C:\Users\val\Desktop\ServerExplorer\ServerExplorer\obj\Debug\ServerExplorer.frmPrincipal.resources -C:\Users\val\Desktop\ServerExplorer\ServerExplorer\obj\Debug\ServerExplorer.frmServidores.resources -C:\Users\val\Desktop\ServerExplorer\ServerExplorer\obj\Debug\ServerExplorer.Properties.Resources.resources -C:\Users\val\Desktop\ServerExplorer\ServerExplorer\obj\Debug\ResGen.read.1.tlog -C:\Users\val\Desktop\ServerExplorer\ServerExplorer\obj\Debug\ResGen.write.1.tlog -C:\Users\val\Desktop\ServerExplorer\ServerExplorer\obj\Debug\ServerExplorer.frmCodeGenConfig.resources -C:\Users\var\Desktop\ServerExplorer\ServerExplorer\obj\Debug\ServerExplorer.exe -C:\Users\var\Desktop\ServerExplorer\ServerExplorer\obj\Debug\ServerExplorer.pdb -C:\Users\var\Desktop\ServerExplorer\ServerExplorer\bin\Debug\ServerExplorer.exe -C:\Users\var\Desktop\ServerExplorer\ServerExplorer\bin\Debug\ServerExplorer.pdb -C:\Users\var\Desktop\ServerExplorer\ServerExplorer\obj\Debug\ResolveAssemblyReference.cache -C:\Users\var\Desktop\ServerExplorer\ServerExplorer\obj\Debug\ServerExplorer.frmBaseDatos.resources -C:\Users\var\Desktop\ServerExplorer\ServerExplorer\obj\Debug\ServerExplorer.frmCodeGenConfig.resources -C:\Users\var\Desktop\ServerExplorer\ServerExplorer\obj\Debug\ServerExplorer.frmPrincipal.resources -C:\Users\var\Desktop\ServerExplorer\ServerExplorer\obj\Debug\ServerExplorer.frmServidores.resources -C:\Users\var\Desktop\ServerExplorer\ServerExplorer\obj\Debug\ServerExplorer.Properties.Resources.resources -C:\Users\var\Desktop\ServerExplorer\ServerExplorer\obj\Debug\ResGen.read.1.tlog -C:\Users\var\Desktop\ServerExplorer\ServerExplorer\obj\Debug\ResGen.write.1.tlog -D:\VAR\ServerExplorer\ServerExplorer\obj\Debug\ServerExplorer.frmCodeGenConfig.resources -D:\VAR\ServerExplorer\ServerExplorer\obj\Debug\GenerateResource-ResGen.read.1.tlog -D:\VAR\ServerExplorer\ServerExplorer\obj\Debug\ResGen.read.1.tlog -D:\VAR\ServerExplorer\ServerExplorer\obj\Debug\GenerateResource-ResGen.write.1.tlog -D:\VAR\ServerExplorer\ServerExplorer\obj\Debug\ResGen.write.1.tlog -D:\VAR\ServerExplorer\ServerExplorer\obj\Debug\ServerExplorer.frmDatos.resources diff --git a/ServerExplorer/ServerExplorer/obj/Debug/ServerExplorer.exe b/ServerExplorer/ServerExplorer/obj/Debug/ServerExplorer.exe deleted file mode 100644 index bc8d12d..0000000 Binary files a/ServerExplorer/ServerExplorer/obj/Debug/ServerExplorer.exe and /dev/null differ diff --git a/ServerExplorer/ServerExplorer/obj/Debug/ServerExplorer.frmBaseDatos.resources b/ServerExplorer/ServerExplorer/obj/Debug/ServerExplorer.frmBaseDatos.resources deleted file mode 100644 index 06c24d0..0000000 Binary files a/ServerExplorer/ServerExplorer/obj/Debug/ServerExplorer.frmBaseDatos.resources and /dev/null differ diff --git a/ServerExplorer/ServerExplorer/obj/Debug/ServerExplorer.frmCodeGenConfig.resources b/ServerExplorer/ServerExplorer/obj/Debug/ServerExplorer.frmCodeGenConfig.resources deleted file mode 100644 index 06c24d0..0000000 Binary files a/ServerExplorer/ServerExplorer/obj/Debug/ServerExplorer.frmCodeGenConfig.resources and /dev/null differ diff --git a/ServerExplorer/ServerExplorer/obj/Debug/ServerExplorer.frmDatos.resources b/ServerExplorer/ServerExplorer/obj/Debug/ServerExplorer.frmDatos.resources deleted file mode 100644 index 06c24d0..0000000 Binary files a/ServerExplorer/ServerExplorer/obj/Debug/ServerExplorer.frmDatos.resources and /dev/null differ diff --git a/ServerExplorer/ServerExplorer/obj/Debug/ServerExplorer.frmPrincipal.resources b/ServerExplorer/ServerExplorer/obj/Debug/ServerExplorer.frmPrincipal.resources deleted file mode 100644 index 06c24d0..0000000 Binary files a/ServerExplorer/ServerExplorer/obj/Debug/ServerExplorer.frmPrincipal.resources and /dev/null differ diff --git a/ServerExplorer/ServerExplorer/obj/Debug/ServerExplorer.frmServidores.resources b/ServerExplorer/ServerExplorer/obj/Debug/ServerExplorer.frmServidores.resources deleted file mode 100644 index 06c24d0..0000000 Binary files a/ServerExplorer/ServerExplorer/obj/Debug/ServerExplorer.frmServidores.resources and /dev/null differ diff --git a/ServerExplorer/ServerExplorer/obj/Debug/ServerExplorer.pdb b/ServerExplorer/ServerExplorer/obj/Debug/ServerExplorer.pdb deleted file mode 100644 index 469aba8..0000000 Binary files a/ServerExplorer/ServerExplorer/obj/Debug/ServerExplorer.pdb and /dev/null differ diff --git a/ServerExplorer/ServerExplorer/obj/Debug/TempPE/Properties.Resources.Designer.cs.dll b/ServerExplorer/ServerExplorer/obj/Debug/TempPE/Properties.Resources.Designer.cs.dll deleted file mode 100644 index d26bc29..0000000 Binary files a/ServerExplorer/ServerExplorer/obj/Debug/TempPE/Properties.Resources.Designer.cs.dll and /dev/null differ diff --git a/ServerExplorer/ServerExplorer/TablaDesc.cs b/ServerExplorer/TablaDesc.cs similarity index 62% rename from ServerExplorer/ServerExplorer/TablaDesc.cs rename to ServerExplorer/TablaDesc.cs index f0a6130..0fbb1ee 100644 --- a/ServerExplorer/ServerExplorer/TablaDesc.cs +++ b/ServerExplorer/TablaDesc.cs @@ -101,13 +101,104 @@ namespace ServerExplorer } } + public enum TipoCol + { + Unset, + Numerico, + AproxNumerico, + Tiempo, + Texto, + Binario, + Booleano, + Otro + } + public class ColumnaDesc { - public String Nombre = ""; - public String Tipo = ""; + public string Nombre = ""; + public string Tipo = ""; public int Tamanho = -1; public bool Primaria = false; public ColumnaDesc() { } + + private TipoCol tipo = TipoCol.Unset; + public TipoCol GetTipo() + { + string stipo=Tipo.ToLower(); + + if (this.tipo != TipoCol.Unset) + { + return this.tipo; + } + + // Numericos + if( + stipo=="bigint" || + stipo=="int" || + stipo=="smallint" || + stipo=="tinyint" || + stipo=="bigint" + ) + { + return TipoCol.Numerico; + } + + // Aproximados numericos + if ( + stipo == "float" || + stipo == "real" + ) + { + return TipoCol.AproxNumerico; + } + + // Tiempo + if ( + stipo == "date" || + stipo == "datetimeoffset" || + stipo == "datetime2" || + stipo == "smalldatetime" || + stipo == "datetime" || + stipo == "time" + ) + { + return TipoCol.Tiempo; + } + + // Texto + if ( + stipo == "char" || + stipo == "varchar" || + stipo == "text" || + stipo == "nchar" || + stipo == "nvarchar" || + stipo == "ntext" + ) + { + return TipoCol.Texto; + } + + // Binario + if ( + stipo == "binary" || + stipo == "varbinary" || + stipo == "image" + ) + { + return TipoCol.Binario; + } + + // Booleano + if ( + stipo == "bit" + ) + { + return TipoCol.Booleano; + } + + // Otro + return TipoCol.Otro; + } } } diff --git a/ServerExplorer/ServerExplorer/Utiles.cs b/ServerExplorer/Utiles.cs similarity index 95% rename from ServerExplorer/ServerExplorer/Utiles.cs rename to ServerExplorer/Utiles.cs index 9bb27ef..2dbf5f5 100644 --- a/ServerExplorer/ServerExplorer/Utiles.cs +++ b/ServerExplorer/Utiles.cs @@ -15,7 +15,7 @@ namespace ServerExplorer { info = new DirectoryInfo(path); } - catch (Exception ex) + catch (Exception ) { info = new DirectoryInfo("."); } diff --git a/ServerExplorer/ServerExplorer/frmBaseDatos.Designer.cs b/ServerExplorer/frmBaseDatos.Designer.cs similarity index 67% rename from ServerExplorer/ServerExplorer/frmBaseDatos.Designer.cs rename to ServerExplorer/frmBaseDatos.Designer.cs index 7a2d8f4..6f9aeb1 100644 --- a/ServerExplorer/ServerExplorer/frmBaseDatos.Designer.cs +++ b/ServerExplorer/frmBaseDatos.Designer.cs @@ -32,14 +32,14 @@ this.lblConString = new System.Windows.Forms.Label(); this.btnCopiarConString = new System.Windows.Forms.Button(); this.lsvTablas = new System.Windows.Forms.ListView(); - this.colNombreTabla = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.colEsquema = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.colTipo = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.colNombreTabla = new System.Windows.Forms.ColumnHeader(); + this.colEsquema = new System.Windows.Forms.ColumnHeader(); + this.colTipo = new System.Windows.Forms.ColumnHeader(); this.lsvColumnas = new System.Windows.Forms.ListView(); - this.colNombreColumna = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.colTipoDatos = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.colTamanho = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.colClave = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.colNombreColumna = new System.Windows.Forms.ColumnHeader(); + this.colTipoDatos = new System.Windows.Forms.ColumnHeader(); + this.colTamanho = new System.Windows.Forms.ColumnHeader(); + this.colClave = new System.Windows.Forms.ColumnHeader(); this.menuBaseDatos = new System.Windows.Forms.MenuStrip(); this.archivoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.menuCargar = new System.Windows.Forms.ToolStripMenuItem(); @@ -49,7 +49,14 @@ 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.menuBaseDatos.SuspendLayout(); + this.splitContainer1.Panel1.SuspendLayout(); + this.splitContainer1.Panel2.SuspendLayout(); + this.splitContainer1.SuspendLayout(); this.SuspendLayout(); // // txtConString @@ -59,7 +66,7 @@ this.txtConString.Location = new System.Drawing.Point(120, 6); this.txtConString.Name = "txtConString"; this.txtConString.ReadOnly = true; - this.txtConString.Size = new System.Drawing.Size(510, 20); + this.txtConString.Size = new System.Drawing.Size(616, 20); this.txtConString.TabIndex = 0; // // lblConString @@ -74,7 +81,7 @@ // 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(636, 4); + 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; @@ -84,17 +91,19 @@ // // lsvTablas // - this.lsvTablas.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left))); + 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.colNombreTabla, this.colEsquema, this.colTipo}); this.lsvTablas.FullRowSelect = true; - this.lsvTablas.Location = new System.Drawing.Point(12, 70); + this.lsvTablas.Location = new System.Drawing.Point(3, 40); this.lsvTablas.Name = "lsvTablas"; - this.lsvTablas.Size = new System.Drawing.Size(326, 394); + this.lsvTablas.Size = new System.Drawing.Size(332, 468); + this.lsvTablas.Sorting = System.Windows.Forms.SortOrder.Ascending; this.lsvTablas.TabIndex = 4; this.lsvTablas.UseCompatibleStateImageBehavior = false; this.lsvTablas.View = System.Windows.Forms.View.Details; @@ -125,9 +134,9 @@ this.colTamanho, this.colClave}); this.lsvColumnas.FullRowSelect = true; - this.lsvColumnas.Location = new System.Drawing.Point(344, 70); + this.lsvColumnas.Location = new System.Drawing.Point(3, 40); this.lsvColumnas.Name = "lsvColumnas"; - this.lsvColumnas.Size = new System.Drawing.Size(344, 365); + this.lsvColumnas.Size = new System.Drawing.Size(458, 439); this.lsvColumnas.TabIndex = 6; this.lsvColumnas.UseCompatibleStateImageBehavior = false; this.lsvColumnas.View = System.Windows.Forms.View.Details; @@ -157,9 +166,9 @@ this.menuBaseDatos.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.archivoToolStripMenuItem, this.menuConfiguracion}); - this.menuBaseDatos.Location = new System.Drawing.Point(348, 467); + this.menuBaseDatos.Location = new System.Drawing.Point(7, 195); this.menuBaseDatos.Name = "menuBaseDatos"; - this.menuBaseDatos.Size = new System.Drawing.Size(148, 24); + this.menuBaseDatos.Size = new System.Drawing.Size(181, 24); this.menuBaseDatos.TabIndex = 9; this.menuBaseDatos.Text = "menuBaseDatos"; this.menuBaseDatos.Visible = false; @@ -171,20 +180,20 @@ this.menuCargar, this.menuGuardar}); this.archivoToolStripMenuItem.Name = "archivoToolStripMenuItem"; - this.archivoToolStripMenuItem.Size = new System.Drawing.Size(55, 20); - this.archivoToolStripMenuItem.Text = "Archivo"; + this.archivoToolStripMenuItem.Size = new System.Drawing.Size(88, 20); + this.archivoToolStripMenuItem.Text = "Base de Datos"; // // menuCargar // this.menuCargar.Name = "menuCargar"; - this.menuCargar.Size = new System.Drawing.Size(124, 22); + this.menuCargar.Size = new System.Drawing.Size(152, 22); this.menuCargar.Text = "Cargar"; this.menuCargar.Click += new System.EventHandler(this.menuCargar_Click); // // menuGuardar // this.menuGuardar.Name = "menuGuardar"; - this.menuGuardar.Size = new System.Drawing.Size(124, 22); + this.menuGuardar.Size = new System.Drawing.Size(152, 22); this.menuGuardar.Text = "Guardar"; this.menuGuardar.Click += new System.EventHandler(this.menuGuardar_Click); // @@ -198,7 +207,7 @@ // btnGenerar // this.btnGenerar.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.btnGenerar.Location = new System.Drawing.Point(613, 441); + this.btnGenerar.Location = new System.Drawing.Point(386, 485); this.btnGenerar.Name = "btnGenerar"; this.btnGenerar.Size = new System.Drawing.Size(75, 23); this.btnGenerar.TabIndex = 10; @@ -208,8 +217,8 @@ // // 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(521, 441); + this.btnVerDatos.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.btnVerDatos.Location = new System.Drawing.Point(3, 485); this.btnVerDatos.Name = "btnVerDatos"; this.btnVerDatos.Size = new System.Drawing.Size(75, 23); this.btnVerDatos.TabIndex = 11; @@ -224,46 +233,107 @@ 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(344, 30); + this.lblTituloTabla.Location = new System.Drawing.Point(3, 0); this.lblTituloTabla.Name = "lblTituloTabla"; - this.lblTituloTabla.Size = new System.Drawing.Size(344, 37); + this.lblTituloTabla.Size = new System.Drawing.Size(458, 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(12, 30); + this.lblTituloDB.Location = new System.Drawing.Point(3, 0); this.lblTituloDB.Name = "lblTituloDB"; - this.lblTituloDB.Size = new System.Drawing.Size(326, 37); + this.lblTituloDB.Size = new System.Drawing.Size(332, 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.Right))); + this.btnDocGen.Location = new System.Drawing.Point(305, 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.Location = new System.Drawing.Point(1, 32); + this.splitContainer1.Name = "splitContainer1"; + // + // splitContainer1.Panel1 + // + this.splitContainer1.Panel1.Controls.Add(this.lblTituloDB); + this.splitContainer1.Panel1.Controls.Add(this.lsvTablas); + this.splitContainer1.Panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.splitContainer1_Panel1_Paint); + // + // splitContainer1.Panel2 + // + this.splitContainer1.Panel2.Controls.Add(this.lblTituloTabla); + this.splitContainer1.Panel2.Controls.Add(this.btnDocGen); + this.splitContainer1.Panel2.Controls.Add(this.btnExec); + this.splitContainer1.Panel2.Controls.Add(this.lsvColumnas); + this.splitContainer1.Panel2.Controls.Add(this.menuBaseDatos); + this.splitContainer1.Panel2.Controls.Add(this.btnGenerar); + this.splitContainer1.Panel2.Controls.Add(this.btnProcs); + this.splitContainer1.Panel2.Controls.Add(this.btnVerDatos); + this.splitContainer1.Size = new System.Drawing.Size(806, 511); + this.splitContainer1.SplitterDistance = 338; + this.splitContainer1.TabIndex = 17; + // // frmBaseDatos // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(700, 476); - this.Controls.Add(this.lblTituloDB); - this.Controls.Add(this.lblTituloTabla); - this.Controls.Add(this.btnVerDatos); - this.Controls.Add(this.btnGenerar); - this.Controls.Add(this.lsvColumnas); - this.Controls.Add(this.lsvTablas); + 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 = "frmBaseDatos"; this.Text = "Base de Datos"; this.Load += new System.EventHandler(this.frmBaseDatos_Load); this.menuBaseDatos.ResumeLayout(false); this.menuBaseDatos.PerformLayout(); + this.splitContainer1.Panel1.ResumeLayout(false); + this.splitContainer1.Panel2.ResumeLayout(false); + this.splitContainer1.Panel2.PerformLayout(); + this.splitContainer1.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); @@ -292,5 +362,9 @@ 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; } } \ No newline at end of file diff --git a/ServerExplorer/ServerExplorer/frmBaseDatos.cs b/ServerExplorer/frmBaseDatos.cs similarity index 72% rename from ServerExplorer/ServerExplorer/frmBaseDatos.cs rename to ServerExplorer/frmBaseDatos.cs index bfe6788..f3c6636 100644 --- a/ServerExplorer/ServerExplorer/frmBaseDatos.cs +++ b/ServerExplorer/frmBaseDatos.cs @@ -9,15 +9,17 @@ using System.Windows.Forms; using System.Data.Sql; using System.Data.SqlClient; using System.Xml.Serialization; +using System.Threading; namespace ServerExplorer { public partial class frmBaseDatos : Form { - SqlConnection cnx; - CodeGenConfig config; - String table_schema = null; - String table_name = null; + private frmBaseDatos instancia; + private SqlConnection cnx; + private Config config; + private String table_schema = null; + private String table_name = null; private void inicializar() { @@ -53,7 +55,7 @@ namespace ServerExplorer { if (item.Checked) { - config.Tablas.Add(new CodeGenTablaInfo( + config.Tablas.Add(new TablaInfo( item.SubItems[1].Text, // Esquema item.SubItems[0].Text // Nombre tabla )); @@ -103,7 +105,7 @@ namespace ServerExplorer public DatabaseDesc CrearDatabaseDesc() { DatabaseDesc db = new DatabaseDesc(cnx.Database); - foreach (CodeGenTablaInfo t in config.Tablas) + foreach (TablaInfo t in config.Tablas) { TablaDesc td = new TablaDesc(); td.FillDesc(t.Esquema, t.Nombre, cnx); @@ -116,15 +118,16 @@ namespace ServerExplorer { InitializeComponent(); - config = new CodeGenConfig(); + instancia = this; + config = new Config(); config.ConString = ConString; - } - public frmBaseDatos(CodeGenConfig config) + public frmBaseDatos(Config config) { InitializeComponent(); + instancia = this; this.config = config; } @@ -194,7 +197,7 @@ namespace ServerExplorer OpenFileDialog dialogo = new OpenFileDialog(); if (dialogo.ShowDialog() == DialogResult.OK) { - config = CodeGenConfig.Cargar(dialogo.FileName); + config = Config.Cargar(dialogo.FileName); inicializar(); } } @@ -216,16 +219,6 @@ namespace ServerExplorer frm.ShowDialog(); } - private void btnGenerar_Click(object sender, EventArgs e) - { - tablas_delistview(); - DatabaseDesc db = CrearDatabaseDesc(); - - //XmlSerializer seriador = new XmlSerializer(typeof(DatabaseDesc)); - //seriador.Serialize(System.Console.Out, db); - - CodeGen.GenerarCodigo(config, db); - } private void btnVerDatos_Click(object sender, EventArgs e) { @@ -235,11 +228,11 @@ namespace ServerExplorer if (table_schema == null || table_name == null) { return; } - nombreTabla=table_schema+"."+table_name; + nombreTabla="["+table_schema+"].["+table_name+"]"; // Obtener un datatable con todos los registros de la tabla. da = new SqlDataAdapter( - "select * from "+nombreTabla, + "select * from " + nombreTabla, cnx); dt = new DataTable(); cnx.Open(); @@ -253,9 +246,96 @@ namespace ServerExplorer } + + private void btnProcs_Click(object sender, EventArgs e) + { + /*DataTable dt; + SqlDataAdapter da; + + // Obtener un datatable con todos los registros de la tabla. + da = new SqlDataAdapter( + "SELECT id,name,crdate FROM sysobjects WHERE type = 'P' AND category = 0 ORDER BY name ", + cnx); + dt = new DataTable(); + cnx.Open(); + da.Fill(dt); + cnx.Close(); + + // Crear y mostrar el formulario de los datos. + frmDatos form = new frmDatos(dt, "Procedimientos"); + form.MdiParent = this.MdiParent; + form.Show();*/ + + // Crear y mostrar el formulario de los procedimientos. + frmProcedimientos form = new frmProcedimientos(config.ConString); + form.MdiParent = this.MdiParent; + form.Show(); + } + + private void btnExec_Click(object sender, EventArgs e) + { + // Crear y mostrar el formulario de exec. + frmExec form = new frmExec(config.ConString); + form.MdiParent = this.MdiParent; + form.Show(); + } + + private void menuBaseDatos_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { } + private void btnGenerar_Click(object sender, EventArgs e) + { + tablas_delistview(); + DatabaseDesc db = CrearDatabaseDesc(); + + //XmlSerializer seriador = new XmlSerializer(typeof(DatabaseDesc)); + //seriador.Serialize(System.Console.Out, db); + + CodeGen.GenerarCodigo(config, db); + } + + private void btnDocGen_Click(object sender, EventArgs e) + { + // Hacer insensible la ventana + this.Parent.Enabled = false; + + // Obtener informacion. + tablas_delistview(); + DatabaseDesc db = CrearDatabaseDesc(); + + // Escribir documentacion + DocGen.GenerarDocumentacion(config, db); + + // Hace sensible la ventana + this.Parent.Enabled = true; + + /* + tablas_delistview(); + Thread hilo=new Thread(new ThreadStart(instancia.GenerarDoc)); + hilo.Start(); + */ + } + public void GenerarDoc() + { + // Hacer insensible la ventana + this.Enabled = false; + + // Obtener informacion. + DatabaseDesc db = CrearDatabaseDesc(); + + // Escribir documentacion + DocGen.GenerarDocumentacion(config, db); + + // Hace sensible la ventana + this.Enabled = true; + } + + private void splitContainer1_Panel1_Paint(object sender, PaintEventArgs e) + { + + } + } } diff --git a/ServerExplorer/ServerExplorer/frmBaseDatos.resx b/ServerExplorer/frmBaseDatos.resx similarity index 100% rename from ServerExplorer/ServerExplorer/frmBaseDatos.resx rename to ServerExplorer/frmBaseDatos.resx diff --git a/ServerExplorer/ServerExplorer/frmCodeGenConfig.Designer.cs b/ServerExplorer/frmCodeGenConfig.Designer.cs similarity index 80% rename from ServerExplorer/ServerExplorer/frmCodeGenConfig.Designer.cs rename to ServerExplorer/frmCodeGenConfig.Designer.cs index 01d9d78..7a69703 100644 --- a/ServerExplorer/ServerExplorer/frmCodeGenConfig.Designer.cs +++ b/ServerExplorer/frmCodeGenConfig.Designer.cs @@ -44,6 +44,10 @@ this.lblPathExtra = new System.Windows.Forms.Label(); this.btnCancelar = new System.Windows.Forms.Button(); this.btnAceptar = new System.Windows.Forms.Button(); + this.lblNSDAL = new System.Windows.Forms.Label(); + this.lblNSDTO = new System.Windows.Forms.Label(); + this.txtNSDAL = new System.Windows.Forms.TextBox(); + this.txtNSDTO = new System.Windows.Forms.TextBox(); this.SuspendLayout(); // // lblConString @@ -57,8 +61,8 @@ // // 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.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(125, 6); this.txtConString.Multiline = true; this.txtConString.Name = "txtConString"; @@ -77,8 +81,8 @@ // // txtPathRaiz // - this.txtPathRaiz.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.txtPathRaiz.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.txtPathRaiz.Location = new System.Drawing.Point(125, 61); this.txtPathRaiz.Name = "txtPathRaiz"; this.txtPathRaiz.ReadOnly = true; @@ -109,8 +113,8 @@ // // txtPathDAL // - this.txtPathDAL.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.txtPathDAL.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.txtPathDAL.Location = new System.Drawing.Point(125, 87); this.txtPathDAL.Name = "txtPathDAL"; this.txtPathDAL.ReadOnly = true; @@ -139,8 +143,8 @@ // // txtPathDTO // - this.txtPathDTO.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.txtPathDTO.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.txtPathDTO.Location = new System.Drawing.Point(125, 113); this.txtPathDTO.Name = "txtPathDTO"; this.txtPathDTO.ReadOnly = true; @@ -169,8 +173,8 @@ // // txtPathExtra // - this.txtPathExtra.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.txtPathExtra.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.txtPathExtra.Location = new System.Drawing.Point(125, 139); this.txtPathExtra.Name = "txtPathExtra"; this.txtPathExtra.ReadOnly = true; @@ -189,7 +193,7 @@ // btnCancelar // this.btnCancelar.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.btnCancelar.Location = new System.Drawing.Point(380, 201); + this.btnCancelar.Location = new System.Drawing.Point(380, 286); this.btnCancelar.Name = "btnCancelar"; this.btnCancelar.Size = new System.Drawing.Size(75, 23); this.btnCancelar.TabIndex = 15; @@ -200,7 +204,7 @@ // btnAceptar // this.btnAceptar.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.btnAceptar.Location = new System.Drawing.Point(299, 201); + this.btnAceptar.Location = new System.Drawing.Point(299, 286); this.btnAceptar.Name = "btnAceptar"; this.btnAceptar.Size = new System.Drawing.Size(75, 23); this.btnAceptar.TabIndex = 16; @@ -208,11 +212,51 @@ this.btnAceptar.UseVisualStyleBackColor = true; this.btnAceptar.Click += new System.EventHandler(this.btnAceptar_Click); // + // lblNSDAL + // + this.lblNSDAL.AutoSize = true; + this.lblNSDAL.Location = new System.Drawing.Point(12, 169); + this.lblNSDAL.Name = "lblNSDAL"; + this.lblNSDAL.Size = new System.Drawing.Size(46, 13); + this.lblNSDAL.TabIndex = 17; + this.lblNSDAL.Text = "NS DAL"; + // + // lblNSDTO + // + this.lblNSDTO.AutoSize = true; + this.lblNSDTO.Location = new System.Drawing.Point(12, 195); + this.lblNSDTO.Name = "lblNSDTO"; + this.lblNSDTO.Size = new System.Drawing.Size(48, 13); + this.lblNSDTO.TabIndex = 18; + this.lblNSDTO.Text = "NS DTO"; + // + // txtNSDAL + // + this.txtNSDAL.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.txtNSDAL.Location = new System.Drawing.Point(125, 166); + this.txtNSDAL.Name = "txtNSDAL"; + this.txtNSDAL.Size = new System.Drawing.Size(330, 20); + this.txtNSDAL.TabIndex = 19; + // + // txtNSDTO + // + this.txtNSDTO.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.txtNSDTO.Location = new System.Drawing.Point(125, 192); + this.txtNSDTO.Name = "txtNSDTO"; + this.txtNSDTO.Size = new System.Drawing.Size(330, 20); + this.txtNSDTO.TabIndex = 20; + // // frmCodeGenConfig // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(467, 236); + this.ClientSize = new System.Drawing.Size(467, 321); + this.Controls.Add(this.txtNSDTO); + this.Controls.Add(this.txtNSDAL); + this.Controls.Add(this.lblNSDTO); + this.Controls.Add(this.lblNSDAL); this.Controls.Add(this.btnAceptar); this.Controls.Add(this.btnCancelar); this.Controls.Add(this.btnPathExtra); @@ -255,5 +299,9 @@ private System.Windows.Forms.Label lblPathExtra; private System.Windows.Forms.Button btnCancelar; private System.Windows.Forms.Button btnAceptar; + private System.Windows.Forms.Label lblNSDAL; + private System.Windows.Forms.Label lblNSDTO; + private System.Windows.Forms.TextBox txtNSDAL; + private System.Windows.Forms.TextBox txtNSDTO; } } \ No newline at end of file diff --git a/ServerExplorer/ServerExplorer/frmCodeGenConfig.cs b/ServerExplorer/frmCodeGenConfig.cs similarity index 90% rename from ServerExplorer/ServerExplorer/frmCodeGenConfig.cs rename to ServerExplorer/frmCodeGenConfig.cs index b06b29f..3d1314b 100644 --- a/ServerExplorer/ServerExplorer/frmCodeGenConfig.cs +++ b/ServerExplorer/frmCodeGenConfig.cs @@ -11,9 +11,9 @@ namespace ServerExplorer { public partial class frmCodeGenConfig : Form { - CodeGenConfig config; + Config config; - public frmCodeGenConfig(CodeGenConfig config) + public frmCodeGenConfig(Config config) { InitializeComponent(); @@ -27,6 +27,8 @@ namespace ServerExplorer txtPathDAL.Text = config.PathDAL; txtPathDTO.Text = config.PathDTO; txtPathExtra.Text = config.PathExtra; + txtNSDAL.Text = config.NamespaceDAL; + txtNSDTO.Text = config.NamespaceDTO; } private void btnPathRaiz_Click(object sender, EventArgs e) @@ -75,6 +77,8 @@ namespace ServerExplorer config.PathDAL = txtPathDAL.Text; config.PathDTO = txtPathDTO.Text; config.PathExtra = txtPathExtra.Text; + config.NamespaceDAL = txtNSDAL.Text; + config.NamespaceDTO = txtNSDTO.Text; this.Close(); } diff --git a/ServerExplorer/ServerExplorer/frmCodeGenConfig.resx b/ServerExplorer/frmCodeGenConfig.resx similarity index 100% rename from ServerExplorer/ServerExplorer/frmCodeGenConfig.resx rename to ServerExplorer/frmCodeGenConfig.resx diff --git a/ServerExplorer/ServerExplorer/frmDatos.Designer.cs b/ServerExplorer/frmDatos.Designer.cs similarity index 86% rename from ServerExplorer/ServerExplorer/frmDatos.Designer.cs rename to ServerExplorer/frmDatos.Designer.cs index 2b9f5f5..1959858 100644 --- a/ServerExplorer/ServerExplorer/frmDatos.Designer.cs +++ b/ServerExplorer/frmDatos.Designer.cs @@ -38,22 +38,23 @@ this.dgvDatos.AllowUserToDeleteRows = false; this.dgvDatos.AllowUserToOrderColumns = true; this.dgvDatos.AllowUserToResizeRows = false; - 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.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, 12); this.dgvDatos.Name = "dgvDatos"; this.dgvDatos.ReadOnly = true; this.dgvDatos.RowHeadersVisible = false; - this.dgvDatos.Size = new System.Drawing.Size(326, 282); + this.dgvDatos.Size = new System.Drawing.Size(347, 308); this.dgvDatos.TabIndex = 0; + this.dgvDatos.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgvDatos_CellContentClick); // // frmDatos // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(350, 306); + this.ClientSize = new System.Drawing.Size(371, 332); this.Controls.Add(this.dgvDatos); this.Name = "frmDatos"; this.Text = "frmDatos"; diff --git a/ServerExplorer/ServerExplorer/frmDatos.cs b/ServerExplorer/frmDatos.cs similarity index 82% rename from ServerExplorer/ServerExplorer/frmDatos.cs rename to ServerExplorer/frmDatos.cs index 9ee99b3..d5e53dc 100644 --- a/ServerExplorer/ServerExplorer/frmDatos.cs +++ b/ServerExplorer/frmDatos.cs @@ -23,5 +23,10 @@ namespace ServerExplorer { } + + private void dgvDatos_CellContentClick(object sender, DataGridViewCellEventArgs e) + { + + } } } diff --git a/ServerExplorer/ServerExplorer/frmDatos.resx b/ServerExplorer/frmDatos.resx similarity index 100% rename from ServerExplorer/ServerExplorer/frmDatos.resx rename to ServerExplorer/frmDatos.resx diff --git a/ServerExplorer/frmExec.Designer.cs b/ServerExplorer/frmExec.Designer.cs new file mode 100644 index 0000000..ed4aac7 --- /dev/null +++ b/ServerExplorer/frmExec.Designer.cs @@ -0,0 +1,136 @@ +namespace ServerExplorer +{ + 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.txtCommand = new System.Windows.Forms.TextBox(); + this.dgvDatos = new System.Windows.Forms.DataGridView(); + this.splitContainer1 = new System.Windows.Forms.SplitContainer(); + this.btnGenInserts = new System.Windows.Forms.Button(); + ((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); + // + // 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; + // + // dgvDatos + // + 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.Size = new System.Drawing.Size(604, 338); + this.dgvDatos.TabIndex = 2; + // + // 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"; + this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal; + // + // splitContainer1.Panel1 + // + 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.Right))); + this.btnGenInserts.Location = new System.Drawing.Point(424, 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); + // + // 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 = "frmExec"; + this.Load += new System.EventHandler(this.frmExec_Load); + ((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 System.Windows.Forms.TextBox txtCommand; + private System.Windows.Forms.DataGridView dgvDatos; + private System.Windows.Forms.SplitContainer splitContainer1; + private System.Windows.Forms.Button btnGenInserts; + } +} \ No newline at end of file diff --git a/ServerExplorer/frmExec.cs b/ServerExplorer/frmExec.cs new file mode 100644 index 0000000..e5c34b8 --- /dev/null +++ b/ServerExplorer/frmExec.cs @@ -0,0 +1,148 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using System.Data.SqlClient; +using System.Globalization; + +namespace ServerExplorer +{ + public partial class frmExec : Form + { + private string cnxString; + + + public frmExec(string cnxString) + { + InitializeComponent(); + + this.cnxString = cnxString; + } + + private void frmExec_Load(object sender, EventArgs e){ + + } + + + private DataTable Exec() + { + SqlConnection cnx; + DataTable dt; + SqlDataAdapter da; + + // Establecer conexion + cnx = new SqlConnection(cnxString); + + // Obtener resultado en un datatable. + da = new SqlDataAdapter(txtCommand.Text, cnx); + dt = new DataTable(); + cnx.Open(); + da.Fill(dt); + cnx.Close(); + + return dt; + } + + private void btnExec_Click(object sender, EventArgs e) + { + try + { + // Ejecutar consulta + DataTable dt = Exec(); + + // Mostrar resultados + dgvDatos.DataSource = dt; + } + catch(Exception ex) + { + MessageBox.Show(ex.Message); + } + } + + private void btnGenInserts_Click(object sender, EventArgs e) + { + DataTable dt=new DataTable(); + DataTable ddt; + string destname = String.Empty; + NumberFormatInfo nfi = new NumberFormatInfo(); + + // Preparar un conversor de formato numerico que use puntos para los decimales + nfi.NumberDecimalSeparator = "."; + + // Obtener el nombre de la tabla destino + destname = Microsoft.VisualBasic.Interaction.InputBox("Nombre de la tabla destino", "tabla destino", String.Empty, + this.Top + (this.Height / 2), this.Left + (this.Width / 2)); + + try + { + // Ejecutar consulta + dt = Exec(); + } + catch(Exception ex) + { + MessageBox.Show(ex.Message); + } + + // Preparar la datatable destino + ddt=new DataTable(); + ddt.Columns.Add("Comando", typeof(String)); + + + // Recorrer la tabla de datos + foreach (DataRow dr in dt.Rows) + { + string strColumns=String.Empty; + string strValues=String.Empty; + foreach (DataColumn dc in dt.Columns) + { + // El nombre de la columna + if (strColumns != String.Empty) + strColumns+=", "; + strColumns += "[" + dc.ColumnName + "]"; + + // El valor de la columna + if (strValues != String.Empty) + strValues+=", "; + object valor = dr[dc]; + if (valor == DBNull.Value) + { + // NULOS + strValues += "NULL"; + }else + if (dc.DataType.Name.ToLower() == "string") + { + // Cadenas + strValues += "'" + ((string)valor).Replace("'", "''") + "'"; + } + else + if (dc.DataType.Name.ToLower() == "decimal") + { + // Decimales + strValues += ((decimal)valor).ToString(nfi); + } + else + { + // Otros + strValues += valor.ToString(); + } + } + + // Insertar fila a la datatable destino + ddt.Rows.Add(new object[] { + "INSERT INTO " + destname + + " (" + strColumns + ") "+ + "VALUES (" + strValues + ")" }); + } + + // Establecer el resultado + dgvDatos.DataSource = ddt; + } + + + + } +} diff --git a/ServerExplorer/frmExec.resx b/ServerExplorer/frmExec.resx new file mode 100644 index 0000000..7080a7d --- /dev/null +++ b/ServerExplorer/frmExec.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/ServerExplorer/ServerExplorer/frmPrincipal.Designer.cs b/ServerExplorer/frmPrincipal.Designer.cs similarity index 100% rename from ServerExplorer/ServerExplorer/frmPrincipal.Designer.cs rename to ServerExplorer/frmPrincipal.Designer.cs diff --git a/ServerExplorer/ServerExplorer/frmPrincipal.cs b/ServerExplorer/frmPrincipal.cs similarity index 82% rename from ServerExplorer/ServerExplorer/frmPrincipal.cs rename to ServerExplorer/frmPrincipal.cs index e3f63ea..396723b 100644 --- a/ServerExplorer/ServerExplorer/frmPrincipal.cs +++ b/ServerExplorer/frmPrincipal.cs @@ -19,8 +19,8 @@ namespace ServerExplorer private void menuConectarPRUEBAS_Click(object sender, EventArgs e) { // Crear ventana de la base de datos de pruebas - //frmBaseDatos frm = new frmBaseDatos("Data Source=SSSRV3;Initial Catalog=PRUEBAS;User ID=sa;Password=SLsssrv3"); - frmBaseDatos frm = new frmBaseDatos("Data Source=DANTE;Initial Catalog=BD_AlfonsoRodriguez;Integrated Security=True"); + frmBaseDatos frm = new frmBaseDatos("Data Source=SSSRV3;Initial Catalog=PRUEBAS;User ID=sa;Password=SLsssrv3"); + //frmBaseDatos frm = new frmBaseDatos("Data Source=DANTE;Initial Catalog=BD_AlfonsoRodriguez;Integrated Security=True"); //frmBaseDatos frm = new frmBaseDatos("Data Source=OSKURITO;Initial Catalog=BD_AlfonsoRodriguez;Integrated Security=True"); frm.MdiParent = this; frm.WindowState = FormWindowState.Maximized; @@ -41,7 +41,7 @@ namespace ServerExplorer OpenFileDialog dialogo = new OpenFileDialog(); if (dialogo.ShowDialog() == DialogResult.OK) { - CodeGenConfig config = CodeGenConfig.Cargar(dialogo.FileName); + Config config = Config.Cargar(dialogo.FileName); // Crear y mostrar ventana frmBaseDatos frm = new frmBaseDatos(config); diff --git a/ServerExplorer/ServerExplorer/frmPrincipal.resx b/ServerExplorer/frmPrincipal.resx similarity index 100% rename from ServerExplorer/ServerExplorer/frmPrincipal.resx rename to ServerExplorer/frmPrincipal.resx diff --git a/ServerExplorer/frmProcedimientos.Designer.cs b/ServerExplorer/frmProcedimientos.Designer.cs new file mode 100644 index 0000000..de12fa9 --- /dev/null +++ b/ServerExplorer/frmProcedimientos.Designer.cs @@ -0,0 +1,138 @@ +namespace ServerExplorer +{ + partial class frmProcedimientos + { + /// + /// 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 System.Windows.Forms.ListView(); + this.colNombre = new System.Windows.Forms.ColumnHeader(); + this.colFecha = new System.Windows.Forms.ColumnHeader(); + this.colTipo = new System.Windows.Forms.ColumnHeader(); + this.txtProc = new System.Windows.Forms.TextBox(); + this.splitContainer1 = new System.Windows.Forms.SplitContainer(); + this.splitContainer1.Panel1.SuspendLayout(); + this.splitContainer1.Panel2.SuspendLayout(); + this.splitContainer1.SuspendLayout(); + this.SuspendLayout(); + // + // lsvProcs + // + 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.colFecha, + this.colTipo}); + this.lsvProcs.Font = new System.Drawing.Font("Lucida Console", 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(262, 369); + this.lsvProcs.Sorting = System.Windows.Forms.SortOrder.Ascending; + 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; + // + // 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(308, 366); + this.txtProc.TabIndex = 1; + // + // 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.lsvProcs); + this.splitContainer1.Panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.splitContainer1_Panel1_Paint); + // + // splitContainer1.Panel2 + // + this.splitContainer1.Panel2.Controls.Add(this.txtProc); + this.splitContainer1.Size = new System.Drawing.Size(583, 372); + this.splitContainer1.SplitterDistance = 265; + this.splitContainer1.TabIndex = 2; + this.splitContainer1.SplitterMoved += new System.Windows.Forms.SplitterEventHandler(this.splitContainer1_SplitterMoved); + // + // frmProcedimientos + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(607, 396); + 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 System.Windows.Forms.ListView lsvProcs; + private System.Windows.Forms.ColumnHeader colNombre; + private System.Windows.Forms.ColumnHeader colFecha; + private System.Windows.Forms.TextBox txtProc; + private System.Windows.Forms.SplitContainer splitContainer1; + private System.Windows.Forms.ColumnHeader colTipo; + } +} \ No newline at end of file diff --git a/ServerExplorer/frmProcedimientos.cs b/ServerExplorer/frmProcedimientos.cs new file mode 100644 index 0000000..ca63deb --- /dev/null +++ b/ServerExplorer/frmProcedimientos.cs @@ -0,0 +1,118 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using System.Data.Sql; +using System.Data.SqlClient; + +namespace ServerExplorer +{ + public partial class frmProcedimientos : Form + { + private string cnxString; + private SqlConnection cnx; + + public frmProcedimientos(string cnxString) + { + InitializeComponent(); + + this.cnxString = cnxString; + } + + + + private void frmProcedimientos_Load(object sender, EventArgs e) + { + DataTable dt; + SqlDataAdapter da; + + // Establecer conexion + cnx = new SqlConnection(cnxString); + + // Obtener un datatable con todos los procedimientos de la base de datos. + da = new SqlDataAdapter( + "SELECT id,name,crdate,type FROM sysobjects "+ + "WHERE (UPPER(type) = 'P' OR UPPER(type) = 'TF' OR UPPER(type) = 'TR' OR UPPER(type) = 'V') AND category = 0 " + + "ORDER BY name ", + cnx); + dt = new DataTable(); + cnx.Open(); + da.Fill(dt); + cnx.Close(); + + // Mostrar todos los procedimientos + lsvProcs.Items.Clear(); + foreach (DataRow dr in dt.Rows) + { + ListViewItem item = lsvProcs.Items.Add((String)dr["name"]); + item.SubItems.Add(((DateTime)dr["crdate"]).ToShortDateString()); + string type = ((string)dr["type"]).ToUpper().Trim(); + if (type == "P") + { + item.SubItems.Add("Proc"); + } + else if (type == "TF") + { + item.SubItems.Add("Func"); + } + else if (type == "TR") + { + item.SubItems.Add("Trigg"); + } + else if (type == "V") + { + item.SubItems.Add("View"); + } + else + { + item.SubItems.Add("Unk: \"" + (string)dr["type"] + "\""); + } + item.Tag = dr["id"]; + } + + + } + + private void lsvProcs_SelectedIndexChanged(object sender, EventArgs e) + { + if (lsvProcs.SelectedItems.Count>0 ) + { + DataTable dt; + SqlDataAdapter da; + int id=(int)lsvProcs.SelectedItems[0].Tag; + + // Obtener un datatable con el contenido del procedimiento. + da = new SqlDataAdapter( + "SELECT text FROM syscomments WHERE id = @id ORDER BY colid", + cnx); + da.SelectCommand.Parameters.AddWithValue("@id", id); + dt = new DataTable(); + cnx.Open(); + da.Fill(dt); + cnx.Close(); + + // Mostrar el contenido del procedimiento + txtProc.Text = String.Empty; + foreach (DataRow dr in dt.Rows) + { + txtProc.Text += ((string)dr[0]).Replace("\r","").Replace("\n","\r\n"); + } + + } + } + + private void splitContainer1_Panel1_Paint(object sender, PaintEventArgs e) + { + + } + + private void splitContainer1_SplitterMoved(object sender, SplitterEventArgs e) + { + + } + } +} diff --git a/ServerExplorer/frmProcedimientos.resx b/ServerExplorer/frmProcedimientos.resx new file mode 100644 index 0000000..7080a7d --- /dev/null +++ b/ServerExplorer/frmProcedimientos.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/ServerExplorer/ServerExplorer/frmServidores.Designer.cs b/ServerExplorer/frmServidores.Designer.cs similarity index 68% rename from ServerExplorer/ServerExplorer/frmServidores.Designer.cs rename to ServerExplorer/frmServidores.Designer.cs index d14acfd..9236ddb 100644 --- a/ServerExplorer/ServerExplorer/frmServidores.Designer.cs +++ b/ServerExplorer/frmServidores.Designer.cs @@ -43,20 +43,25 @@ this.lsvBBDD = new System.Windows.Forms.ListView(); 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(); + this.splitContainer1.Panel1.SuspendLayout(); + this.splitContainer1.Panel2.SuspendLayout(); + this.splitContainer1.SuspendLayout(); this.SuspendLayout(); // // lsvServidores // - this.lsvServidores.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left))); + 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.Location = new System.Drawing.Point(12, 42); + this.lsvServidores.Location = new System.Drawing.Point(3, 32); this.lsvServidores.Name = "lsvServidores"; - this.lsvServidores.Size = new System.Drawing.Size(281, 391); + 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; @@ -79,9 +84,11 @@ // // btnListarServidores // - this.btnListarServidores.Location = new System.Drawing.Point(12, 13); + 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(281, 23); + this.btnListarServidores.Size = new System.Drawing.Size(306, 23); this.btnListarServidores.TabIndex = 2; this.btnListarServidores.Text = "Listar Servidores"; this.btnListarServidores.UseVisualStyleBackColor = true; @@ -90,7 +97,7 @@ // lblServidor // this.lblServidor.AutoSize = true; - this.lblServidor.Location = new System.Drawing.Point(319, 18); + 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; @@ -98,15 +105,17 @@ // // txtServidor // - this.txtServidor.Location = new System.Drawing.Point(429, 15); + 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(180, 20); + this.txtServidor.Size = new System.Drawing.Size(218, 20); this.txtServidor.TabIndex = 4; // // lblUsuario // this.lblUsuario.AutoSize = true; - this.lblUsuario.Location = new System.Drawing.Point(319, 45); + 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; @@ -115,7 +124,7 @@ // lblContrasenha // this.lblContrasenha.AutoSize = true; - this.lblContrasenha.Location = new System.Drawing.Point(319, 70); + 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; @@ -123,24 +132,30 @@ // // txtUsuario // - this.txtUsuario.Location = new System.Drawing.Point(429, 42); + 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(180, 20); + this.txtUsuario.Size = new System.Drawing.Size(218, 20); this.txtUsuario.TabIndex = 7; // // TxtContrasenha // - this.TxtContrasenha.Location = new System.Drawing.Point(429, 67); + 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(180, 20); + this.TxtContrasenha.Size = new System.Drawing.Size(218, 20); this.TxtContrasenha.TabIndex = 8; this.TxtContrasenha.UseSystemPasswordChar = true; // // btnListarBBDD // - this.btnListarBBDD.Location = new System.Drawing.Point(322, 93); + 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(287, 23); + this.btnListarBBDD.Size = new System.Drawing.Size(282, 23); this.btnListarBBDD.TabIndex = 9; this.btnListarBBDD.Text = "Listar BBDD"; this.btnListarBBDD.UseVisualStyleBackColor = true; @@ -148,15 +163,16 @@ // // lsvBBDD // - this.lsvBBDD.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left))); + 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.Location = new System.Drawing.Point(322, 122); + this.lsvBBDD.Location = new System.Drawing.Point(6, 113); this.lsvBBDD.Name = "lsvBBDD"; - this.lsvBBDD.Size = new System.Drawing.Size(287, 311); + 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; @@ -172,26 +188,47 @@ 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; + // // frmServidores // 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.lsvBBDD); - this.Controls.Add(this.btnListarBBDD); - this.Controls.Add(this.TxtContrasenha); - this.Controls.Add(this.txtUsuario); - this.Controls.Add(this.lblContrasenha); - this.Controls.Add(this.lblUsuario); - this.Controls.Add(this.txtServidor); - this.Controls.Add(this.lblServidor); - this.Controls.Add(this.btnListarServidores); - this.Controls.Add(this.lsvServidores); + this.Controls.Add(this.splitContainer1); this.Name = "frmServidores"; this.Text = "Servidores"; this.Load += new System.EventHandler(this.Form1_Load); + this.splitContainer1.Panel1.ResumeLayout(false); + this.splitContainer1.Panel2.ResumeLayout(false); + this.splitContainer1.Panel2.PerformLayout(); + this.splitContainer1.ResumeLayout(false); this.ResumeLayout(false); - this.PerformLayout(); } @@ -212,6 +249,7 @@ private System.Windows.Forms.ListView lsvBBDD; private System.Windows.Forms.ColumnHeader colDBName; private System.Windows.Forms.ColumnHeader colFechaCreacion; + private System.Windows.Forms.SplitContainer splitContainer1; } } diff --git a/ServerExplorer/ServerExplorer/frmServidores.cs b/ServerExplorer/frmServidores.cs similarity index 100% rename from ServerExplorer/ServerExplorer/frmServidores.cs rename to ServerExplorer/frmServidores.cs diff --git a/ServerExplorer/ServerExplorer/frmServidores.resx b/ServerExplorer/frmServidores.resx similarity index 100% rename from ServerExplorer/ServerExplorer/frmServidores.resx rename to ServerExplorer/frmServidores.resx diff --git a/ServerExplorer/ssr.exe b/ServerExplorer/ssr.exe deleted file mode 100644 index e341dc7..0000000 Binary files a/ServerExplorer/ssr.exe and /dev/null differ