private void btnGerarRelatorio_Click(object sender, EventArgs e) { DataTable dt = new DataTable(); Controller.CompraController cc = new Controller.CompraController(); CRCompras crcompra = new CRCompras(); DSCompras ds = new DSCompras(); //fazer busca de acordo com filtros if (dtpInicio.Value > dtpFim.Value && !dtpInicio.Value.ToString("dd-MM-yyyy").Equals(dtpFim.Value.ToString("dd-MM-yyyy"))) { MessageBox.Show("Selecione uma data de inicio inferior a data final!"); } else { bool estado = false; if (cbTodas.Checked) { estado = true; } dt = cc.retornaRelatorio(dtpInicio.Value.ToString("dd-MM-yyyy"), dtpFim.Value.ToString("dd-MM-yyyy"), estado); if (dt != null && dt.Rows.Count > 0) { ds.DTCompra.Merge(dt); } else { MessageBox.Show("Consulta não retornou dados."); } //liga cr no ds crcompra.SetDataSource(ds); FrmRelatorio tela = new FrmRelatorio(); tela.visualizar(crcompra); tela.ShowDialog(); } }