148 lines
4.4 KiB
C#
148 lines
4.4 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.ComponentModel;
|
|
using BeWo.Service.ServiceImplementations;
|
|
using BS.Shared.DataContracts;
|
|
using DevExpress.XtraReports.UI;
|
|
using BeWo.Report.ReportObjects;
|
|
using BeWo.Report;
|
|
using System.Collections.Generic;
|
|
using System.Drawing;
|
|
using System.IO;
|
|
using System.Text.RegularExpressions;
|
|
using BS.Shared.Core;
|
|
|
|
namespace LebenshilfeKusel
|
|
{
|
|
public partial class Stundenzettel : DevExpress.XtraReports.UI.XtraReport, IBeWoReport<ServicesOverviewRO>
|
|
{
|
|
public Stundenzettel()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public void SetReportDataSource(ServicesOverviewRO pRO)
|
|
{
|
|
double hTotal = 0;
|
|
bool showALS = false;
|
|
bool showLMS = false;
|
|
String empName = String.Empty;
|
|
Dictionary<String, bool> empCountDict = new Dictionary<String, bool>();
|
|
|
|
|
|
if (pRO.Services != null)
|
|
{
|
|
List<ServicesOverviewRO.ServiceDetail> servicesBillable = new List<ServicesOverviewRO.ServiceDetail>();
|
|
|
|
foreach (ServicesOverviewRO.ServiceDetail s in pRO.Services)
|
|
{
|
|
if (s.IsBillable)
|
|
{
|
|
ServicesOverviewRO.CreateSignatureString(s);
|
|
if (s.ServiceCategory.StartsWith("Assistenz"))
|
|
{
|
|
showALS = true;
|
|
}
|
|
else if (s.ServiceCategory.StartsWith("Leistung"))
|
|
{
|
|
showLMS = true;
|
|
}
|
|
else
|
|
{
|
|
hTotal += Math.Round(s.Minutes / 60, 2, MidpointRounding.AwayFromZero);
|
|
s.Notice = "d";
|
|
}
|
|
|
|
s.TimeRangeString = String.Format("{0:0.00}", s.Minutes / 60);
|
|
|
|
servicesBillable.Add(s);
|
|
|
|
//if (!String.IsNullOrEmpty(s.EmployeeFullname))
|
|
//{
|
|
// empName = s.EmployeeFullname;
|
|
// if (!empCountDict.ContainsKey(s.EmployeeFullname))
|
|
// empCountDict.Add(s.EmployeeFullname, true);
|
|
//}
|
|
}
|
|
|
|
}
|
|
|
|
pRO.Services = servicesBillable;
|
|
}
|
|
//if (empCountDict.Count == 1)
|
|
// pRO.MainAttendant = empName;
|
|
|
|
lblFLSTotal.Text = String.Format("{0:0.00}", hTotal);
|
|
//lblAbrechenbareFLS.Text = String.Format("{0:0.00}", (minTotal / 60) * 1.2);
|
|
|
|
|
|
|
|
|
|
|
|
lblBewilligteStunden.Text = String.Format("{0:0.##}/{1:0.##}", pRO.ApprovedFLSPerWeek, pRO.ApprovedFLSPerWeek * 4.34m);
|
|
|
|
var stats = GetStatistics(pRO);
|
|
if (stats != null)
|
|
{
|
|
lblBewilligteStunden.Text = String.Format("{0:0.##}/{1:0.##}", stats.MinutesApprovedPerWeek / 60, (stats.MinutesApprovedPerWeek / 60) * 4.34m);
|
|
}
|
|
|
|
bindingSource1.DataSource = pRO;
|
|
|
|
}
|
|
|
|
private SupportConceptPeriodStatisticsDC GetStatistics(ServicesOverviewRO ro)
|
|
{
|
|
if (ro.CostBearer2SupportConceptList != null && ro.CostBearer2SupportConceptList.Count > 0)
|
|
{
|
|
var service = new OperationsServiceImp();
|
|
long cb2scOid = ro.CostBearer2SupportConceptList[0].Oid.Value;
|
|
|
|
|
|
var stats = service.CreateSupportConceptStatistics(cb2scOid, ro.EndDate);
|
|
|
|
if (stats.PeriodStatistics != null && stats.PeriodStatistics.Count > 0)
|
|
{
|
|
foreach (var ps in stats.PeriodStatistics)
|
|
{
|
|
if (ps.SupportConceptApprovalPeriod != null && ps.SupportConceptApprovalPeriod.ServiceCategory != null &&
|
|
ps.SupportConceptApprovalPeriod.ServiceCategory.Name == "Direkte Betreuungsleistung")
|
|
{
|
|
return ps;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
private void picSignature_BeforePrint(object sender, 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;
|
|
}
|
|
|
|
}
|
|
}
|