C# 应用筛选器时XRSubreport不包含任何数据
我有两个报告,第一个“RepGetAsemblyEmployeeForDailyReport”作为主报告,第二个“RepDailyAssemblyProductionByEmployee”作为详细报告 在主报告中,我添加了未绑定的详细信息栏,并将其放入XRSubreport中,然后将报告源属性设置为详细信息报告 这两个报表都有存储过程作为数据源来打开主报表,我使用下面的代码C# 应用筛选器时XRSubreport不包含任何数据,c#,winforms,xtrareport,C#,Winforms,Xtrareport,我有两个报告,第一个“RepGetAsemblyEmployeeForDailyReport”作为主报告,第二个“RepDailyAssemblyProductionByEmployee”作为详细报告 在主报告中,我添加了未绑定的详细信息栏,并将其放入XRSubreport中,然后将报告源属性设置为详细信息报告 这两个报表都有存储过程作为数据源来打开主报表,我使用下面的代码 private async void DailyProductionByEmployee_Click(object sen
private async void DailyProductionByEmployee_Click(object sender, EventArgs e)
{
RepGetAsemblyEmployeeForDailyReport reportEmployee = new RepGetAsemblyEmployeeForDailyReport();
Parameter param1 = new Parameter
{
Name = "shifttime",
Type = typeof(string),
Visible = false,
Value = form.cmbShiftTime.EditValue
};
Parameter param2 = new Parameter
{
Name = "date",
Type = typeof(DateTime),
Visible = false,
Value = Convert.ToDateTime(form.FirstDate.EditValue)//.ToString("MM/dd/yyyy");
};
reportEmployee.Parameters.Add(param1);
reportEmployee.Parameters.Add(param2);
reportEmployee.DataSource = await assembly.RepGetAsemblyEmployeeForDailyReport(Convert.ToDateTime(form.FirstDate.EditValue).ToString("MM/dd/yyyy"),
Convert.ToInt32(form.cmbShiftTime.EditValue));
form.Close();
reportEmployee.ShowRibbonPreviewDialog();
}
为了控制报表,我使用SubReportBeforePrint事件来设置数据源,如下所示
private async void subRepProduction_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
{
((XRSubreport)sender).ReportSource.DataSource = await assembly.RepAssemblyDailyProductionShiftTimeByEmployee(Convert.ToDateTime(Parameters[1].Value).ToString("MM/dd/yyyy"),
Convert.ToInt32(Parameters[0].Value));
}
现在,如果我应用过滤器,我不会得到任何数据
但是当我清除过滤器时,一些第一行不显示,然后所有行都显示,然后只重复第一行
我怎样才能解决这个问题,提前谢谢。
更新:从sql server数据库获取数据的代码
public async Task<DataTable> RepGetAsemblyEmployeeForDailyReport(string DateProduction, int ShiftTime)
{
DAL.DataAccessLayer DAL = new DAL.DataAccessLayer();
DataTable dt = new DataTable();
SqlParameter[] param = new SqlParameter[2];
param[0] = new SqlParameter("@Date", SqlDbType.NVarChar, 50)
{
Value = DateProduction
};
param[1] = new SqlParameter("@ShiftTime", SqlDbType.Int)
{
Value = ShiftTime
};
dt = await DAL.SelectData("RepGetAsemblyEmployeeForDailyReport", param);
DAL.Close();
return dt;
}
公共异步任务RepGetAsemblyEmployeeForDailyReport(字符串DateProduction,int-ShiftTime)
{
DAL.DataAccessLayer DAL=新的DAL.DataAccessLayer();
DataTable dt=新的DataTable();
SqlParameter[]param=新的SqlParameter[2];
param[0]=新的SqlParameter(“@Date”,SqlDbType.NVarChar,50)
{
值=生产日期
};
param[1]=新的SqlParameter(“@ShiftTime”,SqlDbType.Int)
{
值=移位时间
};
dt=等待DAL。选择数据(“RepGetAsemblyEmployeeForDailyReport”,参数);
DAL.Close();
返回dt;
}
此处不能使用“async void”事件处理程序
因为“用火遗忘法”。
从“subRepProduction_BeforePrint”事件处理程序中删除async/await关键字当我删除它时,会出现以下错误:分配给DataSource属性的对象不能用作报表的数据源,因为它没有实现任何支持的接口,所以这是您真正的问题。您分配什么样的数据源?我使用存储过程从sql server数据库中获取数据作为数据表,我更新我的问题