CrystalReports Subreport
Publicado por Pedro Alvarez (7 intervenciones) el 05/09/2019 21:33:48
Hola, muy buenas.
Tengo muchos problemas al establecer los parámetros para dos subreports del mismo reporte. En un subreport no aplica los parámetros, mostrándome toda la información.
Les copio el código. Agradezco su ayuda
Tengo muchos problemas al establecer los parámetros para dos subreports del mismo reporte. En un subreport no aplica los parámetros, mostrándome toda la información.
Les copio el código. Agradezco su ayuda
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
CrystalReport.FormReporte ReporteCorte = new CrystalReport.FormReporte();
CrystalReport.ReporteCorte reporte = new CrystalReport.ReporteCorte();
ReporteCorte.Show();
try//Facturas
{
Conexion.Open();
string sql1 = "SELECT * FROM Facturas WHERE Fecha >= @Fecha1 AND Fecha < @Fecha2";
using (OleDbCommand cmd = new OleDbCommand(sql1, Conexion))
{
cmd.Parameters.Clear();
cmd.Parameters.Add("@Fecha1", OleDbType.Date).Value = DateTime.UtcNow.Date;
cmd.Parameters.Add("@Fecha2", OleDbType.Date).Value = DateTime.UtcNow.Date.AddDays(1);
OleDbDataAdapter adapter = new OleDbDataAdapter(cmd);
DataSet ds = new DataSet();
adapter.Fill(ds, "Facturas");
reporte.Subreports[0].SetDataSource(ds);
}
}
catch (Exception error)
{
MessageBox.Show("Error");
}
finally
{
Conexion.Close();
}
try//Cobros del día
{
Conexion.Open();
string sql1 = "SELECT * FROM Caja WHERE Fecha >= @Fecha1 AND Fecha < @Fecha2";
using (OleDbCommand cmd = new OleDbCommand(sql1, Conexion))
{
cmd.Parameters.Clear();
cmd.Parameters.Add("@Fecha1", OleDbType.Date).Value = DateTime.UtcNow.Date;
cmd.Parameters.Add("@Fecha2", OleDbType.Date).Value = DateTime.UtcNow.Date.AddDays(1);
OleDbDataAdapter adapter = new OleDbDataAdapter(cmd);
DataSet ds = new DataSet();
adapter.Fill(ds, "Cobros");
reporte.Subreports[1].SetDataSource(ds);
}
}
catch (Exception error)
{
MessageBox.Show("Error");
}
finally
{
Conexion.Close();
}
ReporteCorte.crystalReportViewer1.ReportSource = reporte;
ReporteCorte.crystalReportViewer1.Refresh();
Valora esta pregunta


0