Files
BeWoPlaner/ReportImp/Monvita/CustomerDataReport.cs

141 lines
5.1 KiB
C#

using System;
using System.Drawing;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using BeWo.Report;
using DevExpress.XtraReports.UI;
using BeWo.Report.ReportObjects;
using BS.Shared.DataContracts;
namespace Monvita
{
public partial class Klientenstammblatt : DevExpress.XtraReports.UI.XtraReport, IBeWoReport<CustomerDataRO>
{
public Klientenstammblatt()
{
InitializeComponent();
}
public void SetReportDataSource(CustomerDataRO pRO)
{
ErzeugeTabellen(pRO);
this.bindingSource1.DataSource = pRO;
}
private void ErzeugeTabellen(CustomerDataRO pRo)
{
var gesetzlBetreuer = new List<CustomerPersonRelationDC>();
var behandler = new List<CustomerPersonRelationDC>();
var sonstigesUmfeld = new List<CustomerPersonRelationDC>();
foreach (var c2p in pRo.EnvironmentPersons)
{
if (IsGesetzlBetreuer(c2p))
{
gesetzlBetreuer.Add(c2p);
}
else if (IsBehandler(c2p))
{
behandler.Add(c2p);
}
else
{
sonstigesUmfeld.Add(c2p);
}
}
pRo.EnvironmentPersons = sonstigesUmfeld;
ErzeugeGesetzlBetreuerTabelle(gesetzlBetreuer);
ErzeugeBehandlerTabelle(behandler);
}
private void ErzeugeGesetzlBetreuerTabelle(List<CustomerPersonRelationDC> behandler)
{
foreach (var b in behandler)
{
var newRow = tblGesetzlBetreuung.InsertRowBelow(rowGesetzlBetreuung);
newRow.Cells[0].Text = b.Person.ToString();
newRow.Cells[1].Text = b.Person.AddressSummaryInfo;
newRow.Cells[2].Text = b.Person.ContactSummaryInfo;
newRow.Cells[0].Borders = rowGesetzlBetreuung.Cells[0].Borders;
newRow.Cells[1].Borders = rowGesetzlBetreuung.Cells[1].Borders;
newRow.Cells[2].Borders = rowGesetzlBetreuung.Cells[2].Borders;
newRow.Cells[0].Padding = rowGesetzlBetreuung.Cells[0].Padding;
newRow.Cells[1].Padding = rowGesetzlBetreuung.Cells[1].Padding;
newRow.Cells[2].Padding = rowGesetzlBetreuung.Cells[2].Padding;
newRow.Cells[1].Multiline = true;
newRow.Cells[2].Multiline = true;
}
rowGesetzlBetreuung.Visible = false;
}
private void ErzeugeBehandlerTabelle(List<CustomerPersonRelationDC> behandler)
{
foreach (var b in behandler)
{
var newRow = tblBehandler.InsertRowBelow(rowBehandler);
newRow.Cells[0].Text = b.Person.ToString();
newRow.Cells[1].Text = b.RelationRole.ToString();
newRow.Cells[2].Text = b.Person.ContactSummaryInfo;
newRow.Cells[0].Borders = rowBehandler.Cells[0].Borders;
newRow.Cells[1].Borders = rowBehandler.Cells[1].Borders;
newRow.Cells[2].Borders = rowBehandler.Cells[2].Borders;
newRow.Cells[0].Padding = rowBehandler.Cells[0].Padding;
newRow.Cells[1].Padding = rowBehandler.Cells[1].Padding;
newRow.Cells[2].Padding = rowBehandler.Cells[2].Padding;
newRow.Cells[2].Multiline = true;
}
rowBehandler.Visible = false;
}
private bool IsGesetzlBetreuer(CustomerPersonRelationDC c2P)
{
if (c2P.RelationRole != null && c2P.RelationRole.TypeDescription != null
&& c2P.RelationRole.TypeDescription.ToLower() == "gesetzlicher vertreter")
{
return true;
}
return false;
}
private bool IsBehandler(CustomerPersonRelationDC c2P)
{
if (c2P.RelationRole != null && c2P.RelationRole.TypeDescription != null && (
c2P.RelationRole.TypeDescription.ToLower().Contains("diabetholog") ||
c2P.RelationRole.TypeDescription.ToLower() == "hausarzt" ||
c2P.RelationRole.TypeDescription.ToLower().Contains("logopäd") ||
c2P.RelationRole.TypeDescription.ToLower().Contains("ortho") ||
c2P.RelationRole.TypeDescription.ToLower().Contains("pflege") ||
c2P.RelationRole.TypeDescription.ToLower().Contains("physio") ||
c2P.RelationRole.TypeDescription.ToLower().Contains("podolog") ||
c2P.RelationRole.TypeDescription.ToLower().Contains("psych") ||
c2P.RelationRole.TypeDescription.ToLower().Contains("arzt") ||
c2P.RelationRole.TypeDescription.ToLower().Contains("ärzte") ||
c2P.RelationRole.TypeDescription.ToLower().Contains("therap") ||
c2P.RelationRole.TypeDescription.ToLower().Contains("urolog")))
{
return true;
}
return false;
}
}
}