Limpieza de codigo

This commit is contained in:
2013-10-14 20:20:23 +02:00
parent af72a4decb
commit b4eea3818f
22 changed files with 194 additions and 197 deletions

View File

@@ -4,18 +4,18 @@ using System.Linq;
using System.Text; using System.Text;
using System.IO; using System.IO;
namespace ServerExplorer namespace ServerExplorer.Code
{ {
public static class Utiles public static class Utiles
{ {
public static void CrearDirectorio(this String path) public static void CrearDirectorio(this String path)
{ {
DirectoryInfo info=null; DirectoryInfo info = null;
try try
{ {
info = new DirectoryInfo(path); info = new DirectoryInfo(path);
} }
catch (Exception ) catch (Exception)
{ {
info = new DirectoryInfo("."); info = new DirectoryInfo(".");
} }

View File

@@ -4,12 +4,14 @@ using System.Linq;
using System.Text; using System.Text;
using System.IO; using System.IO;
using System.Data; using System.Data;
using ServerExplorer.Code;
namespace ServerExplorer namespace ServerExplorer
{ {
public class CodeGen public class CodeGen
{ {
private static string FixNombre(string strIn){ private static string FixNombre(string strIn)
{
return strIn.Replace(' ', '_'); return strIn.Replace(' ', '_');
} }
@@ -147,7 +149,7 @@ namespace ServerExplorer
{ {
TipoCol tipo = c.GetTipo(); TipoCol tipo = c.GetTipo();
if(tipo==TipoCol.Otro) if (tipo == TipoCol.Otro)
continue; continue;
if (strInsert1 == String.Empty) if (strInsert1 == String.Empty)
@@ -186,7 +188,7 @@ namespace ServerExplorer
private static void GenerarDALActualizar(Config config, TablaDesc t, EscritorCodigo escritor) private static void GenerarDALActualizar(Config config, TablaDesc t, EscritorCodigo escritor)
{ {
string nombreObj = FixNombre(t.Esquema) + "_" + FixNombre(t.Nombre); string nombreObj = FixNombre(t.Esquema) + "_" + FixNombre(t.Nombre);
string strActualizar,strFiltroPrimario; string strActualizar, strFiltroPrimario;
// Cabecera y variables del metodo // Cabecera y variables del metodo
escritor.EscribeInd("public bool Actualizar(" + nombreObj + " reg)"); escritor.EscribeInd("public bool Actualizar(" + nombreObj + " reg)");
@@ -299,13 +301,13 @@ namespace ServerExplorer
escritor.Cerrar(); escritor.Cerrar();
} }
public static Boolean GenerarCodigo(Config config,DatabaseDesc database) public static Boolean GenerarCodigo(Config config, DatabaseDesc database)
{ {
// Asegura la existencia de los directorios destinos // Asegura la existencia de los directorios destinos
if (!System.IO.Directory.Exists(config.PathRaiz)) { Utiles.CrearDirectorio(config.PathRaiz); } if (!Directory.Exists(config.PathRaiz)) { Utiles.CrearDirectorio(config.PathRaiz); }
if (!System.IO.Directory.Exists(config.PathDTO)) { Utiles.CrearDirectorio(config.PathDTO); } if (!Directory.Exists(config.PathDTO)) { Utiles.CrearDirectorio(config.PathDTO); }
if (!System.IO.Directory.Exists(config.PathDAL)) { Utiles.CrearDirectorio(config.PathDAL); } if (!Directory.Exists(config.PathDAL)) { Utiles.CrearDirectorio(config.PathDAL); }
if (!System.IO.Directory.Exists(config.PathExtra)) { Utiles.CrearDirectorio(config.PathExtra); } if (!Directory.Exists(config.PathExtra)) { Utiles.CrearDirectorio(config.PathExtra); }
// Itera por cada tabla para crear sus DTO y DAL // Itera por cada tabla para crear sus DTO y DAL
foreach (TablaDesc t in database.Tablas) foreach (TablaDesc t in database.Tablas)
@@ -337,7 +339,7 @@ namespace ServerExplorer
public string Str() public string Str()
{ {
sb.Remove(0, sb.Length); sb.Remove(0, sb.Length);
for (int i=0; i < indentado; i++) for (int i = 0; i < indentado; i++)
{ {
sb.Append("\t"); sb.Append("\t");
} }

View File

@@ -14,7 +14,7 @@ namespace ServerExplorer
get { return pathRaiz; } get { return pathRaiz; }
set { pathRaiz = value; } set { pathRaiz = value; }
} }
public String pathDAL="."; public String pathDAL = ".";
public String PathDAL public String PathDAL
{ {
get get
@@ -33,7 +33,8 @@ namespace ServerExplorer
public String pathDTO = "."; public String pathDTO = ".";
public String PathDTO public String PathDTO
{ {
get { get
{
if (pathDTO == ".") if (pathDTO == ".")
{ {
return pathRaiz; return pathRaiz;
@@ -48,7 +49,8 @@ namespace ServerExplorer
public String pathExtra = "."; public String pathExtra = ".";
public String PathExtra public String PathExtra
{ {
get { get
{
if (pathExtra == ".") if (pathExtra == ".")
{ {
return pathRaiz; return pathRaiz;
@@ -87,8 +89,8 @@ namespace ServerExplorer
public class TablaInfo public class TablaInfo
{ {
public String Esquema=""; public String Esquema = "";
public String Nombre=""; public String Nombre = "";
public TablaInfo() { } public TablaInfo() { }
public TablaInfo(String esquema, String nombre) public TablaInfo(String esquema, String nombre)
@@ -97,5 +99,4 @@ namespace ServerExplorer
Nombre = nombre; Nombre = nombre;
} }
} }
} }

View File

@@ -16,6 +16,5 @@ namespace ServerExplorer
{ {
Nombre = nombre; Nombre = nombre;
} }
} }
} }

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.IO; using System.IO;
using ServerExplorer.Code;
namespace ServerExplorer namespace ServerExplorer
{ {
@@ -11,15 +12,13 @@ namespace ServerExplorer
public static void GenerarDocumentacion(Config config, DatabaseDesc database) public static void GenerarDocumentacion(Config config, DatabaseDesc database)
{ {
// Asegura la existencia de los directorios destinos // Asegura la existencia de los directorios destinos
if (!System.IO.Directory.Exists(config.PathRaiz)) { Utiles.CrearDirectorio(config.PathRaiz); } if (!Directory.Exists(config.PathRaiz)) { Utiles.CrearDirectorio(config.PathRaiz); }
if (!System.IO.Directory.Exists(config.PathDTO)) { Utiles.CrearDirectorio(config.PathDTO); } if (!Directory.Exists(config.PathDTO)) { Utiles.CrearDirectorio(config.PathDTO); }
if (!System.IO.Directory.Exists(config.PathDAL)) { Utiles.CrearDirectorio(config.PathDAL); } if (!Directory.Exists(config.PathDAL)) { Utiles.CrearDirectorio(config.PathDAL); }
if (!System.IO.Directory.Exists(config.PathExtra)) { Utiles.CrearDirectorio(config.PathExtra); } if (!Directory.Exists(config.PathExtra)) { Utiles.CrearDirectorio(config.PathExtra); }
// Abrir el documento que contendra la documentacion // Abrir el documento que contendra la documentacion
StreamWriter escritor=new StreamWriter(config.PathExtra+"/documentacion.html"); StreamWriter escritor = new StreamWriter(config.PathExtra + "/documentacion.html");
// Poner cabecera de la documentacion // Poner cabecera de la documentacion
escritor.WriteLine("<html><head><title>" + database.Nombre + "</title></head>"); escritor.WriteLine("<html><head><title>" + database.Nombre + "</title></head>");
@@ -29,7 +28,7 @@ namespace ServerExplorer
foreach (TablaDesc t in database.Tablas) foreach (TablaDesc t in database.Tablas)
{ {
// Cabecera de la info de tabla // Cabecera de la info de tabla
escritor.WriteLine("<h2>"+t.Esquema+"."+t.Nombre+"</h2>"); escritor.WriteLine("<h2>" + t.Esquema + "." + t.Nombre + "</h2>");
// Iterar las columnas // Iterar las columnas
escritor.WriteLine("<table>"); escritor.WriteLine("<table>");
@@ -46,11 +45,9 @@ namespace ServerExplorer
escritor.WriteLine("</tbody></table>"); escritor.WriteLine("</tbody></table>");
} }
// Poner pie y cerrar fichero // Poner pie y cerrar fichero
escritor.WriteLine("</body></html>"); escritor.WriteLine("</body></html>");
escritor.Close(); escritor.Close();
} }
} }
} }

View File

@@ -15,7 +15,7 @@ namespace ServerExplorer
{ {
Application.EnableVisualStyles(); Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false); Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new frmPrincipal()); Application.Run(new FrmPrincipal());
} }
} }
} }

View File

@@ -73,72 +73,72 @@
<Compile Include="Config.cs" /> <Compile Include="Config.cs" />
<Compile Include="DatabaseDesc.cs" /> <Compile Include="DatabaseDesc.cs" />
<Compile Include="DocGen.cs" /> <Compile Include="DocGen.cs" />
<Compile Include="frmBaseDatos.cs"> <Compile Include="FrmBaseDatos.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
<Compile Include="frmBaseDatos.Designer.cs"> <Compile Include="FrmBaseDatos.Designer.cs">
<DependentUpon>frmBaseDatos.cs</DependentUpon> <DependentUpon>FrmBaseDatos.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="frmCodeGenConfig.cs"> <Compile Include="FrmCodeGenConfig.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
<Compile Include="frmCodeGenConfig.Designer.cs"> <Compile Include="FrmCodeGenConfig.Designer.cs">
<DependentUpon>frmCodeGenConfig.cs</DependentUpon> <DependentUpon>FrmCodeGenConfig.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="frmDatos.cs"> <Compile Include="FrmDatos.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
<Compile Include="frmDatos.Designer.cs"> <Compile Include="FrmDatos.Designer.cs">
<DependentUpon>frmDatos.cs</DependentUpon> <DependentUpon>FrmDatos.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="frmExec.cs"> <Compile Include="FrmExec.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
<Compile Include="frmExec.Designer.cs"> <Compile Include="FrmExec.Designer.cs">
<DependentUpon>frmExec.cs</DependentUpon> <DependentUpon>FrmExec.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="frmPrincipal.cs"> <Compile Include="FrmPrincipal.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
<Compile Include="frmPrincipal.Designer.cs"> <Compile Include="FrmPrincipal.Designer.cs">
<DependentUpon>frmPrincipal.cs</DependentUpon> <DependentUpon>FrmPrincipal.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="frmProcedimientos.cs"> <Compile Include="FrmProcedimientos.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
<Compile Include="frmProcedimientos.Designer.cs"> <Compile Include="FrmProcedimientos.Designer.cs">
<DependentUpon>frmProcedimientos.cs</DependentUpon> <DependentUpon>FrmProcedimientos.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="frmServidores.cs"> <Compile Include="FrmServidores.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
<Compile Include="frmServidores.Designer.cs"> <Compile Include="FrmServidores.Designer.cs">
<DependentUpon>frmServidores.cs</DependentUpon> <DependentUpon>FrmServidores.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TablaDesc.cs" /> <Compile Include="TablaDesc.cs" />
<Compile Include="Utiles.cs" /> <Compile Include="Code\Utiles.cs" />
<EmbeddedResource Include="frmBaseDatos.resx"> <EmbeddedResource Include="FrmBaseDatos.resx">
<DependentUpon>frmBaseDatos.cs</DependentUpon> <DependentUpon>FrmBaseDatos.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="frmCodeGenConfig.resx"> <EmbeddedResource Include="FrmCodeGenConfig.resx">
<DependentUpon>frmCodeGenConfig.cs</DependentUpon> <DependentUpon>FrmCodeGenConfig.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="frmDatos.resx"> <EmbeddedResource Include="FrmDatos.resx">
<DependentUpon>frmDatos.cs</DependentUpon> <DependentUpon>FrmDatos.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="frmExec.resx"> <EmbeddedResource Include="FrmExec.resx">
<DependentUpon>frmExec.cs</DependentUpon> <DependentUpon>FrmExec.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="frmPrincipal.resx"> <EmbeddedResource Include="FrmPrincipal.resx">
<DependentUpon>frmPrincipal.cs</DependentUpon> <DependentUpon>FrmPrincipal.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="frmProcedimientos.resx"> <EmbeddedResource Include="FrmProcedimientos.resx">
<DependentUpon>frmProcedimientos.cs</DependentUpon> <DependentUpon>FrmProcedimientos.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="frmServidores.resx"> <EmbeddedResource Include="FrmServidores.resx">
<DependentUpon>frmServidores.cs</DependentUpon> <DependentUpon>FrmServidores.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx"> <EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator> <Generator>ResXFileCodeGenerator</Generator>
@@ -177,6 +177,7 @@
<Install>true</Install> <Install>true</Install>
</BootstrapperPackage> </BootstrapperPackage>
</ItemGroup> </ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.

View File

@@ -10,8 +10,8 @@ namespace ServerExplorer
{ {
public class TablaDesc public class TablaDesc
{ {
public String Esquema=""; public String Esquema = String.Empty;
public String Nombre=""; public String Nombre = String.Empty;
public List<ColumnaDesc> Columnas = new List<ColumnaDesc>(); public List<ColumnaDesc> Columnas = new List<ColumnaDesc>();
public TablaDesc() { } public TablaDesc() { }
@@ -56,11 +56,11 @@ namespace ServerExplorer
" col.TABLE_SCHEMA=@nombreEsquema " + " col.TABLE_SCHEMA=@nombreEsquema " +
" order by col.ORDINAL_POSITION", " order by col.ORDINAL_POSITION",
cnx); cnx);
prm=new SqlParameter("@nombreTabla",SqlDbType.VarChar,100); prm = new SqlParameter("@nombreTabla", SqlDbType.VarChar, 100);
prm.Value=nombre; prm.Value = nombre;
da.SelectCommand.Parameters.Add(prm); da.SelectCommand.Parameters.Add(prm);
prm=new SqlParameter("@nombreEsquema",SqlDbType.VarChar,100); prm = new SqlParameter("@nombreEsquema", SqlDbType.VarChar, 100);
prm.Value=esquema; prm.Value = esquema;
da.SelectCommand.Parameters.Add(prm); da.SelectCommand.Parameters.Add(prm);
// Obtener datatable con las columnas // Obtener datatable con las columnas
@@ -76,8 +76,8 @@ namespace ServerExplorer
ColumnaDesc col; ColumnaDesc col;
// Obtener columna // Obtener columna
col=GetCol((String)dr["Columna"]); col = GetCol((String)dr["Columna"]);
if (col==null) if (col == null)
{ {
col = new ColumnaDesc(); col = new ColumnaDesc();
Columnas.Add(col); Columnas.Add(col);
@@ -115,8 +115,8 @@ namespace ServerExplorer
public class ColumnaDesc public class ColumnaDesc
{ {
public string Nombre = ""; public string Nombre = String.Empty;
public string Tipo = ""; public string Tipo = String.Empty;
public int Tamanho = -1; public int Tamanho = -1;
public bool Primaria = false; public bool Primaria = false;
@@ -125,7 +125,7 @@ namespace ServerExplorer
private TipoCol tipo = TipoCol.Unset; private TipoCol tipo = TipoCol.Unset;
public TipoCol GetTipo() public TipoCol GetTipo()
{ {
string stipo=Tipo.ToLower(); string stipo = Tipo.ToLower();
if (this.tipo != TipoCol.Unset) if (this.tipo != TipoCol.Unset)
{ {
@@ -133,12 +133,12 @@ namespace ServerExplorer
} }
// Numericos // Numericos
if( if (
stipo=="bigint" || stipo == "bigint" ||
stipo=="int" || stipo == "int" ||
stipo=="smallint" || stipo == "smallint" ||
stipo=="tinyint" || stipo == "tinyint" ||
stipo=="bigint" stipo == "bigint"
) )
{ {
return TipoCol.Numerico; return TipoCol.Numerico;

View File

@@ -1,6 +1,6 @@
namespace ServerExplorer namespace ServerExplorer
{ {
partial class frmBaseDatos partial class FrmBaseDatos
{ {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.

View File

@@ -13,9 +13,9 @@ using System.Threading;
namespace ServerExplorer namespace ServerExplorer
{ {
public partial class frmBaseDatos : Form public partial class FrmBaseDatos : Form
{ {
private frmBaseDatos instancia; private FrmBaseDatos instancia;
private SqlConnection cnx; private SqlConnection cnx;
private Config config; private Config config;
private String table_schema = null; private String table_schema = null;
@@ -67,7 +67,7 @@ namespace ServerExplorer
// en le listview desde la configuracion // en le listview desde la configuracion
private void tablas_alistview() private void tablas_alistview()
{ {
int i,j,n; int i, j, n;
// Desmarcar todos en caso de no haber ninguna tabla // Desmarcar todos en caso de no haber ninguna tabla
if (config.Tablas.Count == 0) if (config.Tablas.Count == 0)
@@ -78,26 +78,27 @@ namespace ServerExplorer
} }
// Recorrer items marcando los que estan en la configuracion // Recorrer items marcando los que estan en la configuracion
n=config.Tablas.Count; n = config.Tablas.Count;
i=j=0; i = j = 0;
foreach (ListViewItem item in lsvTablas.Items) foreach (ListViewItem item in lsvTablas.Items)
{ {
item.Checked = false; item.Checked = false;
String tablename = String tablename =
item.SubItems[1].Text + // Esquema item.SubItems[1].Text + // Esquema
item.SubItems[0].Text; // Nombre tabla item.SubItems[0].Text; // Nombre tabla
do{ do
if( config.Tablas[i].Esquema. {
if (config.Tablas[i].Esquema.
CompareTo(item.SubItems[1].Text) == 0 && CompareTo(item.SubItems[1].Text) == 0 &&
config.Tablas[i].Nombre. config.Tablas[i].Nombre.
CompareTo(item.SubItems[0].Text) == 0) CompareTo(item.SubItems[0].Text) == 0)
{ {
item.Checked=true; item.Checked = true;
break; break;
} }
i=(i+1)%n; i = (i + 1) % n;
}while(i!=j); } while (i != j);
j=i; j = i;
} }
} }
@@ -114,7 +115,7 @@ namespace ServerExplorer
return (db); return (db);
} }
public frmBaseDatos(String ConString) public FrmBaseDatos(String ConString)
{ {
InitializeComponent(); InitializeComponent();
@@ -123,7 +124,7 @@ namespace ServerExplorer
config.ConString = ConString; config.ConString = ConString;
} }
public frmBaseDatos(Config config) public FrmBaseDatos(Config config)
{ {
InitializeComponent(); InitializeComponent();
@@ -156,11 +157,11 @@ namespace ServerExplorer
ListViewItem item = lsvTablas.SelectedItems[0]; ListViewItem item = lsvTablas.SelectedItems[0];
// Recordar tabla seleccionada // Recordar tabla seleccionada
table_schema=item.SubItems[1].Text.ToString(); table_schema = item.SubItems[1].Text.ToString();
table_name = item.SubItems[0].Text.ToString(); table_name = item.SubItems[0].Text.ToString();
// Establecer titulo de la lista de columnas // Establecer titulo de la lista de columnas
lblTituloTabla.Text=table_schema+"."+table_name; lblTituloTabla.Text = table_schema + "." + table_name;
// Obtener descripcion de tabla // Obtener descripcion de tabla
TablaDesc td = new TablaDesc(); TablaDesc td = new TablaDesc();
@@ -172,7 +173,7 @@ namespace ServerExplorer
{ {
ListViewItem subitem = lsvColumnas.Items.Add(col.Nombre); ListViewItem subitem = lsvColumnas.Items.Add(col.Nombre);
subitem.SubItems.Add(col.Tipo); subitem.SubItems.Add(col.Tipo);
if (col.Tamanho>=0) if (col.Tamanho >= 0)
{ {
subitem.SubItems.Add(String.Format("{0}", col.Tamanho)); subitem.SubItems.Add(String.Format("{0}", col.Tamanho));
} }
@@ -215,11 +216,10 @@ namespace ServerExplorer
private void menuConfiguracion_Click(object sender, EventArgs e) private void menuConfiguracion_Click(object sender, EventArgs e)
{ {
// Llamar a la ventana de configuracion // Llamar a la ventana de configuracion
frmCodeGenConfig frm = new frmCodeGenConfig(config); FrmCodeGenConfig frm = new FrmCodeGenConfig(config);
frm.ShowDialog(); frm.ShowDialog();
} }
private void btnVerDatos_Click(object sender, EventArgs e) private void btnVerDatos_Click(object sender, EventArgs e)
{ {
String nombreTabla; String nombreTabla;
@@ -228,7 +228,7 @@ namespace ServerExplorer
if (table_schema == null || table_name == null) { return; } 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. // Obtener un datatable con todos los registros de la tabla.
da = new SqlDataAdapter( da = new SqlDataAdapter(
@@ -240,7 +240,7 @@ namespace ServerExplorer
cnx.Close(); cnx.Close();
// Crear y mostrar el formulario de los datos. // Crear y mostrar el formulario de los datos.
frmDatos form = new frmDatos(dt, nombreTabla); FrmDatos form = new FrmDatos(dt, nombreTabla);
form.MdiParent = this.MdiParent; form.MdiParent = this.MdiParent;
form.Show(); form.Show();
@@ -267,7 +267,7 @@ namespace ServerExplorer
form.Show();*/ form.Show();*/
// Crear y mostrar el formulario de los procedimientos. // Crear y mostrar el formulario de los procedimientos.
frmProcedimientos form = new frmProcedimientos(config.ConString); FrmProcedimientos form = new FrmProcedimientos(config.ConString);
form.MdiParent = this.MdiParent; form.MdiParent = this.MdiParent;
form.Show(); form.Show();
} }
@@ -275,7 +275,7 @@ namespace ServerExplorer
private void btnExec_Click(object sender, EventArgs e) private void btnExec_Click(object sender, EventArgs e)
{ {
// Crear y mostrar el formulario de exec. // Crear y mostrar el formulario de exec.
frmExec form = new frmExec(config.ConString); FrmExec form = new FrmExec(config.ConString);
form.MdiParent = this.MdiParent; form.MdiParent = this.MdiParent;
form.Show(); form.Show();
} }
@@ -285,6 +285,7 @@ namespace ServerExplorer
{ {
} }
private void btnGenerar_Click(object sender, EventArgs e) private void btnGenerar_Click(object sender, EventArgs e)
{ {
tablas_delistview(); tablas_delistview();
@@ -317,6 +318,7 @@ namespace ServerExplorer
hilo.Start(); hilo.Start();
*/ */
} }
public void GenerarDoc() public void GenerarDoc()
{ {
// Hacer insensible la ventana // Hacer insensible la ventana
@@ -336,6 +338,5 @@ namespace ServerExplorer
{ {
} }
} }
} }

View File

@@ -1,6 +1,6 @@
namespace ServerExplorer namespace ServerExplorer
{ {
partial class frmCodeGenConfig partial class FrmCodeGenConfig
{ {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
@@ -275,7 +275,7 @@
this.Controls.Add(this.lblConString); this.Controls.Add(this.lblConString);
this.Name = "frmCodeGenConfig"; this.Name = "frmCodeGenConfig";
this.Text = "Configuracion del Generador de Codigo"; this.Text = "Configuracion del Generador de Codigo";
this.Load += new System.EventHandler(this.frmCodeGenConfig_Load); this.Load += new System.EventHandler(this.FrmCodeGenConfig_Load);
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();

View File

@@ -9,26 +9,26 @@ using System.Windows.Forms;
namespace ServerExplorer namespace ServerExplorer
{ {
public partial class frmCodeGenConfig : Form public partial class FrmCodeGenConfig : Form
{ {
Config config; Config _config;
public frmCodeGenConfig(Config config) public FrmCodeGenConfig(Config config)
{ {
InitializeComponent(); InitializeComponent();
this.config = config; _config = config;
} }
private void frmCodeGenConfig_Load(object sender, EventArgs e) private void FrmCodeGenConfig_Load(object sender, EventArgs e)
{ {
txtConString.Text = config.ConString; txtConString.Text = _config.ConString;
txtPathRaiz.Text = config.PathRaiz; txtPathRaiz.Text = _config.PathRaiz;
txtPathDAL.Text = config.PathDAL; txtPathDAL.Text = _config.PathDAL;
txtPathDTO.Text = config.PathDTO; txtPathDTO.Text = _config.PathDTO;
txtPathExtra.Text = config.PathExtra; txtPathExtra.Text = _config.PathExtra;
txtNSDAL.Text = config.NamespaceDAL; txtNSDAL.Text = _config.NamespaceDAL;
txtNSDTO.Text = config.NamespaceDTO; txtNSDTO.Text = _config.NamespaceDTO;
} }
private void btnPathRaiz_Click(object sender, EventArgs e) private void btnPathRaiz_Click(object sender, EventArgs e)
@@ -73,12 +73,12 @@ namespace ServerExplorer
private void btnAceptar_Click(object sender, EventArgs e) private void btnAceptar_Click(object sender, EventArgs e)
{ {
config.PathRaiz = txtPathRaiz.Text; _config.PathRaiz = txtPathRaiz.Text;
config.PathDAL = txtPathDAL.Text; _config.PathDAL = txtPathDAL.Text;
config.PathDTO = txtPathDTO.Text; _config.PathDTO = txtPathDTO.Text;
config.PathExtra = txtPathExtra.Text; _config.PathExtra = txtPathExtra.Text;
config.NamespaceDAL = txtNSDAL.Text; _config.NamespaceDAL = txtNSDAL.Text;
config.NamespaceDTO = txtNSDTO.Text; _config.NamespaceDTO = txtNSDTO.Text;
this.Close(); this.Close();
} }

View File

@@ -1,6 +1,6 @@
namespace ServerExplorer namespace ServerExplorer
{ {
partial class frmDatos partial class FrmDatos
{ {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.

View File

@@ -9,24 +9,18 @@ using System.Windows.Forms;
namespace ServerExplorer namespace ServerExplorer
{ {
public partial class frmDatos : Form public partial class FrmDatos : Form
{ {
public frmDatos(DataTable dt,String titulo) public FrmDatos(DataTable dt, String titulo)
{ {
InitializeComponent(); InitializeComponent();
this.Text = titulo; Text = titulo;
dgvDatos.DataSource = dt; dgvDatos.DataSource = dt;
} }
private void frmDatos_Load(object sender, EventArgs e) private void frmDatos_Load(object sender, EventArgs e) { }
{
} private void dgvDatos_CellContentClick(object sender, DataGridViewCellEventArgs e) { }
private void dgvDatos_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
} }
} }

View File

@@ -1,6 +1,6 @@
namespace ServerExplorer namespace ServerExplorer
{ {
partial class frmExec partial class FrmExec
{ {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.

View File

@@ -11,19 +11,20 @@ using System.Globalization;
namespace ServerExplorer namespace ServerExplorer
{ {
public partial class frmExec : Form public partial class FrmExec : Form
{ {
private string cnxString; private string cnxString;
public frmExec(string cnxString) public FrmExec(string cnxString)
{ {
InitializeComponent(); InitializeComponent();
this.cnxString = cnxString; this.cnxString = cnxString;
} }
private void frmExec_Load(object sender, EventArgs e){ private void frmExec_Load(object sender, EventArgs e)
{
} }
@@ -57,7 +58,7 @@ namespace ServerExplorer
// Mostrar resultados // Mostrar resultados
dgvDatos.DataSource = dt; dgvDatos.DataSource = dt;
} }
catch(Exception ex) catch (Exception ex)
{ {
MessageBox.Show(ex.Message); MessageBox.Show(ex.Message);
} }
@@ -65,7 +66,7 @@ namespace ServerExplorer
private void btnGenInserts_Click(object sender, EventArgs e) private void btnGenInserts_Click(object sender, EventArgs e)
{ {
DataTable dt=new DataTable(); DataTable dt = new DataTable();
DataTable ddt; DataTable ddt;
string destname = String.Empty; string destname = String.Empty;
NumberFormatInfo nfi = new NumberFormatInfo(); NumberFormatInfo nfi = new NumberFormatInfo();
@@ -82,53 +83,54 @@ namespace ServerExplorer
// Ejecutar consulta // Ejecutar consulta
dt = Exec(); dt = Exec();
} }
catch(Exception ex) catch (Exception ex)
{ {
MessageBox.Show(ex.Message); MessageBox.Show(ex.Message);
} }
// Preparar la datatable destino // Preparar la datatable destino
ddt=new DataTable(); ddt = new DataTable();
ddt.Columns.Add("Comando", typeof(String)); ddt.Columns.Add("Comando", typeof(String));
// Recorrer la tabla de datos // Recorrer la tabla de datos
foreach (DataRow dr in dt.Rows) foreach (DataRow dr in dt.Rows)
{ {
string strColumns=String.Empty; string strColumns = String.Empty;
string strValues=String.Empty; string strValues = String.Empty;
foreach (DataColumn dc in dt.Columns) foreach (DataColumn dc in dt.Columns)
{ {
// El nombre de la columna // El nombre de la columna
if (strColumns != String.Empty) if (strColumns != String.Empty)
strColumns+=", "; strColumns += ", ";
strColumns += "[" + dc.ColumnName + "]"; strColumns += "[" + dc.ColumnName + "]";
// El valor de la columna // El valor de la columna
if (strValues != String.Empty) if (strValues != String.Empty)
strValues+=", "; strValues += ", ";
object valor = dr[dc]; object valor = dr[dc];
if (valor == DBNull.Value) if (valor == DBNull.Value)
{ {
// NULOS // NULOS
strValues += "NULL"; strValues += "NULL";
}else
if (dc.DataType.Name.ToLower() == "string")
{
// Cadenas
strValues += "'" + ((string)valor).Replace("'", "''") + "'";
} }
else else
if (dc.DataType.Name.ToLower() == "decimal") if (dc.DataType.Name.ToLower() == "string")
{ {
// Decimales // Cadenas
strValues += ((decimal)valor).ToString(nfi); strValues += "'" + ((string)valor).Replace("'", "''") + "'";
} }
else else
{ if (dc.DataType.Name.ToLower() == "decimal")
// Otros {
strValues += valor.ToString(); // Decimales
} strValues += ((decimal)valor).ToString(nfi);
}
else
{
// Otros
strValues += valor.ToString();
}
} }
// Insertar fila a la datatable destino // Insertar fila a la datatable destino

View File

@@ -1,6 +1,6 @@
namespace ServerExplorer namespace ServerExplorer
{ {
partial class frmPrincipal partial class FrmPrincipal
{ {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.

View File

@@ -9,9 +9,9 @@ using System.Windows.Forms;
namespace ServerExplorer namespace ServerExplorer
{ {
public partial class frmPrincipal : Form public partial class FrmPrincipal : Form
{ {
public frmPrincipal() public FrmPrincipal()
{ {
InitializeComponent(); InitializeComponent();
} }
@@ -19,7 +19,7 @@ namespace ServerExplorer
private void menuConectarPRUEBAS_Click(object sender, EventArgs e) private void menuConectarPRUEBAS_Click(object sender, EventArgs e)
{ {
// Crear ventana de la base de datos de pruebas // 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=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=DANTE;Initial Catalog=BD_AlfonsoRodriguez;Integrated Security=True");
//frmBaseDatos frm = new frmBaseDatos("Data Source=OSKURITO;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.MdiParent = this;
@@ -30,7 +30,7 @@ namespace ServerExplorer
private void menuBuscarServidor_Click(object sender, EventArgs e) private void menuBuscarServidor_Click(object sender, EventArgs e)
{ {
// Mostrar ventana de buscador de servidores // Mostrar ventana de buscador de servidores
frmServidores frm = new frmServidores(); FrmServidores frm = new FrmServidores();
frm.MdiParent = this; frm.MdiParent = this;
frm.Show(); frm.Show();
} }
@@ -44,7 +44,7 @@ namespace ServerExplorer
Config config = Config.Cargar(dialogo.FileName); Config config = Config.Cargar(dialogo.FileName);
// Crear y mostrar ventana // Crear y mostrar ventana
frmBaseDatos frm = new frmBaseDatos(config); FrmBaseDatos frm = new FrmBaseDatos(config);
frm.MdiParent = this; frm.MdiParent = this;
frm.WindowState = FormWindowState.Maximized; frm.WindowState = FormWindowState.Maximized;
frm.Show(); frm.Show();

View File

@@ -1,6 +1,6 @@
namespace ServerExplorer namespace ServerExplorer
{ {
partial class frmProcedimientos partial class FrmProcedimientos
{ {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.

View File

@@ -11,12 +11,12 @@ using System.Data.SqlClient;
namespace ServerExplorer namespace ServerExplorer
{ {
public partial class frmProcedimientos : Form public partial class FrmProcedimientos : Form
{ {
private string cnxString; private string cnxString;
private SqlConnection cnx; private SqlConnection cnx;
public frmProcedimientos(string cnxString) public FrmProcedimientos(string cnxString)
{ {
InitializeComponent(); InitializeComponent();
@@ -35,7 +35,7 @@ namespace ServerExplorer
// Obtener un datatable con todos los procedimientos de la base de datos. // Obtener un datatable con todos los procedimientos de la base de datos.
da = new SqlDataAdapter( da = new SqlDataAdapter(
"SELECT id,name,crdate,type FROM sysobjects "+ "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 " + "WHERE (UPPER(type) = 'P' OR UPPER(type) = 'TF' OR UPPER(type) = 'TR' OR UPPER(type) = 'V') AND category = 0 " +
"ORDER BY name ", "ORDER BY name ",
cnx); cnx);
@@ -79,11 +79,11 @@ namespace ServerExplorer
private void lsvProcs_SelectedIndexChanged(object sender, EventArgs e) private void lsvProcs_SelectedIndexChanged(object sender, EventArgs e)
{ {
if (lsvProcs.SelectedItems.Count>0 ) if (lsvProcs.SelectedItems.Count > 0)
{ {
DataTable dt; DataTable dt;
SqlDataAdapter da; SqlDataAdapter da;
int id=(int)lsvProcs.SelectedItems[0].Tag; int id = (int)lsvProcs.SelectedItems[0].Tag;
// Obtener un datatable con el contenido del procedimiento. // Obtener un datatable con el contenido del procedimiento.
da = new SqlDataAdapter( da = new SqlDataAdapter(
@@ -99,7 +99,7 @@ namespace ServerExplorer
txtProc.Text = String.Empty; txtProc.Text = String.Empty;
foreach (DataRow dr in dt.Rows) foreach (DataRow dr in dt.Rows)
{ {
txtProc.Text += ((string)dr[0]).Replace("\r","").Replace("\n","\r\n"); txtProc.Text += ((string)dr[0]).Replace("\r", "").Replace("\n", "\r\n");
} }
} }

View File

@@ -1,6 +1,6 @@
namespace ServerExplorer namespace ServerExplorer
{ {
partial class frmServidores partial class FrmServidores
{ {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.

View File

@@ -12,9 +12,9 @@ using System.Data.SqlTypes;
namespace ServerExplorer namespace ServerExplorer
{ {
public partial class frmServidores : Form public partial class FrmServidores : Form
{ {
public frmServidores() public FrmServidores()
{ {
InitializeComponent(); InitializeComponent();
} }
@@ -62,7 +62,7 @@ namespace ServerExplorer
if (lsvServidores.SelectedItems.Count > 0) if (lsvServidores.SelectedItems.Count > 0)
{ {
ListViewItem item = lsvServidores.SelectedItems[0]; ListViewItem item = lsvServidores.SelectedItems[0];
if (item.SubItems[1].Text.CompareTo("")==0) if (item.SubItems[1].Text.CompareTo("") == 0)
{ {
// Servidor sin subinstancias // Servidor sin subinstancias
txtServidor.Text = item.SubItems[0].Text; txtServidor.Text = item.SubItems[0].Text;
@@ -70,7 +70,7 @@ namespace ServerExplorer
else else
{ {
// Servidor con subinstancias // Servidor con subinstancias
txtServidor.Text = item.SubItems[0].Text+"/"+item.SubItems[1].Text; txtServidor.Text = item.SubItems[0].Text + "/" + item.SubItems[1].Text;
} }
} }
} }
@@ -127,7 +127,7 @@ namespace ServerExplorer
} }
// Llamar a la venta de la base de datos // Llamar a la venta de la base de datos
frmBaseDatos frm = new frmBaseDatos(constructor.ConnectionString); FrmBaseDatos frm = new FrmBaseDatos(constructor.ConnectionString);
frm.MdiParent = this.MdiParent; frm.MdiParent = this.MdiParent;
frm.Show(); frm.Show();
} }