Volgende programmering maakt het mogelijk om in te grijpen op het niveau van de LinesEditor bij de verkopen, aankopen, transfer tussen depots of bij de inventarissen voor dat Mercator de waarde gebruikt.
Dit kan gebruikt worden voor bv. gegevens die door een handscanner gestuurd worden te manipuleren voordat deze verwerkt worden.
In het onderstaande voorbeeld stuurt de handscanner een '1*' bij elke scan voordat de belangrijke informatie gestuurd word. Deze '1*' wordt dan verwijderd uit de sleutel.
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Linq;
using System.Windows.Forms;
using MercatorApi;
using MercatorUi;
using MercatorExtensions;
using MercatorDatabase;
namespace Billing
{
public class Customizer : MercatorUi.ICustomizers.IFormLoadCustomizer, MercatorUi.ICustomizers.IFormClosedCustomizer
{
public void FormLoadCustomize(Form form)
{
MercatorUi.Forms.Billing.BillingForm billingForm = (MercatorUi.Forms.Billing.BillingForm)form;
if (billingForm.LinesEditor != null)
billingForm.LinesEditor.BeforeCellValidated += BillingFormLinesEditor_BeforeCellValidated;
}
public void FormClosedCustomize(Form form)
{
MercatorUi.Forms.Billing.BillingForm billingForm = (MercatorUi.Forms.Billing.BillingForm)form;
if (billingForm.LinesEditor != null)
billingForm.LinesEditor.BeforeCellValidated -= BillingFormLinesEditor_BeforeCellValidated;
}
void BillingFormLinesEditor_BeforeCellValidated(object sender, DataGridViewCellEventArgs e)
{
MercatorUi.Forms.Billing.BillingObjects.LinesEditor linesEditor = (MercatorUi.Forms.Billing.BillingObjects.LinesEditor)sender;
if ((e.RowIndex > -1) && (e.ColumnIndex > -1) && (linesEditor.Grid.Columns[e.ColumnIndex].Name == "id_article"))
{
string id_article = linesEditor.Grid.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString().TrimEnd();
if (id_article.EndsWith("%") && id_article.StartsWith("1*"))
linesEditor.Grid.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = id_article.Substring(2);
}
}
}
}