PsychosozialeProjekteSaarpfalz/CustomReportCreator - Druck für spezielle QueryRos sichergestellt

This commit is contained in:
2024-08-12 14:26:48 +02:00
parent 40e46801e7
commit c0eaaae6c4
2 changed files with 88 additions and 0 deletions

View File

@@ -0,0 +1,87 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using BeWo.Data.Access;
using BeWo.Data.Entities;
using BeWo.Report;
using BeWo.Report.ReportObjects;
using BeWo.Service.DCEntityMapper;
using BS.Shared.Core;
using BS.Shared.DataContracts;
using DevExpress.XtraReports.Design;
using DevExpress.XtraReports.UI;
namespace PsychosozialeProjekteSaarpfalz
{
public class CustomReportCreator : DefaultReportCreator
{
public override XtraReport CreateInvoiceOverviewReport(List<long> oids)
{
var queryReport = new BeWo.Report.DefaultReports.Bericht();
var invoices = MapperFactory.InvoiceBaseDC_InvoiceBase.MapToNewDCs(DAOFactory.GenericDAO.LoadByIDs<InvoiceBase>(oids));
DataTable table = new DataTable();
string[] spalten = new string[] { "Art der Rechnung", "Klient/in", "Zeitraum", "Nummer", "Datum", "Empfänger", "Betrag", "Bemerkung",
"Geprüft", "Versendet", "Exportiert", "Bezahlt", "Teilzahlung"};
for (int i = 0; i < spalten.Length; i++)
table.Columns.Add(spalten[i], typeof(string));
for (int i = 0; i < invoices.Count; i++)
{
DataRow row = table.NewRow();
InvoiceBaseDC invoice = invoices[i];
row[0] = invoice.InvoiceTypeText;
row[1] = invoice.CustomerLastName + ", " + invoice.CustomerFirstName;
row[2] = invoice.PeriodString;
row[3] = invoice.InvoiceNumber;
row[4] = string.Format("{0:dd.MM.yyyy}", invoice.InvoiceDate);
string recipient = invoice.RecipientOrganisation;
if (!string.IsNullOrEmpty(recipient) && (!string.IsNullOrEmpty(invoice.RecipientPersonFirstName) || !string.IsNullOrEmpty(invoice.RecipientPersonLastName)))
{
recipient += " - ";
}
recipient += invoice.RecipientPersonFirstName + " " + invoice.RecipientPersonLastName;
row[5] = recipient;
row[6] = string.Format("{0:0.00}", invoice.TotalAmount);
row[7] = invoice.Notice;
row[8] = invoice.IsReviewed ? "Ja" : "";
row[9] = invoice.IsSent ? "Ja" : "";
row[10] = invoice.IsExported ? "Ja" : "";
row[11] = invoice.IsPaid ? "Ja" : "";
row[12] = invoice.PartialPayment;
table.Rows.Add(row);
}
var queryReportObject = QueryRO.Create(new Query() { Title = "Rechnungen" }, table);
queryReportObject.Name = "Rechnungen";
queryReport.SetReportDataSource(queryReportObject);
return queryReport as XtraReport;
}
public override XtraReport CreateQueryReport(long queryOid, String queryReportId)
{
var query = DAOFactory.GenericDAO.LoadByID<Query>(queryOid);
if (query is null)
{
return new XtraReport();
}
var path = Utils.CreateSavePath(TempPath, queryReportId + ".xml");
var table = Utils.XMLDeserialize<DataTable>(path);
var queryReport = new BeWo.Report.DefaultReports.Bericht();
if (queryOid == 101)
{
queryReport = (BeWo.Report.DefaultReports.Bericht)FindReportImp<QueryRO>(null, query.ReportTypeName);
}
var queryReportObject = QueryRO.Create(query, table);
queryReport.SetReportDataSource(queryReportObject);
return queryReport as XtraReport;
}
}
}

View File

@@ -55,6 +55,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="CustomReportCreator.cs" />
<Compile Include="FLSGroupReport.cs">
<SubType>Component</SubType>
</Compile>