Vous consultez une page technique concernant le logiciel de gestion Mercator. Celle-ci contient des informations spécifiques destinées aux professionnels de Mercator. Souhaitez-vous être redirigés vers des informations plus générales ?


   Ne plus poser cette question

Dans l'écran des rappels, ajouter un bouton qui permet d'atteindre les données

0000002293     -      05/09/2016

Le module illustré ici permet d'ajouter un bouton dans le ruban inférieur de l'écran des rappels. Ce bouton permet de déclencher n'importe quelle action, dont notamment effectuer des modifications sur le DataSet qui se trouve derrière les deux grilles principales de l'écran. Dans notre exemple, nous nous limitons à l'affichage du DataSet.

Comme la fenêtre des rappels ne dispose pas d'un customizer qui lui est propre, il faut l'atteindre via un customizer Main qui va exploiter l'évènement BaseFormCreating. Le bouton qui va être ajouté est de type MercatorUi.BoutonsPro.ButtonXPro, çàd un bouton doté des enrichissements graphiques de Mercator. (Il est possible d'utiliser à la place le simple bouton System.Windows.Forms.Button). Le bouton sera doté d'une image libre 32x32 pixels (reprise dans le zip ci-joint).

Le code s'établit comme suit :

Zoom
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using MercatorApi;
using MercatorUi;
using System.Windows.Forms;
using System.Reflection;

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

        public void Main(MercatorUi.ICustomizers.ExecAction Action)
        {
            if (Action == MercatorUi.ICustomizers.ExecAction.DossierOpen)
            {
                Globals.Main.BaseFormCreating += new MercatorUi.Main.BaseFormCreatingEventHandler(Main_BaseFormCreating);
            }
            else if (Action == MercatorUi.ICustomizers.ExecAction.DossierClose)
            {
                Globals.Main.BaseFormCreating -= new MercatorUi.Main.BaseFormCreatingEventHandler(Main_BaseFormCreating);
            }
        }

        void Main_BaseFormCreating(object sender, MercatorUi.Main.BaseFormCreatingEventArgs e)
        {
            if (e.Form.GetType() == typeof(MercatorUi.Forms.Accounting.AccountingRemindersForm))
                e.Form.Shown += new EventHandler(Form_Shown);
        }

        void Form_Shown(object sender, EventArgs e)
        {
            MercatorUi.Forms.Accounting.AccountingRemindersForm accountingRemindersForm = (MercatorUi.Forms.Accounting.AccountingRemindersForm)sender;
            accountingRemindersForm.Shown -= new EventHandler(Form_Shown); // désinscrire l'évènement
            MercatorUi.BoutonsPro.BleuPro bleuPro1 = (MercatorUi.BoutonsPro.BleuPro)accountingRemindersForm.Controls["bleuPro1"];
            MercatorUi.BoutonsPro.ButtonXPro buttonCustom = new MercatorUi.BoutonsPro.ButtonXPro();
            buttonCustom.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
            buttonCustom.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            buttonCustom.Image = System.Drawing.Image.FromFile("window_edit.png");
            buttonCustom.Location = new System.Drawing.Point(250, 5);
            buttonCustom.Name = "buttonCustom";
            buttonCustom.Size = new System.Drawing.Size(120, 48);
            buttonCustom.SubItemsExpandWidth = 16;
            buttonCustom.Text = "Custom Action";
            buttonCustom.Click += new EventHandler(buttonCustom_Click);
            bleuPro1.Controls.Add(buttonCustom);
        }

        void buttonCustom_Click(object sender, EventArgs e)
        {
            MercatorUi.BoutonsPro.ButtonXPro buttonCustom = (MercatorUi.BoutonsPro.ButtonXPro)sender;
            MercatorUi.Forms.Accounting.AccountingRemindersForm accountingRemindersForm = (MercatorUi.Forms.Accounting.AccountingRemindersForm)buttonCustom.FindForm();
            MercatorUi._Divers.ViewData(accountingRemindersForm.DataSet, true);
        }
    }
}

Notez qu'il est possible d'utiliser ce code dans d'autres écrans :

  • Les domiciliations : le type de form à prendre en compte est MercatorUi.Forms.Accounting.AccountingBankDomForm au lieu de MercatorUi.Forms.Accounting.AccountingRemindersForm
  • Les paiements : le type de form à prendre en compte est MercatorUi.Forms.Accounting.AccountingBankPayForm au lieu de MercatorUi.Forms.Accounting.AccountingRemindersForm


A télécharger : 0000002293.zip (1 Kb - 12/02/2014)