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.Accounting.AccountingBankCodaForm.AfterCodaRecognition += new MercatorUi.Forms.Accounting.AccountingBankCodaForm.AfterCodaRecognitionEventHandler(AccountingBankCodaForm_AfterCodaRecognition);
            else if (Action == MercatorUi.ICustomizers.ExecAction.DossierClose)
                MercatorUi.Forms.Accounting.AccountingBankCodaForm.AfterCodaRecognition -= new MercatorUi.Forms.Accounting.AccountingBankCodaForm.AfterCodaRecognitionEventHandler(AccountingBankCodaForm_AfterCodaRecognition);
        }

        void AccountingBankCodaForm_AfterCodaRecognition(MercatorUi.Forms.Accounting.AccountingBankCodaForm.AfterCodaRecognitionEventArgs e)
        {
            //MercatorUi._Divers.ViewData(e.DtMouvements.Copy(), true);
            foreach (DataRow dr in e.DtMouvements.Rows)
            {
                if ((dr["communicall"].ToString() != "") && (dr["cpte"].ToString() == ""))
                {
                    string id_cli = "...";
                    MercatorUi.Forms.Accounting.AccountingBankCodaForm.CodaInsertAccount(MercatorUi.Sig._SigEnum.CLI, id_cli, dr);
                }
            }
        }
    }
}