175 lines
5.2 KiB
C#
175 lines
5.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using BeWo.Data.Access;
|
|
using BeWo.Data.Entities;
|
|
using BeWo.Report;
|
|
using BeWo.Report.ReportObjects;
|
|
using DevExpress.XtraReports.Design;
|
|
using DevExpress.XtraReports.UI;
|
|
|
|
namespace CaritasAhlen
|
|
{
|
|
public class CustomReportCreator : DefaultReportCreator
|
|
{
|
|
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);
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
private XtraReport CreateServicesOverviewReportForRo(ServicesOverviewRO ro, long? serviceCategoryOid)
|
|
{
|
|
IBeWoReport<ServicesOverviewRO> report = null;
|
|
|
|
bool is67 = false;
|
|
|
|
String kt = "";
|
|
if (!String.IsNullOrWhiteSpace(ro.Costbearer))
|
|
{
|
|
kt = ro.Costbearer.Trim();
|
|
}
|
|
|
|
if (kt.Contains("67"))
|
|
{
|
|
is67 = true;
|
|
}
|
|
|
|
if (!is67)
|
|
{
|
|
foreach (var s in ro.Services)
|
|
{
|
|
if (s.ServiceCategory.Contains("§67"))
|
|
{
|
|
is67 = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (is67)
|
|
{
|
|
return Create67ReportForRo(ro, serviceCategoryOid);
|
|
}
|
|
|
|
report = new CaritasAhlen.Stundenzettel();
|
|
report.SetReportDataSource(ro);
|
|
|
|
return report as XtraReport;
|
|
}
|
|
|
|
private XtraReport Create67ReportForRo(ServicesOverviewRO ro, long? serviceCategoryOid)
|
|
{
|
|
XtraReport report = null;
|
|
|
|
ServicesOverviewRO direktRo = ServicesOverviewRO.CopyFromRO(ro);
|
|
direktRo.SupportConceptCostBearer = ro.SupportConceptCostBearer;
|
|
ServicesOverviewRO indirektRo = ServicesOverviewRO.CopyFromRO(ro);
|
|
indirektRo.SupportConceptCostBearer = ro.SupportConceptCostBearer;
|
|
|
|
if (ro.Services != null)
|
|
{
|
|
foreach (ServicesOverviewRO.ServiceDetail s in ro.Services)
|
|
{
|
|
if (s.IsBillable)
|
|
{
|
|
if (s.ServiceCategory.Contains("§67"))
|
|
{
|
|
indirektRo.Services.Add(s);
|
|
}
|
|
else
|
|
{
|
|
direktRo.Services.Add(s);
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
report = AddReportToReport(report, direktRo, false);
|
|
report = AddReportToReport(report, indirektRo, true);
|
|
|
|
//report = AddReportToReport(report, eingliederungshilfe);
|
|
|
|
if (report == null)
|
|
report = new XtraReport();
|
|
return report;
|
|
}
|
|
|
|
private XtraReport AddReportToReport(XtraReport report, ServicesOverviewRO ro, bool is67)
|
|
{
|
|
if (ro.Services.Count > 0)
|
|
{
|
|
if (report == null)
|
|
{
|
|
if (is67)
|
|
{
|
|
report = new Stundenzettel67();
|
|
((Stundenzettel67)report).SetReportDataSource(ro);
|
|
}
|
|
else
|
|
{
|
|
report = new Stundenzettel67Direkt();
|
|
((Stundenzettel67Direkt)report).SetReportDataSource(ro);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (report.Pages.Count == 0)
|
|
{
|
|
report.CreateDocument();
|
|
}
|
|
|
|
XtraReport newReport = null;
|
|
if (is67)
|
|
{
|
|
newReport = new Stundenzettel67();
|
|
((Stundenzettel67)newReport).SetReportDataSource(ro);
|
|
}
|
|
else
|
|
{
|
|
newReport = new Stundenzettel67Direkt();
|
|
((Stundenzettel67Direkt)newReport).SetReportDataSource(ro);
|
|
}
|
|
if (newReport != null)
|
|
{
|
|
newReport.CreateDocument();
|
|
report.Pages.AddRange(newReport.Pages);
|
|
}
|
|
}
|
|
}
|
|
return report;
|
|
}
|
|
}
|
|
}
|