Files
BeWoPlaner/ReportImp/BeWoSchillingReports/ServicesOverviewReportNeu.cs
2023-06-06 12:31:57 +02:00

108 lines
3.5 KiB
C#

using System;
using BeWo.Data.Access;
using BeWo.Data.Entities;
using BeWo.Report;
using BeWo.Report.ReportObjects;
using BeWo.Service.DCEntityMapper;
namespace BeWoSchillingReports
{
public partial class Quittierungsbeleg : DevExpress.XtraReports.UI.XtraReport, IBeWoReport<ServicesOverviewRO>
{
public Quittierungsbeleg()
{
InitializeComponent();
}
public void SetReportDataSource(ServicesOverviewRO pRO)
{
var customer = MapperFactory.CustomerDC_Customer.MapToNewDC(DAOFactory.GenericDAO.GetByID<Customer>(pRO.CustomerOid));
string betreuungsform = "";
if (customer != null)
{
if (customer.CustomerCareTypes != null)
{
for (int i = 0; i < customer.CustomerCareTypes.Count; i++)
{
var caretype = customer.CustomerCareTypes[i];
if (i == customer.CustomerCareTypes.Count - 1)
betreuungsform += caretype.DisplayName;
else
betreuungsform += caretype.DisplayName + " & ";
}
}
lblStundendokumentation.Text += betreuungsform;
}
if (!String.IsNullOrWhiteSpace(pRO.AbsenceTimes))
{
lblAbsenceTime.Text = "Stationäre Aufenthalte:";
ErstelleAbwesenheitenTabelle(pRO);
}
else
{
xrTableAbwesenheiten.Visible = false;
}
if (pRO.Services != null)
{
foreach (var sd in pRO.Services)
{
if (sd.ServiceDescription.ToLower().Contains("fehlkontakt"))
{
sd.ServiceCategoryAbbr = "Fehlkontakt";
}
}
}
bindingSource1.DataSource = pRO;
}
private void ErstelleAbwesenheitenTabelle(ServicesOverviewRO pRo)
{
if (pRo.Abwesenheiten != null)
{
int newRows = 0;
int index = 1;
foreach (var at in pRo.Abwesenheiten)
{
DevExpress.XtraReports.UI.XRTableRow row = null;
if (index < xrTableAbwesenheiten.Rows.Count)
{
row = xrTableAbwesenheiten.Rows[index];
}
else
{
row = xrTableAbwesenheiten.InsertRowBelow(xrTableAbwesenheiten.Rows[xrTableAbwesenheiten.Rows.Count - 1]);
newRows++;
}
row.Cells[0].Text = String.Format("{0:dd.MM.yyyy}", at.Start);
int? days = null;
if (at.End.HasValue)
{
row.Cells[1].Text = String.Format("{0:dd.MM.yyyy}", at.End);
days = (int)at.End.Value.Subtract(at.Start.Value).TotalDays + 1;
}
else
{
row.Cells[1].Text = "unbekannt";
}
row.Cells[2].Text = String.Format("{0:0}", days);
index++;
}
if (newRows > 0)
{
//lbl1.Top += newRows * 20;
}
}
}
}
}