using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using MercatorApi;
using MercatorUi;

namespace Main
{
    public class Customizer : MercatorUi.ICustomizers.IExec
    {

        public void Main(MercatorUi.ICustomizers.ExecAction Action)
        {
            if (Action == MercatorUi.ICustomizers.ExecAction.DossierOpen)
                MercatorUi.Forms.Gescom.GescomProcedures.Procedures.SimulationDone += new MercatorUi.Forms.Gescom.GescomProcedures.Procedures.SimulationDoneEventHandler(Procedures_SimulationDone);
            else if (Action == MercatorUi.ICustomizers.ExecAction.DossierClose)
                MercatorUi.Forms.Gescom.GescomProcedures.Procedures.SimulationDone -= new MercatorUi.Forms.Gescom.GescomProcedures.Procedures.SimulationDoneEventHandler(Procedures_SimulationDone);
        }

        private void Procedures_SimulationDone(MercatorUi.Forms.Gescom.GescomProcedures.Procedures.SimulationDoneEventArgs e)
        {
            Dialogs.Stop("Nombre de livraisons g?n?r?es : " + e.ParamsForReport["OrdersDeliveryGeneratedDeliveries"].ToString());
            MercatorUi._Divers.ExportDataTableToFile(e.DsForReport.Tables["LIGNES_V"]); // exporter la table des lignes vers Excel
            e.CancelPrint = true; // ne pas poursuivre avec l'impression
        }
    }
}