Refactorings
This commit is contained in:
@@ -4,6 +4,9 @@ using System.Windows.Forms;
|
||||
using System.Data.SqlClient;
|
||||
using System.Xml.Serialization;
|
||||
using ServerExplorer.Code;
|
||||
using System.Collections.Generic;
|
||||
using ServerExplorer.Code.DataTransfer;
|
||||
using ServerExplorer.Code.DataAccess;
|
||||
|
||||
namespace ServerExplorer.UI
|
||||
{
|
||||
@@ -20,22 +23,16 @@ namespace ServerExplorer.UI
|
||||
txtConString.Text = _config.ConnectionString;
|
||||
_cnx = new SqlConnection(_config.ConnectionString);
|
||||
|
||||
// Obtener lista de tablas
|
||||
_cnx.Open();
|
||||
DataTable dt = _cnx.GetSchema("Tables");
|
||||
_cnx.Close();
|
||||
|
||||
// Mostrar todas las tablas
|
||||
List<Table> tables = TableDA.Table_GetRegs(_config.ConnectionString);
|
||||
lsvTablas.Items.Clear();
|
||||
foreach (DataRow dr in dt.Rows)
|
||||
foreach (Table table in tables)
|
||||
{
|
||||
ListViewItem item = lsvTablas.Items.Add((String)dr["TABLE_NAME"]);
|
||||
item.SubItems.Add((String)dr["TABLE_SCHEMA"]);
|
||||
item.SubItems.Add((String)dr["TABLE_TYPE"]);
|
||||
ListViewItem item = lsvTablas.Items.Add(table.Schema);
|
||||
item.SubItems.Add(table.Name);
|
||||
item.SubItems.Add(table.Type);
|
||||
}
|
||||
TablesToListView();
|
||||
|
||||
// Limpiar Columnas
|
||||
TablesToListView();
|
||||
lsvColumnas.Items.Clear();
|
||||
}
|
||||
|
||||
@@ -51,8 +48,8 @@ namespace ServerExplorer.UI
|
||||
{
|
||||
_config.Tablas.Add(new TablaInfo
|
||||
{
|
||||
Esquema = item.SubItems[1].Text,
|
||||
Nombre = item.SubItems[0].Text
|
||||
Esquema = item.SubItems[0].Text,
|
||||
Nombre = item.SubItems[1].Text
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -81,8 +78,8 @@ namespace ServerExplorer.UI
|
||||
item.Checked = false;
|
||||
do
|
||||
{
|
||||
if (String.Compare(_config.Tablas[i].Esquema, item.SubItems[1].Text, StringComparison.Ordinal) == 0 &&
|
||||
String.Compare(_config.Tablas[i].Nombre, item.SubItems[0].Text, StringComparison.Ordinal) == 0)
|
||||
if (String.Compare(_config.Tablas[i].Esquema, item.SubItems[0].Text, StringComparison.Ordinal) == 0 &&
|
||||
String.Compare(_config.Tablas[i].Nombre, item.SubItems[1].Text, StringComparison.Ordinal) == 0)
|
||||
{
|
||||
item.Checked = true;
|
||||
break;
|
||||
@@ -120,8 +117,6 @@ namespace ServerExplorer.UI
|
||||
_config = config;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void frmBaseDatos_Load(object sender, EventArgs e)
|
||||
{
|
||||
Initialize();
|
||||
@@ -145,8 +140,8 @@ namespace ServerExplorer.UI
|
||||
ListViewItem item = lsvTablas.SelectedItems[0];
|
||||
|
||||
// Recordar tabla seleccionada
|
||||
_tableSchema = item.SubItems[1].Text;
|
||||
_tableName = item.SubItems[0].Text;
|
||||
_tableSchema = item.SubItems[0].Text;
|
||||
_tableName = item.SubItems[1].Text;
|
||||
|
||||
// Establecer titulo de la lista de columnas
|
||||
lblTituloTabla.Text = _tableSchema + @"." + _tableName;
|
||||
|
||||
Reference in New Issue
Block a user