Files
BeWoPlaner/ReportImp/BellaDonna/ServiceInvoiceReport.cs

168 lines
6.4 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;
lblRechnungnr.Text = pRO.InvoiceNumber;
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);
if (!String.IsNullOrEmpty(pRO.RecipientOrganisation) && pRO.RecipientOrganisation.Contains("Jugendamt"))
{
lblBetreff.Text = lblBetreff.Text.Replace("#####", "Flexible Erziehungshilfe");
lblAbrechnungszeitraum.Text = lblAbrechnungszeitraum.Text.Replace("Eingliederungshilfe", "wirtschaftliche Jugendhilfe");
lblSender.Text = lblSender.Text.Replace("Nadine Meier", "Stefanie Böcker");
}
else
lblBetreff.Text = lblBetreff.Text.Replace("#####", "Eingliederungshilfe");
this.bindingSource1.DataSource = pRO;
}
private void SetzeAdresse(ServiceInvoiceRO pRO)
{
StringBuilder sb = new StringBuilder();
if (!String.IsNullOrEmpty(pRO.RecipientOrganisation) && pRO.RecipientOrganisation.Contains("Jugendamt"))
{
pRO.RecipientOrganisation = "Jugendamt der Stadt Essen";
pRO.RecipientAddressLine1 = "Wirtschaftliche Jugendhilfe";
pRO.RecipientStreet = "Vereinstr. 2";
pRO.RecipientPostCodeAndTown = "45127 Essen";
pRO.RecipientDivision = null;
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();
}
public static implicit operator RechnungFlex(Rechnung67 v)
{
throw new NotImplementedException();
}
private void ChangeName(object sender, System.ComponentModel.CancelEventArgs e)
{
PrintingSystem.Document.Name = String.Format("Rechnung {0}", lblRechnungnr.Text);
}
}
}