186 lines
6.5 KiB
C#
186 lines
6.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Drawing;
|
|
using System.IO;
|
|
using System.Text.RegularExpressions;
|
|
using BeWo.Data.Access;
|
|
using BeWo.Data.Entities;
|
|
using BeWo.Report;
|
|
using BeWo.Report.ReportObjects;
|
|
using BS.Shared.Core;
|
|
using DevExpress.XtraReports.UI;
|
|
|
|
namespace SelfGbR
|
|
{
|
|
public partial class Quittierungsbeleg : XtraReport, IBeWoReport<ServicesOverviewRO>
|
|
{
|
|
public Quittierungsbeleg()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public void SetReportDataSource(ServicesOverviewRO pRO)
|
|
{
|
|
bool hatGruppen = false;
|
|
|
|
Dictionary<string, string> cats = new Dictionary<string, string>();
|
|
|
|
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") || sd.ServiceCategory.ToLower().Contains("fehlkontakt"))
|
|
{
|
|
ServicesOverviewRO.CreateSignatureString(sd);
|
|
|
|
sd.Notice5 = "E";
|
|
if (sd.IsGroup)
|
|
{
|
|
sd.Notice5 = "GR";
|
|
hatGruppen = true;
|
|
}
|
|
if (sd.ServiceDescription.ToLower().Contains("fehlkontakt") || sd.ServiceCategory.ToLower().Contains("fehlkontakt"))
|
|
{
|
|
sd.Notice5 = "F";
|
|
totalFK += sd.Minutes;
|
|
}
|
|
else
|
|
{
|
|
totalFLM += sd.Minutes;
|
|
}
|
|
|
|
servicesBillable.Add(sd);
|
|
}
|
|
}
|
|
|
|
xrLabel1.Text = String.Format("{0:0.##}", totalFLM);
|
|
xrLabel20.Text = String.Format("{0:0.##}", totalFK);
|
|
|
|
pRO.Services = servicesBillable;
|
|
}
|
|
|
|
if (String.IsNullOrWhiteSpace(pRO.AbsenceTimes))
|
|
{
|
|
lblHatAbwesenheiten.Text = "X";
|
|
}
|
|
|
|
if (!hatGruppen)
|
|
{
|
|
lblHatGruppen.Text = "X";
|
|
}
|
|
|
|
if (pRO.CostBearer2SupportConceptList.Count > 0)
|
|
{
|
|
var c2s = pRO.CostBearer2SupportConceptList[0];
|
|
var c2se = DAOFactory.GenericDAO.LoadByID<CostBearer2SupportConcept>(c2s.Oid.Value);
|
|
var bewilligteWochenStd = "";
|
|
foreach (var scap in c2se.ApprovalPeriodList)
|
|
{
|
|
if (scap.ServiceCategory != null)
|
|
{
|
|
var kategorie = scap.ServiceCategory.Name;
|
|
if (kategorie.ToLower().Contains("fachleistung"))
|
|
{
|
|
bewilligteWochenStd += String.Format(" FLS: {0:0.##}", scap.ApprovedBEPerInterval);
|
|
}
|
|
else if (kategorie.ToLower().Contains("hintergrunddienst"))
|
|
{
|
|
bewilligteWochenStd += String.Format(" HD: {0:0.##}", scap.ApprovedBEPerInterval);
|
|
}
|
|
else if (kategorie.ToLower().Contains("assistenz"))
|
|
{
|
|
// nix tun (eigner QB)
|
|
}
|
|
else
|
|
{
|
|
bewilligteWochenStd += (" " + kategorie);
|
|
bewilligteWochenStd += String.Format(": {0:0.##}", scap.ApprovedBEPerInterval);
|
|
}
|
|
}
|
|
}
|
|
lblBewillgteFLS.Text = bewilligteWochenStd.Trim();
|
|
}
|
|
|
|
|
|
ErstelleAbwesenheitenTabelle(pRO);
|
|
|
|
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++;
|
|
}
|
|
|
|
if (newRows > 0)
|
|
{
|
|
lblUnterschriftKlient.Top += newRows * 20;
|
|
lblUnterschriftMitarbeiter.Top += newRows * 20;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void picSignature_BeforePrint(object sender, System.ComponentModel.CancelEventArgs e)
|
|
{
|
|
XRPictureBox xrBox = sender as XRPictureBox;
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
}
|