Files
BeWoPlaner/ReportImp/FlexibleJugendarbeitFrankfurtEV/LeistungsnachweisEFH.cs
Alexandra 8caf433554 FlexibleJugendarbeitFrankfurtEV/Leistungsnachweise Finetuning
FlexibleJugendarbeitFrankfurtEV/Validation/ServiceRecordValidator.cs - Buchungen bis 5 Tage in Zukunft
2024-12-10 16:15:36 +01:00

123 lines
4.3 KiB
C#

using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using BeWo.Data.Access;
using BeWo.Data.Entities;
using BeWo.Report;
using BeWo.Report.ReportObjects;
using BS.Shared;
using BS.Shared.Core;
using DevExpress.XtraReports.UI;
namespace FlexibleJugendarbeitFrankfurtEV
{
public partial class LeistungnachweisEFH : XtraReport, IBeWoReport<ServicesOverviewRO>
{
public LeistungnachweisEFH()
{
InitializeComponent();
}
public void SetReportDataSource(ServicesOverviewRO pRO)
{
if (pRO.Services != null)
{
List<ServicesOverviewRO.ServiceDetail> servicesBillable = new List<ServicesOverviewRO.ServiceDetail>();
Dictionary<int, ServicesOverviewRO.ServiceDetail> day2Detail = new Dictionary<int, ServicesOverviewRO.ServiceDetail>();
foreach (var sd in pRO.Services)
{
if (sd.IsBillable)
{
ServicesOverviewRO.CreateSignatureString(sd);
servicesBillable.Add(sd);
}
}
pRO.Services = servicesBillable;
}
SetzeMainAttendants(pRO);
pRO.MainAttendant = GetSozialarbeiter(pRO);
bindingSource1.DataSource = pRO;
}
private string GetSozialarbeiter(ServicesOverviewRO pRO)
{
string asd = "";
var c = DAOFactory.GenericDAO.LoadByID<Customer>(pRO.CustomerOid);
foreach (var c2p in c.Customer2PersonList)
{
foreach (var v2o in c2p.ValueList)
{
if (v2o.Entry.Type == ValueListEntryType.EnvironmentPersonType && v2o.Entry.Value.Contains("Zuständiger ASD"))
{
if (asd != "")
{
asd += ", ";
}
asd += c2p.Person.LastName;
}
}
}
return asd;
}
private void SetzeMainAttendants(ServicesOverviewRO pRo)
{
if (pRo.CostBearer2SupportConceptList != null && pRo.CostBearer2SupportConceptList.Count > 0)
{
pRo.MainAttendantCommaSeperated = "";
var c2s = pRo.CostBearer2SupportConceptList[0];
foreach (var scap in c2s.ApprovalPeriodList)
{
if (scap.StartDate <= pRo.EndDate && scap.EndDate >= pRo.StartDate)
{
if (scap.SupportConceptApprovalPeriod2Employee != null && scap.SupportConceptApprovalPeriod2Employee.Count > 0)
{
foreach (var e in scap.SupportConceptApprovalPeriod2Employee)
{
if (pRo.MainAttendantCommaSeperated.Length > 0)
{
pRo.MainAttendantCommaSeperated += ", ";
}
pRo.MainAttendantCommaSeperated += e.Employee.Person.LastName;
}
}
}
}
}
}
private void picSignature_BeforePrint(object sender, System.ComponentModel.CancelEventArgs e)
{
XRPictureBox xrBox = sender as XRPictureBox;
//var test = this.GetCurrent
string base64String = xrBox.Tag as string;
if (!String.IsNullOrWhiteSpace(base64String))
{
var base64Data = Regex.Match(base64String, @"data:image/(?<type>.+?),(?<data>.+)").Groups["data"].Value;
var binData = Convert.FromBase64String(base64Data);
System.Drawing.Image img = ByteArrayToImage(binData);
xrBox.Image = Utils.CropImage(img);
}
else
{
xrBox.Image = null;
}
}
public System.Drawing.Image ByteArrayToImage(byte[] byteArrayIn)
{
using(var memoryStream = new MemoryStream(byteArrayIn))
{
return System.Drawing.Image.FromStream(memoryStream);
}
}
}
}