123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- <?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 both master and detail rows. It does not differ much from the "Row Datasource" example. See the "ManualBuild" 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">
- <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 master data source
- DataSourceBase masterData = Report.GetDataSource("Categories");
- // get the detail data source
- DataSourceBase detailData = Report.GetDataSource("Products");
-
- // init the master data source
- masterData.Init();
-
- while (masterData.HasMoreRows)
- {
- // print first 3 rows that contains data from master data source
- Table1.PrintRow(0);
- Table1.PrintColumns();
- Table1.PrintRow(1);
- Table1.PrintColumns();
- Table1.PrintRow(2);
- Table1.PrintColumns();
- // init the detail data source. Pass masterData to allow master-detail relation
- detailData.Init(masterData);
- // print detail header
- Table1.PrintRow(3);
- Table1.PrintColumns();
-
- // print detail rows
- while (detailData.HasMoreRows)
- {
- // print the detail row
- Table1.PrintRow(4);
- Table1.PrintColumns();
-
- // go next data source row
- detailData.Next();
- }
- // print the detail footer row
- Table1.PrintRow(5);
- Table1.PrintColumns();
- Table1.PrintRow(6);
- Table1.PrintColumns();
-
- // go next data source row
- masterData.Next();
- }
- }
- }
- }
- </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="151.2">
- <TableObject Name="Table1" Left="9.45" Top="9.45" Width="699.3" Height="141.75" ManualBuildEvent="Table1_ManualBuild">
- <TableColumn Name="Column1" Width="321.3"/>
- <TableColumn Name="Column2" Width="189"/>
- <TableColumn Name="Column3" Width="189"/>
- <TableRow Name="Row5" Height="37.8">
- <TableCell Name="Cell17" Fill.Color="160, 120, 120" Text="[Categories.CategoryName]" VertAlign="Center" Font="Segoe UI, 16pt" TextFill.Color="White" ColSpan="3"/>
- <TableCell Name="Cell18" Fill.Color="160, 120, 120" Font="Segoe UI, 10pt" TextFill.Color="White"/>
- <TableCell Name="Cell19" Fill.Color="160, 120, 120" Font="Segoe UI, 10pt" TextFill.Color="White"/>
- </TableRow>
- <TableRow Name="Row4">
- <TableCell Name="Cell14" Fill.Color="160, 120, 120" Text=" [Categories.Description]" VertAlign="Center" Font="Segoe UI, 9pt" TextFill.Color="White" ColSpan="3"/>
- <TableCell Name="Cell15" Fill.Color="160, 120, 120" Font="Segoe UI, 9pt" TextFill.Color="White"/>
- <TableCell Name="Cell16" Fill.Color="160, 120, 120" Font="Segoe UI, 9pt" TextFill.Color="White"/>
- </TableRow>
- <TableRow Name="Row6" Height="9.45">
- <TableCell Name="Cell20" Font="Segoe UI, 9pt"/>
- <TableCell Name="Cell21" Font="Segoe UI, 9pt"/>
- <TableCell Name="Cell22" Font="Segoe UI, 9pt"/>
- </TableRow>
- <TableRow Name="Row1">
- <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"/>
- <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"/>
- <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"/>
- </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="160, 120, 120" VertAlign="Center" Font="Segoe UI, 9pt"/>
- <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"/>
- <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"/>
- </TableRow>
- <TableRow Name="Row7">
- <TableCell Name="Cell23" Font="Segoe UI, 10pt"/>
- <TableCell Name="Cell24" Font="Segoe UI, 10pt"/>
- <TableCell Name="Cell25" Font="Segoe UI, 10pt"/>
- </TableRow>
- </TableObject>
- </DataBand>
- <PageFooterBand Name="PageFooter1" Top="193" 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>
|