using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Windows.Forms;
using MercatorApi;


namespace Billing
{
    public class Customizer : MercatorUi.ICustomizers.IBillingEngineCreated, MercatorUi.ICustomizers.IBillingEngineClosed
    {

        public void BillingEngineCreated(MercatorUi.Engine.Gescom.BillingEngine billingEngine)
        {
            billingEngine.SendingMail += BillingEngine_SendingMail;
        }

        public void BillingEngineClosed(MercatorUi.Engine.Gescom.BillingEngine billingEngine)
        {
            billingEngine.SendingMail -= BillingEngine_SendingMail;
        }

        void BillingEngine_SendingMail(object sender, MercatorUi.Engine.Gescom.BillingEngine.SendingMailEventArgs e)
        {
            MercatorUi.Engine.Gescom.BillingEngine billingEngine = (MercatorUi.Engine.Gescom.BillingEngine)sender;
            if (billingEngine.CLI_LIV != null)
            {
                // e.Recipients is de DataTable die zichtbaar zal zijn in het dialoogvenster uit de selectie(indien er meer dan 1 adres is)
                e.Recipients.Rows.Clear(); // verwijderd de reeds gevonden mailadressen door Mercator
                e.Recipients.Rows.Add(new object[2] { billingEngine.CliLivRecord.C_EMAIL, billingEngine.CliLivRecord.C_EMAIL });
            }
        }
    }
}