using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using MercatorApi;
using MercatorUi;
using System.Drawing;
using System.Windows.Forms;
namespace SigCli
{
public class Customizer : MercatorUi.ICustomizers.IFormLoadCustomizer, MercatorUi.ICustomizers.IFormClosedCustomizer
{
public void FormLoadCustomize(Form form)
{
MercatorUi.Forms.Sig.SigForm sigForm = (MercatorUi.Forms.Sig.SigForm)form;
List<Control> l = sigForm.FindMovableControlsBySource("C_ID_ART1");
if (l.Count > 0)
{
MercatorUi.MovableControls.MovableTextBox textBox = (MercatorUi.MovableControls.MovableTextBox)l[0];
textBox.SuccessSearch += new MercatorUi._BaseClasses.BindableTextBoxTargetSig.SuccessSearchEventHandler(textBox_SuccessSearch);
}
}
public void FormClosedCustomize(Form form)
{
MercatorUi.Forms.Sig.SigForm sigForm = (MercatorUi.Forms.Sig.SigForm)form;
List<Control> l = sigForm.FindMovableControlsBySource("C_ID_ART1");
if (l.Count > 0)
{
MercatorUi.MovableControls.MovableTextBox textBox = (MercatorUi.MovableControls.MovableTextBox)l[0];
textBox.SuccessSearch -= new MercatorUi._BaseClasses.BindableTextBoxTargetSig.SuccessSearchEventHandler(textBox_SuccessSearch);
}
}
void textBox_SuccessSearch(object sender, MercatorUi._BaseClasses.BindableTextBoxTargetSig.SuccessSearchEventArgs e)
{
MercatorUi.Sig.Sig sig = MercatorUi.Sig._SigsStatic.SigByModule(e.TargetSig);
if (!MercatorUi.Dialogs.AnswerYesNo(string.Format("Acceptez-vous la fiche {0} \"{1}\" ?",
sig.Caption[MercatorUi.Globals.Langue].ToLower(),
e.DataRowSig[e.TargetSig == MercatorUi.Sig._SigEnum.STOCK ? "S_MODELE" : sig.Letter1 + "_NOM"])))
{
e.Cancel = true; // rejeter la sélection de la fiche
}
}
}
}