新细节部分细节A部分结束后

时间:2016-09-29 09:20:00

标签: vb.net crystal-reports

我想在详细信息部分A的 end 之后添加另一个数据集中的第二个详细信息部分。当详细信息A中没有更多记录时,Dection B将显示其记录。

我已将CrystalReport2添加为主报表的子报表,如下一屏幕截图所示。但子报告没有显示任何记录。另外,我想计算每个的总数。我该如何解决这个问题?

enter image description here

enter image description here

enter image description here

Private Sub crpt_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Dim cr As New CrystalReport1
    Dim ds As New DataSet1
    Dim dt As DataTable = ds.DataTable1
    For i As Integer = 0 To mrpt.DataGridView1.Rows.Count - 1
        dt.Rows.Add(mrpt.DataGridView1.Rows(i).Cells(0).Value, mrpt.DataGridView1.Rows(i).Cells(1).Value, mrpt.DataGridView1.Rows(i).Cells(2).Value, mrpt.DataGridView1.Rows(i).Cells(5).Value, mrpt.DataGridView1.Rows(i).Cells(6).Value, mrpt.DataGridView1.Rows(i).Cells(7).Value, mrpt.DataGridView1.Rows(i).Cells(9).Value, mrpt.DataGridView1.Rows(i).Cells(4).Value)
    Next
    cr.SetDataSource(dt)
    cr.SetParameterValue("mmonth", mrpt.ComboBox3.SelectedItem & " / " & mrpt.ComboBox4.SelectedItem)
    cr.SetParameterValue("cno", mrpt.ComboBox1.SelectedItem)
    cr.SetParameterValue("ctyp", mrpt.ComboBox2.SelectedItem)
    cr.SetParameterValue("tot", mrpt.TextBox1.Text)
    Dim cr2 As New CrystalReport2
    Dim ds2 As New SubDataSet2
    Dim dt2 As DataTable = ds2.DataTable1
    For i As Integer = 0 To mrpt.DataGridView1.Rows.Count - 1
        dt2.Rows.Add(mrpt.DataGridView1.Rows(i).Cells(0).Value, mrpt.DataGridView1.Rows(i).Cells(1).Value, mrpt.DataGridView1.Rows(i).Cells(2).Value, mrpt.DataGridView1.Rows(i).Cells(5).Value)
    Next
    cr2.SetDataSource(dt2)

    CrystalReportViewer1.ReportSource = cr
End Sub

0 个答案:

没有答案