Tenho um projeto onde apresento um Gridview
em um projeto Webforms Asp.net C#.
Tentei aplicar o conceito de 3 camada desta forma, porem a pagina só da reload e o grid não aparece na pagina.
Segue o exemplo do código abaixo:
public class bltboletoDAL
{
public DataTable GetDataGridView(DataTable Dt, int CodMorador)
{
MySqlDataReader Dr;
MySqlConnection Con = Conexao.GetConnection();
Conexao.AbrirConexao(Con);
MySqlCommand Cmd;
String Sql = "SELECT NumDocumento, Concat(Replace(Replace(Replace(Format(ValorBoleto, 2), '.', '|'), ',', '.'), '|', ',')) As ValorBoleto, DATE_FORMAT( VencimentoBoleto, '%d/%m/%y' ) AS 'VencimentoBoleto',DATE_FORMAT( DataPagamento, '%d/%m/%y' ) AS 'DataPagamento' From TbFatura where CodMorador=@v1 and Pago=1 ORDER BY VencimentoBoleto";
Cmd = new MySqlCommand(Sql, Con);
Cmd.Parameters.AddWithValue("@v1", CodMorador);
Dr = Cmd.ExecuteReader();
if (Dr.Read())
{
Dt.Load(Dr);
}
else
{
}
return Dt;
}
}
Camada de negocio.
public class bltboletoBusiness
{
public void ViewGrid(GridView Grid)
{
Grid.Visible = true;
DataTable Dt = new DataTable();
var SetTable = new bltboletoDAL();
Dt = SetTable.GetDataGridView(Dt, ModuloGlobal.Global.CodMorador);
Grid.DataSource = Dt;
}
}
Camada de visualização.
protected void btnUltimosPagamentos_Click(object sender, EventArgs e)
{
var blt = new bltboletoBusiness();
blt.ViewGrid(GridBltEmAberto);
GridBltEmAberto.Visible = true;
}