Files
BeWoPlaner/ReportImp/BfpDus/CustomReportCreator.cs

291 lines
13 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 BeWo.Service.DCEntityMapper;
using BS.Shared.DataContracts;
using DevExpress.XtraReports.UI;
namespace BfpDus
{
public class CustomReportCreator : DefaultReportCreator
{
public override XtraReport CreateSettlementReport(string dcId, long? invoiceBaseOid)
{
var subreport = base.CreateSettlementReport(dcId, invoiceBaseOid);
StringBuilder anschrift = new StringBuilder();
StringBuilder ansprechpartner = new StringBuilder();
if (subreport is BfpDus.Alt.Spitzabrechnung)
{
var treport = subreport as BfpDus.Alt.Spitzabrechnung;
if (treport != null)
{
ansprechpartner.AppendLine(treport.SettlementRo.InvoiceDate);
ansprechpartner.AppendLine();
ansprechpartner.AppendLine("Frau Jondral");
ansprechpartner.AppendLine("Tel.: 0211/962 90 200");
ansprechpartner.AppendLine("Fax.: 0211/962 90 207");
ansprechpartner.Append("jondral@bfp-dus.de");
if (!String.IsNullOrEmpty(treport.SettlementRo.RecipientOrganisation))
{
anschrift.AppendLine(treport.SettlementRo.RecipientOrganisation);
}
if (!String.IsNullOrEmpty(treport.SettlementRo.RecipientContactPerson))
{
anschrift.AppendLine(treport.SettlementRo.RecipientContactPerson);
}
if (!String.IsNullOrEmpty(treport.SettlementRo.RecipientDivision))
{
anschrift.AppendLine(treport.SettlementRo.RecipientDivision);
}
if (!String.IsNullOrEmpty(treport.SettlementRo.RecipientStreet))
{
anschrift.AppendLine(treport.SettlementRo.RecipientStreet);
}
if (!String.IsNullOrEmpty(treport.SettlementRo.RecipientPostCodeAndTown))
{
anschrift.AppendLine(treport.SettlementRo.RecipientPostCodeAndTown);
}
}
}
else if (subreport is BfpDus.Spitzabrechnung)
{
var treport = subreport as BfpDus.Spitzabrechnung;
if (treport != null)
{
ansprechpartner.AppendLine(String.Format("{0:dd.MM.yyyy}", treport.SettlementRo.InvoiceDate));
ansprechpartner.AppendLine();
ansprechpartner.AppendLine("Frau Jondral");
ansprechpartner.AppendLine("Tel.: 0211/962 90 200");
ansprechpartner.AppendLine("Fax.: 0211/962 90 207");
ansprechpartner.Append("jondral@bfp-dus.de");
if (!String.IsNullOrEmpty(treport.SettlementRo.RecipientOrganisation))
{
anschrift.AppendLine(treport.SettlementRo.RecipientOrganisation);
}
if (!String.IsNullOrEmpty(treport.SettlementRo.RecipientContactPerson))
{
anschrift.AppendLine(treport.SettlementRo.RecipientContactPerson);
}
if (!String.IsNullOrEmpty(treport.SettlementRo.RecipientDivision))
{
anschrift.AppendLine(treport.SettlementRo.RecipientDivision);
}
if (!String.IsNullOrEmpty(treport.SettlementRo.RecipientStreet))
{
anschrift.AppendLine(treport.SettlementRo.RecipientStreet);
}
if (!String.IsNullOrEmpty(treport.SettlementRo.RecipientPostCodeAndTown))
{
anschrift.AppendLine(treport.SettlementRo.RecipientPostCodeAndTown);
}
}
}
var report = new Briefkopf();
report.SetSubReport(subreport, anschrift.ToString(), ansprechpartner.ToString());
report.DisplayName = "Spitzabrechnung";
return report;
}
public override XtraReport CreateCustomerInvoiceReport(long invoiceOid)
{
var subreport = base.CreateCustomerInvoiceReport(invoiceOid);
StringBuilder anschrift = new StringBuilder();
StringBuilder ansprechpartner = new StringBuilder();
var treport = subreport as BfpDus.InvoiceCustomerReport;
if (treport != null)
{
ansprechpartner.AppendLine(treport.InvoiceCustomerRo.InvoiceDate);
ansprechpartner.AppendLine();
ansprechpartner.AppendLine("Frau Jondral");
ansprechpartner.AppendLine("Tel.: 0211/962 90 200");
ansprechpartner.AppendLine("Fax.: 0211/962 90 207");
ansprechpartner.Append("jondral@bfp-dus.de");
if (!String.IsNullOrEmpty(treport.InvoiceCustomerRo.RecipientOrganisation))
{
anschrift.AppendLine(treport.InvoiceCustomerRo.RecipientOrganisation);
}
if (!String.IsNullOrEmpty(treport.InvoiceCustomerRo.RecipientDivision))
{
anschrift.AppendLine(treport.InvoiceCustomerRo.RecipientDivision);
}
if (!String.IsNullOrEmpty(treport.InvoiceCustomerRo.RecipientSalutationAddressField))
{
anschrift.AppendLine(treport.InvoiceCustomerRo.RecipientSalutationAddressField);
}
if (!String.IsNullOrEmpty(treport.InvoiceCustomerRo.RecipientFirstName) || !String.IsNullOrEmpty(treport.InvoiceCustomerRo.RecipientLastName))
{
anschrift.AppendLine(String.Format("{0} {1}", treport.InvoiceCustomerRo.RecipientFirstName, treport.InvoiceCustomerRo.RecipientLastName).Trim());
}
if (!String.IsNullOrEmpty(treport.InvoiceCustomerRo.RecipientStreet))
{
anschrift.AppendLine(treport.InvoiceCustomerRo.RecipientStreet);
}
if (!String.IsNullOrEmpty(treport.InvoiceCustomerRo.RecipientPostCode) || !String.IsNullOrEmpty(treport.InvoiceCustomerRo.RecipientTown))
{
anschrift.AppendLine(String.Format("{0} {1}", treport.InvoiceCustomerRo.RecipientPostCode, treport.InvoiceCustomerRo.RecipientTown).Trim());
}
}
var report = new Briefkopf();
report.SetSubReport(subreport, anschrift.ToString(), ansprechpartner.ToString());
report.DisplayName = "Rechnung";
return report;
}
//public override XtraReport CreateServiceInvoiceReport(string dcIds, long? invoiceBaseOid)
//{
// XtraReport allReports = null;
// if (String.IsNullOrEmpty(dcIds) && invoiceBaseOid.HasValue)
// {
// var serviceInvoice = DAOFactory.SearchDAO.GetServiceInvoiceByInvoiceBaseOid(invoiceBaseOid.Value);
// dcIds = String.Format("{0}", serviceInvoice.Oid);
// }
// if (!string.IsNullOrEmpty(dcIds))
// {
// var serviceInvoiceOid2CostbearerId = new Dictionary<long, string>();
// 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);
// if (serviceInvoiceOid2CostbearerId.ContainsKey(oid))
// continue;
// if (!String.IsNullOrEmpty(invoice.InvoiceBase.InvoiceId))
// serviceInvoiceOid2CostbearerId.Add(oid, invoice.InvoiceBase.InvoiceId);
// else
// {
// foreach (var period in invoice.ServiceInvoicePeriodList)
// {
// try
// {
// if (period.SupportConceptApprovalPeriod != null)
// {
// AddCostBearerIdToDict(oid, serviceInvoiceOid2CostbearerId,
// period.SupportConceptApprovalPeriod.CostBearer2SupportConcept);
// }
// foreach (var item in period.InvoiceItemList)
// {
// if (item.SupportConceptApprovalPeriodOid.HasValue)
// {
// var approvalPeriod =
// DAOFactory.GenericDAO.LoadByID<SupportConceptApprovalPeriod>(item.SupportConceptApprovalPeriodOid.Value);
// if (approvalPeriod.CostBearer2SupportConcept != null)
// {
// AddCostBearerIdToDict(oid, serviceInvoiceOid2CostbearerId, approvalPeriod.CostBearer2SupportConcept);
// }
// }
// }
// }
// catch (Exception)
// {
// //ignore
// }
// }
// }
// }
// foreach (var iDC in dcList)
// {
// String reportId = null;
// if (serviceInvoiceOid2CostbearerId.ContainsKey(iDC.ServiceInvoiceOid.Value))
// reportId = serviceInvoiceOid2CostbearerId[iDC.ServiceInvoiceOid.Value];
// IBeWoReport<ServiceInvoiceRO> singleReport = FindReportImp<ServiceInvoiceRO>(reportId);
// singleReport.SetReportDataSource(ServiceInvoiceRO.Create(iDC));
// var briefkopf = CreateReportMitBriefkopf(singleReport);
// if (allReports == null)
// allReports = briefkopf;
// else
// allReports.Pages.AddRange(briefkopf.Pages);
// }
// }
// allReports.DisplayName = "Rechnung";
// allReports.CreateDocument();
// return allReports;
//}
private Briefkopf CreateReportMitBriefkopf(IBeWoReport<ServiceInvoiceRO> subreport)
{
StringBuilder anschrift = new StringBuilder();
StringBuilder ansprechpartner = new StringBuilder();
var treport = subreport as BfpDus.ServiceInvoiceReport;
if (treport != null)
{
ansprechpartner.AppendLine(treport.ServiceInvoiceRo.InvoiceDate);
ansprechpartner.AppendLine();
ansprechpartner.AppendLine("Frau Jondral");
ansprechpartner.AppendLine("Tel.: 0211/962 90 200");
ansprechpartner.AppendLine("Fax.: 0211/962 90 207");
ansprechpartner.Append("jondral@bfp-dus.de");
if (!String.IsNullOrEmpty(treport.ServiceInvoiceRo.RecipientOrganisation))
{
anschrift.AppendLine(treport.ServiceInvoiceRo.RecipientOrganisation);
}
if (!String.IsNullOrEmpty(treport.ServiceInvoiceRo.RecipientContactPerson))
{
anschrift.AppendLine(treport.ServiceInvoiceRo.RecipientContactPerson);
}
if (!String.IsNullOrEmpty(treport.ServiceInvoiceRo.RecipientDivision))
{
anschrift.AppendLine(treport.ServiceInvoiceRo.RecipientDivision);
}
if (!String.IsNullOrEmpty(treport.ServiceInvoiceRo.RecipientStreet))
{
anschrift.AppendLine(treport.ServiceInvoiceRo.RecipientStreet);
}
if (!String.IsNullOrEmpty(treport.ServiceInvoiceRo.RecipientPostCodeAndTown))
{
anschrift.AppendLine(treport.ServiceInvoiceRo.RecipientPostCodeAndTown);
}
}
var report = new Briefkopf();
report.SetSubReport(subreport as XtraReport, anschrift.ToString(), ansprechpartner.ToString());
return report;
}
}
}