151 lines
6.0 KiB
C#
151 lines
6.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using BeWo.Data.Access;
|
|
using BeWo.Data.Entities;
|
|
using BeWo.Report;
|
|
using BeWo.Report.ReportObjects;
|
|
using BeWo.Service.DCEntityMapper;
|
|
using BS.Shared.DataContracts;
|
|
using DevExpress.XtraReports.UI;
|
|
|
|
namespace AsSozialeDienstleistungenEV
|
|
{
|
|
public class CustomReportCreator : DefaultReportCreator
|
|
{
|
|
|
|
public override XtraReport CreateServiceInvoiceReport(string dcIds, long? invoiceBaseOid)
|
|
{
|
|
if (String.IsNullOrEmpty(dcIds) && invoiceBaseOid.HasValue)
|
|
{
|
|
var serviceInvoice = DAOFactory.SearchDAO.GetServiceInvoiceByInvoiceBaseOid(invoiceBaseOid.Value);
|
|
dcIds = String.Format("{0}", serviceInvoice.Oid);
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(dcIds))
|
|
{
|
|
|
|
var dcList = new List<ServiceInvoiceDC>();
|
|
var dcidStrs = dcIds.Split(';');
|
|
|
|
foreach (var oidStr in dcidStrs)
|
|
{
|
|
var oid = long.Parse(oidStr);
|
|
var invoice = DAOFactory.GenericDAO.LoadByID<ServiceInvoice>(oid);
|
|
var dc = MapperFactory.ServiceInvoiceDC_ServiceInvoice.MapToNewDC(invoice);
|
|
dcList.Add(dc);
|
|
}
|
|
|
|
return CreateInvoiceReport(dcList);
|
|
}
|
|
return new XtraReport();
|
|
}
|
|
|
|
private XtraReport CreateInvoiceReport(List<ServiceInvoiceDC> invoices)
|
|
{
|
|
XtraReport allReports = null;
|
|
|
|
foreach (var iDC in invoices)
|
|
{
|
|
XtraReport invoiceReport = null;
|
|
IBeWoReport<ServiceInvoiceRO> seite1 = FindReportImp<ServiceInvoiceRO>(iDC.InvoiceBase.InvoiceId);
|
|
|
|
if (iDC.ServiceInvoicePeriods.Count > 0 && iDC.ServiceInvoicePeriods[0].SupportConceptApprovalPeriod.ServiceCategory != null)
|
|
{
|
|
var ro = ServiceInvoiceRO.Create(iDC);
|
|
seite1.SetReportDataSource(ro);
|
|
((XtraReport)seite1).CreateDocument();
|
|
invoiceReport = seite1 as XtraReport;
|
|
|
|
int month = iDC.InvoiceBase.AccountingPeriodStart.Value.Month;
|
|
int year = iDC.InvoiceBase.AccountingPeriodStart.Value.Year;
|
|
long cOid = iDC.InvoiceBase.SupportConceptCostBearerRelDc.SupportConcept.Customer.CustomerOid;
|
|
long oOid = iDC.InvoiceBase.RecipientOrganisationOid ?? 0;
|
|
|
|
while (month <= iDC.InvoiceBase.AccountingPeriodEnd.Value.Month)
|
|
{
|
|
var qb = CreateServiceOverviewSingleCustomerReport(cOid, month, year, oOid, 0, null, 1, DateTime.DaysInMonth(year, month));
|
|
qb.CreateDocument();
|
|
|
|
invoiceReport.Pages.AddRange(qb.Pages);
|
|
month++;
|
|
}
|
|
}
|
|
if (invoiceReport == null)
|
|
{
|
|
var ro = ServiceInvoiceRO.Create(iDC);
|
|
seite1.SetReportDataSource(ro);
|
|
((XtraReport)seite1).CreateDocument();
|
|
invoiceReport = seite1 as XtraReport;
|
|
}
|
|
if (allReports == null)
|
|
{
|
|
allReports = invoiceReport;
|
|
}
|
|
else
|
|
{
|
|
((XtraReport)allReports).Pages.AddRange(invoiceReport.Pages);
|
|
}
|
|
}
|
|
|
|
return allReports as 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);
|
|
var reports = CreateServicesOverviewReportsForRo(ro, serviceCategoryOid);
|
|
if (reports.Count == 1)
|
|
{
|
|
return reports[0];
|
|
}
|
|
if (reports.Count > 1)
|
|
{
|
|
var rootReport = reports[0];
|
|
rootReport.CreateDocument();
|
|
|
|
for (int i = 1; i < reports.Count; i++)
|
|
{
|
|
var lNext = reports[i];
|
|
lNext.CreateDocument();
|
|
rootReport.Pages.AddRange(lNext.Pages);
|
|
}
|
|
return rootReport;
|
|
}
|
|
return new XtraReport();
|
|
}
|
|
|
|
private IList<XtraReport> CreateServicesOverviewReportsForRo(ServicesOverviewRO ro, long? serviceCategoryOid)
|
|
{
|
|
IList<XtraReport> reports = new List<XtraReport>();
|
|
|
|
if (!TemplateOid.HasValue || TemplateOid.HasValue && TemplateOid == 1)
|
|
{
|
|
IBeWoReport<ServicesOverviewRO> report = new AsSozialeDienstleistungenEV.Taetigkeitsnachweis();
|
|
report.SetReportDataSource(ro);
|
|
reports.Add(report as XtraReport);
|
|
}
|
|
|
|
else if (TemplateOid.HasValue && TemplateOid.Value == 2)
|
|
{
|
|
IBeWoReport<ServicesOverviewRO> report = new AsSozialeDienstleistungenEV.TaetigkeitsnachweisMitUnterschrift();
|
|
report.SetReportDataSource(ro);
|
|
reports.Add(report as XtraReport);
|
|
}
|
|
else if (TemplateOid.HasValue && TemplateOid.Value == 3)
|
|
{
|
|
IBeWoReport<ServicesOverviewRO> report = new AsSozialeDienstleistungenEV.LeistungsnachweisWirtschaftlDienst();
|
|
report.SetReportDataSource(ro);
|
|
reports.Add(report as XtraReport);
|
|
}
|
|
else if (TemplateOid.HasValue && TemplateOid.Value == 4)
|
|
{
|
|
IBeWoReport<ServicesOverviewRO> report = new AsSozialeDienstleistungenEV.LeistungnachweisMonatsbericht();
|
|
report.SetReportDataSource(ro);
|
|
reports.Add(report as XtraReport);
|
|
}
|
|
return reports;
|
|
}
|
|
}
|
|
}
|
|
|