private void BtnAnnuler_OnClick(object sender, RoutedEventArgs e)
        {
            if (MessageBox.Show("Voulez vous vraiment annuler ce paiement?", "Annulation de paiement", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
            {
                //Load current used data to use
                int noPaiement = _infoPaiements[IDPaiementList.SelectedIndex].NoPaiement;

                try
                {
                    _loanEntities.InfoPaiements.Remove(_loanEntities.InfoPaiements.Single(a => a.NoPaiement == noPaiement));
                    _loanEntities.SaveChanges();
                    _paiementAccepter = true;
                }
                catch (Exception exception)
                {
                    MessageBox.Show(exception.Message, "Attention !", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                    throw;
                }
                finally
                {
                    if (_paiementAccepter)
                    {
                        MessageBox.Show("Votre paiement à correctement été annuler", "Confirmation");
                    }
                    Close();
                }
            }
            else
            {
                Close();
            }
        }
Esempio n. 2
0
        private void BtnModifier_OnClick(object sender, RoutedEventArgs e)
        {
            if (MontantTxt.Text == String.Empty || DateDebutDP.SelectedDate == null ||
                PremierPaiementDP.SelectedDate == null)
            {
                _locationAccepter = false;
                MessageBox.Show("Veuillez remplir les informations correctement", "Attention !", MessageBoxButton.OK,
                                MessageBoxImage.Exclamation);
                Close();
            }
            else
            {
                if (MessageBox.Show("Voulez vous vraiment modifier cette location?", "Modification de location",
                                    MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                {
                    try
                    {
                        if (IDLocationList.SelectedItem is Location sLocation)
                        {
                            sLocation.DateLocation               = DateDebutDP.SelectedDate;
                            sLocation.DatePaiement               = PremierPaiementDP.SelectedDate;
                            sLocation.MontantPaiement            = decimal.Parse(MontantTxt.Text);
                            sLocation.NbrPaiement                = int.Parse(NbrPaiementList.SelectedValue.ToString());
                            sLocation.VINVehicule                = _infoVehicle[NivList.SelectedIndex].VINVehicule;
                            sLocation.NoClient                   = _infoClient[ClientList.SelectedIndex].NoClient;
                            sLocation.TermesDeLocation.NbrAnnees = byte.Parse(TermeList.SelectedValue.ToString());
                            sLocation.TermesDeLocation.KiloMax   = int.Parse(TermeList.SelectedValue.ToString()) * 20000;
                            sLocation.TermesDeLocation.Prime     = decimal.Parse(TermeList.SelectedValue.ToString()) * 150;
                        }

                        _loanEntities.SaveChanges();
                    }
                    catch (Exception ex)
                    {
                        _locationAccepter = false;
                        MessageBox.Show("" + ex, "Attention !", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                        throw;
                    }
                    finally
                    {
                        if (_locationAccepter)
                        {
                            MessageBox.Show("Votre nouvelle location à été enregistrer.", "Succès !",
                                            MessageBoxButton.OK);
                        }

                        Close();
                    }
                }
                else
                {
                    Close();
                }
            }
        }