Files
BeWoPlaner/ReportImp/AsbRheinErftDuerenSBD/CustomerDataReport.cs

183 lines
8.7 KiB
C#

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using DevExpress.XtraReports.UI;
using BeWo.Report.ReportObjects;
using BeWo.Data.Access;
using BeWo.Data.Entities;
using BS.Shared;
using BS.Shared.Core;
using BeWo.Report;
using System.Text;
using BS.Shared.DataContracts;
using System.Collections.Generic;
namespace AsbRheinErftDuerenSBD
{
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);
foreach (var vv in c.VarFieldValueList)
{
var varFieldValue = Utils.XMLDeserializeFromString(vv.SerializedValue, Type.GetType(vv.TypeName));
if (varFieldValue != null)
{
var vValue = varFieldValue.ToString();
switch (vv.VarFieldDefOid)
{
case 1: // Versicherungsnummer
zusatzDiagnoseLabel.Text = vValue;
break;
}
}
}
StringBuilder sbKategorie = new StringBuilder();
StringBuilder sbFLS = new StringBuilder();
StringBuilder sbFLSEinheit = new StringBuilder();
foreach (var sc in c.SupportConcepts)
{
if (sc.IsActive == ActivationTypeId.Active)
{
foreach (var c2s in sc.CostBearer2SupportConceptList)
{
if (c2s.StartDate <= DateTime.Now && c2s.EndDate >= DateTime.Now)
{
lblHilfeplan.Text = c2s.CostBearer.Organisation.Name;
foreach (var ap in c2s.ApprovalPeriodList)
{
if (ap.StartDate <= DateTime.Now && ap.EndDate >= DateTime.Now)
{
lblBewilligtVon.Text = String.Format("{0:dd.MM.yyyy}", ap.StartDate);
lblBewilligtBis.Text = String.Format("{0:dd.MM.yyyy}", ap.EndDate);
if (ap.ServiceCategory != null && ap.ServiceCategory.Name.StartsWith("Fachleistung"))
sbFLS.AppendLine(String.Format("{0:0.00} pro {1} für Fachkraft", ap.ApprovedBEPerInterval, ap.ApprovedBEInterval != null ? EnumTranslations.SupportConceptApprovalInterval2Translations[(SupportConceptApprovalInterval)ap.ApprovedBEInterval] : null));
else if (ap.ServiceCategory != null && !ap.ServiceCategory.Name.StartsWith("Fachleistung"))
sbFLS.AppendLine(String.Format("{0:0.00} pro {1} für Hilfskraft", ap.ApprovedBEPerInterval, ap.ApprovedBEInterval != null ? EnumTranslations.SupportConceptApprovalInterval2Translations[(SupportConceptApprovalInterval)ap.ApprovedBEInterval] : null));
else
sbFLS.AppendLine(String.Format("{0:0.00} pro {1}", ap.ApprovedBEPerInterval, ap.ApprovedBEInterval != null ? EnumTranslations.SupportConceptApprovalInterval2Translations[(SupportConceptApprovalInterval)ap.ApprovedBEInterval] : null));
//lblLeistungskategorie.Text += String.Format(" ({0}):", ap.ServiceCategory);
//lblFls.Text = String.Format("{0:0.00}", ap.ApprovedBEPerInterval);
//lblFlsEinheit.Text = ap.ApprovedBEInterval != null ? EnumTranslations.SupportConceptApprovalInterval2Translations[(SupportConceptApprovalInterval)ap.ApprovedBEInterval] : null;
}
}
}
}
}
}
lblFls.Text = sbFLS.ToString();
StringBuilder sbSchule = new StringBuilder();
StringBuilder sbSchule2 = new StringBuilder();
StringBuilder sbLehrer = new StringBuilder();
if (pRO.EnvironmentOrganisations != null)
{
for (int i = pRO.EnvironmentOrganisations.Count - 1; i >= 0; i--)
{
var org = pRO.EnvironmentOrganisations[i];
if (org.RelationRole != null && org.RelationRole.DisplayName == "Schule")
{
sbSchule.AppendLine(org.Organisation.Name);
sbSchule.AppendLine(org.Organisation.Street);
sbSchule.Append(org.Organisation.PostalCode);
sbSchule.Append(" ");
sbSchule.AppendLine(org.Organisation.Town);
sbSchule.AppendLine("");
sbSchule2.AppendLine(org.Organisation.ContactSummaryInfo);
sbSchule2.AppendLine("");
var o = DAOFactory.GenericDAO.LoadByID<Organisation>(org.Organisation.OrganisationOid);
sbSchule2.Append(o.Notice);
pRO.EnvironmentOrganisations.Remove(org);
}
//if (org.RelationRole != null && org.RelationRole.DisplayName == "Kostenträger")
//{
// pRO.EnvironmentOrganisations.Remove(org);
//}
}
}
if (pRO.EnvironmentPersons != null)
{
for (int i = pRO.EnvironmentPersons.Count - 1; i >= 0; i--)
{
var p = pRO.EnvironmentPersons[i];
if (p.RelationRole != null && p.RelationRole.DisplayName.Contains("Klassenlehrer"))
{
var person = DAOFactory.GenericDAO.LoadByID<Person>(p.Person.PersonOid);
String anrede = "";
if (person.Sex.Equals(Sex.Male))
anrede = "Herr ";
else if (person.Sex.Equals(Sex.Female))
anrede = "Frau ";
sbLehrer.AppendLine(anrede + p.Person.TitleFirstNameLastNameToString());
sbLehrer.AppendLine(p.Customer2PersonNotice);
lblLehrer2.Text = p.Person.ContactSummaryInfo;
pRO.EnvironmentPersons.Remove(p);
}
}
}
CreateArbeitszeitenTable(pRO.Customer.Arbeitszeiten);
lblLehrer.Text = sbLehrer.ToString();
lblSchule.Text = sbSchule.ToString();
lblSchule2.Text = sbSchule2.ToString();
lblDatum.Text += DateTime.Now.Date.ToString("dd.MM.yyyy");
this.bindingSource1.DataSource = pRO;
}
private void CreateArbeitszeitenTable(List<ArbeitszeitDC> zeiten)
{
if (zeiten != null)
{
foreach (var az in zeiten)
{
if ((!az.GueltigVon.HasValue || az.GueltigVon <= DateTime.Now) &&
(!az.GueltigBis.HasValue || az.GueltigBis >= DateTime.Now) && az.Eintraege != null)
{
lblStundenplan.Text = az.GueltigVon.HasValue ? lblStundenplan.Text.Replace("von", string.Format("{0: dd.MM.yyyy}", az.GueltigVon.Value)) : "";
lblStundenplan.Text = az.GueltigBis.HasValue ? lblStundenplan.Text.Replace("bis", string.Format("{0: dd.MM.yyyy}", az.GueltigBis.Value)) : "";
foreach (var e in az.Eintraege)
{
AddArbeitszeit(e);
}
}
}
}
}
private void AddArbeitszeit(ArbeitszeitEintragDC ae)
{
XRTableRow newRow = null;
if (tableBetreuungszeiten.Rows[0].Cells[0].Text == null|| tableBetreuungszeiten.Rows[0].Cells[0].Text == "")
newRow = tableBetreuungszeiten.Rows[0];
else
newRow = tableBetreuungszeiten.InsertRowBelow(tableBetreuungszeiten.Rows[tableBetreuungszeiten.Rows.Count - 1]);
newRow.Font = new System.Drawing.Font("Arial", 9F, FontStyle.Regular);
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;
}
}
}