or
protected
void
Report_Load()
{
this
.DataSource =
this
.obj;
#region Generierung der Komponenten-Tabellen
// Für jede Komponentengruppe müssen wir eine Tabelle im Report dynamisch erstellen.
int
cgid = 0;
// Component Group ID
foreach
(PRODUKTKOMPONENTENGRUPPE componentGroup
in
this
.obj.Lizenz.PRODUKTVERSION.PRODUKTKOMPONENTENGRUPPE.OrderBy(x => x.SortNo))
{
TextBox lComponentGroup =
new
TextBox()
// Komponentengruppe - Überschrift
{
Name =
"lComponentGroup"
+ cgid.ToString(),
Location =
new
PointU(Unit.Cm(cgid * 2), Unit.Cm(0)),
// Location anhand ID im Panel
Size =
new
SizeU(LicenseReport.MaxWidth, Unit.Cm(0.5)),
Value = componentGroup.Name +
":"
};
lComponentGroup.Style.Font.Italic =
true
;
lComponentGroup.Style.BorderColor.Top = Color.Gray;
lComponentGroup.Style.BorderStyle.Top = BorderType.Outset;
lComponentGroup.Style.VerticalAlign = VerticalAlign.Middle;
this
.pComponentGroups.Items.Add(lComponentGroup);
//// Die Tabelle für eine Komponentengruppe:
Table tComponentGroup =
new
Table()
// Tabelle
{
Name =
"tComponentGroup"
+ cgid.ToString(),
Location =
new
PointU(Unit.Cm(0), lComponentGroup.Location.Y + lComponentGroup.Size.Height),
Size =
new
SizeU(LicenseReport.MaxWidth, Unit.Cm(1))
};
tComponentGroup.Body.Columns.AddRange(
new
TableBody.ColumnCollection()
// Spalten erstellen und Breiten setzen
{
new
TableBodyColumn(LicenseReport.MaxWidth / 16 * 4),
new
TableBodyColumn(LicenseReport.MaxWidth / 16 * 7),
new
TableBodyColumn(LicenseReport.MaxWidth / 16 * 2.5),
new
TableBodyColumn(LicenseReport.MaxWidth / 16 * 2.5),
});
// row width
// Controls für die Spaltenköpfe erstellen und die Spaltenköpfe mit ihnen füllen:
TextBox tbComponentColumnKey =
new
TextBox()
{
Name =
"tbComponentColumnKey"
+ cgid.ToString(),
Size =
new
SizeU(tComponentGroup.Body.Columns[0].Width, Unit.Cm(0.5)),
Value =
"Schlüssel"
};
tbComponentColumnKey.Style.Font.Bold =
true
;
tComponentGroup.Items.Add(tbComponentColumnKey);
tComponentGroup.ColumnGroups.Add(
new
TableGroup() { ReportItem = tbComponentColumnKey });
TextBox tbComponentColumnName =
new
TextBox()
{
Name =
"tbComponentColumnName"
+ cgid.ToString(),
Size =
new
SizeU(tComponentGroup.Body.Columns[1].Width, Unit.Cm(0.5)),
Value =
"Name"
};
tbComponentColumnName.Style.Font.Bold =
true
;
tComponentGroup.Items.Add(tbComponentColumnName);
tComponentGroup.ColumnGroups.Add(
new
TableGroup() { ReportItem = tbComponentColumnName });
TextBox tbComponentColumnUnitPrice =
new
TextBox()
{
Name =
"tbComponentColumnUnitPrice"
+ cgid.ToString(),
Size =
new
SizeU(tComponentGroup.Body.Columns[2].Width, Unit.Cm(0.5)),
Value =
"Stückpreis"
};
tbComponentColumnUnitPrice.Style.Font.Bold =
true
;
tComponentGroup.Items.Add(tbComponentColumnUnitPrice);
tComponentGroup.ColumnGroups.Add(
new
TableGroup() { ReportItem = tbComponentColumnUnitPrice });
TextBox tbComponentColumnTotalPrice =
new
TextBox()
{
Name =
"tbComponentColumnTotalPrice"
+ cgid.ToString(),
Size =
new
SizeU(tComponentGroup.Body.Columns[3].Width, Unit.Cm(0.5)),
Value =
"Preis"
};
tbComponentColumnTotalPrice.Style.Font.Bold =
true
;
tComponentGroup.Items.Add(tbComponentColumnTotalPrice);
tComponentGroup.ColumnGroups.Add(
new
TableGroup() { ReportItem = tbComponentColumnTotalPrice });
tComponentGroup.Body.Rows.Add(
new
TableBodyRow(Unit.Cm(0.5)));
// Zeilen erstellen / row height
// (Wir erstellen nur eine Reihe die dynamisch für jedes Item in die Tabelle angefügt wird)
// Controls erstellen, und Zeilen mit Controls füllen:
TextBox tbComponentCellKey =
new
TextBox()
{
Name =
"tbComponentCellKey"
+ cgid.ToString(),
Size =
new
SizeU(tComponentGroup.Body.Columns[0].Width, Unit.Cm(0.5)),
Value = @
"=Key"
};
tComponentGroup.Items.Add(tbComponentCellKey);
tComponentGroup.Body.SetCellContent(0, 0, tbComponentCellKey);
TextBox tbComponentCellName =
new
TextBox()
{
Name =
"tbComponentCellName"
+ cgid.ToString(),
Size =
new
SizeU(tComponentGroup.Body.Columns[0].Width, Unit.Cm(0.5)),
Value = @
"=Name"
};
tComponentGroup.Items.Add(tbComponentCellName);
tComponentGroup.Body.SetCellContent(0, 0, tbComponentCellName);
TextBox tbComponentCellUnitPrice =
new
TextBox()
{
Name =
"tbComponentCellUnitPrice"
+ cgid.ToString(),
Size =
new
SizeU(tComponentGroup.Body.Columns[0].Width, Unit.Cm(0.5)),
Value = @
"=UnitPrice"
};
tComponentGroup.Items.Add(tbComponentCellUnitPrice);
tComponentGroup.Body.SetCellContent(0, 0, tbComponentCellUnitPrice);
TextBox tbComponentCellTotalPrice =
new
TextBox()
{
Name =
"tbComponentCellTotalPrice"
+ cgid.ToString(),
Size =
new
SizeU(tComponentGroup.Body.Columns[0].Width, Unit.Cm(0.5)),
Value = @
"=TotalPrice"
};
tComponentGroup.Items.Add(tbComponentCellKey);
tComponentGroup.Body.SetCellContent(0, 0, tbComponentCellKey);
TableGroup tgComponentDetailGroup =
new
TableGroup()
// Detailgruppe für den dynamischen Teil (notwendig)
{
Name =
"DetailGroup"
};
tgComponentDetailGroup.Groupings.Add(
new
Grouping(
null
));
tComponentGroup.RowGroups.Add(tgComponentDetailGroup);
// Zum Panel hinzufügen und Daten anbinden:
this
.pComponentGroups.Items.Add(tComponentGroup);
tComponentGroup.DataSource =
this
.obj.Komponenten.Where(x => x.GroupName.Equals(componentGroup.Name)).OrderBy(x => x.SortNo);
cgid++;
}
this
.pComponentGroups.Height = Unit.Cm(cgid * 2);
this
.pComponentGroups.Style.BackgroundColor = Color.Transparent;
#endregion
}