Limpieza de codigo
This commit is contained in:
@@ -4,18 +4,18 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
namespace ServerExplorer
|
||||
namespace ServerExplorer.Code
|
||||
{
|
||||
public static class Utiles
|
||||
{
|
||||
public static void CrearDirectorio(this String path)
|
||||
{
|
||||
DirectoryInfo info=null;
|
||||
DirectoryInfo info = null;
|
||||
try
|
||||
{
|
||||
info = new DirectoryInfo(path);
|
||||
}
|
||||
catch (Exception )
|
||||
catch (Exception)
|
||||
{
|
||||
info = new DirectoryInfo(".");
|
||||
}
|
||||
@@ -4,12 +4,14 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using System.Data;
|
||||
using ServerExplorer.Code;
|
||||
|
||||
namespace ServerExplorer
|
||||
{
|
||||
public class CodeGen
|
||||
{
|
||||
private static string FixNombre(string strIn){
|
||||
private static string FixNombre(string strIn)
|
||||
{
|
||||
return strIn.Replace(' ', '_');
|
||||
}
|
||||
|
||||
@@ -147,7 +149,7 @@ namespace ServerExplorer
|
||||
{
|
||||
TipoCol tipo = c.GetTipo();
|
||||
|
||||
if(tipo==TipoCol.Otro)
|
||||
if (tipo == TipoCol.Otro)
|
||||
continue;
|
||||
|
||||
if (strInsert1 == String.Empty)
|
||||
@@ -186,7 +188,7 @@ namespace ServerExplorer
|
||||
private static void GenerarDALActualizar(Config config, TablaDesc t, EscritorCodigo escritor)
|
||||
{
|
||||
string nombreObj = FixNombre(t.Esquema) + "_" + FixNombre(t.Nombre);
|
||||
string strActualizar,strFiltroPrimario;
|
||||
string strActualizar, strFiltroPrimario;
|
||||
|
||||
// Cabecera y variables del metodo
|
||||
escritor.EscribeInd("public bool Actualizar(" + nombreObj + " reg)");
|
||||
@@ -299,13 +301,13 @@ namespace ServerExplorer
|
||||
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
|
||||
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); }
|
||||
if (!Directory.Exists(config.PathRaiz)) { Utiles.CrearDirectorio(config.PathRaiz); }
|
||||
if (!Directory.Exists(config.PathDTO)) { Utiles.CrearDirectorio(config.PathDTO); }
|
||||
if (!Directory.Exists(config.PathDAL)) { Utiles.CrearDirectorio(config.PathDAL); }
|
||||
if (!Directory.Exists(config.PathExtra)) { Utiles.CrearDirectorio(config.PathExtra); }
|
||||
|
||||
// Itera por cada tabla para crear sus DTO y DAL
|
||||
foreach (TablaDesc t in database.Tablas)
|
||||
@@ -337,7 +339,7 @@ namespace ServerExplorer
|
||||
public string Str()
|
||||
{
|
||||
sb.Remove(0, sb.Length);
|
||||
for (int i=0; i < indentado; i++)
|
||||
for (int i = 0; i < indentado; i++)
|
||||
{
|
||||
sb.Append("\t");
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace ServerExplorer
|
||||
get { return pathRaiz; }
|
||||
set { pathRaiz = value; }
|
||||
}
|
||||
public String pathDAL=".";
|
||||
public String pathDAL = ".";
|
||||
public String PathDAL
|
||||
{
|
||||
get
|
||||
@@ -33,7 +33,8 @@ namespace ServerExplorer
|
||||
public String pathDTO = ".";
|
||||
public String PathDTO
|
||||
{
|
||||
get {
|
||||
get
|
||||
{
|
||||
if (pathDTO == ".")
|
||||
{
|
||||
return pathRaiz;
|
||||
@@ -48,7 +49,8 @@ namespace ServerExplorer
|
||||
public String pathExtra = ".";
|
||||
public String PathExtra
|
||||
{
|
||||
get {
|
||||
get
|
||||
{
|
||||
if (pathExtra == ".")
|
||||
{
|
||||
return pathRaiz;
|
||||
@@ -82,13 +84,13 @@ namespace ServerExplorer
|
||||
lector.Close();
|
||||
return config;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class TablaInfo
|
||||
{
|
||||
public String Esquema="";
|
||||
public String Nombre="";
|
||||
public String Esquema = "";
|
||||
public String Nombre = "";
|
||||
|
||||
public TablaInfo() { }
|
||||
public TablaInfo(String esquema, String nombre)
|
||||
@@ -97,5 +99,4 @@ namespace ServerExplorer
|
||||
Nombre = nombre;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,5 @@ namespace ServerExplorer
|
||||
{
|
||||
Nombre = nombre;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using ServerExplorer.Code;
|
||||
|
||||
namespace ServerExplorer
|
||||
{
|
||||
@@ -11,15 +12,13 @@ namespace ServerExplorer
|
||||
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); }
|
||||
|
||||
if (!Directory.Exists(config.PathRaiz)) { Utiles.CrearDirectorio(config.PathRaiz); }
|
||||
if (!Directory.Exists(config.PathDTO)) { Utiles.CrearDirectorio(config.PathDTO); }
|
||||
if (!Directory.Exists(config.PathDAL)) { Utiles.CrearDirectorio(config.PathDAL); }
|
||||
if (!Directory.Exists(config.PathExtra)) { Utiles.CrearDirectorio(config.PathExtra); }
|
||||
|
||||
// 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
|
||||
escritor.WriteLine("<html><head><title>" + database.Nombre + "</title></head>");
|
||||
@@ -29,8 +28,8 @@ namespace ServerExplorer
|
||||
foreach (TablaDesc t in database.Tablas)
|
||||
{
|
||||
// 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
|
||||
escritor.WriteLine("<table>");
|
||||
escritor.WriteLine("<thead><tr><th>Nombre</th><th>Tipo</th><th>Tamaño</th><th>Primaria</th></tr></thead>");
|
||||
@@ -46,11 +45,9 @@ namespace ServerExplorer
|
||||
escritor.WriteLine("</tbody></table>");
|
||||
}
|
||||
|
||||
|
||||
// Poner pie y cerrar fichero
|
||||
escritor.WriteLine("</body></html>");
|
||||
escritor.Close();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace ServerExplorer
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new frmPrincipal());
|
||||
Application.Run(new FrmPrincipal());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,72 +73,72 @@
|
||||
<Compile Include="Config.cs" />
|
||||
<Compile Include="DatabaseDesc.cs" />
|
||||
<Compile Include="DocGen.cs" />
|
||||
<Compile Include="frmBaseDatos.cs">
|
||||
<Compile Include="FrmBaseDatos.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="frmBaseDatos.Designer.cs">
|
||||
<DependentUpon>frmBaseDatos.cs</DependentUpon>
|
||||
<Compile Include="FrmBaseDatos.Designer.cs">
|
||||
<DependentUpon>FrmBaseDatos.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="frmCodeGenConfig.cs">
|
||||
<Compile Include="FrmCodeGenConfig.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="frmCodeGenConfig.Designer.cs">
|
||||
<DependentUpon>frmCodeGenConfig.cs</DependentUpon>
|
||||
<Compile Include="FrmCodeGenConfig.Designer.cs">
|
||||
<DependentUpon>FrmCodeGenConfig.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="frmDatos.cs">
|
||||
<Compile Include="FrmDatos.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="frmDatos.Designer.cs">
|
||||
<DependentUpon>frmDatos.cs</DependentUpon>
|
||||
<Compile Include="FrmDatos.Designer.cs">
|
||||
<DependentUpon>FrmDatos.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="frmExec.cs">
|
||||
<Compile Include="FrmExec.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="frmExec.Designer.cs">
|
||||
<DependentUpon>frmExec.cs</DependentUpon>
|
||||
<Compile Include="FrmExec.Designer.cs">
|
||||
<DependentUpon>FrmExec.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="frmPrincipal.cs">
|
||||
<Compile Include="FrmPrincipal.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="frmPrincipal.Designer.cs">
|
||||
<DependentUpon>frmPrincipal.cs</DependentUpon>
|
||||
<Compile Include="FrmPrincipal.Designer.cs">
|
||||
<DependentUpon>FrmPrincipal.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="frmProcedimientos.cs">
|
||||
<Compile Include="FrmProcedimientos.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="frmProcedimientos.Designer.cs">
|
||||
<DependentUpon>frmProcedimientos.cs</DependentUpon>
|
||||
<Compile Include="FrmProcedimientos.Designer.cs">
|
||||
<DependentUpon>FrmProcedimientos.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="frmServidores.cs">
|
||||
<Compile Include="FrmServidores.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="frmServidores.Designer.cs">
|
||||
<DependentUpon>frmServidores.cs</DependentUpon>
|
||||
<Compile Include="FrmServidores.Designer.cs">
|
||||
<DependentUpon>FrmServidores.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="TablaDesc.cs" />
|
||||
<Compile Include="Utiles.cs" />
|
||||
<EmbeddedResource Include="frmBaseDatos.resx">
|
||||
<DependentUpon>frmBaseDatos.cs</DependentUpon>
|
||||
<Compile Include="Code\Utiles.cs" />
|
||||
<EmbeddedResource Include="FrmBaseDatos.resx">
|
||||
<DependentUpon>FrmBaseDatos.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="frmCodeGenConfig.resx">
|
||||
<DependentUpon>frmCodeGenConfig.cs</DependentUpon>
|
||||
<EmbeddedResource Include="FrmCodeGenConfig.resx">
|
||||
<DependentUpon>FrmCodeGenConfig.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="frmDatos.resx">
|
||||
<DependentUpon>frmDatos.cs</DependentUpon>
|
||||
<EmbeddedResource Include="FrmDatos.resx">
|
||||
<DependentUpon>FrmDatos.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="frmExec.resx">
|
||||
<DependentUpon>frmExec.cs</DependentUpon>
|
||||
<EmbeddedResource Include="FrmExec.resx">
|
||||
<DependentUpon>FrmExec.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="frmPrincipal.resx">
|
||||
<DependentUpon>frmPrincipal.cs</DependentUpon>
|
||||
<EmbeddedResource Include="FrmPrincipal.resx">
|
||||
<DependentUpon>FrmPrincipal.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="frmProcedimientos.resx">
|
||||
<DependentUpon>frmProcedimientos.cs</DependentUpon>
|
||||
<EmbeddedResource Include="FrmProcedimientos.resx">
|
||||
<DependentUpon>FrmProcedimientos.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="frmServidores.resx">
|
||||
<DependentUpon>frmServidores.cs</DependentUpon>
|
||||
<EmbeddedResource Include="FrmServidores.resx">
|
||||
<DependentUpon>FrmServidores.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
@@ -177,6 +177,7 @@
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- 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.
|
||||
@@ -185,4 +186,4 @@
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
</Project>
|
||||
@@ -10,8 +10,8 @@ namespace ServerExplorer
|
||||
{
|
||||
public class TablaDesc
|
||||
{
|
||||
public String Esquema="";
|
||||
public String Nombre="";
|
||||
public String Esquema = String.Empty;
|
||||
public String Nombre = String.Empty;
|
||||
public List<ColumnaDesc> Columnas = new List<ColumnaDesc>();
|
||||
|
||||
public TablaDesc() { }
|
||||
@@ -56,11 +56,11 @@ namespace ServerExplorer
|
||||
" col.TABLE_SCHEMA=@nombreEsquema " +
|
||||
" order by col.ORDINAL_POSITION",
|
||||
cnx);
|
||||
prm=new SqlParameter("@nombreTabla",SqlDbType.VarChar,100);
|
||||
prm.Value=nombre;
|
||||
prm = new SqlParameter("@nombreTabla", SqlDbType.VarChar, 100);
|
||||
prm.Value = nombre;
|
||||
da.SelectCommand.Parameters.Add(prm);
|
||||
prm=new SqlParameter("@nombreEsquema",SqlDbType.VarChar,100);
|
||||
prm.Value=esquema;
|
||||
prm = new SqlParameter("@nombreEsquema", SqlDbType.VarChar, 100);
|
||||
prm.Value = esquema;
|
||||
da.SelectCommand.Parameters.Add(prm);
|
||||
|
||||
// Obtener datatable con las columnas
|
||||
@@ -76,8 +76,8 @@ namespace ServerExplorer
|
||||
ColumnaDesc col;
|
||||
|
||||
// Obtener columna
|
||||
col=GetCol((String)dr["Columna"]);
|
||||
if (col==null)
|
||||
col = GetCol((String)dr["Columna"]);
|
||||
if (col == null)
|
||||
{
|
||||
col = new ColumnaDesc();
|
||||
Columnas.Add(col);
|
||||
@@ -115,8 +115,8 @@ namespace ServerExplorer
|
||||
|
||||
public class ColumnaDesc
|
||||
{
|
||||
public string Nombre = "";
|
||||
public string Tipo = "";
|
||||
public string Nombre = String.Empty;
|
||||
public string Tipo = String.Empty;
|
||||
public int Tamanho = -1;
|
||||
public bool Primaria = false;
|
||||
|
||||
@@ -125,7 +125,7 @@ namespace ServerExplorer
|
||||
private TipoCol tipo = TipoCol.Unset;
|
||||
public TipoCol GetTipo()
|
||||
{
|
||||
string stipo=Tipo.ToLower();
|
||||
string stipo = Tipo.ToLower();
|
||||
|
||||
if (this.tipo != TipoCol.Unset)
|
||||
{
|
||||
@@ -133,12 +133,12 @@ namespace ServerExplorer
|
||||
}
|
||||
|
||||
// Numericos
|
||||
if(
|
||||
stipo=="bigint" ||
|
||||
stipo=="int" ||
|
||||
stipo=="smallint" ||
|
||||
stipo=="tinyint" ||
|
||||
stipo=="bigint"
|
||||
if (
|
||||
stipo == "bigint" ||
|
||||
stipo == "int" ||
|
||||
stipo == "smallint" ||
|
||||
stipo == "tinyint" ||
|
||||
stipo == "bigint"
|
||||
)
|
||||
{
|
||||
return TipoCol.Numerico;
|
||||
@@ -147,7 +147,7 @@ namespace ServerExplorer
|
||||
// Aproximados numericos
|
||||
if (
|
||||
stipo == "float" ||
|
||||
stipo == "real"
|
||||
stipo == "real"
|
||||
)
|
||||
{
|
||||
return TipoCol.AproxNumerico;
|
||||
@@ -173,7 +173,7 @@ namespace ServerExplorer
|
||||
stipo == "text" ||
|
||||
stipo == "nchar" ||
|
||||
stipo == "nvarchar" ||
|
||||
stipo == "ntext"
|
||||
stipo == "ntext"
|
||||
)
|
||||
{
|
||||
return TipoCol.Texto;
|
||||
@@ -183,7 +183,7 @@ namespace ServerExplorer
|
||||
if (
|
||||
stipo == "binary" ||
|
||||
stipo == "varbinary" ||
|
||||
stipo == "image"
|
||||
stipo == "image"
|
||||
)
|
||||
{
|
||||
return TipoCol.Binario;
|
||||
@@ -191,7 +191,7 @@ namespace ServerExplorer
|
||||
|
||||
// Booleano
|
||||
if (
|
||||
stipo == "bit"
|
||||
stipo == "bit"
|
||||
)
|
||||
{
|
||||
return TipoCol.Booleano;
|
||||
|
||||
2
ServerExplorer/frmBaseDatos.Designer.cs
generated
2
ServerExplorer/frmBaseDatos.Designer.cs
generated
@@ -1,6 +1,6 @@
|
||||
namespace ServerExplorer
|
||||
{
|
||||
partial class frmBaseDatos
|
||||
partial class FrmBaseDatos
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
|
||||
@@ -13,9 +13,9 @@ using System.Threading;
|
||||
|
||||
namespace ServerExplorer
|
||||
{
|
||||
public partial class frmBaseDatos : Form
|
||||
public partial class FrmBaseDatos : Form
|
||||
{
|
||||
private frmBaseDatos instancia;
|
||||
private FrmBaseDatos instancia;
|
||||
private SqlConnection cnx;
|
||||
private Config config;
|
||||
private String table_schema = null;
|
||||
@@ -67,7 +67,7 @@ namespace ServerExplorer
|
||||
// en le listview desde la configuracion
|
||||
private void tablas_alistview()
|
||||
{
|
||||
int i,j,n;
|
||||
int i, j, n;
|
||||
|
||||
// Desmarcar todos en caso de no haber ninguna tabla
|
||||
if (config.Tablas.Count == 0)
|
||||
@@ -78,26 +78,27 @@ namespace ServerExplorer
|
||||
}
|
||||
|
||||
// Recorrer items marcando los que estan en la configuracion
|
||||
n=config.Tablas.Count;
|
||||
i=j=0;
|
||||
n = config.Tablas.Count;
|
||||
i = j = 0;
|
||||
foreach (ListViewItem item in lsvTablas.Items)
|
||||
{
|
||||
item.Checked = false;
|
||||
String tablename =
|
||||
item.SubItems[1].Text + // Esquema
|
||||
item.SubItems[0].Text; // Nombre tabla
|
||||
do{
|
||||
if( config.Tablas[i].Esquema.
|
||||
do
|
||||
{
|
||||
if (config.Tablas[i].Esquema.
|
||||
CompareTo(item.SubItems[1].Text) == 0 &&
|
||||
config.Tablas[i].Nombre.
|
||||
CompareTo(item.SubItems[0].Text) == 0)
|
||||
{
|
||||
item.Checked=true;
|
||||
item.Checked = true;
|
||||
break;
|
||||
}
|
||||
i=(i+1)%n;
|
||||
}while(i!=j);
|
||||
j=i;
|
||||
i = (i + 1) % n;
|
||||
} while (i != j);
|
||||
j = i;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,7 +115,7 @@ namespace ServerExplorer
|
||||
return (db);
|
||||
}
|
||||
|
||||
public frmBaseDatos(String ConString)
|
||||
public FrmBaseDatos(String ConString)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
@@ -123,7 +124,7 @@ namespace ServerExplorer
|
||||
config.ConString = ConString;
|
||||
}
|
||||
|
||||
public frmBaseDatos(Config config)
|
||||
public FrmBaseDatos(Config config)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
@@ -156,11 +157,11 @@ namespace ServerExplorer
|
||||
ListViewItem item = lsvTablas.SelectedItems[0];
|
||||
|
||||
// Recordar tabla seleccionada
|
||||
table_schema=item.SubItems[1].Text.ToString();
|
||||
table_schema = item.SubItems[1].Text.ToString();
|
||||
table_name = item.SubItems[0].Text.ToString();
|
||||
|
||||
// Establecer titulo de la lista de columnas
|
||||
lblTituloTabla.Text=table_schema+"."+table_name;
|
||||
lblTituloTabla.Text = table_schema + "." + table_name;
|
||||
|
||||
// Obtener descripcion de tabla
|
||||
TablaDesc td = new TablaDesc();
|
||||
@@ -172,7 +173,7 @@ namespace ServerExplorer
|
||||
{
|
||||
ListViewItem subitem = lsvColumnas.Items.Add(col.Nombre);
|
||||
subitem.SubItems.Add(col.Tipo);
|
||||
if (col.Tamanho>=0)
|
||||
if (col.Tamanho >= 0)
|
||||
{
|
||||
subitem.SubItems.Add(String.Format("{0}", col.Tamanho));
|
||||
}
|
||||
@@ -215,11 +216,10 @@ namespace ServerExplorer
|
||||
private void menuConfiguracion_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Llamar a la ventana de configuracion
|
||||
frmCodeGenConfig frm = new frmCodeGenConfig(config);
|
||||
FrmCodeGenConfig frm = new FrmCodeGenConfig(config);
|
||||
frm.ShowDialog();
|
||||
}
|
||||
|
||||
|
||||
private void btnVerDatos_Click(object sender, EventArgs e)
|
||||
{
|
||||
String nombreTabla;
|
||||
@@ -228,7 +228,7 @@ 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(
|
||||
@@ -240,7 +240,7 @@ namespace ServerExplorer
|
||||
cnx.Close();
|
||||
|
||||
// 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.Show();
|
||||
|
||||
@@ -267,7 +267,7 @@ namespace ServerExplorer
|
||||
form.Show();*/
|
||||
|
||||
// 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.Show();
|
||||
}
|
||||
@@ -275,7 +275,7 @@ namespace ServerExplorer
|
||||
private void btnExec_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Crear y mostrar el formulario de exec.
|
||||
frmExec form = new frmExec(config.ConString);
|
||||
FrmExec form = new FrmExec(config.ConString);
|
||||
form.MdiParent = this.MdiParent;
|
||||
form.Show();
|
||||
}
|
||||
@@ -285,6 +285,7 @@ namespace ServerExplorer
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void btnGenerar_Click(object sender, EventArgs e)
|
||||
{
|
||||
tablas_delistview();
|
||||
@@ -317,6 +318,7 @@ namespace ServerExplorer
|
||||
hilo.Start();
|
||||
*/
|
||||
}
|
||||
|
||||
public void GenerarDoc()
|
||||
{
|
||||
// Hacer insensible la ventana
|
||||
@@ -336,6 +338,5 @@ namespace ServerExplorer
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
4
ServerExplorer/frmCodeGenConfig.Designer.cs
generated
4
ServerExplorer/frmCodeGenConfig.Designer.cs
generated
@@ -1,6 +1,6 @@
|
||||
namespace ServerExplorer
|
||||
{
|
||||
partial class frmCodeGenConfig
|
||||
partial class FrmCodeGenConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
@@ -275,7 +275,7 @@
|
||||
this.Controls.Add(this.lblConString);
|
||||
this.Name = "frmCodeGenConfig";
|
||||
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.PerformLayout();
|
||||
|
||||
|
||||
@@ -9,26 +9,26 @@ using System.Windows.Forms;
|
||||
|
||||
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();
|
||||
|
||||
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;
|
||||
txtPathRaiz.Text = config.PathRaiz;
|
||||
txtPathDAL.Text = config.PathDAL;
|
||||
txtPathDTO.Text = config.PathDTO;
|
||||
txtPathExtra.Text = config.PathExtra;
|
||||
txtNSDAL.Text = config.NamespaceDAL;
|
||||
txtNSDTO.Text = config.NamespaceDTO;
|
||||
txtConString.Text = _config.ConString;
|
||||
txtPathRaiz.Text = _config.PathRaiz;
|
||||
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)
|
||||
@@ -73,12 +73,12 @@ namespace ServerExplorer
|
||||
|
||||
private void btnAceptar_Click(object sender, EventArgs e)
|
||||
{
|
||||
config.PathRaiz = txtPathRaiz.Text;
|
||||
config.PathDAL = txtPathDAL.Text;
|
||||
config.PathDTO = txtPathDTO.Text;
|
||||
config.PathExtra = txtPathExtra.Text;
|
||||
config.NamespaceDAL = txtNSDAL.Text;
|
||||
config.NamespaceDTO = txtNSDTO.Text;
|
||||
_config.PathRaiz = txtPathRaiz.Text;
|
||||
_config.PathDAL = txtPathDAL.Text;
|
||||
_config.PathDTO = txtPathDTO.Text;
|
||||
_config.PathExtra = txtPathExtra.Text;
|
||||
_config.NamespaceDAL = txtNSDAL.Text;
|
||||
_config.NamespaceDTO = txtNSDTO.Text;
|
||||
this.Close();
|
||||
}
|
||||
|
||||
|
||||
2
ServerExplorer/frmDatos.Designer.cs
generated
2
ServerExplorer/frmDatos.Designer.cs
generated
@@ -1,6 +1,6 @@
|
||||
namespace ServerExplorer
|
||||
{
|
||||
partial class frmDatos
|
||||
partial class FrmDatos
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
|
||||
@@ -9,24 +9,18 @@ using System.Windows.Forms;
|
||||
|
||||
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();
|
||||
|
||||
this.Text = titulo;
|
||||
Text = titulo;
|
||||
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) { }
|
||||
}
|
||||
}
|
||||
|
||||
2
ServerExplorer/frmExec.Designer.cs
generated
2
ServerExplorer/frmExec.Designer.cs
generated
@@ -1,6 +1,6 @@
|
||||
namespace ServerExplorer
|
||||
{
|
||||
partial class frmExec
|
||||
partial class FrmExec
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
|
||||
@@ -11,20 +11,21 @@ using System.Globalization;
|
||||
|
||||
namespace ServerExplorer
|
||||
{
|
||||
public partial class frmExec : Form
|
||||
public partial class FrmExec : Form
|
||||
{
|
||||
private string cnxString;
|
||||
|
||||
|
||||
public frmExec(string cnxString)
|
||||
public FrmExec(string cnxString)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
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
|
||||
dgvDatos.DataSource = dt;
|
||||
}
|
||||
catch(Exception ex)
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
@@ -65,11 +66,11 @@ namespace ServerExplorer
|
||||
|
||||
private void btnGenInserts_Click(object sender, EventArgs e)
|
||||
{
|
||||
DataTable dt=new DataTable();
|
||||
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 = ".";
|
||||
|
||||
@@ -82,53 +83,54 @@ namespace ServerExplorer
|
||||
// Ejecutar consulta
|
||||
dt = Exec();
|
||||
}
|
||||
catch(Exception ex)
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
|
||||
// Preparar la datatable destino
|
||||
ddt=new DataTable();
|
||||
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;
|
||||
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 += ", ";
|
||||
strColumns += "[" + dc.ColumnName + "]";
|
||||
|
||||
// El valor de la columna
|
||||
if (strValues != String.Empty)
|
||||
strValues+=", ";
|
||||
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();
|
||||
}
|
||||
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
|
||||
|
||||
2
ServerExplorer/frmPrincipal.Designer.cs
generated
2
ServerExplorer/frmPrincipal.Designer.cs
generated
@@ -1,6 +1,6 @@
|
||||
namespace ServerExplorer
|
||||
{
|
||||
partial class frmPrincipal
|
||||
partial class FrmPrincipal
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
|
||||
@@ -9,9 +9,9 @@ using System.Windows.Forms;
|
||||
|
||||
namespace ServerExplorer
|
||||
{
|
||||
public partial class frmPrincipal : Form
|
||||
public partial class FrmPrincipal : Form
|
||||
{
|
||||
public frmPrincipal()
|
||||
public FrmPrincipal()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
@@ -19,7 +19,7 @@ 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=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;
|
||||
@@ -30,7 +30,7 @@ namespace ServerExplorer
|
||||
private void menuBuscarServidor_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Mostrar ventana de buscador de servidores
|
||||
frmServidores frm = new frmServidores();
|
||||
FrmServidores frm = new FrmServidores();
|
||||
frm.MdiParent = this;
|
||||
frm.Show();
|
||||
}
|
||||
@@ -44,7 +44,7 @@ namespace ServerExplorer
|
||||
Config config = Config.Cargar(dialogo.FileName);
|
||||
|
||||
// Crear y mostrar ventana
|
||||
frmBaseDatos frm = new frmBaseDatos(config);
|
||||
FrmBaseDatos frm = new FrmBaseDatos(config);
|
||||
frm.MdiParent = this;
|
||||
frm.WindowState = FormWindowState.Maximized;
|
||||
frm.Show();
|
||||
|
||||
2
ServerExplorer/frmProcedimientos.Designer.cs
generated
2
ServerExplorer/frmProcedimientos.Designer.cs
generated
@@ -1,6 +1,6 @@
|
||||
namespace ServerExplorer
|
||||
{
|
||||
partial class frmProcedimientos
|
||||
partial class FrmProcedimientos
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
|
||||
@@ -11,12 +11,12 @@ using System.Data.SqlClient;
|
||||
|
||||
namespace ServerExplorer
|
||||
{
|
||||
public partial class frmProcedimientos : Form
|
||||
public partial class FrmProcedimientos : Form
|
||||
{
|
||||
private string cnxString;
|
||||
private SqlConnection cnx;
|
||||
|
||||
public frmProcedimientos(string cnxString)
|
||||
public FrmProcedimientos(string cnxString)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace ServerExplorer
|
||||
|
||||
// Obtener un datatable con todos los procedimientos de la base de datos.
|
||||
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 " +
|
||||
"ORDER BY name ",
|
||||
cnx);
|
||||
@@ -79,11 +79,11 @@ namespace ServerExplorer
|
||||
|
||||
private void lsvProcs_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (lsvProcs.SelectedItems.Count>0 )
|
||||
if (lsvProcs.SelectedItems.Count > 0)
|
||||
{
|
||||
DataTable dt;
|
||||
SqlDataAdapter da;
|
||||
int id=(int)lsvProcs.SelectedItems[0].Tag;
|
||||
int id = (int)lsvProcs.SelectedItems[0].Tag;
|
||||
|
||||
// Obtener un datatable con el contenido del procedimiento.
|
||||
da = new SqlDataAdapter(
|
||||
@@ -99,7 +99,7 @@ namespace ServerExplorer
|
||||
txtProc.Text = String.Empty;
|
||||
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");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
2
ServerExplorer/frmServidores.Designer.cs
generated
2
ServerExplorer/frmServidores.Designer.cs
generated
@@ -1,6 +1,6 @@
|
||||
namespace ServerExplorer
|
||||
{
|
||||
partial class frmServidores
|
||||
partial class FrmServidores
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
|
||||
@@ -12,9 +12,9 @@ using System.Data.SqlTypes;
|
||||
|
||||
namespace ServerExplorer
|
||||
{
|
||||
public partial class frmServidores : Form
|
||||
public partial class FrmServidores : Form
|
||||
{
|
||||
public frmServidores()
|
||||
public FrmServidores()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
@@ -62,7 +62,7 @@ namespace ServerExplorer
|
||||
if (lsvServidores.SelectedItems.Count > 0)
|
||||
{
|
||||
ListViewItem item = lsvServidores.SelectedItems[0];
|
||||
if (item.SubItems[1].Text.CompareTo("")==0)
|
||||
if (item.SubItems[1].Text.CompareTo("") == 0)
|
||||
{
|
||||
// Servidor sin subinstancias
|
||||
txtServidor.Text = item.SubItems[0].Text;
|
||||
@@ -70,7 +70,7 @@ namespace ServerExplorer
|
||||
else
|
||||
{
|
||||
// Servidor con subinstancias
|
||||
txtServidor.Text = item.SubItems[0].Text+"/"+item.SubItems[1].Text;
|
||||
txtServidor.Text = item.SubItems[0].Text + "/" + item.SubItems[1].Text;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -97,7 +97,7 @@ namespace ServerExplorer
|
||||
DataTable dt = cnx.GetSchema("Databases");
|
||||
cnx.Close();
|
||||
|
||||
|
||||
|
||||
// Mostrar bases de datos
|
||||
lsvBBDD.Items.Clear();
|
||||
foreach (DataRow dr in dt.Rows)
|
||||
@@ -127,7 +127,7 @@ namespace ServerExplorer
|
||||
}
|
||||
|
||||
// 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.Show();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user