De lijst (gefilterde) elementen zien van een informatiebestand

0000002350     -      10-11-2016

De customizer hieronder toont de lijst met artikels en haalt de geselecteerde lijn van de gebruiker op.

In het getoonde voorbeeld voert het zich uit wanneer een artikel in een grid van een usercontrol, toegevoegd aan een verkoopdocument, wordt geselecteerd.

Het helpt ook om een filter te implementeren op de weergegeven gegevens: in dit geval zijn de artikels van het veld s_id_rayon met waarde 'RAYON_A' of 'RAYON_B' of 'RAYON_C', en voegt het geselecteerde artikel toe in de tabel die gekoppeld is aan de grid, diegene die vooraf toegevoegd is aan de huidige BillingEngine dataset.

De customizer code is als volgt:

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];
    }
}