private void ValidateRemise(object sender, RoutedEventArgs e) { string nomClient = RemiseNomClientBox.Text; string remiseType = ((ComboboxBean)RemiseTypeCombobox.SelectedItem).Id; string valeur = RemiseValeurBox.Text.Replace(".", ","); decimal valeurDecimal; if (!decimal.TryParse(valeur, out valeurDecimal)) { MessageBox.Show("La valeur est mal formatée !"); return; } var formattedValeur = string.Format("{0:0.00}", valeurDecimal); RemiseCollection.Add(new TableRemise { Client = nomClient, Type = remiseType, Valeur = valeur }); RemiseNomClientBox.Text = ""; RemiseValeurBox.Text = ""; calculateOnUi(true, false, false, false, false, true); }
private void Context_Delete_Remise(object sender, RoutedEventArgs e) { //Get the clicked MenuItem var menuItem = (MenuItem)sender; //Get the ContextMenu to which the menuItem belongs var contextMenu = (ContextMenu)menuItem.Parent; //Find the placementTarget var item = (DataGrid)contextMenu.PlacementTarget; if (item.SelectedCells.Count > 0) { var toDeleteFromBindedList = (TableRemise)item.SelectedCells[0].Item; RemiseCollection.Remove(toDeleteFromBindedList); } calculateOnUi(true, false, false, false, false, true); }