using System; using System.Text; using BeWo.Data.Entities; using BeWo.Report; using BeWo.Report.ReportObjects; using BS.Shared; using DevExpress.XtraReports.UI; namespace WhbRefrath { public partial class ServiceInvoiceReport : XtraReport, IBeWoReport { public ServiceInvoiceReport() { this.InitializeComponent(); } public void SetReportDataSource(ServiceInvoiceRO pRO) { DateTime start = pRO.AccountingPeriodStart; DateTime end = pRO.AccountingPeriodEnd; StringBuilder sb = new StringBuilder(); if (!String.IsNullOrEmpty(pRO.RecipientOrganisation)) { sb.AppendLine(pRO.RecipientOrganisation); } if (!String.IsNullOrEmpty(pRO.RecipientContactPerson) && pRO.RecipientOrganisation != pRO.CustomerName) { 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.RecipientPoBox)) { sb.AppendLine(String.Format("Postfach {0}", pRO.RecipientPoBox)); } if (!String.IsNullOrEmpty(pRO.RecipientPostCodeAndTown)) { sb.AppendLine(pRO.RecipientPostCodeAndTown); } lblAdresse.Text = sb.ToString(); if (pRO.CustomerSalutation == "Herr") pRO.CustomerSalutation = "Herrn"; if (pRO.RecipientOrganisation == pRO.CustomerName) { if (pRO.ServiceInvoicePeriods != null && pRO.ServiceInvoicePeriods.Count > 0) { foreach (var p in pRO.ServiceInvoicePeriods) { if (p.ServiceInvoiceItems != null && p.ServiceInvoiceItems.Count > 0) { foreach (var i in p.ServiceInvoiceItems) { i.ServiceDescription = "hauswirtschaftliche Hilfen"; } } } } lblBetreff.Visible = false; } SetzeAnrede(pRO); this.bindingSource1.DataSource = pRO; } private void SetzeAnrede(ServiceInvoiceRO pRO) { String anrede = "Sehr geehrte Damen und Herren,"; var p = GetKontaktPerson(pRO); if (p != null) { if (p.Sex.HasValue && p.Sex.Value == Sex.Male) { anrede = "Sehr geehrter Herr " + p.LastName + ","; } else if (p.Sex.HasValue && p.Sex.Value == Sex.Female) { anrede = "Sehr geehrte Frau " + p.LastName + ","; } } lblAnrede.Text = anrede; } private Person GetKontaktPerson(ServiceInvoiceRO pRO) { if (pRO.ServiceInvoicePeriods.Count > 0) { var c2s = pRO.ServiceInvoicePeriods[0].CostBearer2SupportConcept; return c2s.CostBearerContactPerson; } return null; } } }