1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
private void dg_ProdLivr_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
{
try
{
int ind = dg_ProdLivr.SelectedIndex;//Récupération de l'index de la ligne où se trouve la cellule.
TextBox txt_Cell = e.EditingElement as TextBox;
if (e.Column.DisplayIndex.Equals(3))
{
Data.ServiceWSPharmacie.vueProdMagLiv prodMaglivr = (Data.ServiceWSPharmacie.vueProdMagLiv)dg_ProdLivr.CurrentItem; // conversion de la ligne au type de la liste qui a servi à remplir le datagrid
this.montantTotal += prodMaglivr.montLiv;
prodMaglivr.montLiv = int.Parse(txt_Cell.Text) * prodMaglivr.PULiv; //le calcul
this.montantTotal += prodMaglivr.montLiv;
lsVueProdMagLivr.RemoveAt(ind); // suppression de la ligne dans la liste (la liste s'appelle lsVueProdMagLivr)
lsVueProdMagLivr.Insert(ind, prodMaglivr); //insertion de la nouvelle ligne à la même place que l'ancienne
this.txt_MontTotal.Text = this.montantTotal.ToString();
}
e.Row.Background = System.Windows.Media.Brushes.SeaGreen;
}
catch (Exception Ex)
{
tm.messageErreur(Ex.Message);
}
} |
Partager