209 lines
6.6 KiB
C#
209 lines
6.6 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.Linq;
|
|
using System.Text.RegularExpressions;
|
|
using BS.Shared.Core;
|
|
|
|
namespace BeWo.LebenshilfeDuisburgReports.Neu
|
|
{
|
|
public partial class Stundenzettel : DevExpress.XtraReports.UI.XtraReport, IBeWoReport<ServicesOverviewRO>
|
|
{
|
|
public Stundenzettel()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public void SetReportDataSource(ServicesOverviewRO pRO)
|
|
{
|
|
double minTotal = 0;
|
|
bool hatGruppen = 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.IsGroup)
|
|
{
|
|
//sd.Notice5 = String.Format("{0} Teilnehmer", sd.CustomerCount);
|
|
hatGruppen = true;
|
|
}
|
|
|
|
minTotal += s.Minutes;
|
|
s.Notice = "d";
|
|
|
|
|
|
|
|
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 (pRO.Abwesenheiten != null)
|
|
{
|
|
pRO.Abwesenheiten = pRO.Abwesenheiten.Where(a => a.AbsenceReason.Description.Contains("Krankenhaus")).ToList();
|
|
}
|
|
|
|
//if (empCountDict.Count == 1)
|
|
// pRO.MainAttendant = empName;
|
|
|
|
lblFLSTotal.Text = String.Format("{0:0.00}", minTotal / 60);
|
|
lblAbrechenbareFLS.Text = String.Format("{0:0.00}", (minTotal / 60) * 1.2);
|
|
|
|
lblMinutenTotal.Text = String.Format("{0:0.##}", minTotal);
|
|
lblMinutenMitFaktor.Text = String.Format("{0:0.##}", (minTotal) * 1.2);
|
|
|
|
|
|
|
|
lblBewilligteStunden.Text = String.Format("{0:0.##} Stunden", pRO.ApprovedFLSPerWeek);
|
|
|
|
var stats = GetStatistics(pRO);
|
|
if (stats != null)
|
|
{
|
|
lblBewilligteStunden.Text = String.Format("{0:0.##} Stunden", stats.MinutesApprovedPerWeek / 60);
|
|
}
|
|
|
|
if (pRO.Abwesenheiten == null || pRO.Abwesenheiten.Count == 0)
|
|
{
|
|
lblHatAbwesenheiten.Text = "X";
|
|
FooterKrankenhaus.Visible = false;
|
|
}
|
|
else
|
|
{
|
|
ErstelleAbwesenheitenTabelle(pRO);
|
|
}
|
|
|
|
if (!hatGruppen)
|
|
{
|
|
lblHatGruppen.Text = "X";
|
|
}
|
|
|
|
|
|
bindingSource1.DataSource = pRO;
|
|
|
|
}
|
|
|
|
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 SupportConceptPeriodStatisticsDC GetStatistics(ServicesOverviewRO ro)
|
|
{
|
|
if (ro.CostBearer2SupportConceptList != null && ro.CostBearer2SupportConceptList.Count > 0)
|
|
{
|
|
foreach (var c2s in ro.CostBearer2SupportConceptList)
|
|
{
|
|
var service = new OperationsServiceImp();
|
|
long cb2scOid = c2s.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;
|
|
}
|
|
}
|
|
}
|