138 lines
4.8 KiB
C#
138 lines
4.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.IO;
|
|
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;
|
|
using SKFLeverkusenJuHi;
|
|
|
|
namespace SkfLeverkusenJuHi
|
|
{
|
|
public class CustomReportCreator : DefaultReportCreator
|
|
{
|
|
public override XtraReport CreateQueryReport(long queryOid, string queryReportId)
|
|
{
|
|
if (queryOid == 100)
|
|
return CreateHilfeplanStand(queryOid, queryReportId);
|
|
|
|
return base.CreateQueryReport(queryOid, queryReportId);
|
|
}
|
|
|
|
private XtraReport CreateHilfeplanStand(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)
|
|
{
|
|
DateTime monat = DateTime.Parse(qro.Rows[0].Field1.ToString());
|
|
DateTime start = new DateTime(monat.Year, monat.Month, 1);
|
|
DateTime end = monat.AddMonths(1).AddDays(-1);
|
|
|
|
var ro = FinanceRO.Create(start, end);
|
|
var druck = new HilfeplanStand();
|
|
druck.SetReportDataSource(ro);
|
|
return druck;
|
|
}
|
|
|
|
return new XtraReport();
|
|
}
|
|
|
|
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.InvoiceBase.InvoiceId == "Sammelrechnung")
|
|
{
|
|
var anhang = new ServiceInvoiceReport();
|
|
//var seite1 = new Sammelrechnung();
|
|
var ro = ServiceInvoiceRO.Create(iDC);
|
|
|
|
//seite1.SetReportDataSource(ro);
|
|
//seite1.CreateDocument();
|
|
|
|
if (ro.ServiceInvoicePeriods.Count > 0)
|
|
{
|
|
ro.ServiceInvoicePeriods = ro.ServiceInvoicePeriods.OrderBy(s => s.Customer.LastNameFirstName).ToList();
|
|
foreach (var sip in ro.ServiceInvoicePeriods)
|
|
{
|
|
var newro = ServiceInvoiceRO.Create(iDC);
|
|
newro.ServiceInvoicePeriods = new List<ServiceInvoicePeriodRO>();
|
|
newro.ServiceInvoicePeriods.Add(sip);
|
|
|
|
//var anhang = new ServiceInvoiceReport();
|
|
anhang.SetReportDataSource(newro);
|
|
anhang.CreateDocument();
|
|
}
|
|
}
|
|
|
|
invoiceReport = anhang;
|
|
}
|
|
|
|
else
|
|
{
|
|
IBeWoReport<ServiceInvoiceRO> singleReport = FindReportImp<ServiceInvoiceRO>(iDC.InvoiceBase.InvoiceId);
|
|
|
|
singleReport.SetReportDataSource(ServiceInvoiceRO.Create(iDC));
|
|
((XtraReport)singleReport).CreateDocument();
|
|
invoiceReport = singleReport as XtraReport;
|
|
}
|
|
if (allReports == null)
|
|
allReports = invoiceReport;
|
|
else
|
|
((XtraReport)allReports).Pages.AddRange(invoiceReport.Pages);
|
|
}
|
|
|
|
return allReports as XtraReport;
|
|
}
|
|
}
|
|
}
|