public Reservation rechercherReservation(Client client) { foreach (Reservation r in this.Reservations) { if (r.Client == client) return r; } return null; }
public Reservation(Client client, int nbplaces) { Client = client; NbPlaces = nbplaces; }
/// <summary> /// Ajouter/Modifier un client /// </summary> /// <param name="s"></param> private static char enterClient(Client c = null) { char choix = '\u0000'; //unicode de null string _nom = null; string _prenom = null; string _tel = null; string _mail = null; char _reponse; //pour un abonné string _anneeA = null; string _solde = null; //pour un non abonné string _numCB = null; string _dateValide = null; string _cvc = null; bool ajout = false; bool abonne = false; do { Console.Clear(); if (c == null) ajout = true; if (ajout) { //ici, on crée un nouveau client Console.WriteLine(Environment.NewLine); Console.WriteLine("--- Nouveau client ---"); Console.WriteLine(Environment.NewLine); /* * saisir les informations */ Console.Write("Nom : "); _nom = Console.ReadLine(); Console.Write("Prenom : "); _prenom = Console.ReadLine(); Console.Write("Telephone : "); _tel = Console.ReadLine(); Console.Write("Mail : "); _mail = Console.ReadLine(); do { Console.WriteLine(Environment.NewLine); Console.Write("Abonné (O/N) : "); _reponse = Console.ReadKey().KeyChar; } while (_reponse != 'o' && _reponse != 'O' && _reponse != 'n' && _reponse != 'N'); switch (_reponse) { case 'o': case 'O': abonne = true; Console.Write("Année abonnement : "); _anneeA = Console.ReadLine(); Console.Write("Solde : "); _solde = Console.ReadLine(); break; case 'n': case 'N': abonne = false; Console.Write("N° CB : "); _numCB = Console.ReadLine(); Console.Write("Expire fin (JJ/MM/YYYY) : "); _dateValide = Console.ReadLine(); Console.Write("Cryptogramme (3 chiffres) : "); _cvc = Console.ReadLine(); break; } Console.WriteLine(Environment.NewLine); } else { //ici, on modifie un client existant //ici, on crée un nouveau client Console.WriteLine(Environment.NewLine); Console.WriteLine("--- Modification client ---"); Console.WriteLine(Environment.NewLine); /* * saisir les informations */ Console.Write("Nom ({0}) : ", c.Nom); _nom = Console.ReadLine(); Console.Write("Prenom ({0}) : ", c.Prenom); _prenom = Console.ReadLine(); Console.Write("Telephone ({0}) : ", c.Tel); _tel = Console.ReadLine(); Console.Write("Mail ({0}) : ", c.Mail); _mail = Console.ReadLine(); if (c is ClientAbonne) { abonne = true; Console.Write("Année abonnement ({0}) : ", ((ClientAbonne)c).AnneeAbonnement); _anneeA = Console.ReadLine(); Console.Write("Solde ({0}): ", ((ClientAbonne)c).Solde); _solde = Console.ReadLine(); } else { abonne = false; Console.Write("N° CB ({0}) : ", ((ClientNonAbonne)c).NumCB); _numCB = Console.ReadLine(); Console.Write("Expire fin (JJ/MM/YYYY)({0}) : ", ((ClientNonAbonne)c).DateValide); _dateValide = Console.ReadLine(); Console.Write("Cryptogramme (3 chiffres) : ", ((ClientNonAbonne)c).Cvc); _cvc = Console.ReadLine(); } Console.WriteLine(Environment.NewLine); } Console.WriteLine("V. valider - P. Retour menu principal"); choix = Console.ReadKey().KeyChar; switch (choix) { case 'v': case 'V': try { Client client; if (ajout) { if (abonne) { //ici, on crée un nouvel abonne ClientAbonne ca = new ClientAbonne(); ca.AnneeAbonnement = int.Parse(_anneeA); ca.Solde = double.Parse(_solde); client = (Client)ca; } else { //ici, on crée un nouvel non abonné ClientNonAbonne cna = new ClientNonAbonne(); cna.NumCB = _numCB; cna.DateValide = DateTime.Parse(_dateValide); cna.Cvc = int.Parse(_cvc); client = (Client)cna; } client.Nom = _nom; client.Prenom = _prenom; client.Tel = _tel; client.Mail = _mail; //ajout du client à la liste des clients fc.clients.Add(client); } else { if (abonne) { //ici, on modifie un abonné ClientAbonne ca = (ClientAbonne)c; ca.AnneeAbonnement = (_anneeA == null ? ca.AnneeAbonnement : int.Parse(_anneeA)); ca.Solde = (_solde == null ? ca.Solde : double.Parse(_solde)); client = (Client)ca; } else { //ici, on modifie un non abonné ClientNonAbonne cna = (ClientNonAbonne)c; cna.NumCB = (_numCB == null ? cna.NumCB : _numCB); cna.DateValide = (_dateValide == null ? cna.DateValide : DateTime.Parse(_dateValide)); cna.Cvc = (_cvc == null ? cna.Cvc : int.Parse(_cvc)); client = (Client)cna; } client.Nom = (_nom == null ? client.Nom : _nom); client.Prenom = (_prenom == null ? client.Prenom : _prenom); client.Tel = (_tel == null ? client.Tel : _tel); client.Mail = (_mail == null ? client.Mail : _mail); } } catch (Exception) { Console.WriteLine("Erreur lors de la création/modification du client."); } break; } } while (choix != 'p' && choix != 'P' && choix != 'v' && choix != 'V'); return choix; }
public void annulerReservation(Client client) { this.Reservations.Remove(this.rechercherReservation(client)); }
public void ajouterReservation(Client client,int nbplaces) { this.Reservations.Add(new Reservation(client,nbplaces)); }
public void ajouterClient(Client c) { _clients.Add(c); }