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

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

        public void SetReportDataSource(SettlementRO pRO)
        {
			//decimal max = Math.Round(pRO.TotalApprovedFLSWithOldHourlyRate * (pRO.HourlyRateOld ?? 0) * pRO.RateFactor, 2, MidpointRounding.AwayFromZero);
			//max += Math.Round(pRO.TotalApprovedFLSWithNewHourlyRate * (pRO.HourlyRateNew ?? 0) * pRO.RateFactor, 2, MidpointRounding.AwayFromZero);
			//max += Math.Round(pRO.TotalApprovedFLSWithHourlyRate3 * pRO.HourlyRate3 * pRO.RateFactor, 2, MidpointRounding.AwayFromZero);
			//max = Math.Round(max, 2, MidpointRounding.AwayFromZero);

			//if (Math.Round(pRO.AmountRecordedFLS, 2, MidpointRounding.AwayFromZero) > max)
			//{
			//	decimal diff = pRO.AmountRecordedFLS - max;
			//	pRO.AmountRecordedFLS = max;
			//	pRO.ClaimWithEigenbeteiligung -= diff;
			//}

            if (pRO.ClaimWithEigenbeteiligung < 0)
            {
                lblClaimText1.Text = "Rückzahlungsanspruch LWL:";
                lblClaimText2.Text = "Rückzahlungsanspruch LWL:";
            }
            else
            {
                lblClaimText1.Text = "Betrag:";
                lblClaimText2.Text = "Betrag:";
            }

            xrPanel1Amount.Location = xrPanel2Amounts.Location;
            xrPanel3Amount.Location = xrPanel2Amounts.Location;
            if (pRO.DifferentHourlyRateCount == 1)
            {
                //pRO.TotalApprovedFLSWithNewHourlyRate = Math.Round(pRO.ApprovedFLSWeekly * pRO.WeeksWithNewHourlyRate, 2, MidpointRounding.AwayFromZero);
                //pRO.TotalApprovedFLSWithNewHourlyRateString = string.Format("{0:0.00}", pRO.TotalApprovedFLSWithNewHourlyRate);

                xrPanel3Amount.Visible = false;
                xrPanel2Amounts.Visible = false;
                xrPanel1Amount.Visible = true;
            }

            else if (pRO.DifferentHourlyRateCount == 2)
            {
                xrPanel2Amounts.Visible = true;
                xrPanel1Amount.Visible = false;
                xrPanel3Amount.Visible = false;
            }
            else
            {
                xrPanel2Amounts.Visible = false;
                xrPanel1Amount.Visible = false;
                xrPanel3Amount.Visible = true;
            }

            this.bindingSource1.DataSource = pRO;
        }
    }
}
