335 lines
12 KiB
C#
335 lines
12 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using BeWo.Data.Access;
|
|
using BeWo.Data.Entities;
|
|
using DevExpress.XtraReports.UI;
|
|
using BeWo.Report.ReportObjects;
|
|
using BS.Shared.DataContracts;
|
|
using BeWo.Report;
|
|
using BeWo.Service.ServiceImplementations;
|
|
using BS.Shared.Core;
|
|
|
|
namespace SHKServiceSBD
|
|
{
|
|
public partial class SBDCharacteristicsReport : DevExpress.XtraReports.UI.XtraReport, IBeWoReport<SBDCharacteristicsRO>
|
|
{
|
|
public SBDCharacteristicsReport()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public void SetReportDataSource(SBDCharacteristicsRO pRO)
|
|
{
|
|
StringBuilder sbSchule = new StringBuilder();
|
|
String klasse = "";
|
|
String klassenLeitung = "";
|
|
String kontaktAnsprechperson = "";
|
|
|
|
if (pRO.EnvironmentOrganisations != null)
|
|
{
|
|
foreach (var org in pRO.EnvironmentOrganisations)
|
|
{
|
|
if (org.RelationRole != null && (org.RelationRole.DisplayName.Contains("Schule") || org.RelationRole.DisplayName.Contains("Kindergarten")))
|
|
{
|
|
sbSchule.AppendLine(org.Organisation.Name);
|
|
|
|
sbSchule.AppendLine(org.Organisation.Street);
|
|
sbSchule.Append(org.Organisation.PostalCode);
|
|
sbSchule.Append(" ");
|
|
sbSchule.AppendLine(org.Organisation.Town);
|
|
//sbSchule.AppendLine("");
|
|
|
|
//sbSchule.AppendLine(org.Organisation.ContactSummaryInfo);
|
|
//sbSchule.AppendLine("");
|
|
|
|
klasse = org.Customer2OrganisationNotice;
|
|
|
|
if (org.Person != null)
|
|
{
|
|
if (org.Person.Geschlecht.HasValue)
|
|
{
|
|
if (org.Person.Geschlecht.Value == BS.Shared.Sex.Male)
|
|
{
|
|
klassenLeitung = "Herr ";
|
|
}
|
|
else if (org.Person.Geschlecht.Value == BS.Shared.Sex.Female)
|
|
{
|
|
klassenLeitung = "Frau ";
|
|
}
|
|
}
|
|
klassenLeitung += org.Person.LastName;
|
|
}
|
|
|
|
//var o = DAOFactory.GenericDAO.LoadByID<Organisation>(org.Organisation.OrganisationOid);
|
|
//sbSchule.Append(o.Notice);
|
|
}
|
|
}
|
|
}
|
|
|
|
foreach (var item in pRO.Customer.ContactInformations)
|
|
{
|
|
if (kontaktAnsprechperson.Length > 0)
|
|
{
|
|
kontaktAnsprechperson += "\n";
|
|
}
|
|
if (item.ContactType == BS.Shared.ContactType.business_Phone)
|
|
{
|
|
kontaktAnsprechperson += "Tel: " + item.ContactValue;
|
|
}
|
|
else if (item.ContactType == BS.Shared.ContactType.business_MobilePhone)
|
|
{
|
|
kontaktAnsprechperson += "Handy: " + item.ContactValue;
|
|
}
|
|
}
|
|
|
|
|
|
lblSchule.Text = sbSchule.ToString();
|
|
lblKlassenleitung.Text = klassenLeitung;
|
|
lblAnsprechperson.Text = kontaktAnsprechperson;
|
|
|
|
|
|
|
|
//if (!String.IsNullOrEmpty(klasse) && !klasse.Contains("Klasse"))
|
|
//{
|
|
// klasse = "Klasse " + klasse;
|
|
//}
|
|
|
|
lblKlasse.Text = klasse;
|
|
|
|
|
|
|
|
//Alter ermitteln
|
|
int? alter = null;
|
|
if (pRO.Customer.DateOfBirth.HasValue)
|
|
{
|
|
alter = DateTime.Now.Year - pRO.Customer.DateOfBirth.Value.Year;
|
|
var birthday = pRO.Customer.DateOfBirth.Value.AddYears(alter.Value);
|
|
if (DateTime.Now.CompareTo(birthday) < 0)
|
|
{
|
|
alter--;
|
|
}
|
|
}
|
|
lblAlter.Text = String.Format("{0}", alter);
|
|
|
|
String team = "";
|
|
if (pRO.Customer.RelatedTeams != null && pRO.Customer.RelatedTeams.Count > 0)
|
|
{
|
|
foreach (var item in pRO.Customer.RelatedTeams)
|
|
{
|
|
if (team.Length > 0)
|
|
{
|
|
team += ", ";
|
|
}
|
|
team += item.Team.LeaderString;
|
|
}
|
|
}
|
|
lblTeamleiter.Text = team;
|
|
|
|
String kraft = "";
|
|
if (pRO.Customer.RelatedEmployees != null && pRO.Customer.RelatedEmployees.Count > 0)
|
|
{
|
|
foreach (var item in pRO.Customer.RelatedEmployees)
|
|
{
|
|
if (item.RelationRole.Type == BS.Shared.ValueListEntryType.StaffRoleType && item.RelationRole.DisplayName.Contains("Hauptbetreuung"))
|
|
{
|
|
if (kraft.Length > 0)
|
|
{
|
|
kraft += ", ";
|
|
}
|
|
kraft += String.Format("{0} {1}", item.Employee.FirstName, item.Employee.LastName);
|
|
}
|
|
}
|
|
}
|
|
lblFesteKraft.Text = kraft;
|
|
|
|
|
|
String vertretungsregelung = "Vertretung nicht erforderlich";
|
|
if (pRO.Customer.SubstitutionNeed == BS.Shared.SubstitutionNeed.SubstitutionNeeded)
|
|
{
|
|
vertretungsregelung = "Vertretung dringend erforderlich";
|
|
}
|
|
else if (pRO.Customer.SubstitutionNeed == BS.Shared.SubstitutionNeed.SubstitutionWanted)
|
|
{
|
|
if (pRO.Customer.AbWelchemKrankheitsTag < 1)
|
|
{
|
|
pRO.Customer.AbWelchemKrankheitsTag = 1;
|
|
}
|
|
|
|
vertretungsregelung = String.Format("Vertretung gewünscht ab {0}.Tag", pRO.Customer.AbWelchemKrankheitsTag);
|
|
|
|
}
|
|
|
|
lblVertretungsregelung.Text = vertretungsregelung;
|
|
|
|
chkAggro.Checked = pRO.Customer.Aggressiv;
|
|
chkKlo.Checked = pRO.Customer.Toilettengang;
|
|
chkPflege.Checked = pRO.Customer.Pflege;
|
|
//chkK.Checked = pRO.Customer.Toilettengang;
|
|
lblUebernahmeort.Text = pRO.Customer.Uebernahmeort;
|
|
lblVerhalten.Text = pRO.Customer.Verhalten;
|
|
lblBetreuungsbedarf.Text = pRO.Customer.Betreuungsbedarf;
|
|
lblAllgBemerkungen.Text = pRO.Customer.BemerkungenSbd;
|
|
|
|
String diagnosen = "";
|
|
|
|
foreach (var item in pRO.ICD10Diagnosen)
|
|
{
|
|
if (diagnosen.Length > 0)
|
|
{
|
|
diagnosen += ", ";
|
|
}
|
|
diagnosen += String.Format("{0}: {1}", item.ICD10Code, item.Beschreibung);
|
|
}
|
|
lblDiagnosen.Text = diagnosen;
|
|
|
|
|
|
//var customer = DAOFactory.GenericDAO.LoadByID<Customer>(pRO.Customer.CustomerOid.Value);
|
|
|
|
|
|
CreateArbeitszeitenTable(pRO.Customer.Arbeitszeiten);
|
|
|
|
//CreateLetzteVertreterTable(pRO.Customer);
|
|
|
|
SetzeToken(pRO.Customer);
|
|
|
|
SetzeBetreuungsarten(pRO.Customer);
|
|
|
|
this.bindingSource1.DataSource = pRO;
|
|
}
|
|
|
|
private void SetzeBetreuungsarten(CustomerDC customer)
|
|
{
|
|
if (customer.CustomerCareTypes != null)
|
|
{
|
|
foreach (var item in customer.CustomerCareTypes)
|
|
{
|
|
if (item.DisplayName == "Pause")
|
|
{
|
|
chkPause.Checked = true;
|
|
}
|
|
else if (item.DisplayName == "Unterricht")
|
|
{
|
|
chkUnterricht.Checked = true;
|
|
}
|
|
else if (item.DisplayName == "Busbegleitung")
|
|
{
|
|
chkBus.Checked = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
private void SetzeToken(CustomerDC customer)
|
|
{
|
|
String wunsch = "";
|
|
String ausschluss = "";
|
|
|
|
var c2tList = DAOFactory.SearchDAO.GetCustomer2TokensByCustomerOid(customer.CustomerOid.Value);
|
|
|
|
foreach (var c2t in c2tList)
|
|
{
|
|
if (c2t.Token.TokenTyp == BS.Shared.TokenTyp.WunschKriterium)
|
|
{
|
|
if (wunsch.Length > 0)
|
|
{
|
|
wunsch += "\n";
|
|
}
|
|
wunsch += c2t.Token.Beschreibung;
|
|
}
|
|
else if (c2t.Token.TokenTyp == BS.Shared.TokenTyp.AusschlussKriterium)
|
|
{
|
|
if (ausschluss.Length > 0)
|
|
{
|
|
ausschluss += "\n";
|
|
}
|
|
ausschluss += c2t.Token.Beschreibung;
|
|
}
|
|
}
|
|
|
|
cellWunschKrits.Text = wunsch;
|
|
cellAusschlussKrits.Text = ausschluss;
|
|
}
|
|
|
|
//private void CreateLetzteVertreterTable(CustomerDC customer)
|
|
//{
|
|
// XRTableRow newRow = null;
|
|
// var os = new OperationsServiceImp();
|
|
// var last = os.GetLastVertreter(customer.CustomerOid);
|
|
// int index = 0;
|
|
|
|
// foreach (var item in last)
|
|
// {
|
|
// if (index == 0)
|
|
// {
|
|
// newRow = tableLetzteVertreter.Rows[0];
|
|
// }
|
|
// else
|
|
// {
|
|
// newRow = tableLetzteVertreter.InsertRowBelow(tableLetzteVertreter.Rows[tableLetzteVertreter.Rows.Count - 1]);
|
|
// }
|
|
// newRow.Cells[0].Text = String.Format("{0}", String.Format("{0}, {1}", item.LastName, item.FirstName));
|
|
// }
|
|
//}
|
|
|
|
private void CreateArbeitszeitenTable(List<ArbeitszeitDC> zeiten)
|
|
{
|
|
if (zeiten != null)
|
|
{
|
|
int index = 0;
|
|
foreach (var az in zeiten)
|
|
{
|
|
if ((!az.GueltigVon.HasValue || az.GueltigVon <= DateTime.Now) &&
|
|
(!az.GueltigBis.HasValue || az.GueltigBis >= DateTime.Now) && az.Eintraege != null)
|
|
{
|
|
SortiereArbeitszeiten(az.Eintraege);
|
|
foreach (var e in az.Eintraege)
|
|
{
|
|
AddArbeitszeit(e, index++);
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
private void SortiereArbeitszeiten(List<ArbeitszeitEintragDC> zeiten)
|
|
{
|
|
zeiten.Sort(
|
|
(a, b) =>
|
|
{
|
|
var at1 = DateTimeUtils.GetAssistanceTimeComparisonDateTime(a.UhrzeitVon, a.UhrzeitBis, DateTime.Now.Date.AddDays((int)a.DayOfWeek));
|
|
var at2 = DateTimeUtils.GetAssistanceTimeComparisonDateTime(b.UhrzeitVon, b.UhrzeitBis, DateTime.Now.Date.AddDays((int)b.DayOfWeek));
|
|
|
|
return at1.Start.CompareTo(at2.Start);
|
|
});
|
|
}
|
|
|
|
private void AddArbeitszeit(ArbeitszeitEintragDC ae, int index)
|
|
{
|
|
XRTableRow newRow = null;
|
|
if (index == 0)
|
|
{
|
|
newRow = tableBetreuungszeiten.Rows[0];
|
|
}
|
|
else
|
|
{
|
|
newRow = tableBetreuungszeiten.InsertRowBelow(tableBetreuungszeiten.Rows[tableBetreuungszeiten.Rows.Count - 1]);
|
|
}
|
|
|
|
|
|
|
|
newRow.Cells[0].Text = String.Format("{0}", ae.Tag);
|
|
newRow.Cells[1].Text = String.Format("{0} - {1}", ae.UhrzeitVon, ae.UhrzeitBis);
|
|
if (ae.Employee != null)
|
|
{
|
|
newRow.Cells[2].Text = String.Format("{0} {1}", ae.Employee.LastName, ae.Employee.FirstName);
|
|
}
|
|
|
|
newRow.Cells[3].Text = ae.Notice;
|
|
}
|
|
}
|
|
}
|