Files
2026-06-18 11:05:29 +02:00

148 lines
6.1 KiB
C#

using BeWo.Service.Reporting.Straffaelligenhilfe;
using DevExpress.XtraPrinting.Native;
using DevExpress.XtraReports.UI;
using System;
using System.Collections.Generic;
namespace BeWo.Report.DefaultReports.Straffaelligenhilfe
{
/// <summary>
/// XtraReport für die "Statistik der Treuhänderischen Geldverwaltung (TGV)" (V 2014.1).
///
/// Verwendung:
/// var rows = TgvStatistikReport.CreateRows(tgv);
/// var report = new TgvStatistikReport();
/// report.Parameters["Vermittlungsstelle"].Value = "Musterstadt";
/// report.Parameters["Staatsanwaltschaft"].Value = "GESAMT";
/// report.Parameters["Berichtszeitraum"].Value = new DateTime(2025, 6, 30);
/// report.SetReportDataSource(rows);
/// report.ShowPreview();
/// </summary>
public partial class AsaStatistikReport : XtraReport
{
public AsaStatistikReport()
{
InitializeComponent();
}
/// <summary>
/// Setzt die Datenquelle des Reports.
/// </summary>
public void SetReportDataSource(AsaStatistic statistik)
{
lblBerichtszeitraum.Text = String.Format("{0:dd.MM.yyyy}-{1:dd.MM.yyyy}", statistik.StartDate, statistik.EndDate);
this.bindingSource1.DataSource = CreateRows(statistik);
}
// ── Factory ─────────────────────────────────────────────────────────────
/// <summary>
/// Konvertiert ein ausgefülltes TgvStatistic-Objekt in die Zeilenliste für den Report.
/// </summary>
public static List<AsaStatistikReportRow> CreateRows(AsaStatistic asa)
{
AsaStatistikReportRow Row(string pos, string beschr, string wert,
AsaReportRowType type = AsaReportRowType.Normal) =>
new AsaStatistikReportRow
{
Position = pos,
Beschreibung = beschr,
Wert = wert,
RowType = type
};
AsaStatistikReportRow RowInt(string pos, string beschr, int val,
AsaReportRowType type = AsaReportRowType.Normal) =>
Row(pos, beschr, val.ToString("N0"), type);
return new List<AsaStatistikReportRow>
{
// ── Auftragsbestand ────────────────────────────────────────────
RowInt("0.1",
"Anzahl der aus dem vorhergehenden Berichtszeitraum übernommenen offenen Aufträge",
asa.Anzahl01),
RowInt("0.2",
"Anzahl der im aktuellen Berichtszeitraum erteilten Aufträge",
asa.Anzahl02, AsaReportRowType.Highlighted),
RowInt("1.",
"Anzahl der insges. erteilten Aufträge (Summe Zeilen 0.1 + 0.2)",
asa.Anzahl1, AsaReportRowType.Highlighted),
Row("2.",
"Anzahl aller erledigten Aufträge (incl. Abbrüche, teilweise erledigter Aufträge, gescheiterte Fälle)",
asa.Anzahl2.ToString("N2"), AsaReportRowType.Highlighted),
AsaStatistikReportRow.SectionHeader(
"3.",
"Fallverlauf (der erledigten Aufträge gem. Zeile 2)"),
AsaStatistikReportRow.SectionHeader(
"3.1.",
"Methode (der erledigten Aufträge gem. Zeile 2)"),
// ── Erledigte Aufträge ─────────────────────────────────────────
RowInt("3.1.1.",
"Klient wurde aufgesucht",
asa.Anzahl3_1_1),
RowInt("3.1.2.",
"Klient wurde angetroffen",
asa.Anzahl3_1_2),
RowInt("3.1.3.",
"Klient wurde nicht angetroffen",
asa.Anzahl3_1_3),
RowInt("3.1.4.",
"Klient wurde nicht aufgesucht, da Klient sich in VBS meldet (1. Anschreiben)",
asa.Anzahl3_1_4),
AsaStatistikReportRow.SectionHeader(
"3.2.",
"Verlauf (der erledigten Aufträge gem. Zeile 2)"),
RowInt("3.2.1.",
"Übergang in Schwitzen statt Sitzen",
asa.Anzahl3_2_1),
RowInt("3.2.2.",
"Übergang in Treuhänderische Geldverwaltung",
asa.Anzahl3_2_2),
RowInt("3.2.3.",
"Kein Interesse / Abbruch / Scheitern",
asa.Anzahl3_2_3),
};
}
}
/// <summary>
/// Zeilentyp für die bedingte Formatierung im TGV-Statistik Report.
/// </summary>
public enum AsaReportRowType
{
Normal = 0,
Highlighted = 1, // Orangefarbener Hintergrund (z. B. Zeilen 0.2, 1., 2., 3.2., 5.)
SectionHeader = 2 // Blauer Hintergrund (Abschnittsüberschrift 4.)
}
/// <summary>
/// Datenmodell für eine Zeile im TGV-Statistik Report.
/// </summary>
public class AsaStatistikReportRow
{
public string Position { get; set; } = "";
public string Beschreibung { get; set; } = "";
public string Wert { get; set; } = "";
public AsaReportRowType RowType { get; set; } = AsaReportRowType.Normal;
/// <summary>
/// Erstellt eine Abschnittsüberschrift (blauer Hintergrund).
/// </summary>
internal static AsaStatistikReportRow SectionHeader(string position, string beschreibung)
{
return new AsaStatistikReportRow
{
Position = position,
Beschreibung = beschreibung,
RowType = AsaReportRowType.SectionHeader
};
}
}
}