public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport() { RelatorioLdia rpt = new RelatorioLdia(); rpt.Site = this.Site; return(rpt); }
public void carregarRelatorioLactacaoDia(DateTime dtInicial, DateTime dtFinal) { dsVirtual dsVirt = new dsVirtual(); try { //Codigo para o relatorio Cursor.Current = Cursors.WaitCursor; DataTable t = dsVirt.Tables["LDIA"]; DataRow rDataSet; FbConnection fbConn = new FbConnection(frmHome.strConn); string query; query = string.Format("SELECT LACTACAO_DIA.DATA, LACTACAO_DIA.PRODUCAO, GADO.NUMERO, GADO.NOME, LACTACAO_DIA.TIRADA FROM GADO, LACTACAO_DIA WHERE ((GADO.ID = LACTACAO_DIA.ID_GADO) AND (GADO.ID_FAZENDA = {0}) AND (LACTACAO_DIA.DATA >= '{1}') AND (LACTACAO_DIA.DATA <= '{2}'))", frmHome.IDFazendaSelecionada, dtInicial.ToString("MM/dd/yyyy"), dtFinal.ToString("MM/dd/yyyy")); FbCommand fbCmd = new FbCommand(query, fbConn); try { fbConn.Open(); FbDataReader r = fbCmd.ExecuteReader(); while (r.Read()) { rDataSet = t.NewRow(); rDataSet["PRODUCAO"] = r[1]; rDataSet["NUMERO"] = r[2]; rDataSet["NOME"] = r[3]; rDataSet["DATA"] = r[0]; rDataSet["TIRADA"] = r[4]; t.Rows.Add(rDataSet); } } catch (FbException fbex) { MessageBox.Show("Erro ao acessar o Banco de Dados:\n" + fbex.Message, "Erro"); } finally { fbConn.Close(); } RelatorioLdia objRpt = new RelatorioLdia(); objRpt.Database.Tables[0].SetDataSource(t); // objRpt.SetDataSource(ds); crystalReportViewer1.ReportSource = objRpt; crystalReportViewer1.Refresh(); } catch (Exception ee) { MessageBox.Show("Erro ao carregar o relatório\n" + ee.Message); } finally { Cursor.Current = Cursors.Default; } }