144 lines
5.3 KiB
C#
144 lines
5.3 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 LebenshilfeKusel
|
|
{
|
|
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;
|
|
|
|
if (iDC.ServiceInvoicePeriods.Count > 0 && iDC.ServiceInvoicePeriods[0].SupportConceptApprovalPeriod.ServiceCategory != null)
|
|
{
|
|
XtraReport masterReport = new XtraReport();
|
|
masterReport.CreateDocument();
|
|
|
|
var seite1 = new ServiceInvoiceReport();
|
|
var ro = ServiceInvoiceRO.Create(iDC);
|
|
|
|
seite1.SetReportDataSource(ro);
|
|
seite1.CreateDocument();
|
|
|
|
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;
|
|
|
|
var qb = CreateServiceOverviewSingleCustomerReport(cOid, month, year, oOid, 0, null, 1, DateTime.DaysInMonth(year, month));
|
|
qb.CreateDocument();
|
|
|
|
masterReport.Pages.AddRange(seite1.Pages);
|
|
foreach (DevExpress.XtraPrinting.Page item in masterReport.Pages)
|
|
{
|
|
item.AssignWatermark(seite1.Watermark);
|
|
}
|
|
masterReport.Pages.AddRange(qb.Pages);
|
|
invoiceReport = masterReport;
|
|
|
|
}
|
|
else
|
|
{
|
|
IBeWoReport<ServiceInvoiceRO> singleReport = FindReportImp<ServiceInvoiceRO>(iDC.InvoiceBase.InvoiceId);
|
|
var ro = ServiceInvoiceRO.Create(iDC);
|
|
singleReport.SetReportDataSource(ro);
|
|
((XtraReport)singleReport).CreateDocument();
|
|
invoiceReport = singleReport as XtraReport;
|
|
}
|
|
|
|
if (allReports == null)
|
|
{
|
|
allReports = invoiceReport;
|
|
}
|
|
else
|
|
{
|
|
((XtraReport)allReports).Pages.AddRange(invoiceReport.Pages);
|
|
}
|
|
}
|
|
|
|
return allReports as XtraReport;
|
|
}
|
|
|
|
//private XtraReport CreateInvoiceReport(List<ServiceInvoiceDC> invoices)
|
|
//{
|
|
// XtraReport allReports = null;
|
|
// XtraReport report = null;
|
|
|
|
// foreach (var iDC in invoices)
|
|
// {
|
|
// report = new XtraReport();
|
|
// report.CreateDocument();
|
|
|
|
// var seite1 = new ServiceInvoiceReport();
|
|
// var ro = ServiceInvoiceRO.Create(iDC);
|
|
|
|
// seite1.SetReportDataSource(ro);
|
|
// seite1.CreateDocument();
|
|
|
|
// 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;
|
|
|
|
// var qb = CreateServiceOverviewSingleCustomerReport(cOid, month, year, oOid, 0, null, 1, DateTime.DaysInMonth(year, month));
|
|
// qb.CreateDocument();
|
|
|
|
// report.Pages.AddRange(seite1.Pages);
|
|
// report.Pages.AddRange(qb.Pages);
|
|
|
|
// if (allReports == null)
|
|
// {
|
|
// allReports = report;
|
|
// }
|
|
// else
|
|
// {
|
|
// ((XtraReport)allReports).Pages.AddRange(report.Pages);
|
|
// }
|
|
// }
|
|
|
|
// return allReports as XtraReport;
|
|
//}
|
|
}
|
|
}
|
|
|