160 lines
6.1 KiB
C#
160 lines
6.1 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 AspBegleitungNrw.Reporting
|
|
{
|
|
public partial class Quittierungsbeleg : XtraReport, IBeWoReport<ServicesOverviewRO>
|
|
{
|
|
public Quittierungsbeleg()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public void SetReportDataSource(ServicesOverviewRO pRO)
|
|
{
|
|
pRO.ReferenceNumber = "";
|
|
pRO.MainAttendantCommaSeperated = GetSchule(pRO);
|
|
bool pausenabzug = CheckPausenabzug(pRO);
|
|
if (pRO.StartDate < new DateTime(2024,06,01))
|
|
{
|
|
lblUnterschriftKlient.Text = "Datum, Unterschrift Klient*in";
|
|
}
|
|
|
|
if (pRO.Services != null)
|
|
{
|
|
if (pRO.Services[0].ServiceCategory != null)
|
|
{
|
|
pRO.ReferenceNumber = pRO.Services[0].ServiceCategory;
|
|
}
|
|
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 (!day2Detail.ContainsKey(sd.StartDate.Day))
|
|
{
|
|
sd.StartDateString = String.Format("{0:dddd dd.MM.}", sd.StartDate);
|
|
day2Detail.Add(sd.StartDate.Day, sd);
|
|
}
|
|
|
|
if (sd.IsBillable)
|
|
{
|
|
ServicesOverviewRO.CreateSignatureString(sd);
|
|
sd.Notice5 = "E";
|
|
if (sd.IsGroup)
|
|
{
|
|
//sd.Notice5 = String.Format("{0} Teilnehmer", sd.CustomerCount);
|
|
sd.Notice5 = "GR";
|
|
if (pausenabzug && sd.GroupRoundedDuration > 360)
|
|
{
|
|
sd.Minutes = (double)((sd.GroupRoundedDuration - 30) / sd.CustomerCount);
|
|
sd.Notice4 = "P";
|
|
}
|
|
}
|
|
if (!sd.IsGroup && pausenabzug && sd.Minutes > 360)
|
|
{
|
|
sd.Minutes = sd.Minutes - 30;
|
|
sd.Notice4 = "P";
|
|
}
|
|
servicesBillable.Add(sd);
|
|
}
|
|
}
|
|
|
|
//var count = pRO.EndDate - pRO.StartDate;
|
|
for (int i = 1; i <= pRO.EndDate.Day; i++)
|
|
{
|
|
if (!day2Detail.ContainsKey(i))
|
|
{
|
|
//Erstelle Dummy Records für fehlende Tage
|
|
var newSr = new ServicesOverviewRO.ServiceDetail();
|
|
if (i <= pRO.EndDate.Day)
|
|
{
|
|
newSr.StartDate = new DateTime(pRO.StartDate.Year, pRO.StartDate.Month, i);
|
|
newSr.StartDateString = String.Format("{0:dddd dd.MM.}", newSr.StartDate);
|
|
|
|
servicesBillable.Add(newSr);
|
|
}
|
|
}
|
|
}
|
|
|
|
pRO.Services = servicesBillable;
|
|
}
|
|
|
|
bindingSource1.DataSource = pRO;
|
|
}
|
|
|
|
private string GetSchule(ServicesOverviewRO pRO)
|
|
{
|
|
if (pRO.CostBearer2SupportConceptList != null && pRO.CostBearer2SupportConceptList.Count > 0)
|
|
{
|
|
var customer = pRO.CostBearer2SupportConceptList[0].SupportConcept.Customer;
|
|
foreach (var c2o in customer.Customer2OrganisationList)
|
|
{
|
|
foreach (var v2e in c2o.ValueList)
|
|
{
|
|
if (v2e.Entry.Type == ValueListEntryType.EnvironmentOrganisationType && v2e.Entry.Value.ToLower().Contains("schule"))
|
|
{
|
|
return c2o.Organisation.Name;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
private bool CheckPausenabzug(ServicesOverviewRO pRO)
|
|
{
|
|
if (pRO.CostBearer2SupportConceptList != null && pRO.CostBearer2SupportConceptList.Count > 0)
|
|
{
|
|
var vv = pRO.CostBearer2SupportConceptList[0].SupportConcept.VarFieldValueList.FirstOrDefault(v => v.VarFieldDefOid.Value == 90);
|
|
if (vv != null)
|
|
{
|
|
var varFieldValue = BS.Shared.Core.Utils.XMLDeserializeFromString(vv.SerializedValue, Type.GetType(vv.TypeName));
|
|
if (varFieldValue != null && varFieldValue.ToString().ToLower() == "true")
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
}
|