Beispiel #1
0
        static void SupprimerContact(List <Contact> ListContact)
        {
            Console.Clear();
            AfficherListContact(ListContact);
            string g = OutilsConsole.PosezQuestion("\nRentrez le Nom du contact à supprimer:");

            foreach (Contact leContact in ListContact)
            {
                if (g.ToLower() == leContact.Nom.ToLower())
                {
                    ListContact.Remove(leContact);
                    break;
                }
            }

            Console.Clear();
        }
Beispiel #2
0
        static void TrierContact(List <Contact> ListContact)
        {
            Console.Clear();
            string c       = OutilsConsole.PosezQuestionObligatoire("Trier par :\n-1 Nom\n-2 Prenom");
            var    requete = from Contact in ListContact
                             select Contact;

            Console.Clear();
            Console.ForegroundColor = ConsoleColor.Blue;
            if (c == "1")
            {
                requete = from Contact in ListContact
                          orderby Contact.Nom ascending
                          select Contact;
                foreach (var Resultat in requete)
                {
                    Console.ForegroundColor = ConsoleColor.Blue;
                    AfficherChamps("Nom", 10);
                    AfficherChamps("Prenom", 10);
                    AfficherChamps("Numéro", 11);
                    AfficherChamps("Email", 15);
                    AfficherChamps("Date", 6);
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("");
                    Console.ForegroundColor = ConsoleColor.Green;
                    AfficherChamps(Resultat.Nom, 10);
                    AfficherChamps(Resultat.Prenom, 10);
                    AfficherChamps(Resultat.Num, 11);
                    AfficherChamps(Resultat.Email, 15);
                    AfficherChamps(Resultat.Date.ToString(), 10);
                    Console.WriteLine("");
                }
                Console.WriteLine("");
            }
            else
            {
                requete = from Contact in ListContact
                          orderby Contact.Prenom ascending
                          select Contact;
                foreach (var Resultat in requete)
                {
                    Console.ForegroundColor = ConsoleColor.Blue;
                    AfficherChamps("Prenom", 10);
                    AfficherChamps("Nom", 10);
                    AfficherChamps("Numéro", 11);
                    AfficherChamps("Email", 15);
                    AfficherChamps("Date", 6);
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("");
                    Console.ForegroundColor = ConsoleColor.Green;
                    AfficherChamps(Resultat.Prenom, 10);
                    AfficherChamps(Resultat.Nom, 10);
                    AfficherChamps(Resultat.Num, 11);
                    AfficherChamps(Resultat.Email, 15);
                    AfficherChamps(Resultat.Date.ToString(), 10);
                    Console.WriteLine("");
                }
            }
            Console.ReadLine();
            Console.Clear();
        }