Files
BeWoPlaner/ReportImp/AwoIntegrationsGGmbH/Quittierungsbeleg.cs

127 lines
4.6 KiB
C#

using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using BeWo.Data.Access;
using BeWo.Data.Entities;
using BeWo.Report.ReportObjects;
using BS.Shared;
using BS.Shared.Core;
using DevExpress.XtraReports.UI;
namespace BeWo.Report.DefaultReports
{
public partial class Quittierungsbeleg : XtraReport, IBeWoReport<ServicesOverviewRO>
{
public Quittierungsbeleg()
{
InitializeComponent();
}
public void SetReportDataSource(ServicesOverviewRO pRO)
{
if (pRO.Services != null)
{
List<ServicesOverviewRO.ServiceDetail> servicesBillable = new List<ServicesOverviewRO.ServiceDetail>();
foreach (var sd in pRO.Services)
{
if (sd.IsBillable || sd.ServiceDescription.ToLower().Contains("fehlkontakt") || sd.ServiceCategory.ToLower().Contains("fehlkontakt"))
{
ServicesOverviewRO.CreateSignatureString(sd);
// abklären, wann facetoface ja ist und wann nein
sd.Notice5 = "Nein";
if (sd.ServiceDescription.ToLower().Contains("face") || sd.ServiceDescription.ToLower().StartsWith("co"))
{
sd.Notice5 = "Ja";
}
servicesBillable.Add(sd);
}
}
pRO.Services = servicesBillable;
}
if (pRO.CostBearer2SupportConceptList != null)
{
SetzeBetreuungsAngaben(pRO.CostBearer2SupportConceptList);
}
bindingSource1.DataSource = pRO;
}
private void SetzeBetreuungsAngaben(IList<CostBearer2SupportConcept> costBearer2SupportConceptList)
{
var cb2sc = costBearer2SupportConceptList[0];
var customer = cb2sc.SupportConcept.Customer;
foreach (var c2o in customer.Employee2CustomerList)
{
foreach (var v2o in c2o.ValueList)
{
if (v2o.Entry.SystemEntryID.HasValue && v2o.Entry.SystemEntryID.Value == SystemEntryID.EmployeeRoleMainAttendant
&& c2o.Employee != null && c2o.Employee.ValueList != null && c2o.Employee.ValueList.Count > 0)
{
var quali = c2o.Employee.ValueList.Where(v => v.Entry.Type == ValueListEntryType.StaffQualificationsType).FirstOrDefault();
if (quali != null)
{
lblQuali.Text = quali.Entry.Value;
}
}
}
}
//Angaben zur Betreuungsart / Hilfeart
string angabe = "";
var betreuungsarten = customer.ValueList.Where(v2o => v2o.Entry.Type == ValueListEntryType.CustomerCareType).ToList();
if (betreuungsarten != null && betreuungsarten.Count > 0)
{
foreach (var art in betreuungsarten)
{
Match match = Regex.Match(art.Entry.Value, @"\(([^)]*)\)");
if (match.Success)
{
if (angabe != "")
{
angabe += ", ";
}
angabe += match.Groups[1].Value.Trim();
}
}
lblBetreuungsart.Text = angabe;
}
}
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);
}
}
}
}