Files
BeWoPlaner/ReportImp/Kette2/ServiceInvoiceReport.cs
2021-05-24 21:40:02 +02:00

135 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 DevExpress.XtraReports.UI;
namespace KetteReports
{
public partial class ServiceInvoiceReport : XtraReport, IBeWoReport<ServiceInvoiceRO>
{
public ServiceInvoiceReport()
{
this.InitializeComponent();
}
public void SetReportDataSource(ServiceInvoiceRO pRO)
{
if (!String.IsNullOrEmpty(pRO.SenderContactPersonMail))
{
pRO.SenderContactPersonMail = pRO.SenderContactPersonMail.Replace("E-Mail:", "").Trim();
}
if (!String.IsNullOrEmpty(pRO.SenderContactPersonPhone))
{
pRO.SenderContactPersonPhone = pRO.SenderContactPersonPhone.Replace("Tel.:", "").Trim();
}
if (!String.IsNullOrEmpty(pRO.SenderContactPersonFax))
{
pRO.SenderContactPersonFax = pRO.SenderContactPersonFax.Replace("Fax:", "").Trim();
}
//Rechnung an Sozialamt Bergisch Gladbach, Gybowitch und Herrn Schulze. Adresse Abrechnungsbetreuungsleistung für steht kein Name
SetzeAdresse(pRO);
DateTime start = pRO.AccountingPeriodStart;
DateTime end = pRO.AccountingPeriodEnd;
if (start.Month == end.Month && start.Year == end.Year)
{
lblAbrechnungszeitraum.Text = String.Format("hiermit berechnen wir für den Monat {0:MMMM yyyy} folgende erbrachte Tätigkeiten:", start);
}
else
{
lblAbrechnungszeitraum.Text = String.Format("hiermit berechnen wir für den Zeitraum {0:MMMM yyyy} - {1:MMMM yyyy} folgende erbrachte Tätigkeiten:", start, end);
}
String notice = String.Format("Bitte überweisen Sie den geforderten Betrag bis zum {0:dd.MM.yyyy} auf die unten aufgeführte Bankverbindung.", pRO.InvoiceDateTime.Value.AddDays(21));
notice +=
"\nSollten Sie dem Lastschriftverfahren zugestimmt haben, wird der Rechnungsbetrag in den nächsten Tagen von ihrem Konto eingezogen.\nUm Ihre Überweisung besser zuordnen zu können bitten wir sie um die Angabe des Leistungsmonats, der Kundennummer und der Rechnungsnummer.";
if (String.IsNullOrEmpty(pRO.Notice))
{
pRO.Notice = notice;
}
else
{
pRO.Notice += "\n\n" + notice;
}
this.bindingSource1.DataSource = pRO;
}
private void SetzeAdresse(ServiceInvoiceRO pRO)
{
if (pRO.CustomerOid.HasValue)
{
Customer c = DAOFactory.GenericDAO.LoadByID<Customer>(pRO.CustomerOid.Value);
if (c.Person.InvoiceAddress != null)
{
StringBuilder sb = new StringBuilder();
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());
}
lblAdresse.Text = sb.ToString();
return;
}
}
SetzeDefaultAdresse(pRO);
}
private void SetzeDefaultAdresse(ServiceInvoiceRO pRO)
{
StringBuilder sb = new StringBuilder();
if (!String.IsNullOrEmpty(pRO.RecipientAddressLine1))
{
if (pRO.RecipientAddressLine1.StartsWith("Herrn "))
{
pRO.RecipientAddressLine1 = pRO.RecipientAddressLine1.Replace("Herrn", "Herr");
}
pRO.RecipientOrganisation = pRO.RecipientAddressLine1;
}
if (!String.IsNullOrEmpty(pRO.RecipientOrganisation))
{
sb.AppendLine(pRO.RecipientOrganisation);
}
if (!String.IsNullOrEmpty(pRO.RecipientContactPerson))
{
sb.AppendLine(pRO.RecipientContactPerson);
}
if (!String.IsNullOrEmpty(pRO.RecipientDivision))
{
sb.AppendLine(pRO.RecipientDivision);
}
if (!String.IsNullOrEmpty(pRO.RecipientStreet))
{
sb.AppendLine(pRO.RecipientStreet);
}
if (!String.IsNullOrEmpty(pRO.RecipientPostCodeAndTown))
{
sb.AppendLine(pRO.RecipientPostCodeAndTown);
}
lblAdresse.Text = sb.ToString();
}
}
}