291 lines
11 KiB
C#
291 lines
11 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text.RegularExpressions;
|
|
using BeWo.Data.Access;
|
|
using BeWo.Data.Entities;
|
|
using BeWo.Report;
|
|
using BeWo.Report.ReportObjects;
|
|
using BS.Shared;
|
|
using BS.Shared.Core;
|
|
using DevExpress.XtraReports.UI;
|
|
using Image = System.Drawing.Image;
|
|
|
|
namespace LebenshilfeTrier
|
|
{
|
|
public partial class Stundenzettel : DevExpress.XtraReports.UI.XtraReport, IBeWoReport<ServicesOverviewRO>
|
|
{
|
|
public Stundenzettel()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public void SetReportDataSource(ServicesOverviewRO pRO)
|
|
{
|
|
double geleistetQ1 = 0;
|
|
double geleistetQ2 = 0;
|
|
decimal anzHausbesuch = 0;
|
|
decimal anzKlientKommt = 0;
|
|
decimal anzEinzel = 0;
|
|
decimal anzGruppe = 0;
|
|
|
|
|
|
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);
|
|
|
|
servicesBillable.Add(s);
|
|
|
|
if (s.IsGroup)
|
|
{
|
|
anzGruppe++;
|
|
}
|
|
else
|
|
{
|
|
anzEinzel++;
|
|
}
|
|
|
|
if (s.ServiceCategory == "Q1")
|
|
{
|
|
geleistetQ1 += s.Minutes;
|
|
}
|
|
else if (s.ServiceCategory == "Q2")
|
|
{
|
|
geleistetQ2 += s.Minutes;
|
|
}
|
|
ServicesOverviewRO.CreateGoalList(s);
|
|
if (!String.IsNullOrEmpty(s.GoalList))
|
|
{
|
|
if (s.GoalList.Contains("Hausbesuch"))
|
|
{
|
|
anzHausbesuch++;
|
|
}
|
|
if (s.GoalList.Contains("Klient kommt"))
|
|
{
|
|
anzKlientKommt++;
|
|
}
|
|
|
|
if (s.GoalList.Contains("0"))
|
|
{
|
|
s.Notice5 = "0";
|
|
}
|
|
else if (s.GoalList.Contains("1"))
|
|
{
|
|
s.Notice5 = "1";
|
|
}
|
|
else if (s.GoalList.Contains("2"))
|
|
{
|
|
s.Notice5 = "2";
|
|
}
|
|
else if (s.GoalList.Contains("3"))
|
|
{
|
|
s.Notice5 = "3";
|
|
}
|
|
else if (s.GoalList.Contains("4"))
|
|
{
|
|
s.Notice5 = "4";
|
|
}
|
|
else if (s.GoalList.Contains("5"))
|
|
{
|
|
s.Notice5 = "5";
|
|
}
|
|
else if (s.GoalList.Contains("6"))
|
|
{
|
|
s.Notice5 = "6";
|
|
}
|
|
|
|
|
|
}
|
|
|
|
s.ServiceDescription = s.ServiceDescription.Substring(0, 2).Trim();
|
|
}
|
|
}
|
|
|
|
pRO.Services = servicesBillable;
|
|
}
|
|
|
|
lblGeleistetQ1.Text = String.Format("{0:0.00}", geleistetQ1 / 60);
|
|
lblGeleistetQ2.Text = String.Format("{0:0.00}", geleistetQ2 / 60);
|
|
|
|
lblAnzahlHausbesuch.Text = String.Format("{0:0}", anzHausbesuch);
|
|
lblAnzahlKlientKommt.Text = String.Format("{0:0}", anzKlientKommt);
|
|
lblAnzahlIndAngebot.Text = String.Format("{0:0}", anzEinzel);
|
|
lblAnzahlGruppe.Text = String.Format("{0:0}", anzGruppe);
|
|
|
|
lblQ1SummeMinuten.Text = String.Format("Summe Q1 in Minuten: {0:0.##}", geleistetQ1);
|
|
lblQ2SummeMinuten.Text = String.Format("Summe Q2 in Minuten: {0:0.##}", geleistetQ2);
|
|
|
|
SetKopfdaten(pRO);
|
|
|
|
lblDatum.Text = String.Format("{0:dddd, dd.MMMM yyyy}", DateTime.Now);
|
|
|
|
bindingSource1.DataSource = pRO;
|
|
}
|
|
|
|
private void SetKopfdaten(ServicesOverviewRO ro)
|
|
{
|
|
if (ro.CostBearer2SupportConceptList != null && ro.CostBearer2SupportConceptList.Count > 0)
|
|
{
|
|
foreach (var cb2sc in ro.CostBearer2SupportConceptList)
|
|
{
|
|
var c = ro.CostBearer2SupportConceptList[0].SupportConcept.Customer;
|
|
|
|
lblDebitor.Text = c.DebitorNumber;
|
|
|
|
long cb2scOid = cb2sc.Oid.Value;
|
|
|
|
var c2s = DAOFactory.GenericDAO.LoadByID<CostBearer2SupportConcept>(cb2scOid);
|
|
|
|
var org = c2s.CostBearer.Organisation;
|
|
ro.Costbearer = org.Name;
|
|
|
|
if (org.Address != null)
|
|
{
|
|
lblCostbearerStreet.Text = org.Address.Street;
|
|
lblCostbearerAdresszusatz.Text = org.Address.AddressLine1;
|
|
lblCostbearerPlzOrt.Text = String.Format("{0} {1}", org.Address.PostalCode, org.Address.Town);
|
|
}
|
|
|
|
if (c2s.CostBearerContactPerson != null)
|
|
{
|
|
lblSachbearbeiter.Text = c2s.CostBearerContactPerson.LastName;
|
|
}
|
|
var q1 = c2s.ApprovalPeriodList.FirstOrDefault(a => a.ServiceCategory != null && a.ServiceCategory.Name == "Q1");
|
|
var q2 = c2s.ApprovalPeriodList.FirstOrDefault(a => a.ServiceCategory != null && a.ServiceCategory.Name == "Q2");
|
|
|
|
if (q1 != null)
|
|
{
|
|
SetBewilligung(q1, lblBewilligtQ1Woche, lblBewilligtQ1Monat);
|
|
|
|
}
|
|
if (q2 != null)
|
|
{
|
|
SetBewilligung(q2, lblBewilligtQ2Woche, lblBewilligtQ2Monat);
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
if (ro.Mandator != null)
|
|
{
|
|
lblMandatorName.Text = ro.Mandator.Name;
|
|
lblMandatorStreet.Text = ro.Mandator.Street;
|
|
lblMandatorPlzOrt.Text = String.Format("{0} {1}", ro.Mandator.PostalCode, ro.Mandator.Town);
|
|
}
|
|
}
|
|
|
|
private void SetBewilligung(SupportConceptApprovalPeriod scap, XRLabel wochenLabel, XRLabel monatsLabel)
|
|
{
|
|
decimal proWoche = 0;
|
|
decimal proMonat = 0;
|
|
|
|
if (scap.ApprovedBEPerInterval.HasValue && scap.ApprovedBEInterval.HasValue)
|
|
{
|
|
if (scap.ApprovedBEInterval.Value == SupportConceptApprovalInterval.Weekly)
|
|
{
|
|
proWoche = scap.ApprovedBEPerInterval.Value;
|
|
proMonat = proWoche * 4.33m;
|
|
}
|
|
else if (scap.ApprovedBEInterval.Value == SupportConceptApprovalInterval.Monthly)
|
|
{
|
|
proMonat = scap.ApprovedBEPerInterval.Value;
|
|
proWoche = proMonat / 4.33m;
|
|
}
|
|
}
|
|
else if (scap.ApprovedBETotal.HasValue)
|
|
{
|
|
var monate = DateTimeUtils.GetTotalMonths(scap.StartDate.Value, scap.EndDate.Value);
|
|
if (monate.GanzeMonate > 0)
|
|
{
|
|
proMonat = scap.ApprovedBETotal.Value / monate.GanzeMonate;
|
|
proWoche = proMonat / 4.33m;
|
|
}
|
|
}
|
|
wochenLabel.Text = String.Format("{0:0.00}", proWoche);
|
|
monatsLabel.Text = String.Format("{0:0.00}", proMonat);
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
private void chkHausbesuch_BeforePrint(object sender, System.ComponentModel.CancelEventArgs e)
|
|
{
|
|
var sd = DetailReport.GetCurrentRow() as ServicesOverviewRO.ServiceDetail;
|
|
|
|
bool check = false;
|
|
if (sd != null)
|
|
{
|
|
if (!String.IsNullOrWhiteSpace(sd.GoalList) && sd.GoalList.Contains("Hausbesuch"))
|
|
{
|
|
check = true;
|
|
}
|
|
}
|
|
|
|
((XRCheckBox) sender).Checked = check;
|
|
}
|
|
|
|
private void chkKlientKommt_BeforePrint(object sender, System.ComponentModel.CancelEventArgs e)
|
|
{
|
|
var sd = DetailReport.GetCurrentRow() as ServicesOverviewRO.ServiceDetail;
|
|
|
|
bool check = false;
|
|
if (sd != null)
|
|
{
|
|
if (!String.IsNullOrWhiteSpace(sd.GoalList) && sd.GoalList.Contains("Klient kommt"))
|
|
{
|
|
check = true;
|
|
}
|
|
}
|
|
|
|
((XRCheckBox)sender).Checked = check;
|
|
}
|
|
|
|
private void chkNichtTeilgenommen_BeforePrint(object sender, System.ComponentModel.CancelEventArgs e)
|
|
{
|
|
var sd = DetailReport.GetCurrentRow() as ServicesOverviewRO.ServiceDetail;
|
|
|
|
bool check = false;
|
|
if (sd != null)
|
|
{
|
|
if (!String.IsNullOrWhiteSpace(sd.GoalList) && sd.GoalList.Contains("nicht teilgenommen"))
|
|
{
|
|
check = true;
|
|
}
|
|
}
|
|
|
|
((XRCheckBox)sender).Checked = check;
|
|
}
|
|
}
|
|
}
|