using System; using BeWo.Data.Access; using BeWo.Data.Entities; using BeWo.Report; using BeWo.Report.ReportObjects; using DevExpress.XtraReports.UI; namespace BfpDus { public partial class ServiceInvoiceReport : XtraReport, IBeWoReport { private ServiceInvoiceRO ro; public ServiceInvoiceReport() { this.InitializeComponent(); } public ServiceInvoiceRO ServiceInvoiceRo { get { return ro; } } public void SetReportDataSource(ServiceInvoiceRO pRO) { ro = pRO; DateTime start = pRO.AccountingPeriodStart; DateTime end = pRO.AccountingPeriodEnd; if (pRO.InvoiceBase != null && pRO.InvoiceBase.SupportConceptCostBearerRelDc != null) { if (pRO.InvoiceBase.SupportConceptCostBearerRelDc.StartDate.HasValue) { start = pRO.InvoiceBase.SupportConceptCostBearerRelDc.StartDate.Value; } if (pRO.InvoiceBase.SupportConceptCostBearerRelDc.EndDate.HasValue) { end = pRO.InvoiceBase.SupportConceptCostBearerRelDc.EndDate.Value; } } if (pRO.RecipientOrganisation == "Privat") { pRO.RecipientOrganisation = ""; if (pRO.InvoiceBase != null) { var cOid = pRO.InvoiceBase?.RecipientCustomerOid; if (cOid.HasValue) { var c = DAOFactory.GenericDAO.LoadByID(cOid.Value); if (c.Person.Sex.HasValue) { if (c.Person.Sex.Value == BS.Shared.Sex.Male) { pRO.RecipientOrganisation = "Herr"; } else if (c.Person.Sex.Value == BS.Shared.Sex.Female) { pRO.RecipientOrganisation = "Frau"; } } } } } foreach (var sip in pRO.ServiceInvoicePeriods) { int index = 1; foreach (var item in sip.ServiceInvoiceItems) { if (item.ServiceDescription.Contains("Fehl")) { item.UnitDescription = item.ServiceDescription; } else { item.UnitDescription = "Stunden"; } if (index++ == 1) { item.ServiceDescription = String.Format("Monat {0:yyyy.MM}", pRO.AccountingPeriodStart); } else { item.ServiceDescription = ""; } } } //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("Zeitraum von {0:MMMM yyyy} bis {1:MMMM yyyy} folgende erbrachte Tätigkeiten:", start, end); //} this.bindingSource1.DataSource = pRO; } } }