Files
BeWoPlaner/ReportImp/DiakonieLandshut/CustomerDataReport.cs
2019-07-19 15:41:16 +02:00

196 lines
6.9 KiB
C#

using System;
using BeWo.Data.Access;
using BeWo.Data.Entities;
using BeWo.Report;
using DevExpress.XtraReports.UI;
using BeWo.Report.ReportObjects;
using BS.Shared;
using BS.Shared.Core;
using BS.Shared.DataContracts;
namespace DiakonieLandshut
{
public partial class Klientenstammblatt : DevExpress.XtraReports.UI.XtraReport, IBeWoReport<CustomerDataRO>
{
public Klientenstammblatt()
{
InitializeComponent();
}
public void SetReportDataSource(CustomerDataRO pRO)
{
var c = DAOFactory.GenericDAO.LoadByID<Customer>(pRO.CustomerOid);
lblVersorgungsamt.Text = c.AusstVersAmt;
lblAusweisGueltigVon.Text = String.Format("{0:dd.MM.yyyy}", c.AusweisGueltigVon);
if (c.AusweisUnbefristetGueltig.HasValue && c.AusweisUnbefristetGueltig.Value)
{
lblAusweisGueltigBis.Text = "unbefristet";
}
else
{
lblAusweisGueltigBis.Text = String.Format("{0:dd.MM.yyyy}", c.AusweisGueltigBis);
}
lblBeiblattGueltigBis.Text = String.Format("{0:dd.MM.yyyy}", c.BeiblattGueltigBis);
lblGrad.Text = c.GradDerBehinderung;
String merkzeichen = "";
if (c.MerkzeichenListe != null)
{
foreach (var mz in c.MerkzeichenListe)
{
if (merkzeichen.Length > 0)
{
merkzeichen += ", ";
}
merkzeichen += Translate(mz);
}
}
lblMerkzeichen.Text = merkzeichen;
String bastr = "";
if (c.BehinderungsartenListe != null)
{
foreach (var ba in c.BehinderungsartenListe)
{
if (bastr.Length > 0)
{
bastr += ", ";
}
bastr += Translate(ba);
}
}
lblBehinderungsart.Text = bastr;
if (c.Pflegegrad.HasValue)
lblPflegegrad.Text = EnumTranslations.PflegegradTranslations[c.Pflegegrad];
else
{
lblPflegegrad.Text = "";
}
if (pRO.CostBearers != null)
{
foreach (var cb in pRO.CostBearers)
{
SetAnsprechpartnerUndBewilligung(pRO, cb);
}
}
SetUmfeldPersons(pRO);
this.bindingSource1.DataSource = pRO;
}
private void SetUmfeldPersons(CustomerDataRO pRo)
{
int table1Index = 0;
int table2Index = 0;
int table3Index = 0;
if (pRo.EnvironmentPersons != null)
{
foreach (var c2p in pRo.EnvironmentPersons)
{
if (c2p.RelationRole.TypeDescription == "Gesetzliche Betreuung" || c2p.RelationRole.TypeDescription == "Rechtlicher Vertreter" || c2p.RelationRole.TypeDescription == "Rechtliche Betreuung")
{
AddPerson2RechtlicheBetreuerTable(c2p, table1Index++);
}
else if (c2p.RelationRole.TypeDescription.ToLower().Contains("arzt") || c2p.RelationRole.TypeDescription.ToLower().Contains("ärzt") || c2p.RelationRole.TypeDescription == "Psychiater/in" || c2p.RelationRole.TypeDescription == "Therapeut/in")
{
AddPerson2ArztTable(c2p, table2Index++);
}
else
{
AddPerson2UmfeldTable(c2p, table3Index++);
}
}
}
}
private void AddPerson2UmfeldTable(CustomerPersonRelationDC c2P, int rowIndex)
{
XRTableRow newRow = rowPersonenUmfeld;
if (rowIndex > 0)
{
newRow = tablePersonenUmfeld.InsertRowBelow(tablePersonenUmfeld.Rows[tablePersonenUmfeld.Rows.Count - 1]);
}
newRow.Cells[0].Text = c2P.Person.ToString();
newRow.Cells[1].Text = c2P.RelationRole.ToString();
newRow.Cells[2].Text = c2P.Person.ContactSummaryInfo;
newRow.Cells[3].Text = c2P.Customer2PersonNotice;
}
private void AddPerson2ArztTable(CustomerPersonRelationDC c2P, int rowIndex)
{
XRTableRow newRow = rowAerzte;
if (rowIndex > 0)
{
newRow = tableAerzte.InsertRowBelow(tableAerzte.Rows[tableAerzte.Rows.Count - 1]);
}
newRow.Cells[0].Text = c2P.Person.ToString();
newRow.Cells[1].Text = c2P.RelationRole.ToString();
newRow.Cells[2].Text = c2P.Person.ContactSummaryInfo;
newRow.Cells[3].Text = c2P.Customer2PersonNotice;
}
private void AddPerson2RechtlicheBetreuerTable(CustomerPersonRelationDC c2P, int rowIndex)
{
XRTableRow newRow = rowRechtlicheBetreuer;
if (rowIndex > 0)
{
newRow = tableRechtlicheBetreuer.InsertRowBelow(tableRechtlicheBetreuer.Rows[tableRechtlicheBetreuer.Rows.Count - 1]);
}
newRow.Cells[0].Text = c2P.Person.ToString();
newRow.Cells[1].Text = c2P.Customer2PersonNotice;
//newRow.Cells[1].Text = c2P.RelationRole.ToString();
newRow.Cells[2].Text = c2P.Person.ContactSummaryInfo;
//newRow.Cells[3].Text = c2P.Customer2PersonNotice;
}
private void SetAnsprechpartnerUndBewilligung(CustomerDataRO pRo, CustomerCostBearerRelationDC cb)
{
decimal bewilligt = 0;
String ap = "";
var c = DAOFactory.GenericDAO.LoadByID<Customer>(pRo.CustomerOid);
foreach (var sc in c.SupportConcepts)
{
foreach (var c2s in sc.CostBearer2SupportConceptList)
{
foreach (var scap in c2s.ApprovalPeriodList)
{
if (scap.StartDate <= DateTime.Now.Date && DateTime.Now.Date <= scap.EndDate)
{
bewilligt = scap.ApprovedBEPerInterval ?? 0;
if (c2s.CostBearerContactPerson != null)
{
ap = String.Format("{0}, {1}", c2s.CostBearerContactPerson.LastName, c2s.CostBearerContactPerson.FirstName);
}
}
}
}
}
cb.Notice = String.Format("{0:0.##}", bewilligt);
cb.CostBearer.Name2 = ap;
}
private string Translate(Behinderungsart ba)
{
return EnumTranslations.BehinderungsartTranslations[ba];
}
private string Translate(Merkzeichen mz)
{
return EnumTranslations.MerkzeichenTranslations[mz];
}
}
}