private void btn_editer_Click_1(object sender, RoutedEventArgs e) { if (dgListeRedevence.SelectedItem != null) { if (btn_editer.Content.ToString().Trim() == "Editer".Trim()) { txt_tranche.Text = ((ServiceTarification.CsTrancheRedevence)dgListeRedevence.SelectedItem).LIBELLE; txt_tranche.Tag = ((ServiceTarification.CsTrancheRedevence)dgListeRedevence.SelectedItem); chk_gratuit.IsChecked = ((ServiceTarification.CsTrancheRedevence)dgListeRedevence.SelectedItem).GRATUIT; btn_editer.Content = "Mise a Jour"; } else { ServiceTarification.CsTrancheRedevence tranche = ((ServiceTarification.CsTrancheRedevence)txt_tranche.Tag); if (tranche != null) { int index = this.csRedevance.TRANCHEREDEVANCE.IndexOf(tranche); tranche.LIBELLE = txt_tranche.Text; tranche.GRATUIT = chk_gratuit.IsChecked.Value; this.csRedevance.TRANCHEREDEVANCE[index] = tranche; btn_editer.Content = "Editer".Trim(); txt_tranche.Tag = null; LayoutRoot.DataContext = null; LayoutRoot.DataContext = this.csRedevance; InitCentreProduit(); } } } }
private void btn_supprimer_Click_1(object sender, RoutedEventArgs e) { var messageBox = new MessageBoxControl.MessageBoxChildWindow("Attention", "Êtes-vous sûr de vouloir supprimer la ligne?", MessageBoxControl.MessageBoxButtons.OkCancel, MessageBoxControl.MessageBoxIcon.Information); messageBox.OnMessageBoxClosed += (_, result) => { if (messageBox.Result == MessageBoxResult.OK) { ServiceTarification.CsTrancheRedevence tranche = ((ServiceTarification.CsTrancheRedevence)dgListeRedevence.SelectedItem); this.csRedevance.TRANCHEREDEVANCE.Remove(tranche); LayoutRoot.DataContext = null; LayoutRoot.DataContext = this.csRedevance; InitCentreProduit(); } else { return; } }; messageBox.Show(); }