Это мой отчет:
Это мой отчет
Это мой подотчет:
Это мой подотчет
Используйте эту опцию для создания подотчетов:
Используйте эту опцию для создания подотчетов
Код: Выделить всё
private void ConsultarCheckOperation(string Miku, int Mode)
{
try
{
// This is other Report, this is Report 1
Reporteador.ConsultaSP s = new Reporteador.ConsultaSP();
DataSet Ds = s.CheckOp(Miku, Mode);
RptCheckOperation RDOC = new RptCheckOperation();
RDOC.SetDataSource(Ds.Tables[0]);
FormCheckOperation ChO = new FormCheckOperation();
ChO.crystalReportViewer1.ReportSource = RDOC;
if (activeForm != null)
activeForm.Close();
activeForm = ChO;
ChO.TopLevel = false;
ChO.FormBorderStyle = FormBorderStyle.None;
ChO.Dock = DockStyle.Fill;
panel4.Controls.Add(ChO);
ChO.BringToFront();
ChO.Show();
// This is report 2, where I have the problem, but I put the first one, because that is where I make the call to the table, yes, I use the same DataSet to load 2 reports, I don't know if that is a problem
DateTime Cartman = DateTime.Now;
int Kenny;
Kenny = Cartman.Year;
Reporteador.ConsultaSP R = new Reporteador.ConsultaSP();
DataSet Dr = R.SelectDate(1);
Sanae RDOCA = new Sanae();
RDOCA.SetParameterValue("Year", Kenny);
RDOCA.Load("Subreport21");
RDOCA.Subreports[0].DataSourceConnections.Clear();
RDOCA.Subreports[0].SetDataSource(Ds.Tables[0]);
/*
RDOCA.Subreports["Mon"].SetDataSource(Ds.Tables[0]);
RDOCA.Subreports["Tues"].SetDataSource(Ds.Tables[0]);
RDOCA.Subreports["Weds"].SetDataSource(Ds.Tables[0]);
RDOCA.Subreports["Thurs"].SetDataSource(Ds.Tables[0]);
RDOCA.Subreports["Fri"].SetDataSource(Ds.Tables[0]);
RDOCA.Subreports["Sat"].SetDataSource(Ds.Tables[0]);
*/
FormProMes Ch1 = new FormProMes();
Ch1.crystalReportViewer1.ReportSource = RDOCA;
if (activeForma != null)
activeForma.Close();
activeForma = Ch1;
Ch1.TopLevel = false;
Ch1.FormBorderStyle = FormBorderStyle.None;
Ch1.Dock = DockStyle.Fill;
panel3.Controls.Add(Ch1);
Ch1.BringToFront();
Ch1.Show();
}
catch (Exception x)
{
MessageBox.Show(x.Message);
}
}
// This is my DataSet
public DataSet CheckOp(string Jo, int Accion)
{
var ConnectionString = conexionP.ConnectionString;
using (SqlConnection sql = new SqlConnection(ConnectionString))
{
using (SqlCommand Con = new SqlCommand("[dbo].[SELECTCHECKOP]", sql))
{
Con.CommandType = CommandType.StoredProcedure;
Con.Parameters.Add(new SqlParameter("@CheckOp", Jo));
Con.Parameters.Add(new SqlParameter("@Accion", Accion));
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(Con);
sql.Open();
da.Fill(ds);
return ds;
}
}
}
// Finally this is my stored procedure
ALTER PROCEDURE [dbo].[SELECTCHECKOP]
@CheckOp varchar(40),
@Accion int
AS
BEGIN
IF @Accion = 1
BEGIN
SELECT *
FROM viewcheckoperation
WHERE [N° de OT (secundario)] = @CheckOp
ORDER BY Assembly_Level ASC, [N° de OT (secundario)] ASC, Sequence ASC
END
IF @Accion = 2
BEGIN
SELECT *
FROM viewcheckoperation
WHERE [N° de OT Primario] = @CheckOp
ORDER BY Assembly_Level ASC, [N° de OT (secundario)] ASC, Sequence ASC
END
END
Подробнее здесь: https://stackoverflow.com/questions/778 ... al-reports