Files
BeWoPlaner/ReportImp/SchillingerReports/SupportConceptReport.cs
2019-02-12 19:10:37 +01:00

106 lines
3.6 KiB
C#

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using BeWo.Data.Access;
using BeWo.Data.Entities;
using DevExpress.XtraReports.UI;
using BS.Shared.Extensions;
using BeWo.Report.ReportObjects;
using BeWo.Report;
using BS.Shared;
namespace BeWo.SchillingerReports
{
public partial class Hilfeplanuebersicht : DevExpress.XtraReports.UI.XtraReport, IBeWoReport<SupportConceptListRO>
{
public Hilfeplanuebersicht()
{
InitializeComponent();
}
public void SetReportDataSource(SupportConceptListRO pRO)
{
if (pRO.AppointedDate.HasValue && pRO.AppointedDate.Value.Date < DateTime.Now.Date)
{
xrLabel1.Text = String.Format("Hilfeplanübersicht Stand {0:dd.MM.yyyy}", pRO.AppointedDate);
}
if (pRO.SupportConceptDetailList != null)
{
foreach (var sc in pRO.SupportConceptDetailList)
{
if (sc.IsApproved)
{
sc.Custom1 = "bewilligt";
if (sc.ApprovalDate.HasValue)
{
sc.Custom1 += String.Format(" am {0:dd.MM.yyyy}", sc.ApprovalDate);
}
}
else
{
if (sc.SupportConceptSendDate.HasValue)
{
sc.Custom1 = String.Format("eingereicht am {0:dd.MM.yyyy}", sc.SupportConceptSendDate);
}
else if (sc.RequisitionSendDate.HasValue)
{
sc.Custom1 = String.Format("beantragt am {0:dd.MM.yyyy}", sc.RequisitionSendDate);
}
else
{
sc.Custom1 = "nicht bewilligt";
}
}
sc.Custom2 = GetCoBetreuer(sc);
}
}
this.bindingSource1.DataSource = pRO;
}
private string GetCoBetreuer(SupportConceptListRO.SupportConceptDetail sc)
{
String name = "";
if (sc.CostBearer2SupportConceptOid > 0)
{
var c2s = DAOFactory.GenericDAO.LoadByID<CostBearer2SupportConcept>(sc.CostBearer2SupportConceptOid);
var customer = c2s.SupportConcept.Customer;
foreach (var item in customer.Employee2CustomerList)
{
foreach (var valueEntry in item.ValueList)
{
if (valueEntry.Entry.Type == ValueListEntryType.StaffRoleType)
{
if (valueEntry.Entry.Value == "Co-Betreuung")
{
string employeeAbbr = item.Employee.Person.Abbreviation;
if (string.IsNullOrEmpty(employeeAbbr))
{
employeeAbbr = item.Employee.Person.FirstName.Substring(0, 1) + ". " +
item.Employee.Person.LastName;
}
if (name.Length > 0)
{
name += ", ";
}
name += employeeAbbr;
}
}
}
}
}
return name;
}
}
}