184 lines
7.0 KiB
C#
184 lines
7.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Drawing;
|
|
using System.IO;
|
|
using System.Text.RegularExpressions;
|
|
using BeWo.Report;
|
|
using BeWo.Report.ReportObjects;
|
|
using BeWo.Service.ServiceImplementations;
|
|
using BS.Shared.Core;
|
|
using DevExpress.XtraReports.UI;
|
|
|
|
namespace LebenshilfeRemscheidWohngruppe
|
|
{
|
|
partial class Quittierungsbeleg : DevExpress.XtraReports.UI.XtraReport, IBeWoReport<ServicesOverviewRO>
|
|
{
|
|
public Quittierungsbeleg()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public void SetReportDataSource(ServicesOverviewRO pRO)
|
|
{
|
|
lblBewilligteLeistung.Text = String.Format("{0:0.00} h / {1:0} min. mtl. // {2:0.##} h ges.", pRO.ApprovedFLSPerWeek, Math.Round(pRO.ApprovedFLSPerWeek * 4.34m * 60, 0, MidpointRounding.AwayFromZero), pRO.ApprovedFLSTotal);
|
|
|
|
bool hatGruppen = false;
|
|
|
|
if (pRO.Services != null)
|
|
{
|
|
List<ServicesOverviewRO.ServiceDetail> servicesBillable = new List<ServicesOverviewRO.ServiceDetail>();
|
|
|
|
double totalFLM = 0;
|
|
double totalFK = 0;
|
|
|
|
foreach (var sd in pRO.Services)
|
|
{
|
|
if (sd.IsBillable || sd.ServiceDescription.ToLower().Contains("fehlkontakt"))
|
|
{
|
|
ServicesOverviewRO.CreateSignatureString(sd);
|
|
servicesBillable.Add(sd);
|
|
}
|
|
sd.Notice5 = "";
|
|
if (sd.ServiceDescription.ToLower().Contains("fehlkontakt"))
|
|
{
|
|
sd.Notice5 = "X";
|
|
totalFK += sd.Minutes;
|
|
}
|
|
else
|
|
{
|
|
totalFLM += sd.Minutes;
|
|
}
|
|
if (sd.IsGroup)
|
|
{
|
|
hatGruppen = true;
|
|
}
|
|
}
|
|
|
|
lblSummeFLM.Text = String.Format("{0:0.##}", totalFLM);
|
|
lblSummeFK.Text = String.Format("{0:0.##}", totalFK);
|
|
|
|
pRO.Services = servicesBillable;
|
|
}
|
|
|
|
if (String.IsNullOrWhiteSpace(pRO.AbsenceTimes))
|
|
{
|
|
lblHatAbwesenheiten.Text = "X";
|
|
}
|
|
|
|
if (!hatGruppen)
|
|
{
|
|
lblHatGruppen.Text = "X";
|
|
}
|
|
|
|
SetzeBewilligungInfos(pRO);
|
|
ErstelleAbwesenheitenTabelle(pRO);
|
|
|
|
bindingSource1.DataSource = pRO;
|
|
}
|
|
|
|
private void SetzeBewilligungInfos(ServicesOverviewRO ro)
|
|
{
|
|
if (ro.CostBearer2SupportConceptList != null && ro.CostBearer2SupportConceptList.Count > 0)
|
|
{
|
|
var service = new OperationsServiceImp();
|
|
|
|
foreach (var cb2sc in ro.CostBearer2SupportConceptList)
|
|
{
|
|
long cb2scOid = cb2sc.Oid.Value;
|
|
|
|
var stats = service.CreateSupportConceptStatistics(cb2scOid, ro.EndDate);
|
|
|
|
if (stats.PeriodStatistics != null && stats.PeriodStatistics.Count > 0)
|
|
{
|
|
foreach (var ps in stats.PeriodStatistics)
|
|
{
|
|
// Assistenzbewilligung ausschließen
|
|
if (ps.SupportConceptApprovalPeriod != null && ps.SupportConceptApprovalPeriod.ServiceCategory != null &&
|
|
!ps.SupportConceptApprovalPeriod.ServiceCategory.Name.Contains("Assistenz"))
|
|
{
|
|
var bewillgteFlsProWoche = ps.MinutesApprovedPerWeek / 60;
|
|
lblBewilligteLeistung.Text = String.Format("{0:0.00} h / {1:0} min. mtl. // {2:0.##} h ges.",
|
|
bewillgteFlsProWoche,
|
|
Math.Round(bewillgteFlsProWoche * 4.34m * 60, 0, MidpointRounding.AwayFromZero),
|
|
ps.MinutesApprovedTotal / 60);
|
|
if (ps.SupportConceptApprovalPeriod != null)
|
|
{
|
|
lblBewilligungszeitraum.Text = String.Format("{0:dd.MM.yyyy} - {1:dd.MM.yyyy}",
|
|
ps.SupportConceptApprovalPeriod.StartDate,
|
|
ps.SupportConceptApprovalPeriod.EndDate);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private void ErstelleAbwesenheitenTabelle(ServicesOverviewRO pRo)
|
|
{
|
|
if (pRo.Abwesenheiten != null)
|
|
{
|
|
int newRows = 0;
|
|
int index = 1;
|
|
foreach (var at in pRo.Abwesenheiten)
|
|
{
|
|
DevExpress.XtraReports.UI.XRTableRow row = null;
|
|
if (index < xrTableAbwesenheiten.Rows.Count)
|
|
{
|
|
row = xrTableAbwesenheiten.Rows[index];
|
|
}
|
|
else
|
|
{
|
|
row = xrTableAbwesenheiten.InsertRowBelow(xrTableAbwesenheiten.Rows[xrTableAbwesenheiten.Rows.Count - 1]);
|
|
newRows++;
|
|
}
|
|
|
|
row.Cells[0].Text = String.Format("{0:dd.MM.yyyy}", at.Start);
|
|
int? days = null;
|
|
|
|
if (at.End.HasValue)
|
|
{
|
|
row.Cells[1].Text = String.Format("{0:dd.MM.yyyy}", at.End);
|
|
days = (int)at.End.Value.Subtract(at.Start.Value).TotalDays + 1;
|
|
}
|
|
else
|
|
{
|
|
row.Cells[1].Text = "unbekannt";
|
|
}
|
|
|
|
row.Cells[2].Text = String.Format("{0:0}", days);
|
|
|
|
index++;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void xrPictureBox2_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);
|
|
Image img = ByteArrayToImage(binData);
|
|
xrBox.Image = Utils.CropImage(img);
|
|
}
|
|
else
|
|
{
|
|
xrBox.Image = null;
|
|
}
|
|
}
|
|
|
|
public Image ByteArrayToImage(byte[] byteArrayIn)
|
|
{
|
|
Image returnImage = null;
|
|
MemoryStream ms = new System.IO.MemoryStream(byteArrayIn);
|
|
returnImage = Image.FromStream(ms);
|
|
|
|
return returnImage;
|
|
}
|
|
}
|
|
}
|