예제 #1
0
        static void ChangerContact(List <Contact> ListContact)
        {
            Console.Clear();
            AfficherListContact(ListContact);
            string nom = OutilsConsole.PosezQuestion("\nAppeler le nom du contact a changer");

            foreach (Contact leContact in ListContact)
            {
                if (nom.ToLower() == leContact.Nom.ToLower())
                {
                    Console.Clear();
                    string choix = OutilsConsole.PosezQuestion("Quel est l'élément du Contact que vous voulez Changer?\n1- Le nom\n2- Le prenom\n3- Le numéro\n4- L'émail\n5- La date de naissance");
                    switch (choix)
                    {
                    case "1":
                        Console.Clear();
                        leContact.Nom = OutilsConsole.PosezQuestionObligatoire("Quel Nouveau Nom voulez-vous?");
                        break;

                    case "2":

                        Console.Clear();
                        leContact.Prenom = OutilsConsole.PosezQuestionObligatoire("Quel Nouveau Prenom voulez-vous?");
                        break;

                    case "3":
                        Console.Clear();
                        leContact.Num = OutilsConsole.PosezQuestionObligatoire("Quel Nouveau Numéro voulez-vous?");
                        break;

                    case "4":
                        Console.Clear();
                        leContact.Email = OutilsConsole.PosezQuestionObligatoire("Quel Nouveau Email voulez-vous?");
                        break;

                    case "5":
                        Console.Clear();
                        leContact.Date = OutilsConsole.SaisirDate("Quel Nouvelle Date de Naissance voulez-vous?");
                        break;

                    default:
                        Console.Clear();
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("Mauvais choix");
                        Console.ForegroundColor = ConsoleColor.Green;
                        break;
                    }
                    Console.Clear();
                    break;
                }
                else
                {
                    Console.Clear();
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("Pas de Contact correspondant à ce Nom");
                    Console.ForegroundColor = ConsoleColor.Green;
                }
            }
        }
예제 #2
0
        static void AjouterContact(List <Contact> ListContact)
        {
            Console.Clear();
            Contact LeContact = new Contact();

            LeContact.Prenom = OutilsConsole.PosezQuestionObligatoire("Rentrez le prénom du contact à ajouter");
            LeContact.Nom    = OutilsConsole.PosezQuestionObligatoire("Rentrez le nom du contact à ajouter");
            LeContact.Num    = OutilsConsole.PosezQuestion("Rentrez le numéro du contact à ajouter");
            LeContact.Email  = OutilsConsole.PosezQuestion("Rentrez l'émail du contact à ajouter");
            LeContact.Date   = OutilsConsole.SaisirDate("Rentrez la date de naissance du contact à ajouter");
            ListContact.Add(LeContact);
            Console.Clear();
        }
예제 #3
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();
        }