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

Afficher la liste (filtrée) des éléments d'un signalétique

0000002350     -      10/11/2016

Le customizer ci-dessous permet d'afficher la liste des articles et de récupérer la ligne sélectionnée par l'utilisateur.

Dans l'exemple illustré, il s'exécute lors de la sélection d'un article dans une grille d'un usercontrol ajouté dans un document de vente.

Il permet également d'implémenter un filtre sur les données affichées : dans le cas présent, les articles dont le champ s_id_rayon vaut 'RAYON_A' ou 'RAYON_B' ou 'RAYON_C', et ajoute l'article sélectionné dans la table liée à la grille, celle-ci ayant été au préalable ajoutée dans le dataset du BillingEngine courant.

Le code du customizer s'établit comme suit :

Zoom
private void MaGrillePerso_CellValidated(object sender, DataGridViewCellEventArgs e)
{
    if (sender == null)
        return;

    if ((e.ColumnIndex > -1) && (e.RowIndex > -1))
    {
        MercatorUi.GridPro.DataGridViewXPro Grid = (MercatorUi.GridPro.DataGridViewXPro)sender;

        MercatorUi.Forms.Billing.BillingForm billingForm = (MercatorUi.Forms.Billing.BillingForm)Grid.FindForm();
        MercatorUi.Engine.Gescom.BillingEngine billingEngine = billingForm.BillingEngine;

        if ((Grid.Columns[e.ColumnIndex].Name == "ID_ARTICLE") && (Grid.Rows[e.RowIndex].Cells[Grid.Columns[e.ColumnIndex].Name].Value != null))
        {
            // la cellule sur laquelle on a cliqué est la zone référence
            string Rech = Grid.Rows[e.RowIndex].Cells[Grid.Columns[e.ColumnIndex].Name].Value.ToString();
            MercatorUi.Sig.SigStock sigStock = (MercatorUi.Sig.SigStock)MercatorUi.Sig._SigsStatic.SigByModule(MercatorUi.Sig._SigEnum.STOCK);
            DataRow StockRecherche = sigStock.Search(Rech, "s_id_rayon in ('RAYON_A', 'RAYON_B', 'RAYON_C')");
            if (StockRecherche != null)
            {
                if (!billingEngine.InsertItem(StockRecherche, billingEngine.DataSet.Tables["LIGNES_DETAIL"].Rows[e.RowIndex]))
                    Dialogs.Stop("InsertItem BillingEngine : " + billingEngine.LastError + (Api.LastError != "" ? " - " + Api.LastError : ""));
            }
            else
            {
                Grid.Rows[e.RowIndex].Cells[Grid.Columns[e.ColumnIndex].Name].Value = "";
                Dialogs.Stop("Article non trouvé !");
            }
        }
        if ((Grid.CurrentCell.ColumnIndex != e.ColumnIndex) || (Grid.CurrentCell.RowIndex != e.RowIndex))
            Grid.CurrentCell = Grid[e.ColumnIndex, e.RowIndex];
    }
}