Files
BeWoPlaner/ReportImp/DiakonischesWerkDinslakenSozio/LeistungsnachweisSoziotherapie.cs

166 lines
6.7 KiB
C#

using System;
using BS.Shared.Core;
using DevExpress.XtraReports.UI;
using BeWo.Report.ReportObjects;
using BeWo.Report;
using BeWo.Data.Access;
using BeWo.Data.Entities;
using BeWo.Service.DCEntityMapper;
using System.Text.RegularExpressions;
using System.IO;
namespace DiakonischesWerkDinslakenSozio
{
public partial class LeistungsnachweisSoziotherapie : DevExpress.XtraReports.UI.XtraReport, IBeWoReport<ServicesOverviewRO>
{
public LeistungsnachweisSoziotherapie()
{
InitializeComponent();
}
public void SetReportDataSource(ServicesOverviewRO pRO)
{
double gesamt = 0;
double gesamtGruppe = 0;
if (pRO.Services != null)
{
foreach (ServicesOverviewRO.ServiceDetail s in pRO.Services)
{
ServicesOverviewRO.CreateSignatureString(s);
var serviceRecord = DAOFactory.GenericDAO.LoadByID<ServiceRecord>(s.ServiceRecordOid);
pRO.ReferenceNumber = serviceRecord.CostBearer2SupportConcept.CustomerReferenceNumber;
if (serviceRecord.CostBearer2SupportConcept.ApprovedStartDate != null)
pRO.ApprovedStartDate = String.Format("{0:dd.MM.yyyy}", serviceRecord.CostBearer2SupportConcept.ApprovedStartDate);
if (serviceRecord.CostBearer2SupportConcept.ApprovedEndDate != null)
pRO.ApprovedEndDate = String.Format("{0:dd.MM.yyyy}", serviceRecord.CostBearer2SupportConcept.ApprovedEndDate);
var srDc = MapperFactory.ServiceRecordDC_ServiceRecord.MapToNewDC(serviceRecord);
s.GoalList = String.Empty;
if (srDc.Goals != null && srDc.Goals.Count > 0)
{
foreach (var goal in srDc.Goals)
{
if (!String.IsNullOrEmpty(goal.Abbreviation))
{
if (s.GoalList.Length > 0)
s.GoalList += ", ";
s.GoalList += goal.Abbreviation;
}
}
}
var leistung = s.ServiceDescription.ToLower();
if (leistung.Contains("gruppe")) //die erstellen meist über Mehrfachbuchung
{
s.IsGroup = true;
gesamtGruppe += s.Minutes;
s.ServiceDescription = "G";
if (s.Minutes <= 45)
s.Notice5 = "2002678";
else if (s.Minutes <= 60)
s.Notice5 = "2002677";
else
s.Notice5 = "2002672";
}
else
{
gesamt += s.Minutes;
if (leistung.Contains("video"))
{
s.ServiceDescription = "V";
if (s.Minutes <= 30)
s.Notice5 = "2001616";
else
s.Notice5 = "2001615";
}
else if (leistung.Contains("telefonat"))
{
s.ServiceDescription = "T";
if (s.Minutes <= 30)
s.Notice5 = "2001618";
else
s.Notice5 = "2001617";
}
else if (leistung.Contains("aufsuchende einheit"))
{
s.ServiceDescription = "A";
if (s.Minutes <= 10)
s.Notice5 = "2001613 / 2009690";
else if (s.Minutes <= 30)
s.Notice5 = "2001612 / 2009690";
else if (s.Minutes <= 45)
s.Notice5 = "2001611 / 2009690";
else
s.Notice5 = "2001610 / 2009690";
}
else if (leistung.Contains("probatorik"))
{
if (leistung.Contains("aufsuchend"))
{
s.ServiceDescription = "AP";
s.Notice5 = "2001607 / 2009690";
}
else if (leistung.Contains("büro"))
{
s.ServiceDescription = "P";
s.Notice5 = "2001607";
}
}
else if (leistung.Contains("büro-einheit"))
{
s.ServiceDescription = "E";
if (s.Minutes <= 10)
s.Notice5 = "2001613";
else if (s.Minutes <= 30)
s.Notice5 = "2001612";
else if (s.Minutes <= 45)
s.Notice5 = "2001611";
else
s.Notice5 = "2001610";
}
}
}
}
cellGesamt.Text = String.Format("{0:0.00}", gesamt / 60);
if (gesamtGruppe > 0)
{
cellGesamtGruppe.Text = String.Format("{0:0.00}", gesamtGruppe / 90);
}
this.bindingSource1.DataSource = pRO;
}
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);
}
}
}
}