Files
BeWoPlaner/ReportImp/FlexibleJugendarbeitFrankfurtEV/LeistungsnachweisOderSpree.cs

127 lines
4.7 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 LeistungnachweisOderSpree : XtraReport, IBeWoReport<ServicesOverviewRO>
{
public LeistungnachweisOderSpree()
{
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;
}
SetzeBewilligung(pRO);
SetzeMainAttendants(pRO);
bindingSource1.DataSource = pRO;
}
private void SetzeBewilligung(ServicesOverviewRO pRo)
{
if (pRo.CostBearer2SupportConceptList != null && pRo.CostBearer2SupportConceptList.Count > 0)
{
pRo.MainAttendantCommaSeperated = "";
var c2s = pRo.CostBearer2SupportConceptList[0];
if (c2s.SupportConcept.Customer.CustomerAlias.Contains("AFB"))
{
lblLeistung.Text = "Fachberatung und -betreuung Autismusspektrum";
}
c2s.ApprovalPeriodList = c2s.ApprovalPeriodList.OrderBy(a => a.StartDate).ToList();
foreach (var scap in c2s.ApprovalPeriodList)
{
if (scap.StartDate <= pRo.EndDate && scap.EndDate >= pRo.StartDate)
{
if (scap.ApprovedBEInterval.HasValue)
{
if (scap.ApprovedBETotal != null)
{
pRo.ApprovedFLSTotal = scap.ApprovedBETotal ?? 0;
}
}
}
}
}
}
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);
}
}
}
}