123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- <?xml version="1.0" encoding="utf-8"?>
- <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 "Row Datasource" example. See the "ManualBuild" 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">
- <ScriptText>using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Windows.Forms;
- using System.Drawing;
- using System.Data;
- using FastReport;
- using FastReport.Data;
- using FastReport.Dialog;
- using FastReport.Barcode;
- using FastReport.Table;
- using FastReport.Utils;
- namespace FastReport
- {
- public class ReportScript
- {
- private void Table1_ManualBuild(object sender, EventArgs e)
- {
- // get the parent data source by its name
- DataSourceBase parentData = Report.GetDataSource("Categories");
- // get the data source by its name
- DataSourceBase rowData = Report.GetDataSource("Products");
- // init the data source. Pass parentData to allow master-detail relation
- rowData.Init(parentData);
-
- // print the first table row - it is a header
- Table1.PrintRow(0);
- // each PrintRow call must be followed by either PrintColumn or PrintColumns call
- // to print cells on the row
- Table1.PrintColumns();
-
- // now enumerate the data source and print the table body
- while (rowData.HasMoreRows)
- {
- // print the table body
- Table1.PrintRow(1);
- Table1.PrintColumns();
-
- // go next data source row
- rowData.Next();
- }
-
- // print the last table row - it is a footer
- Table1.PrintRow(2);
- Table1.PrintColumns();
- }
- }
- }
- </ScriptText>
- <Dictionary>
- <TableDataSource Name="Products" ReferenceName="NorthWind.Products" DataType="System.Int32" Enabled="true">
- <Column Name="ProductID" DataType="System.Int32"/>
- <Column Name="ProductName" DataType="System.String"/>
- <Column Name="SupplierID" DataType="System.Int32"/>
- <Column Name="CategoryID" DataType="System.Int32"/>
- <Column Name="QuantityPerUnit" DataType="System.String"/>
- <Column Name="UnitPrice" DataType="System.Decimal"/>
- <Column Name="UnitsInStock" DataType="System.Int16"/>
- <Column Name="UnitsOnOrder" DataType="System.Int16"/>
- <Column Name="ReorderLevel" DataType="System.Int16"/>
- <Column Name="Discontinued" DataType="System.Boolean" BindableControl="CheckBox"/>
- <Column Name="EAN13" DataType="System.String"/>
- </TableDataSource>
- <TableDataSource Name="Categories" ReferenceName="NorthWind.Categories" DataType="System.Int32" Enabled="true">
- <Column Name="CategoryID" DataType="System.Int32"/>
- <Column Name="CategoryName" DataType="System.String"/>
- <Column Name="Description" DataType="System.String"/>
- <Column Name="Picture" DataType="System.Byte[]" BindableControl="Picture"/>
- </TableDataSource>
- <Relation Name="CategoriesProducts" ReferenceName="NorthWind.CategoriesProducts" ParentDataSource="Categories" ChildDataSource="Products" ParentColumns="CategoryID" ChildColumns="CategoryID" Enabled="true"/>
- </Dictionary>
- <ReportPage Name="Page1" Watermark.Font="Arial, 60pt">
- <ReportTitleBand Name="ReportTitle1" Width="718.2" Height="37.8" CanGrow="true">
- <TextObject Name="Text2" Width="718.2" Height="37.8" Text="PRODUCTS BY CATEGORIES" HorzAlign="Center" VertAlign="Center" Font="Segoe UI, 14pt, style=Bold"/>
- </ReportTitleBand>
- <DataBand Name="Data1" Top="39.8" Width="718.2" Height="132.3" DataSource="Categories">
- <TableObject Name="Table1" Left="9.45" Top="75.6" Width="699.3" Height="56.7" FixedRows="1" ManualBuildEvent="Table1_ManualBuild">
- <TableColumn Name="Column1" Width="321.3"/>
- <TableColumn Name="Column2" Width="189"/>
- <TableColumn Name="Column3" Width="189"/>
- <TableRow Name="Row1">
- <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"/>
- <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"/>
- <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"/>
- </TableRow>
- <TableRow Name="Row2">
- <TableCell Name="Cell6" Border.Lines="All" Border.Color="WhiteSmoke" Text="[Products.ProductName]" Padding="5, 0, 0, 0" VertAlign="Center" Font="Segoe UI, 9pt"/>
- <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"/>
- <TableCell Name="Cell8" Border.Lines="All" Border.Color="WhiteSmoke" Text="[Products.UnitsInStock]" HorzAlign="Center" VertAlign="Center" Font="Segoe UI, 9pt"/>
- </TableRow>
- <TableRow Name="Row3">
- <TableCell Name="Cell11" Border.Lines="All" Border.Color="WhiteSmoke" Fill.Color="170, 150, 130" VertAlign="Center" Font="Segoe UI, 9pt"/>
- <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"/>
- <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"/>
- </TableRow>
- </TableObject>
- <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"/>
- <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"/>
- </DataBand>
- <PageFooterBand Name="PageFooter1" Top="174.1" Width="718.2" Height="28.35" Fill.Color="WhiteSmoke">
- <TextObject Name="Text1" Left="614.25" Width="94.5" Height="28.35" Text="[PageN]" HorzAlign="Right" VertAlign="Center" Font="Segoe UI, 9pt"/>
- <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"/>
- </PageFooterBand>
- </ReportPage>
- </Report>
|