Example #1
0
 public void annulerSpectacle(Spectacle s)
 {
     foreach (Representation r in s.Representations)
     {
     s.annulerRepresentation(r);
     }
 }
Example #2
0
        public void lireFichier(String nomFichier)
        {
            StreamReader sr = null;
            //vider la liste des spectacles
            _spectacles.Clear();
            try
            {
            if (File.Exists(nomFichier))
            {
                sr = File.OpenText(nomFichier);
                String ligne;
                while (!sr.EndOfStream)
                {
                    ligne = sr.ReadLine();
                    string[] data = ligne.Split(new Char[] { ';' });
                        Spectacle sp;
                        sp= new Spectacle();
                        sp.Titre = data[0];
                        sp.Duree = int.Parse(data[1]);
                        sp.Producteur = data[2];
                        switch (data[3])
                        {
                            case "concert":
                                sp.Type = TypeSpectacle.concert;
                                break;
                            case "danse":
                                sp.Type = TypeSpectacle.danse;
                                break;
                            case "oneManShow":
                                sp.Type = TypeSpectacle.oneManShow;
                                break;
                            case "theatre" :
                                sp.Type = TypeSpectacle.theatre;
                                break;
                        }
                        ajouterSpectacle(sp);
                }

            }
            }
            catch (Exception e)
            {
            //En cas de problème d'accès au fichier
            Console.WriteLine(e.Message);
            Console.WriteLine("Problème de lecture du fichier.");
            Console.WriteLine("Appuyez sur une touche pour continuer...");
            Console.ReadKey();
            }
            finally
            {
            //Dans tous les cas
            if (sr != null)
                sr.Close();
            }
        }
Example #3
0
        /// <summary>
        /// Lister les représentations d'un spectacle
        /// </summary>
        /// <returns></returns>
        private static char MnuRepresentations(Spectacle spectacle)
        {
            char choix = '\u0000'; //unicode de null
            do
            {
                Console.Clear();
                Console.WriteLine("--- {0} ---", spectacle.ToString());
                Console.WriteLine(Environment.NewLine);
                Console.WriteLine("--- Liste des représentations ---");
                Console.WriteLine(Environment.NewLine);
                int num = 0;
                foreach (Representation rp in spectacle.Representations)
                {
                    num++;
                    Console.WriteLine("{0} - date : {1} places libres : {2} tarif : {3}", num, rp.Date, rp.PlacesDispo, rp.Tarif);
                }
                Console.WriteLine(Environment.NewLine);
                Console.WriteLine("A. ajouter - S. supprimer - P. Retour menu principal");
                choix = Console.ReadKey().KeyChar;
                switch (choix)
                {
                    case 'a':
                    case 'A':
                        enterRepresentation(spectacle);

                        break;

                    case 's':
                    case 'S':
                        Console.WriteLine("\nEntrer le numero du spectacle à supprimer ?");
                        int numero;
                        if (int.TryParse(Console.ReadLine(), out numero))
                            if (0 < numero && spectacle.Representations.Count > numero-1)
                                spectacle.annulerRepresentation(spectacle.Representations[numero-1]);

                        break;
                }
            } while (choix != 'p' && choix != 'P'); //unicode de P et p
            return choix;
        }
Example #4
0
        /// <summary>
        /// Ajouter une nouvelle représentation au spectacle
        /// </summary>
        /// <param name="s"></param>
        private static char enterRepresentation(Spectacle s)
        {
            char choix = '\u0000'; //unicode de null
            string _date;
            string _places;
            string _tarif;
            do
            {
                Console.Clear();
                Console.WriteLine("--- {0} ---", s.ToString());
                Console.WriteLine(Environment.NewLine);
                Console.WriteLine("--- Nouvelle représentation ---");
                Console.WriteLine(Environment.NewLine);
                /*
                 * saisir les informations
                 */
                Console.Write("Date représentation : ");
                _date = Console.ReadLine();
                Console.Write("Nb places disponibles : ");
                _places = Console.ReadLine();
                Console.Write("tarif : ");
                _tarif = 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
                        {
                            /*
                             * construire la représentation en mémoire
                             */
                            Representation rp = new Representation();
                            rp.PlacesDispo = int.Parse(_places);
                            rp.Tarif = double.Parse(_tarif);
                            rp.Date = DateTime.Parse(_date);
                            /*
                            * ajouter la représentation au spectacle
                            */
                            s.ajouterRepresentation(rp);
                        }
                        catch (Exception)
                        {
                            Console.WriteLine("Erreur lors de la création de la représentation.");
                        }

                        break;
                }
            } while (choix != 'p' && choix != 'P' && choix != 'v' && choix != 'V');
            return choix;
        }
Example #5
0
 public void ajouterSpectacle(Spectacle s)
 {
     _spectacles.Add(s);
 }