Beispiel #1
0
        /// <summary>
        /// Bouton pour supprimer un contact
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSupprimer_Click(object sender, RoutedEventArgs e)
        {
            bool?Result = new MBPerso("Êtes-vous sûr ?", MessageButtons.YesNo).ShowDialog();

            if (Result.Value)
            {
                Liste.SupprimerContact(Liste.Registre[LstContacts.SelectedIndex]);
                EntreeSortie.Ecriture(Liste);
            }
        }
Beispiel #2
0
 private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     EntreeSortie.Ecriture(Liste);
 }
Beispiel #3
0
 private void Window_Closing(object sender, EventArgs e)
 {
     EntreeSortie.Ecriture(Liste);
 }
Beispiel #4
0
 private void BtnSauver_Click(object sender, RoutedEventArgs e)
 {
     if (Modification)
     {
         try
         {
             mainWindow.Liste.SupprimerContact(Index);
             mainWindow.Liste.InsererContact(new Contact(NomBox.Text, PrenomBox.Text, AdresseBox.Text, CPBox.Text, VilleBox.Text, NoTelBox.Text, EmailBox.Text, ProvinceComboBox.Text), Index);
             EntreeSortie.Ecriture(mainWindow.Liste);
             this.Close();
         }
         catch (EmailInvalideException exception)
         {
             EmailBox.Focus();
             MBPerso mBPerso = new MBPerso(exception.Message, MessageButtons.Ok);
         }
         catch (CodePostalException exception)
         {
             CPBox.Focus();
             MBPerso mBPerso = new MBPerso(exception.Message, MessageButtons.Ok);
         }
         catch (TelephoneInvalideException exception)
         {
             NoTelBox.Focus();
             MBPerso mBPerso = new MBPerso(exception.Message, MessageButtons.Ok);
         }
     }
     else
     {
         try
         {
             mainWindow.Liste.AjouterContact(new Contact(NomBox.Text, PrenomBox.Text, AdresseBox.Text, CPBox.Text, VilleBox.Text, NoTelBox.Text, EmailBox.Text, ProvinceComboBox.Text));
             EntreeSortie.Ecriture(mainWindow.Liste);
             this.Close();
         }
         catch (EmailInvalideException exception)
         {
             EmailBox.Focus();
             MBPerso mBPerso = new MBPerso(exception.Message, MessageButtons.Ok);
         }
         catch (CodePostalException exception)
         {
             CPBox.Focus();
             MBPerso mBPerso = new MBPerso(exception.Message, MessageButtons.Ok);
         }
         catch (TelephoneInvalideException exception)
         {
             NoTelBox.Focus();
             MBPerso mBPerso = new MBPerso(exception.Message, MessageButtons.Ok);
         }
         catch (ContactDejaPresentException exception)
         {
             bool?result = new MBPerso(exception.Message, MessageButtons.YesNo).ShowDialog();
             if (result.Value)
             {
                 mainWindow.Liste.SupprimerContact(exception.Contact);
                 mainWindow.Liste.InsererContact(new Contact(NomBox.Text, PrenomBox.Text, AdresseBox.Text, CPBox.Text, VilleBox.Text, NoTelBox.Text, EmailBox.Text, ProvinceComboBox.Text), exception.Index);
                 EntreeSortie.Ecriture(mainWindow.Liste);
             }
             else
             {
                 NomBox.Focus();
             }
         }
     }
 }