using System; using System.Collections; using System.ComponentModel; using DevExpress.XtraReports.UI; using BeWo.Report.ReportObjects; using BeWo.Report; using System.Collections.Generic; namespace AbwKlassen { public partial class Stundenzettel : DevExpress.XtraReports.UI.XtraReport, IBeWoReport { public Stundenzettel() { InitializeComponent(); } public void SetReportDataSource(ServicesOverviewRO pRO) { bool hatGruppen = false; if (pRO.Services != null) { List servicesBillable = new List(); foreach (ServicesOverviewRO.ServiceDetail s in pRO.Services) { if (s.IsBillable || s.ServiceDescription.ToLower().Contains("fehlkontakt")) { if (s.ServiceDescription.ToLower().Contains("fehlkontakt")) s.TimeRangeString = "(FK) " + s.TimeRangeString; if (s.IsGroup) { hatGruppen = true; } servicesBillable.Add(s); } } pRO.Services = servicesBillable; } if (String.IsNullOrWhiteSpace(pRO.AbsenceTimes)) { lblHatAbwesenheiten.Text = "X"; } if (!hatGruppen) { lblHatGruppen.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++; } if (newRows > 0) { lbl1.Top += newRows * 20; lbl2.Top += newRows * 20; lbl3.Top += newRows * 20; } } } } }