Code clean up

This commit is contained in:
2018-10-24 21:28:27 +02:00
parent 4b5ce5b834
commit 4da1292698
27 changed files with 110 additions and 123 deletions

1
.gitignore vendored
View File

@@ -5,3 +5,4 @@
*.user *.user
*/bin/* */bin/*
*/obj/* */obj/*
/.vs/*

View File

@@ -1,5 +1,4 @@
using System; using System.IO;
using System.IO;
using VAR.DatabaseExplorer.Code.DataAccess; using VAR.DatabaseExplorer.Code.DataAccess;
using VAR.DatabaseExplorer.Code.DataTransfer; using VAR.DatabaseExplorer.Code.DataTransfer;
@@ -69,7 +68,7 @@ namespace VAR.DatabaseExplorer.Code.BusinessLogic
// Preparar cabecera del script // Preparar cabecera del script
txtWriter.WriteLine("SET NOCOUNT ON;"); txtWriter.WriteLine("SET NOCOUNT ON;");
txtWriter.WriteLine(string.Empty); txtWriter.WriteLine(string.Empty);
// Desactivar todas las FKs // Desactivar todas las FKs
txtWriter.WriteLine("-- Disable all constraints"); txtWriter.WriteLine("-- Disable all constraints");
txtWriter.WriteLine("EXEC sp_MSforeachtable 'ALTER TABLE ? NOCHECK CONSTRAINT all'"); txtWriter.WriteLine("EXEC sp_MSforeachtable 'ALTER TABLE ? NOCHECK CONSTRAINT all'");
@@ -83,7 +82,7 @@ namespace VAR.DatabaseExplorer.Code.BusinessLogic
txtWriter.WriteLine(string.Format("PRINT '*** Importing data of {0}....';", tableName)); txtWriter.WriteLine(string.Format("PRINT '*** Importing data of {0}....';", tableName));
TableBL.Table_ExportData(txtWriter, connectionString, tableName); TableBL.Table_ExportData(txtWriter, connectionString, tableName);
} }
// Activar todas las FKs // Activar todas las FKs
txtWriter.WriteLine("-- Enable all constraints"); txtWriter.WriteLine("-- Enable all constraints");
txtWriter.WriteLine("EXEC sp_MSforeachtable @command1='print ''?''', @command2='ALTER TABLE ? WITH CHECK CHECK CONSTRAINT all'"); txtWriter.WriteLine("EXEC sp_MSforeachtable @command1='print ''?''', @command2='ALTER TABLE ? WITH CHECK CHECK CONSTRAINT all'");
@@ -91,4 +90,4 @@ namespace VAR.DatabaseExplorer.Code.BusinessLogic
txtWriter.WriteLine(string.Empty); txtWriter.WriteLine(string.Empty);
} }
} }
} }

View File

@@ -18,6 +18,5 @@ namespace VAR.DatabaseExplorer.Code.BusinessLogic
} }
return procedures; return procedures;
} }
} }
} }

View File

@@ -13,7 +13,7 @@ namespace VAR.DatabaseExplorer.Code.BusinessLogic
List<Table> tables = TableDA.GetAllTables(connectionString); List<Table> tables = TableDA.GetAllTables(connectionString);
if (fillColumns) if (fillColumns)
{ {
foreach(Table table in tables) foreach (Table table in tables)
{ {
table.Columns = ColumnDA.GetColumns(connectionString, table.Schema, table.Name); table.Columns = ColumnDA.GetColumns(connectionString, table.Schema, table.Name);
} }
@@ -34,6 +34,5 @@ namespace VAR.DatabaseExplorer.Code.BusinessLogic
txtWriter.WriteLine("GO"); txtWriter.WriteLine("GO");
txtWriter.WriteLine(string.Empty); txtWriter.WriteLine(string.Empty);
} }
} }
} }

View File

@@ -48,7 +48,7 @@ namespace VAR.DatabaseExplorer.Code.DataAccess
{ {
string columnName = Convert.ToString(dr["ColumnName"]); string columnName = Convert.ToString(dr["ColumnName"]);
Column col = columns.FirstOrDefault(c => c.Name == columnName); Column col = columns.FirstOrDefault(c => c.Name == columnName);
if(col == null) if (col == null)
{ {
col = new Column(); col = new Column();
columns.Add(col); columns.Add(col);
@@ -76,4 +76,4 @@ namespace VAR.DatabaseExplorer.Code.DataAccess
return columns; return columns;
} }
} }
} }

View File

@@ -12,7 +12,7 @@ namespace VAR.DatabaseExplorer.Code.DataAccess
{ {
var databases = new List<Database>(); var databases = new List<Database>();
var cnx = new SqlConnection(connectionString); var cnx = new SqlConnection(connectionString);
cnx.Open(); cnx.Open();
DataTable dt = cnx.GetSchema("Databases"); DataTable dt = cnx.GetSchema("Databases");
cnx.Close(); cnx.Close();
@@ -23,22 +23,21 @@ namespace VAR.DatabaseExplorer.Code.DataAccess
{ {
databases.Add(new Database databases.Add(new Database
{ {
Name = (string) dr["database_name"], Name = (string)dr["database_name"],
CreateDate = (DateTime) dr["create_date"] CreateDate = (DateTime)dr["create_date"]
}); });
} }
return databases; return databases;
} }
public static Database GetInfo(string connectionString) public static Database GetInfo(string connectionString)
{ {
var cnx = new SqlConnection(connectionString); var cnx = new SqlConnection(connectionString);
string strCmd = string.Format(@" string strCmd = string.Format(@"
SELECT SELECT
[name] DatabaseName, [name] DatabaseName,
[create_date] CreateDate [create_date] CreateDate
FROM sys.databases FROM sys.databases
WHERE database_id = DB_ID(); WHERE database_id = DB_ID();
"); ");
var da = new SqlDataAdapter(strCmd, cnx); var da = new SqlDataAdapter(strCmd, cnx);
@@ -55,4 +54,4 @@ namespace VAR.DatabaseExplorer.Code.DataAccess
return database; return database;
} }
} }
} }

View File

@@ -21,7 +21,7 @@ namespace VAR.DatabaseExplorer.Code.DataAccess
cnx.Open(); cnx.Open();
da.Fill(dt); da.Fill(dt);
cnx.Close(); cnx.Close();
foreach (DataRow dr in dt.Rows) foreach (DataRow dr in dt.Rows)
{ {
procedures.Add(new Procedure procedures.Add(new Procedure
@@ -79,4 +79,4 @@ namespace VAR.DatabaseExplorer.Code.DataAccess
return sbProc.ToString(); return sbProc.ToString();
} }
} }
} }

View File

@@ -12,7 +12,7 @@ namespace VAR.DatabaseExplorer.Code.DataAccess
{ {
var servers = new List<Server>(); var servers = new List<Server>();
SqlDataSourceEnumerator enumerador = SqlDataSourceEnumerator.Instance; SqlDataSourceEnumerator enumerador = SqlDataSourceEnumerator.Instance;
DataTable dtServers = enumerador.GetDataSources(); DataTable dtServers = enumerador.GetDataSources();
dtServers.DefaultView.Sort = "ServerName ASC, InstanceName ASC, Version ASC"; dtServers.DefaultView.Sort = "ServerName ASC, InstanceName ASC, Version ASC";
dtServers = dtServers.DefaultView.ToTable(); dtServers = dtServers.DefaultView.ToTable();
@@ -29,4 +29,4 @@ namespace VAR.DatabaseExplorer.Code.DataAccess
return servers; return servers;
} }
} }
} }

View File

@@ -17,7 +17,7 @@ namespace VAR.DatabaseExplorer.Code.DataAccess
cnx.Close(); cnx.Close();
dt.DefaultView.Sort = "TABLE_SCHEMA ASC, TABLE_NAME ASC, TABLE_TYPE ASC"; dt.DefaultView.Sort = "TABLE_SCHEMA ASC, TABLE_NAME ASC, TABLE_TYPE ASC";
dt = dt.DefaultView.ToTable(); dt = dt.DefaultView.ToTable();
foreach (DataRow dr in dt.Rows) foreach (DataRow dr in dt.Rows)
{ {
Table table = new Table Table table = new Table
@@ -32,7 +32,7 @@ namespace VAR.DatabaseExplorer.Code.DataAccess
return tables; return tables;
} }
public static DataTable GetData(string connectionString, string tableFullName) public static DataTable GetData(string connectionString, string tableFullName)
{ {
var cnx = new SqlConnection(connectionString); var cnx = new SqlConnection(connectionString);
@@ -45,6 +45,5 @@ namespace VAR.DatabaseExplorer.Code.DataAccess
return dt; return dt;
} }
} }
} }

View File

@@ -1,5 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.Data; using System.Data;
using System.Globalization; using System.Globalization;
using System.IO; using System.IO;
@@ -12,7 +11,7 @@ namespace VAR.DatabaseExplorer.Code
public static void DataTable_GenerateInserts(TextWriter txtWriter, DataTable dataTable, string destTable) public static void DataTable_GenerateInserts(TextWriter txtWriter, DataTable dataTable, string destTable)
{ {
var nfi = new NumberFormatInfo { NumberDecimalSeparator = "." }; var nfi = new NumberFormatInfo { NumberDecimalSeparator = "." };
var sbColumns = new StringBuilder(); var sbColumns = new StringBuilder();
foreach (DataColumn dc in dataTable.Columns) foreach (DataColumn dc in dataTable.Columns)
{ {
@@ -20,7 +19,7 @@ namespace VAR.DatabaseExplorer.Code
if (sbColumns.Length > 0) { sbColumns.Append(", "); } if (sbColumns.Length > 0) { sbColumns.Append(", "); }
sbColumns.AppendFormat("[{0}]", dc.ColumnName); sbColumns.AppendFormat("[{0}]", dc.ColumnName);
} }
// Recorrer la tabla de datos // Recorrer la tabla de datos
foreach (DataRow dr in dataTable.Rows) foreach (DataRow dr in dataTable.Rows)
{ {
@@ -83,14 +82,13 @@ namespace VAR.DatabaseExplorer.Code
// Otros // Otros
sbValues.AppendFormat("'{0}'", valor.ToString()); sbValues.AppendFormat("'{0}'", valor.ToString());
} }
} }
} }
// Insertar fila a la datatable destino // Insertar fila a la datatable destino
txtWriter.WriteLine(string.Format("INSERT INTO {0} ({1}) VALUES ({2});", txtWriter.WriteLine(string.Format("INSERT INTO {0} ({1}) VALUES ({2});",
destTable, sbColumns.ToString(), sbValues.ToString())); destTable, sbColumns.ToString(), sbValues.ToString()));
} }
} }
} }
} }

View File

@@ -1,5 +1,4 @@
using System;
using System;
using System.Xml.Serialization; using System.Xml.Serialization;
namespace VAR.DatabaseExplorer.Code.DataTransfer namespace VAR.DatabaseExplorer.Code.DataTransfer
@@ -22,4 +21,4 @@ namespace VAR.DatabaseExplorer.Code.DataTransfer
[XmlAttribute] [XmlAttribute]
public bool PK { get; set; } public bool PK { get; set; }
} }
} }

View File

@@ -1,5 +1,4 @@
using System;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Xml.Serialization; using System.Xml.Serialization;
@@ -20,4 +19,4 @@ namespace VAR.DatabaseExplorer.Code.DataTransfer
[XmlArray] [XmlArray]
public List<Procedure> Procedures { get; set; } public List<Procedure> Procedures { get; set; }
} }
} }

View File

@@ -21,4 +21,4 @@ namespace VAR.DatabaseExplorer.Code.DataTransfer
[XmlElement] [XmlElement]
public string Definition { get; set; } public string Definition { get; set; }
} }
} }

View File

@@ -22,4 +22,4 @@ namespace VAR.DatabaseExplorer.Code.DataTransfer
[XmlArray] [XmlArray]
public List<Database> Databases { get; set; } public List<Database> Databases { get; set; }
} }
} }

View File

@@ -1,5 +1,4 @@
using System;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Xml.Serialization; using System.Xml.Serialization;
@@ -20,4 +19,4 @@ namespace VAR.DatabaseExplorer.Code.DataTransfer
[XmlArray] [XmlArray]
public List<Column> Columns { get; set; } public List<Column> Columns { get; set; }
} }
} }

View File

@@ -15,4 +15,4 @@ namespace VAR.DatabaseExplorer.Code.DataTransfer
[XmlAttribute] [XmlAttribute]
public string Password { get; set; } public string Password { get; set; }
} }
} }

View File

@@ -1,11 +1,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections;
using System.Linq;
using System.Text;
using System.ComponentModel; using System.ComponentModel;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Windows.Forms; using System.Windows.Forms;
using System.Collections;
namespace VAR.DatabaseExplorer.Controls namespace VAR.DatabaseExplorer.Controls
{ {
@@ -18,20 +15,21 @@ namespace VAR.DatabaseExplorer.Controls
{ {
#region Declarations #region Declarations
ListViewItemComparer itemComparer = new ListViewItemComparer(); private ListViewItemComparer itemComparer = new ListViewItemComparer();
#endregion #endregion Declarations
#region Properties #region Properties
private bool allowSorting = false; private bool allowSorting = false;
public bool AllowSorting public bool AllowSorting
{ {
get { return allowSorting; } get { return allowSorting; }
set { allowSorting = value; } set { allowSorting = value; }
} }
#endregion #endregion Properties
#region Control life cicle #region Control life cicle
@@ -40,7 +38,7 @@ namespace VAR.DatabaseExplorer.Controls
ColumnClick += CustomListView_ColumnClick; ColumnClick += CustomListView_ColumnClick;
} }
#endregion #endregion Control life cicle
#region Events #region Events
@@ -52,7 +50,7 @@ namespace VAR.DatabaseExplorer.Controls
Sort(); Sort();
} }
#endregion #endregion Events
} }
#region ListViewItemComparer #region ListViewItemComparer
@@ -70,8 +68,8 @@ namespace VAR.DatabaseExplorer.Controls
public int Compare(object x, object y) public int Compare(object x, object y)
{ {
var itemA = (ListViewItem) x; var itemA = (ListViewItem)x;
var itemB = (ListViewItem) y; var itemB = (ListViewItem)y;
if (itemA.SubItems.Count <= _col || itemB.SubItems.Count <= _col) if (itemA.SubItems.Count <= _col || itemB.SubItems.Count <= _col)
{ {
@@ -83,5 +81,5 @@ namespace VAR.DatabaseExplorer.Controls
} }
} }
#endregion #endregion ListViewItemComparer
} }

View File

@@ -20,9 +20,10 @@ namespace VAR.DatabaseExplorer.Controls
SendMessage(Handle, EM_SETTABSTOPS, 1, new int[] { tabWidth * 4 }); SendMessage(Handle, EM_SETTABSTOPS, 1, new int[] { tabWidth * 4 });
} }
#endregion #endregion SetTabWidth
private int _tabWidth = 8;
private int _tabWidth=8;
public int TabWidth public int TabWidth
{ {
get { return _tabWidth; } get { return _tabWidth; }
@@ -33,4 +34,4 @@ namespace VAR.DatabaseExplorer.Controls
} }
} }
} }
} }

View File

@@ -9,6 +9,7 @@ namespace VAR.DatabaseExplorer.Controls
#region Properties #region Properties
private Form _window = null; private Form _window = null;
public Form Window public Form Window
{ {
get { return _window; } get { return _window; }
@@ -16,6 +17,7 @@ namespace VAR.DatabaseExplorer.Controls
} }
private bool _active = false; private bool _active = false;
public bool Active public bool Active
{ {
get { return _active; } get { return _active; }
@@ -26,7 +28,7 @@ namespace VAR.DatabaseExplorer.Controls
} }
} }
#endregion #endregion Properties
#region Creator #region Creator
@@ -37,16 +39,16 @@ namespace VAR.DatabaseExplorer.Controls
Click += WindowButton_Click; Click += WindowButton_Click;
} }
#endregion #endregion Creator
#region Events #region Events
void WindowButton_Click(object sender, EventArgs e) private void WindowButton_Click(object sender, EventArgs e)
{ {
if (_window == null) { return; } if (_window == null) { return; }
_window.Activate(); _window.Activate();
} }
#endregion #endregion Events
} }
} }

View File

@@ -4,17 +4,17 @@ using VAR.DatabaseExplorer.UI;
namespace VAR.DatabaseExplorer namespace VAR.DatabaseExplorer
{ {
static class Program internal static class Program
{ {
/// <summary> /// <summary>
/// The main entry point for the application. /// The main entry point for the application.
/// </summary> /// </summary>
[STAThread] [STAThread]
static void Main() private static void Main()
{ {
Application.EnableVisualStyles(); Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false); Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new FrmPrincipal()); Application.Run(new FrmPrincipal());
} }
} }
} }

View File

@@ -11,4 +11,4 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
[assembly: ComVisible(false)] [assembly: ComVisible(false)]
[assembly: Guid("31f76805-336c-471c-8af2-a4c1364e97b9")] [assembly: Guid("31f76805-336c-471c-8af2-a4c1364e97b9")]
[assembly: AssemblyVersion("1.0.0.*")] [assembly: AssemblyVersion("1.0.0.*")]

View File

@@ -1,10 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data.SqlClient;
using System.IO; using System.IO;
using System.Windows.Forms; using System.Windows.Forms;
using System.Xml.Serialization;
using VAR.DatabaseExplorer.Code;
using VAR.DatabaseExplorer.Code.BusinessLogic; using VAR.DatabaseExplorer.Code.BusinessLogic;
using VAR.DatabaseExplorer.Code.DataAccess; using VAR.DatabaseExplorer.Code.DataAccess;
using VAR.DatabaseExplorer.Code.DataTransfer; using VAR.DatabaseExplorer.Code.DataTransfer;
@@ -28,17 +25,17 @@ namespace VAR.DatabaseExplorer.UI
item.SubItems.Add(table.Name); item.SubItems.Add(table.Name);
item.SubItems.Add(table.Type); item.SubItems.Add(table.Type);
} }
lsvColumnas.Items.Clear(); lsvColumnas.Items.Clear();
} }
public FrmBaseDatos(string connectionString) public FrmBaseDatos(string connectionString)
{ {
InitializeComponent(); InitializeComponent();
_connectionString = connectionString; _connectionString = connectionString;
txtConString.Text = connectionString; txtConString.Text = connectionString;
} }
private void frmBaseDatos_Load(object sender, EventArgs e) private void frmBaseDatos_Load(object sender, EventArgs e)
{ {
Initialize(); Initialize();
@@ -55,13 +52,13 @@ namespace VAR.DatabaseExplorer.UI
private void lsvTablas_SelectedIndexChanged(object sender, EventArgs e) private void lsvTablas_SelectedIndexChanged(object sender, EventArgs e)
{ {
if (lsvTablas.SelectedItems.Count != 1) { return; } if (lsvTablas.SelectedItems.Count != 1) { return; }
ListViewItem item = lsvTablas.SelectedItems[0]; ListViewItem item = lsvTablas.SelectedItems[0];
_tableSchema = item.SubItems[0].Text; _tableSchema = item.SubItems[0].Text;
_tableName = item.SubItems[1].Text; _tableName = item.SubItems[1].Text;
lblTituloTabla.Text = _tableSchema + @"." + _tableName; lblTituloTabla.Text = _tableSchema + @"." + _tableName;
List<Column> columns = ColumnDA.GetColumns(_connectionString, _tableSchema, _tableName); List<Column> columns = ColumnDA.GetColumns(_connectionString, _tableSchema, _tableName);
lsvColumnas.Items.Clear(); lsvColumnas.Items.Clear();
foreach (Column col in columns) foreach (Column col in columns)
@@ -73,16 +70,15 @@ namespace VAR.DatabaseExplorer.UI
subitem.SubItems.Add(col.Nullable ? "Null" : "NotNull"); subitem.SubItems.Add(col.Nullable ? "Null" : "NotNull");
} }
} }
private void btnVerDatos_Click(object sender, EventArgs e) private void btnVerDatos_Click(object sender, EventArgs e)
{ {
if (string.IsNullOrEmpty(_tableSchema) || string.IsNullOrEmpty(_tableName)) { return; } if (string.IsNullOrEmpty(_tableSchema) || string.IsNullOrEmpty(_tableName)) { return; }
var form = new FrmDatos(_connectionString, _tableSchema, _tableName); var form = new FrmDatos(_connectionString, _tableSchema, _tableName);
FrmPrincipal.AddForm(form); FrmPrincipal.AddForm(form);
} }
private void btnProcs_Click(object sender, EventArgs e) private void btnProcs_Click(object sender, EventArgs e)
{ {
var form = new FrmProcedimientos(_connectionString); var form = new FrmProcedimientos(_connectionString);
@@ -94,21 +90,21 @@ namespace VAR.DatabaseExplorer.UI
var form = new FrmExec(_connectionString); var form = new FrmExec(_connectionString);
FrmPrincipal.AddForm(form); FrmPrincipal.AddForm(form);
} }
private void btnDocGen_Click(object sender, EventArgs e) private void btnDocGen_Click(object sender, EventArgs e)
{ {
Parent.Enabled = false; Parent.Enabled = false;
Database database = DatabaseBL.Database_GetSchema(connectionString: _connectionString, fillDefinitions: true); Database database = DatabaseBL.Database_GetSchema(connectionString: _connectionString, fillDefinitions: true);
string fixedDatabaseName = database.Name.Replace(' ', '_'); string fixedDatabaseName = database.Name.Replace(' ', '_');
var streamWriter = new StreamWriter(fixedDatabaseName + ".documentation.html"); var streamWriter = new StreamWriter(fixedDatabaseName + ".documentation.html");
DatabaseBL.Database_GenerateDocumentation(streamWriter, database); DatabaseBL.Database_GenerateDocumentation(streamWriter, database);
streamWriter.Close(); streamWriter.Close();
Parent.Enabled = true; Parent.Enabled = true;
} }
private void btnRefresh_Click(object sender, EventArgs e) private void btnRefresh_Click(object sender, EventArgs e)
{ {
Initialize(); Initialize();
@@ -117,15 +113,14 @@ namespace VAR.DatabaseExplorer.UI
private void btnExportData_Click(object sender, EventArgs e) private void btnExportData_Click(object sender, EventArgs e)
{ {
Parent.Enabled = false; Parent.Enabled = false;
Database database = DatabaseBL.Database_GetSchema(connectionString: _connectionString, fillDefinitions: false); Database database = DatabaseBL.Database_GetSchema(connectionString: _connectionString, fillDefinitions: false);
string fixedDatabaseName = database.Name.Replace(' ', '_'); string fixedDatabaseName = database.Name.Replace(' ', '_');
var streamWriter = new StreamWriter(fixedDatabaseName + ".data.sql"); var streamWriter = new StreamWriter(fixedDatabaseName + ".data.sql");
DatabaseBL.Database_ExportData(streamWriter, _connectionString, database); DatabaseBL.Database_ExportData(streamWriter, _connectionString, database);
streamWriter.Close(); streamWriter.Close();
Parent.Enabled = true; Parent.Enabled = true;
} }
} }
} }

View File

@@ -1,9 +1,8 @@
using System; using System;
using System.Data; using System.Data;
using System.Data.SqlClient;
using System.Drawing; using System.Drawing;
using System.Windows.Forms; using System.Windows.Forms;
using VAR.DatabaseExplorer.Code;
using System.Data.SqlClient;
namespace VAR.DatabaseExplorer.UI namespace VAR.DatabaseExplorer.UI
{ {
@@ -15,7 +14,7 @@ namespace VAR.DatabaseExplorer.UI
private readonly string _tableSchema = string.Empty; private readonly string _tableSchema = string.Empty;
private readonly string _tableName = string.Empty; private readonly string _tableName = string.Empty;
#endregion #endregion Declarations
#region Form life cycle #region Form life cycle
@@ -28,14 +27,18 @@ namespace VAR.DatabaseExplorer.UI
_conexionString = conexionString; _conexionString = conexionString;
LoadDataFromTable(); LoadDataFromTable();
} }
private void frmDatos_Load(object sender, EventArgs e) { }
#endregion private void frmDatos_Load(object sender, EventArgs e)
{
}
#endregion Form life cycle
#region Events #region Events
private void dgvDatos_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { } private void dgvDatos_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
}
private void dgvDatos_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) private void dgvDatos_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{ {
@@ -53,7 +56,7 @@ namespace VAR.DatabaseExplorer.UI
LoadDataFromTable(); LoadDataFromTable();
} }
#endregion #endregion Events
#region Private methods #region Private methods
@@ -61,15 +64,15 @@ namespace VAR.DatabaseExplorer.UI
{ {
Text = _tableSchema + @"." + _tableName; Text = _tableSchema + @"." + _tableName;
string tableFullName = "[" + _tableSchema + "].[" + _tableName + "]"; string tableFullName = "[" + _tableSchema + "].[" + _tableName + "]";
var dt= new DataTable(); var dt = new DataTable();
var cnx = new SqlConnection(_conexionString); var cnx = new SqlConnection(_conexionString);
var da = new SqlDataAdapter( "select * from " + tableFullName, cnx); var da = new SqlDataAdapter("select * from " + tableFullName, cnx);
cnx.Open(); cnx.Open();
da.Fill(dt); da.Fill(dt);
cnx.Close(); cnx.Close();
dgvDatos.DataSource = dt; dgvDatos.DataSource = dt;
} }
#endregion #endregion Private methods
} }
} }

View File

@@ -1,5 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.Data; using System.Data;
using System.Data.SqlClient; using System.Data.SqlClient;
using System.Drawing; using System.Drawing;
@@ -15,7 +14,7 @@ namespace VAR.DatabaseExplorer.UI
private readonly string _cnxString; private readonly string _cnxString;
#endregion #endregion Declarations
#region Form life cycle #region Form life cycle
@@ -26,7 +25,7 @@ namespace VAR.DatabaseExplorer.UI
_cnxString = cnxString; _cnxString = cnxString;
} }
#endregion #endregion Form life cycle
#region Events #region Events
@@ -79,7 +78,7 @@ namespace VAR.DatabaseExplorer.UI
} }
} }
#endregion #endregion Events
#region Private methods #region Private methods
@@ -98,6 +97,6 @@ namespace VAR.DatabaseExplorer.UI
return dt; return dt;
} }
#endregion #endregion Private methods
} }
} }

View File

@@ -11,7 +11,7 @@ namespace VAR.DatabaseExplorer.UI
private static FrmPrincipal _currentInstance; private static FrmPrincipal _currentInstance;
#endregion #endregion Declarations
#region Creator #region Creator
@@ -21,7 +21,7 @@ namespace VAR.DatabaseExplorer.UI
InitializeComponent(); InitializeComponent();
} }
#endregion #endregion Creator
#region WindowList #region WindowList
@@ -77,16 +77,16 @@ namespace VAR.DatabaseExplorer.UI
} }
} }
#endregion #endregion WindowList
#region Menus #region Menus
private void menuBuscarServidor_Click(object sender, EventArgs e) private void menuBuscarServidor_Click(object sender, EventArgs e)
{ {
var frm = new FrmServidores(); var frm = new FrmServidores();
FrmPrincipal.AddForm(frm); FrmPrincipal.AddForm(frm);
} }
#endregion #endregion Menus
} }
} }

View File

@@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient; using System.Data.SqlClient;
using System.Windows.Forms; using System.Windows.Forms;
using VAR.DatabaseExplorer.Code.DataAccess; using VAR.DatabaseExplorer.Code.DataAccess;
@@ -16,7 +15,7 @@ namespace VAR.DatabaseExplorer.UI
private readonly SqlConnection _cnx; private readonly SqlConnection _cnx;
#endregion #endregion Declarations
#region Form life cycle #region Form life cycle
@@ -33,7 +32,7 @@ namespace VAR.DatabaseExplorer.UI
lsvProcs_LoadData(); lsvProcs_LoadData();
} }
#endregion #endregion Form life cycle
#region Events #region Events
@@ -53,7 +52,7 @@ namespace VAR.DatabaseExplorer.UI
lsvProcs_LoadData(); lsvProcs_LoadData();
} }
#endregion #endregion Events
#region Private methods #region Private methods
@@ -71,6 +70,6 @@ namespace VAR.DatabaseExplorer.UI
} }
} }
#endregion #endregion Private methods
} }
} }

View File

@@ -52,7 +52,6 @@ namespace VAR.DatabaseExplorer.UI
} }
} }
private void lsvBBDD_DoubleClick(object sender, EventArgs e) private void lsvBBDD_DoubleClick(object sender, EventArgs e)
{ {
if (lsvBBDD.SelectedItems.Count != 1) return; if (lsvBBDD.SelectedItems.Count != 1) return;
@@ -83,4 +82,4 @@ namespace VAR.DatabaseExplorer.UI
return constructor.ConnectionString; return constructor.ConnectionString;
} }
} }
} }