Files
BeWoPlaner/ReportImp/GrundsteinEV/Betreuungsverlauf.cs
2022-05-13 10:37:20 +02:00

82 lines
2.6 KiB
C#

using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Text.RegularExpressions;
using BeWo.Report;
using BeWo.Report.ReportObjects;
using BeWo.Service.ServiceImplementations;
using BS.Shared.Core;
using BS.Shared.DataContracts;
using DevExpress.XtraReports.UI;
namespace GrundsteinEV
{
public partial class Betreuungsverlauf : XtraReport, IBeWoReport<ServicesOverviewRO>
{
public Betreuungsverlauf()
{
InitializeComponent();
}
public void SetReportDataSource(ServicesOverviewRO pRO)
{
if (pRO.Services != null)
{
List<ServicesOverviewRO.ServiceDetail> servicesBillable = new List<ServicesOverviewRO.ServiceDetail>();
lblKategorie.Text = pRO.Services[0].ServiceCategory;
foreach (var sd in pRO.Services)
{
if (sd.IsBillable)
{
servicesBillable.Add(sd);
}
}
pRO.Services = servicesBillable;
}
var approved = pRO.ApprovedFLSPerWeek;
var stats = GetStatistics(pRO);
if (stats != null)
approved = stats.MinutesApprovedPerWeek / 60;
lblBewilligteStunden.Text = string.Format("{0:0.##}", approved);
bindingSource1.DataSource = pRO;
}
private SupportConceptPeriodStatisticsDC GetStatistics(ServicesOverviewRO ro)
{
if (ro.CostBearer2SupportConceptList != null && ro.CostBearer2SupportConceptList.Count > 0)
{
var service = new OperationsServiceImp();
foreach (var cb2sc in ro.CostBearer2SupportConceptList)
{
long cb2scOid = cb2sc.Oid.Value;
var stats = service.CreateSupportConceptStatistics(cb2scOid, ro.EndDate);
if (stats.PeriodStatistics != null && stats.PeriodStatistics.Count > 0)
{
foreach (var ps in stats.PeriodStatistics)
{
if (ps.SupportConceptApprovalPeriod != null && ps.SupportConceptApprovalPeriod.ServiceCategory != null &&
ps.SupportConceptApprovalPeriod.ServiceCategory.Name == ro.Services[0].ServiceCategory)
{
return ps;
}
}
}
}
}
return null;
}
}
}