Files
BeWoPlaner/ReportImp/LebenshilfeStadeMID/SbdLeistungsnachweisAbrechnung.cs

115 lines
4.2 KiB
C#

using System;
using System.Collections.Generic;
using BeWo.Report.ReportObjects;
using BeWo.Report;
using DevExpress.XtraReports.UI;
using System.Data;
using BS.Shared.Core;
using BS.Shared.DataContracts;
using BeWo.Data.Entities;
using BeWo.Data.Access;
using System.Linq;
using BS.Shared;
namespace LebenshilfeStadeMID
{
public partial class LeistungsnachweisAbrechnung : DevExpress.XtraReports.UI.XtraReport,
IBeWoReport<ServiceInvoiceRO>
{
public LeistungsnachweisAbrechnung()
{
InitializeComponent();
}
public void SetReportDataSource(ServiceInvoiceRO pRO)
{
pRO.BillableServiceRecords = new List<ServiceRecordDC>();
if (pRO.CustomerOid != null)
{
Customer c = DAOFactory.GenericDAO.LoadByID<Customer>((long)pRO.CustomerOid);
if (c != null)
{
var hauptbetreuung = c.Employee2CustomerList.FirstOrDefault(
e2c => e2c.ValueList.Any(ve => ve.Entry.SystemEntryID.HasValue
&& ve.Entry.SystemEntryID.Value == SystemEntryID.EmployeeRoleMainAttendant));
if (hauptbetreuung != null && hauptbetreuung.Employee.Person != null)
{
lblMitarbeiter.Text = hauptbetreuung.Employee.Person.FirstNameLastName;
}
var vertretung = c.Employee2CustomerList.FirstOrDefault(
e2c => e2c.ValueList.Any(ve => ve.Entry.SystemEntryID.HasValue
&& ve.Entry.SystemEntryID.Value == SystemEntryID.PersonRepresentative));
if (vertretung != null && vertretung.Employee.Person != null)
{
lblVertretung.Text = vertretung.Employee.Person.FirstNameLastName;
}
}
}
if (pRO.ServiceInvoicePeriods != null)
{
foreach (var sip in pRO.ServiceInvoicePeriods)
{
foreach (var ii in sip.ServiceInvoiceItems)
{
if (ii.ServiceDescription != null && ii.ServiceDescription != "Betreuungseinsätze" &&
!ii.ServiceDescription.Contains("Zuschlag auf Betreuungszeit"))
{
ServiceRecordDC sr = new ServiceRecordDC();
if (ii.AccountingPeriodStart.HasValue && ii.AccountingPeriodEnd.HasValue)
{
sr.Start = ii.AccountingPeriodStart;
sr.RoundedDuration = (decimal) ii.AccountingPeriodEnd.Value
.Subtract(ii.AccountingPeriodStart.Value).TotalMinutes;
}
sr.Notice = String.Format("{0:HH:mm}", ii.AccountingPeriodStart);
sr.Notice2 = String.Format("{0:HH:mm}", ii.AccountingPeriodEnd);
sr.Notice3 = ii.ServiceDescription;
pRO.BillableServiceRecords.Add(sr);
}
}
}
}
//if (pRO.BillableServiceRecords != null)
//{
// foreach (var sr in pRO.BillableServiceRecords)
// {
// if (sr.Start.HasValue && sr.Start.Value.Second == 0)
// {
// sr.Notice = String.Format("{0:HH:mm}", sr.Start);
// }
// else
// {
// sr.Notice = "";
// }
// if (sr.End.HasValue && sr.End.Value.Second == 0)
// {
// sr.Notice2 = String.Format("{0:HH:mm}", sr.End);
// }
// else
// {
// sr.Notice2 = "";
// }
// sr.Notice3 = String.Format("{0} {1}", sr.Employee.FirstName, sr.Employee.LastName);
// }
//}
this.bindingSource1.DataSource = pRO;
}
}
}