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