Limpieza de codigo
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user