144 lines
5.2 KiB
C#
144 lines
5.2 KiB
C#
using System;
|
|
using System.Text;
|
|
using BeWo.Data.Access;
|
|
using BeWo.Data.Entities;
|
|
using BeWo.Report;
|
|
using BeWo.Report.ReportObjects;
|
|
using BS.Shared;
|
|
using DevExpress.XtraReports.UI;
|
|
|
|
namespace BellaDonna
|
|
{
|
|
public partial class RechnungFlex : XtraReport, IBeWoReport<ServiceInvoiceRO>
|
|
{
|
|
public RechnungFlex()
|
|
{
|
|
this.InitializeComponent();
|
|
}
|
|
|
|
public void SetReportDataSource(ServiceInvoiceRO pRO)
|
|
{
|
|
SetzeAdresse(pRO);
|
|
|
|
|
|
DateTime start = pRO.AccountingPeriodStart;
|
|
DateTime end = pRO.AccountingPeriodEnd;
|
|
|
|
String text = "";
|
|
if (start.Month == end.Month && start.Year == end.Year)
|
|
{
|
|
text = String.Format("Monat {0:MMMM yyyy}", start);
|
|
}
|
|
else
|
|
{
|
|
text = String.Format("Zeitraum {0:MMMM yyyy} - {1:MMMM yyyy}", start, end);
|
|
}
|
|
lblAbrechnungszeitraum.Text = lblAbrechnungszeitraum.Text.Replace("#####", text);
|
|
|
|
this.bindingSource1.DataSource = pRO;
|
|
}
|
|
|
|
private void SetzeAdresse(ServiceInvoiceRO pRO)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
if (!String.IsNullOrEmpty(pRO.RecipientOrganisation) && pRO.RecipientOrganisation.Contains("Jugendamt"))
|
|
{
|
|
if (pRO.InvoiceBase.SupportConceptCostBearerRelDc != null)
|
|
{
|
|
var c2sOid = pRO.InvoiceBase.SupportConceptCostBearerRelDc.CostBearer2SupportConceptOid;
|
|
if (c2sOid.HasValue)
|
|
{
|
|
var c2s = DAOFactory.GenericDAO.LoadByID<CostBearer2SupportConcept>(c2sOid.Value);
|
|
var p = c2s.CostBearerContactPerson;
|
|
if (p != null)
|
|
{
|
|
pRO.RecipientContactPerson = "Frau ";
|
|
if (p.Sex.HasValue && p.Sex.Value == Sex.Male)
|
|
{
|
|
pRO.RecipientContactPerson = "Herr ";
|
|
}
|
|
|
|
pRO.RecipientContactPerson += p.FirstNameLastName;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
long? customerOid = pRO.CustomerOid;
|
|
if (!customerOid.HasValue)
|
|
{
|
|
if (pRO.InvoiceBase.SupportConceptCostBearerRelDc != null)
|
|
{
|
|
var c2sOid = pRO.InvoiceBase.SupportConceptCostBearerRelDc.CostBearer2SupportConceptOid;
|
|
if (c2sOid.HasValue)
|
|
{
|
|
var c2s = DAOFactory.GenericDAO.LoadByID<CostBearer2SupportConcept>(c2sOid.Value);
|
|
customerOid = c2s.SupportConcept.Customer.Oid;
|
|
}
|
|
}
|
|
|
|
}
|
|
if (customerOid.HasValue)
|
|
{
|
|
Customer c = DAOFactory.GenericDAO.LoadByID<Customer>(customerOid.Value);
|
|
|
|
if (c.Person.InvoiceAddress != null)
|
|
{
|
|
if (!String.IsNullOrEmpty(c.Person.InvoiceAddress.AddressLine1))
|
|
{
|
|
sb.AppendLine(c.Person.InvoiceAddress.AddressLine1);
|
|
}
|
|
if (!String.IsNullOrEmpty(c.Person.InvoiceAddress.AddressLine2))
|
|
{
|
|
sb.AppendLine(c.Person.InvoiceAddress.AddressLine2);
|
|
}
|
|
if (!String.IsNullOrEmpty(c.Person.InvoiceAddress.Street))
|
|
{
|
|
sb.AppendLine(c.Person.InvoiceAddress.Street);
|
|
}
|
|
if (!String.IsNullOrEmpty(c.Person.InvoiceAddress.PostalCode) || !String.IsNullOrEmpty(c.Person.InvoiceAddress.Town))
|
|
{
|
|
sb.AppendLine(String.Format("{0} {1}", c.Person.InvoiceAddress.PostalCode, c.Person.InvoiceAddress.Town).Trim());
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
if (sb.Length == 0)
|
|
{
|
|
if (!String.IsNullOrEmpty(pRO.RecipientOrganisation))
|
|
{
|
|
sb.AppendLine(pRO.RecipientOrganisation);
|
|
}
|
|
if (!String.IsNullOrEmpty(pRO.RecipientAddressLine1))
|
|
{
|
|
sb.AppendLine(pRO.RecipientAddressLine1);
|
|
}
|
|
if (!String.IsNullOrEmpty(pRO.RecipientDivision))
|
|
{
|
|
sb.AppendLine(pRO.RecipientDivision);
|
|
}
|
|
|
|
if (!String.IsNullOrEmpty(pRO.RecipientContactPerson))
|
|
{
|
|
sb.AppendLine(pRO.RecipientContactPerson);
|
|
}
|
|
|
|
if (!String.IsNullOrEmpty(pRO.RecipientStreet))
|
|
{
|
|
sb.AppendLine(pRO.RecipientStreet);
|
|
}
|
|
|
|
if (!String.IsNullOrEmpty(pRO.RecipientPostCodeAndTown))
|
|
{
|
|
sb.AppendLine(pRO.RecipientPostCodeAndTown);
|
|
}
|
|
}
|
|
|
|
lblAdresse.Text = sb.ToString();
|
|
}
|
|
}
|
|
} |