Files
BeWoPlaner/ReportImp/AdikKleve/ServiceInvoiceReport.cs
2017-09-14 19:03:26 +02:00

99 lines
3.4 KiB
C#

using System;
using System.Linq;
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 AdikKleve
{
public partial class ServiceInvoiceReport : XtraReport, IBeWoReport<ServiceInvoiceRO>
{
public ServiceInvoiceReport()
{
this.InitializeComponent();
}
public void SetReportDataSource(ServiceInvoiceRO pRO)
{
SetFaxNrAndAnsprechpartner(pRO);
StringBuilder sb = new StringBuilder();
if (!String.IsNullOrEmpty(pRO.RecipientOrganisation) && !String.IsNullOrEmpty(pRO.RecipientOrganisation.Trim()))
{
sb.AppendLine(pRO.RecipientOrganisation);
}
if (!String.IsNullOrEmpty(pRO.RecipientContactPerson) && !String.IsNullOrEmpty(pRO.RecipientContactPerson.Trim()))
{
sb.AppendLine(pRO.RecipientContactPerson);
}
if (!String.IsNullOrEmpty(pRO.RecipientDivision) && !String.IsNullOrEmpty(pRO.RecipientDivision.Trim()))
{
sb.AppendLine(pRO.RecipientDivision);
}
if (!String.IsNullOrEmpty(pRO.RecipientStreet) && !String.IsNullOrEmpty(pRO.RecipientStreet.Trim()))
{
sb.AppendLine(pRO.RecipientStreet);
}
if (!String.IsNullOrEmpty(pRO.RecipientPostCodeAndTown) && !String.IsNullOrEmpty(pRO.RecipientPostCodeAndTown.Trim()))
{
sb.Append(pRO.RecipientPostCodeAndTown);
}
lblAddress.Text = sb.ToString();
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);
}
this.bindingSource1.DataSource = pRO;
}
private void SetFaxNrAndAnsprechpartner(ServiceInvoiceRO pRO)
{
String fax = null;
if (pRO.InvoiceBase.RecipientOrganisationOid.HasValue)
{
var org = DAOFactory.GenericDAO.LoadByID<Organisation>(pRO.InvoiceBase.RecipientOrganisationOid.Value);
var contact = org.Contacts.FirstOrDefault(c => c.Type == ContactType.business_Fax);
if (contact != null)
{
fax = contact.Value;
}
if (String.IsNullOrWhiteSpace(pRO.RecipientContactPerson))
{
contact = org.Contacts.FirstOrDefault(c => c.Type == ContactType.ContactPerson);
if (contact != null)
{
pRO.RecipientContactPerson = contact.Value;
}
}
}
if (fax != null)
{
lblFax.Text = String.Format("Fax: {0}", fax);
}
else
{
lblFax.Text = "";
}
}
}
}