using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using DevExpress.XtraReports.UI;
using BeWo.Report.ReportObjects;
using BeWo.Report;

namespace BeWo.Report.DefaultReports
{
    public partial class Spitzabrechnung : DevExpress.XtraReports.UI.XtraReport, IBeWoReport<Settlement2RO>
    {
        public Spitzabrechnung()
        {
            InitializeComponent();
        }

        public void SetReportDataSource(Settlement2RO pRO)
        {
			//if (String.IsNullOrEmpty(pRO.Notice))
			//{
			//	lblNotice.Visible = false;
			//}

	        if (pRO.TerminationDate.HasValue)
	        {
		        chkBetreuungBeendet.Text = String.Format("Die Betreuung wurde am {0:dd.MM.yyyy} beendet.", pRO.TerminationDate);
				chkBetreuungBeendet.Checked = true;
	        }
	        else
	        {
		        chkBetreuungDauertAn.Checked = true;
	        }

			decimal rateFactor = 1;

			foreach (var ii in pRO.InvoiceItems)
			{
				if (ii.RateFactor.HasValue)
				{
					rateFactor = (100 + ii.RateFactor.Value) / 100;
				}
			}
			pRO.RateFactor = (double)rateFactor;

            this.bindingSource1.DataSource = pRO;
        }
    }
}
