148 lines
5.2 KiB
C#
148 lines
5.2 KiB
C#
using System;
|
|
using DevExpress.XtraReports.UI;
|
|
using BeWo.Report.ReportObjects;
|
|
using BeWo.Report;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Text.RegularExpressions;
|
|
using BS.Shared.Core;
|
|
using BS.Shared.Extensions;
|
|
using Image = System.Drawing.Image;
|
|
|
|
namespace BeWo.BrueckeABW
|
|
{
|
|
public partial class Stundenzettel : DevExpress.XtraReports.UI.XtraReport, IBeWoReport<ServicesOverviewRO>
|
|
{
|
|
public Stundenzettel()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public void SetReportDataSource(ServicesOverviewRO pRO)
|
|
{
|
|
Dictionary<string, string> empDict = new Dictionary<string, string>();
|
|
|
|
if (pRO.Services != null)
|
|
{
|
|
List<ServicesOverviewRO.ServiceDetail> servicesBillable = new List<ServicesOverviewRO.ServiceDetail>();
|
|
|
|
foreach (var s in pRO.Services)
|
|
{
|
|
if (s.IsBillable || s.ServiceDescription.ToLower().Contains("fehlkontakt") || s.ServiceCategory.ToLower().Contains("fehlkontakt"))
|
|
{
|
|
ServicesOverviewRO.CreateSignatureString(s);
|
|
s.Notice5 = "E";
|
|
if (s.IsGroup)
|
|
{
|
|
s.Notice5 = "G";
|
|
}
|
|
if (s.ServiceDescription.ToLower().Contains("fehlkontakt") || s.ServiceCategory.ToLower().Contains("fehlkontakt") || (s.ProzentAbrechenbar < 100))
|
|
{
|
|
s.Notice5 = "F";
|
|
}
|
|
|
|
if (!empDict.ContainsKey(s.EmployeeFullname))
|
|
{
|
|
empDict.Add(s.EmployeeFullname, s.EmployeeFullname);
|
|
}
|
|
|
|
if (s.SignatureDate.HasValue && s.SignatureDate.Value.Date == s.StartDate.Date)
|
|
{
|
|
s.SignatureDate = null;
|
|
}
|
|
|
|
servicesBillable.Add(s);
|
|
}
|
|
}
|
|
|
|
pRO.Services = servicesBillable;
|
|
}
|
|
|
|
cellSummeFLS.Text = String.Format("{0:0.00}", pRO.TotalFLSoFehlkontakte);
|
|
cellSummeFK.Text = String.Format("{0:0.00}", pRO.TotalFLSFehlkontakte);
|
|
|
|
if (empDict.Count > 0)
|
|
{
|
|
pRO.MainAttendant = empDict.Values.ToSeparatedString(", ");
|
|
}
|
|
|
|
if (String.IsNullOrWhiteSpace(pRO.AbsenceTimes))
|
|
{
|
|
lblHatAbwesenheiten.Text = "X";
|
|
}
|
|
|
|
ErstelleAbwesenheitenTabelle(pRO);
|
|
|
|
this.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 void picSignature_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);
|
|
System.Drawing.Image img = ByteArrayToImage(binData);
|
|
xrBox.Image = Utils.CropImage(img);
|
|
}
|
|
else
|
|
{
|
|
xrBox.Image = null;
|
|
}
|
|
}
|
|
|
|
public System.Drawing.Image ByteArrayToImage(byte[] byteArrayIn)
|
|
{
|
|
System.Drawing.Image returnImage = null;
|
|
MemoryStream ms = new System.IO.MemoryStream(byteArrayIn);
|
|
returnImage = Image.FromStream(ms);
|
|
|
|
return returnImage;
|
|
}
|
|
}
|
|
}
|
|
|