Row Datasource, Master-Detail.frx 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <Report ScriptLanguage="CSharp" ReportInfo.Description="Demonstrates how to print a Master-detail report using the Table object. In this example the Table object is used to print both master and detail rows. It does not differ much from the &quot;Row Datasource&quot; example.&#13;&#10;See the &quot;ManualBuild&quot; event handler for more details." ReportInfo.Created="01/17/2008 20:40:24" ReportInfo.Modified="04/07/2023 14:32:03" ReportInfo.CreatorVersion="1.0.0.0">
  3. <ScriptText>using System;
  4. using System.Collections;
  5. using System.Collections.Generic;
  6. using System.ComponentModel;
  7. using System.Windows.Forms;
  8. using System.Drawing;
  9. using System.Data;
  10. using FastReport;
  11. using FastReport.Data;
  12. using FastReport.Dialog;
  13. using FastReport.Barcode;
  14. using FastReport.Table;
  15. using FastReport.Utils;
  16. namespace FastReport
  17. {
  18. public class ReportScript
  19. {
  20. private void Table1_ManualBuild(object sender, EventArgs e)
  21. {
  22. // get the master data source
  23. DataSourceBase masterData = Report.GetDataSource(&quot;Categories&quot;);
  24. // get the detail data source
  25. DataSourceBase detailData = Report.GetDataSource(&quot;Products&quot;);
  26. // init the master data source
  27. masterData.Init();
  28. while (masterData.HasMoreRows)
  29. {
  30. // print first 3 rows that contains data from master data source
  31. Table1.PrintRow(0);
  32. Table1.PrintColumns();
  33. Table1.PrintRow(1);
  34. Table1.PrintColumns();
  35. Table1.PrintRow(2);
  36. Table1.PrintColumns();
  37. // init the detail data source. Pass masterData to allow master-detail relation
  38. detailData.Init(masterData);
  39. // print detail header
  40. Table1.PrintRow(3);
  41. Table1.PrintColumns();
  42. // print detail rows
  43. while (detailData.HasMoreRows)
  44. {
  45. // print the detail row
  46. Table1.PrintRow(4);
  47. Table1.PrintColumns();
  48. // go next data source row
  49. detailData.Next();
  50. }
  51. // print the detail footer row
  52. Table1.PrintRow(5);
  53. Table1.PrintColumns();
  54. Table1.PrintRow(6);
  55. Table1.PrintColumns();
  56. // go next data source row
  57. masterData.Next();
  58. }
  59. }
  60. }
  61. }
  62. </ScriptText>
  63. <Dictionary>
  64. <TableDataSource Name="Products" ReferenceName="NorthWind.Products" DataType="System.Int32" Enabled="true">
  65. <Column Name="ProductID" DataType="System.Int32"/>
  66. <Column Name="ProductName" DataType="System.String"/>
  67. <Column Name="SupplierID" DataType="System.Int32"/>
  68. <Column Name="CategoryID" DataType="System.Int32"/>
  69. <Column Name="QuantityPerUnit" DataType="System.String"/>
  70. <Column Name="UnitPrice" DataType="System.Decimal"/>
  71. <Column Name="UnitsInStock" DataType="System.Int16"/>
  72. <Column Name="UnitsOnOrder" DataType="System.Int16"/>
  73. <Column Name="ReorderLevel" DataType="System.Int16"/>
  74. <Column Name="Discontinued" DataType="System.Boolean" BindableControl="CheckBox"/>
  75. <Column Name="EAN13" DataType="System.String"/>
  76. </TableDataSource>
  77. <TableDataSource Name="Categories" ReferenceName="NorthWind.Categories" DataType="System.Int32" Enabled="true">
  78. <Column Name="CategoryID" DataType="System.Int32"/>
  79. <Column Name="CategoryName" DataType="System.String"/>
  80. <Column Name="Description" DataType="System.String"/>
  81. <Column Name="Picture" DataType="System.Byte[]" BindableControl="Picture"/>
  82. </TableDataSource>
  83. <Relation Name="CategoriesProducts" ReferenceName="NorthWind.CategoriesProducts" ParentDataSource="Categories" ChildDataSource="Products" ParentColumns="CategoryID" ChildColumns="CategoryID" Enabled="true"/>
  84. </Dictionary>
  85. <ReportPage Name="Page1" Watermark.Font="Arial, 60pt">
  86. <ReportTitleBand Name="ReportTitle1" Width="718.2" Height="37.8" CanGrow="true">
  87. <TextObject Name="Text2" Width="718.2" Height="37.8" Text="PRODUCTS BY CATEGORIES" HorzAlign="Center" VertAlign="Center" Font="Segoe UI, 14pt, style=Bold"/>
  88. </ReportTitleBand>
  89. <DataBand Name="Data1" Top="39.8" Width="718.2" Height="151.2">
  90. <TableObject Name="Table1" Left="9.45" Top="9.45" Width="699.3" Height="141.75" ManualBuildEvent="Table1_ManualBuild">
  91. <TableColumn Name="Column1" Width="321.3"/>
  92. <TableColumn Name="Column2" Width="189"/>
  93. <TableColumn Name="Column3" Width="189"/>
  94. <TableRow Name="Row5" Height="37.8">
  95. <TableCell Name="Cell17" Fill.Color="160, 120, 120" Text="[Categories.CategoryName]" VertAlign="Center" Font="Segoe UI, 16pt" TextFill.Color="White" ColSpan="3"/>
  96. <TableCell Name="Cell18" Fill.Color="160, 120, 120" Font="Segoe UI, 10pt" TextFill.Color="White"/>
  97. <TableCell Name="Cell19" Fill.Color="160, 120, 120" Font="Segoe UI, 10pt" TextFill.Color="White"/>
  98. </TableRow>
  99. <TableRow Name="Row4">
  100. <TableCell Name="Cell14" Fill.Color="160, 120, 120" Text=" [Categories.Description]" VertAlign="Center" Font="Segoe UI, 9pt" TextFill.Color="White" ColSpan="3"/>
  101. <TableCell Name="Cell15" Fill.Color="160, 120, 120" Font="Segoe UI, 9pt" TextFill.Color="White"/>
  102. <TableCell Name="Cell16" Fill.Color="160, 120, 120" Font="Segoe UI, 9pt" TextFill.Color="White"/>
  103. </TableRow>
  104. <TableRow Name="Row6" Height="9.45">
  105. <TableCell Name="Cell20" Font="Segoe UI, 9pt"/>
  106. <TableCell Name="Cell21" Font="Segoe UI, 9pt"/>
  107. <TableCell Name="Cell22" Font="Segoe UI, 9pt"/>
  108. </TableRow>
  109. <TableRow Name="Row1">
  110. <TableCell Name="Cell1" Border.Lines="All" Border.Color="WhiteSmoke" Fill.Color="160, 120, 120" Text="Product name" Padding="5, 0, 0, 0" VertAlign="Center" Font="Segoe UI, 9pt, style=Bold" TextFill.Color="White"/>
  111. <TableCell Name="Cell2" Border.Lines="All" Border.Color="WhiteSmoke" Fill.Color="160, 120, 120" Text="Unit price" Padding="0, 0, 5, 0" HorzAlign="Right" VertAlign="Center" Font="Segoe UI, 9pt, style=Bold" TextFill.Color="White"/>
  112. <TableCell Name="Cell3" Border.Lines="All" Border.Color="WhiteSmoke" Fill.Color="160, 120, 120" Text="Units in stock" HorzAlign="Center" VertAlign="Center" Font="Segoe UI, 9pt, style=Bold" TextFill.Color="White"/>
  113. </TableRow>
  114. <TableRow Name="Row2">
  115. <TableCell Name="Cell6" Border.Lines="All" Border.Color="WhiteSmoke" Text="[Products.ProductName]" Padding="5, 0, 0, 0" VertAlign="Center" Font="Segoe UI, 9pt"/>
  116. <TableCell Name="Cell7" Border.Lines="All" Border.Color="WhiteSmoke" Text="[Products.UnitPrice]" Padding="0, 0, 5, 0" Format="Currency" Format.UseLocale="true" Format.DecimalDigits="2" HorzAlign="Right" VertAlign="Center" Font="Segoe UI, 9pt"/>
  117. <TableCell Name="Cell8" Border.Lines="All" Border.Color="WhiteSmoke" Text="[Products.UnitsInStock]" HorzAlign="Center" VertAlign="Center" Font="Segoe UI, 9pt"/>
  118. </TableRow>
  119. <TableRow Name="Row3">
  120. <TableCell Name="Cell11" Border.Lines="All" Border.Color="WhiteSmoke" Fill.Color="160, 120, 120" VertAlign="Center" Font="Segoe UI, 9pt"/>
  121. <TableCell Name="Cell12" Border.Lines="All" Border.Color="WhiteSmoke" Fill.Color="160, 120, 120" Text="Total:" Padding="0, 0, 5, 0" HorzAlign="Right" VertAlign="Center" Font="Segoe UI, 9pt" TextFill.Color="White"/>
  122. <TableCell Name="Cell13" Border.Lines="All" Border.Color="WhiteSmoke" Fill.Color="160, 120, 120" Text="[Sum(Cell8)]" HorzAlign="Center" VertAlign="Center" Font="Segoe UI, 9pt" TextFill.Color="White"/>
  123. </TableRow>
  124. <TableRow Name="Row7">
  125. <TableCell Name="Cell23" Font="Segoe UI, 10pt"/>
  126. <TableCell Name="Cell24" Font="Segoe UI, 10pt"/>
  127. <TableCell Name="Cell25" Font="Segoe UI, 10pt"/>
  128. </TableRow>
  129. </TableObject>
  130. </DataBand>
  131. <PageFooterBand Name="PageFooter1" Top="193" Width="718.2" Height="28.35" Fill.Color="WhiteSmoke">
  132. <TextObject Name="Text1" Left="614.25" Width="94.5" Height="28.35" Text="[PageN]" HorzAlign="Right" VertAlign="Center" Font="Segoe UI, 9pt"/>
  133. <TextObject Name="Text12" Left="9.45" Width="217.35" Height="28.35" Cursor="Hand" Hyperlink.Value="https://www.fast-report.com/en/product/fast-report-net/" Text="Generated by FastReport" VertAlign="Center" Font="Segoe UI, 9pt, style=Underline" TextFill.Color="Blue"/>
  134. </PageFooterBand>
  135. </ReportPage>
  136. </Report>