77 lines
2.0 KiB
C#
77 lines
2.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using ServerExplorer.Code;
|
|
using System.Data.SqlClient;
|
|
|
|
namespace ServerExplorer.UI
|
|
{
|
|
public partial class FrmDatos : Form
|
|
{
|
|
#region Declarations
|
|
|
|
private TablaDesc tablaDesc = null;
|
|
private string conexionString = string.Empty;
|
|
|
|
#endregion
|
|
|
|
#region Form life cycle
|
|
|
|
public FrmDatos(TablaDesc tablaDesc, string conexionString)
|
|
{
|
|
InitializeComponent();
|
|
this.tablaDesc = tablaDesc;
|
|
this.conexionString = conexionString;
|
|
LoadDataFromTable();
|
|
}
|
|
|
|
private void frmDatos_Load(object sender, EventArgs e) { }
|
|
|
|
#endregion
|
|
|
|
#region Events
|
|
|
|
private void dgvDatos_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { }
|
|
|
|
private void dgvDatos_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
|
|
{
|
|
if (e.DesiredType == typeof(Image))
|
|
{
|
|
if (e.Value is DBNull || (e.Value is byte[] && ((byte[])e.Value).Length <= 0))
|
|
{
|
|
e.Value = new Bitmap(1, 1);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void btnRefresh_Click(object sender, EventArgs e)
|
|
{
|
|
LoadDataFromTable();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Private methods
|
|
|
|
private void LoadDataFromTable()
|
|
{
|
|
Text = tablaDesc.Esquema + "." + tablaDesc.Nombre;
|
|
string tableFullName = "[" + tablaDesc.Esquema + "].[" + tablaDesc.Nombre + "]";
|
|
DataTable dt= new DataTable();
|
|
SqlConnection cnx = new SqlConnection(conexionString);
|
|
SqlDataAdapter da = new SqlDataAdapter( "select * from " + tableFullName, cnx);
|
|
cnx.Open();
|
|
da.Fill(dt);
|
|
cnx.Close();
|
|
dgvDatos.DataSource = dt;
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|