private void VisualizarRptPeriodo_Load(object sender, EventArgs e) { try { NpgsqlConnection conn = new NpgsqlConnection("Server=localhost; Port=5432; User Id=postgres; Password=@postgre; Database=ouvidoria;"); conn.Open(); NpgsqlCommand comando = new NpgsqlCommand("SELECT * FROM manifestacao WHERE data_gravacao BETWEEN @dataInicial AND @dataFinal", conn); comando.Parameters.AddWithValue("@dataInicial", dataInicial); comando.Parameters.AddWithValue("@dataFinal", dataFinal); NpgsqlDataAdapter da = new NpgsqlDataAdapter(comando); DataSet ds = new DataSet(); DataTable manifestacao = new DataTable(); da.Fill(manifestacao); RptPeriodo rptPeriodo = new RptPeriodo(); rptPeriodo.SetDataSource(manifestacao); crystalReportViewerPeriodo.ReportSource = rptPeriodo; crystalReportViewerPeriodo.Refresh(); this.WindowState = FormWindowState.Maximized; } catch { MessageBox.Show("PostgreSQL Error!", "Erro!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport() { RptPeriodo rpt = new RptPeriodo(); rpt.Site = this.Site; return(rpt); }