Files
BeWoPlaner/ReportImp/SKFLeverkusen/CustomReportCreator.cs
Kojo 719a07289d SKFLeverkusen: Soziotherapie-Bereich eingerichtet
bei Spitzabrechnungen nur noch SR2 erzeugen
2026-02-20 15:37:51 +01:00

220 lines
7.1 KiB
C#

using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using BeWo.Data.Access;
using BeWo.Data.Entities;
using BeWo.Report;
using BeWo.Report.ReportObjects;
using BeWo.Service.DCEntityMapper;
using BS.Shared.Core;
using DevExpress.XtraReports.UI;
namespace SKFLeverkusen
{
public class CustomReportCreator : DefaultReportCreator
{
public override XtraReport CreateQueryReport(long queryOid, string queryReportId)
{
if (queryOid == 300 || queryOid == 310 || queryOid == 320 || queryOid == 330 || queryOid == 340 || queryOid == 350)
return CreateCustomerReport(queryOid, queryReportId);
return base.CreateQueryReport(queryOid, queryReportId);
}
private XtraReport CreateCustomerReport(long queryOid, string queryReportId)
{
var query = DAOFactory.GenericDAO.LoadByID<Query>(queryOid);
if (query == null)
return new XtraReport();
var path = Path.Combine(TempPath, queryReportId + ".xml");
var table = Utils.XMLDeserialize<DataTable>(path);
var qro = QueryRO.Create(query, table);
if (qro.Rows.Count > 0)
{
long? customerOid = null;
if (qro.Rows[0].Field1 != null && qro.Rows[0].Field1.ToString() != "0")
{
customerOid = Int64.Parse(qro.Rows[0].Field1.ToString());
var c = DAOFactory.GenericDAO.LoadByID<Customer>(customerOid.Value);
var ro = (CustomerDataRO.Create(MapperFactory.CustomerDC_Customer.MapToNewDC(c)));
if (queryOid == 300)
{
var druck = new Betreuungsvertrag();
druck.SetReportDataSource(ro);
return druck;
}
else if (queryOid == 310)
{
var druck = new ABWErstantrag();
druck.SetReportDataSource(ro);
return druck;
}
else if (queryOid == 320)
{
var druck = new ABWFolgeantrag();
druck.SetReportDataSource(ro);
return druck;
}
else if (queryOid == 330)
{
var druck = new ABWAenderungsmitteilung();
druck.SetReportDataSource(ro);
return druck;
}
else if (queryOid == 340)
{
var druck = new Krisenplan();
druck.SetReportDataSource(ro);
return druck;
}
else if (queryOid == 350)
{
var druck = new ABWAufnahmeanzeigeLVR();
druck.SetReportDataSource(ro);
return druck;
}
}
}
return new XtraReport();
}
public override XtraReport CreateSettlementReport(string dcId, long? invoiceBaseOid)
{
return base.CreateSettlementReport(dcId, invoiceBaseOid, true);
}
public override XtraReport CreateServiceOverviewAllCustomersReport(int month, int year, long orgaOid, long empOid, long? serviceCategoryOid, int startDay, int endDay)
{
List<ServicesOverviewRO> lROs = ServicesOverviewRO.Create(month, year, orgaOid, empOid, startDay, endDay, serviceCategoryOid);
if (lROs.Count > 0)
{
var rootReport = CreateServicesOverviewReportForRo(lROs[0], serviceCategoryOid);
if (rootReport.Pages.Count == 0)
{
rootReport.CreateDocument();
}
for (int i = 1; i < lROs.Count; i++)
{
var lNext = CreateServicesOverviewReportForRo(lROs[i], serviceCategoryOid);
if (lNext.Pages.Count == 0)
{
lNext.CreateDocument();
}
rootReport.Pages.AddRange(lNext.Pages);
}
return rootReport;
}
return new XtraReport();
}
public override XtraReport CreateServiceOverviewSingleCustomerReport(long customerOid, int month, int year, long orgaOid, long empOid, long? serviceCategoryOid, int startDay, int endDay)
{
var ro = ServicesOverviewRO.Create(customerOid, month, year, false, orgaOid, empOid, startDay, endDay, serviceCategoryOid);
return CreateServicesOverviewReportForRo(ro, serviceCategoryOid);
}
public override XtraReport CreateServiceOverviewReportForCustomers(IList<long> customerOids, int month, int year, long? orgaOid, long? empOid, long? serviceCategoryOid, int startDay, int endDay, bool nurFehlende)
{
var roList = new List<ServicesOverviewRO>();
foreach (var coid in customerOids)
{
var ro = ServicesOverviewRO.Create(coid, month, year, true, orgaOid ?? 0, empOid ?? 0, startDay, endDay, serviceCategoryOid);
if (ro != null)
{
roList.Add(ro);
}
}
if (roList.Count > 0)
{
var rootReport = CreateServicesOverviewReportForRo(roList[0], serviceCategoryOid);
rootReport.CreateDocument();
for (int i = 1; i < roList.Count; i++)
{
var lNext = CreateServicesOverviewReportForRo(roList[i], serviceCategoryOid);
lNext.CreateDocument();
rootReport.Pages.AddRange(lNext.Pages);
}
return rootReport;
}
return new XtraReport();
}
private XtraReport CreateServicesOverviewReportForRo(ServicesOverviewRO ro, long? serviceCategoryOid)
{
ServicesOverviewRO defaultRo = ServicesOverviewRO.CopyFromRO(ro);
ServicesOverviewRO sozioRo = ServicesOverviewRO.CopyFromRO(ro);
if (ro.Services != null)
{
foreach (ServicesOverviewRO.ServiceDetail s in ro.Services)
{
ServicesOverviewRO.CreateSignatureString(s);
if (s.ServiceCategory.ToLower().Contains("sozio"))
{
sozioRo.Services.Add(s);
}
else
{
defaultRo.Services.Add(s);
}
}
}
XtraReport report = null;
report = AddReportToReport<Quittierungsbeleg>(report, defaultRo);
report = AddReportToReport<LeistungsnachweisSoziotherapie>(report, sozioRo);
if (report == null)
report = new XtraReport();
return report;
}
public override XtraReport CreateReportForServicesOverviewRo(ServicesOverviewRO ro, string reportId)
{
return CreateServicesOverviewReportForRo(ro, null);
}
private XtraReport AddReportToReport<T>(XtraReport report, ServicesOverviewRO ro) where T : XtraReport, IBeWoReport<ServicesOverviewRO>, new()
{
if (ro.Services.Count > 0)
{
if (report == null)
{
report = new T();
((T)report).SetReportDataSource(ro);
}
else
{
if (report.Pages.Count == 0)
{
report.CreateDocument();
}
XtraReport newReport = new T();
((T)newReport).SetReportDataSource(ro);
newReport.CreateDocument();
report.Pages.AddRange(newReport.Pages);
}
}
return report;
}
}
}