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;

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);

View File

@@ -23,14 +23,13 @@ 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);

View File

@@ -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;
@@ -83,7 +82,6 @@ namespace VAR.DatabaseExplorer.Code
// Otros // Otros
sbValues.AppendFormat("'{0}'", valor.ToString()); sbValues.AppendFormat("'{0}'", valor.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

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;

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;

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; }

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,13 +4,13 @@ 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);

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;
@@ -82,7 +79,6 @@ namespace VAR.DatabaseExplorer.UI
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);
@@ -126,6 +122,5 @@ namespace VAR.DatabaseExplorer.UI
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
@@ -29,13 +28,17 @@ namespace VAR.DatabaseExplorer.UI
LoadDataFromTable(); LoadDataFromTable();
} }
private void frmDatos_Load(object sender, EventArgs e) { } private void frmDatos_Load(object sender, EventArgs e)
{
}
#endregion #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,7 +77,7 @@ namespace VAR.DatabaseExplorer.UI
} }
} }
#endregion #endregion WindowList
#region Menus #region Menus
@@ -87,6 +87,6 @@ namespace VAR.DatabaseExplorer.UI
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;