【发布时间】:2015-08-20 02:24:52
【问题描述】:
我需要一些帮助,以便在 Delphi XE2 的快速报告中创建主/详细报告。
我有一个简单的表单,它接受来自用户的 2 个日期和 2 个时间。然后,我在表单上有 2 个 Oracle 数据集,用于检索我的数据。当用户按下打印按钮时,程序接受用户的值并将值发送到第一个 oracle 数据集,然后依次检索第一个值,然后将该值与用户接受的值一起发送到第二个数据集打印与检索到的值有关的详细信息。
对于每个数据集,我确实有一个相应的 frxDBDataset 组件,然后将其分配给 frxReport1 组件。在报告中,我创建了一个分配给 dataset1 的 Master Band,以及一个分配给 datset2 的 Detail Band。当我运行我的报告时,数据集 1 带回所有记录,但数据集 2 只带回第一个值的记录,并为数据集 1 中的每条记录复制它。
下面是我要执行的代码:
opr_operator_ods.Close;
opr_operator_ods.SetVariable('DATEFROM', opr_datefrom_dtp.Date);
opr_operator_ods.SetVariable('DATETO', opr_dateto_dtp.Date);
opr_operator_ods.SetVariable('TIMEFROM', opr_timefrom_dtp.Text);
opr_operator_ods.SetVariable('TIMETO', opr_timeto_dtp.Text);
opr_operator_ods.Open;
if opr_operator_ods.RecordCount > 0 then
begin
while not opr_operator_ods.Eof do
begin
opr_operatorcount_ods.Close;
opr_operatorcount_ods.SetVariable('DATEFROM', opr_datefrom_dtp.Date);
opr_operatorcount_ods.SetVariable('DATETO', opr_dateto_dtp.Date);
opr_operatorcount_ods.SetVariable('TIMEFROM', opr_timefrom_dtp.Text);
opr_operatorcount_ods.SetVariable('TIMETO', opr_timeto_dtp.Text);
opr_operatorcount_ods.SetVariable('OPERATOR',
opr_operator_ods.FieldByName('opr_code').AsString);
opr_operatorcount_ods.Open;
while not opr_operatorcount_ods.Eof do
begin
frxReport1.PrepareReport(false);
opr_operatorcount_ods.Next;
end;
frxReport1.PrepareReport(true);
opr_operator_ods.Next;
end;
DecodeDate(opr_datefrom_dtp.Date, tyear, tmonth, tday);
StartDate := '''' + IntToStr(tday) + '/' + IntToStr(tmonth) + '/' + IntToStr(tyear) + '''';
DecodeDate(opr_dateto_dtp.Date, tyear, tmonth, tday);
EndDate := '''' + IntToStr(tday) + '/' + IntToStr(tmonth) + '/' + IntToStr(tyear) + '''';
frxReport1.Variables['StartDate'] := StartDate;
frxReport1.Variables['EndDate'] := EndDate;
//frxReport1.PrepareReport(True);
frxReport1.ShowPreparedReport;
如何让第二个数据集移动到下一条记录的值?
该报告曾经在 Delphi 2005 中使用 RaveReports6 完美运行,但我们使用了基于代码的表单开发,使用“writeln”更容易操作,而不像使用 Fast Reports 那样直观。
【问题讨论】:
标签: oracle delphi fastreport