213 lines
6.4 KiB
C#
213 lines
6.4 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using BS.Shared;
|
|
using DevExpress.XtraReports.UI;
|
|
using BeWo.Report.ReportObjects;
|
|
using BeWo.Report;
|
|
using System.Text.RegularExpressions;
|
|
using System.Drawing;
|
|
using System.IO;
|
|
using BS.Shared.Core;
|
|
|
|
namespace ProfEggersStiftung
|
|
{
|
|
public partial class Stundenzettel : DevExpress.XtraReports.UI.XtraReport, IBeWoReport<ServicesOverviewRO>
|
|
{
|
|
public Stundenzettel()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public void SetReportDataSource(ServicesOverviewRO pRO)
|
|
{
|
|
bool isJugendamt = CheckJugendamt(pRO);
|
|
|
|
|
|
double total = 0;
|
|
bool hatGruppen = false;
|
|
bool hatKlinik = false;
|
|
|
|
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)
|
|
{
|
|
hatGruppen = true;
|
|
}
|
|
|
|
if (isJugendamt)
|
|
{
|
|
if (s.ServiceCategory != "Terminausfall")
|
|
{
|
|
s.Minutes *= 1.2;
|
|
|
|
}
|
|
}
|
|
total += s.Minutes;
|
|
servicesBillable.Add(s);
|
|
|
|
if (s.Notice != null && (s.Notice.ToLower().Contains("krankenhaus") || s.Notice.ToLower().Contains("klinik")))
|
|
{
|
|
hatKlinik = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
pRO.Services = servicesBillable;
|
|
}
|
|
if (isJugendamt)
|
|
{
|
|
pRO.TotalFLMBillable = total;
|
|
|
|
cellFaktorHeader.Text = "Zeiteinheit in Minuten\ninkl.Faktor 1,2";
|
|
tableRowHeader.Height = 60;
|
|
tableGroup1.Top = 13;
|
|
tableGroup2.Top = 13;
|
|
}
|
|
else
|
|
{
|
|
cellFaktorHeader.Text = "Zeiteinheit in Minuten";
|
|
}
|
|
lbl1.Visible = false;
|
|
lbl2.Visible = false;
|
|
lbl3.Visible = false;
|
|
lbl4.Visible = false;
|
|
|
|
if (String.IsNullOrWhiteSpace(pRO.AbsenceTimes) && !hatKlinik)
|
|
{
|
|
lblHatAbwesenheiten.Text = "X";
|
|
}
|
|
|
|
if (!hatGruppen)
|
|
{
|
|
lblHatGruppen.Text = "X";
|
|
}
|
|
|
|
ErstelleAbwesenheitenTabelle(pRO);
|
|
|
|
this.bindingSource1.DataSource = pRO;
|
|
}
|
|
|
|
private bool CheckJugendamt(ServicesOverviewRO pRo)
|
|
{
|
|
bool isJugendamt = true;
|
|
|
|
if (pRo.CostBearer2SupportConceptList != null && pRo.CostBearer2SupportConceptList.Count > 0)
|
|
{
|
|
var c2s = pRo.CostBearer2SupportConceptList[0];
|
|
|
|
var f = c2s.CostBearer.Organisation.Function;
|
|
if (f != null)
|
|
{
|
|
if (f.Value.Contains("ohne"))
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
if (pRo.Costbearer == "LWL" || pRo.Costbearer == "LVR")
|
|
{
|
|
isJugendamt = false;
|
|
}
|
|
|
|
return isJugendamt;
|
|
}
|
|
|
|
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++;
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
public String GetBetreuungsart(ServicesOverviewRO pRO)
|
|
{
|
|
if (pRO.CostBearer2SupportConceptList != null && pRO.CostBearer2SupportConceptList.Count > 0)
|
|
{
|
|
var c2s = pRO.CostBearer2SupportConceptList[0];
|
|
|
|
foreach (var v2o in c2s.SupportConcept.Customer.ValueList)
|
|
{
|
|
if (v2o.Entry.Type == ValueListEntryType.CustomerCareType)
|
|
{
|
|
return v2o.Entry.Value;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
return "";
|
|
}
|
|
|
|
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)
|
|
{
|
|
using (var memoryStream = new MemoryStream(byteArrayIn))
|
|
{
|
|
return Image.FromStream(memoryStream);
|
|
}
|
|
}
|
|
}
|
|
}
|