Row Datasource, Detail Rows.frx 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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 detail rows. It does not differ much from the &quot;Row Datasource&quot; example.&#13;&#10;See the &quot;ManualBuild&quot; event handler to see how to init the datasource to allow master-detail relation." ReportInfo.Created="01/17/2008 20:40:24" ReportInfo.Modified="04/07/2023 14:29:14" 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 parent data source by its name
  23. DataSourceBase parentData = Report.GetDataSource(&quot;Categories&quot;);
  24. // get the data source by its name
  25. DataSourceBase rowData = Report.GetDataSource(&quot;Products&quot;);
  26. // init the data source. Pass parentData to allow master-detail relation
  27. rowData.Init(parentData);
  28. // print the first table row - it is a header
  29. Table1.PrintRow(0);
  30. // each PrintRow call must be followed by either PrintColumn or PrintColumns call
  31. // to print cells on the row
  32. Table1.PrintColumns();
  33. // now enumerate the data source and print the table body
  34. while (rowData.HasMoreRows)
  35. {
  36. // print the table body
  37. Table1.PrintRow(1);
  38. Table1.PrintColumns();
  39. // go next data source row
  40. rowData.Next();
  41. }
  42. // print the last table row - it is a footer
  43. Table1.PrintRow(2);
  44. Table1.PrintColumns();
  45. }
  46. }
  47. }
  48. </ScriptText>
  49. <Dictionary>
  50. <TableDataSource Name="Products" ReferenceName="NorthWind.Products" DataType="System.Int32" Enabled="true">
  51. <Column Name="ProductID" DataType="System.Int32"/>
  52. <Column Name="ProductName" DataType="System.String"/>
  53. <Column Name="SupplierID" DataType="System.Int32"/>
  54. <Column Name="CategoryID" DataType="System.Int32"/>
  55. <Column Name="QuantityPerUnit" DataType="System.String"/>
  56. <Column Name="UnitPrice" DataType="System.Decimal"/>
  57. <Column Name="UnitsInStock" DataType="System.Int16"/>
  58. <Column Name="UnitsOnOrder" DataType="System.Int16"/>
  59. <Column Name="ReorderLevel" DataType="System.Int16"/>
  60. <Column Name="Discontinued" DataType="System.Boolean" BindableControl="CheckBox"/>
  61. <Column Name="EAN13" DataType="System.String"/>
  62. </TableDataSource>
  63. <TableDataSource Name="Categories" ReferenceName="NorthWind.Categories" DataType="System.Int32" Enabled="true">
  64. <Column Name="CategoryID" DataType="System.Int32"/>
  65. <Column Name="CategoryName" DataType="System.String"/>
  66. <Column Name="Description" DataType="System.String"/>
  67. <Column Name="Picture" DataType="System.Byte[]" BindableControl="Picture"/>
  68. </TableDataSource>
  69. <Relation Name="CategoriesProducts" ReferenceName="NorthWind.CategoriesProducts" ParentDataSource="Categories" ChildDataSource="Products" ParentColumns="CategoryID" ChildColumns="CategoryID" Enabled="true"/>
  70. </Dictionary>
  71. <ReportPage Name="Page1" Watermark.Font="Arial, 60pt">
  72. <ReportTitleBand Name="ReportTitle1" Width="718.2" Height="37.8" CanGrow="true">
  73. <TextObject Name="Text2" Width="718.2" Height="37.8" Text="PRODUCTS BY CATEGORIES" HorzAlign="Center" VertAlign="Center" Font="Segoe UI, 14pt, style=Bold"/>
  74. </ReportTitleBand>
  75. <DataBand Name="Data1" Top="39.8" Width="718.2" Height="132.3" DataSource="Categories">
  76. <TableObject Name="Table1" Left="9.45" Top="75.6" Width="699.3" Height="56.7" FixedRows="1" ManualBuildEvent="Table1_ManualBuild">
  77. <TableColumn Name="Column1" Width="321.3"/>
  78. <TableColumn Name="Column2" Width="189"/>
  79. <TableColumn Name="Column3" Width="189"/>
  80. <TableRow Name="Row1">
  81. <TableCell Name="Cell1" Border.Lines="All" Border.Color="WhiteSmoke" Fill.Color="170, 150, 130" Text="Product name" Padding="5, 0, 0, 0" VertAlign="Center" Font="Segoe UI, 9pt, style=Bold" TextFill.Color="White"/>
  82. <TableCell Name="Cell2" Border.Lines="All" Border.Color="WhiteSmoke" Fill.Color="170, 150, 130" Text="Unit price" Padding="0, 0, 5, 0" HorzAlign="Right" VertAlign="Center" Font="Segoe UI, 9pt, style=Bold" TextFill.Color="White"/>
  83. <TableCell Name="Cell3" Border.Lines="All" Border.Color="WhiteSmoke" Fill.Color="170, 150, 130" Text="Units in stock" HorzAlign="Center" VertAlign="Center" Font="Segoe UI, 9pt, style=Bold" TextFill.Color="White"/>
  84. </TableRow>
  85. <TableRow Name="Row2">
  86. <TableCell Name="Cell6" Border.Lines="All" Border.Color="WhiteSmoke" Text="[Products.ProductName]" Padding="5, 0, 0, 0" VertAlign="Center" Font="Segoe UI, 9pt"/>
  87. <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"/>
  88. <TableCell Name="Cell8" Border.Lines="All" Border.Color="WhiteSmoke" Text="[Products.UnitsInStock]" HorzAlign="Center" VertAlign="Center" Font="Segoe UI, 9pt"/>
  89. </TableRow>
  90. <TableRow Name="Row3">
  91. <TableCell Name="Cell11" Border.Lines="All" Border.Color="WhiteSmoke" Fill.Color="170, 150, 130" VertAlign="Center" Font="Segoe UI, 9pt"/>
  92. <TableCell Name="Cell12" Border.Lines="All" Border.Color="WhiteSmoke" Fill.Color="170, 150, 130" Text="Total:" Padding="0, 0, 5, 0" HorzAlign="Right" VertAlign="Center" Font="Segoe UI, 9pt" TextFill.Color="White"/>
  93. <TableCell Name="Cell13" Border.Lines="All" Border.Color="WhiteSmoke" Fill.Color="170, 150, 130" Text="[Sum(Cell8)]" HorzAlign="Center" VertAlign="Center" Font="Segoe UI, 9pt" TextFill.Color="White"/>
  94. </TableRow>
  95. </TableObject>
  96. <TextObject Name="Text3" Left="9.45" Top="9.45" Width="699.3" Height="37.8" Fill.Color="170, 150, 130" Text="[Categories.CategoryName]" VertAlign="Center" Font="Segoe UI, 16pt" TextFill.Color="White"/>
  97. <TextObject Name="Text4" Left="9.45" Top="47.25" Width="699.3" Height="18.9" Fill.Color="170, 150, 130" Text="[Categories.Description]" VertAlign="Center" Font="Segoe UI, 9pt" TextFill.Color="White"/>
  98. </DataBand>
  99. <PageFooterBand Name="PageFooter1" Top="174.1" Width="718.2" Height="28.35" Fill.Color="WhiteSmoke">
  100. <TextObject Name="Text1" Left="614.25" Width="94.5" Height="28.35" Text="[PageN]" HorzAlign="Right" VertAlign="Center" Font="Segoe UI, 9pt"/>
  101. <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"/>
  102. </PageFooterBand>
  103. </ReportPage>
  104. </Report>