Exemplo n.º 1
0
        public void creationTablesXml()
        {
            //le logiciel lit le fichier xml correspondant au restaurant
            XmlDocument doc = new XmlDocument();
            doc.Load("restaurant.xml");

            //Comptage du nombre de tables en fonction de chaque type(carrées, rectangulaires et rondes)
            XmlNodeList tablecarreeNodes = doc.SelectNodes("//Restaurant/Tables/TableCarees/TableCaree");
            XmlNodeList tablerectNodes = doc.SelectNodes("//Restaurant/Tables/TableRectangulaires/TableRectangulaire");
            XmlNodeList tablerondeNodes = doc.SelectNodes("//Restaurant/Tables/TableRondes/TableRonde");
            int nbTableCarree = 0;
            int nbTableRect = 0;
            int nbTableRonde = 0;
            foreach (XmlNode tablecaree in tablecarreeNodes)
            {
                nbTableCarree++;
            }
            foreach (XmlNode tablerect in tablerectNodes)
            {
                nbTableRect++;
            }
            foreach (XmlNode tableronde in tablerondeNodes)
            {
                nbTableRonde++;
            }

            //Lecture des informations concernants les Tables Carrées
            XmlNodeList occupationsNodes = doc.SelectNodes("//Restaurant/Tables/TableCarees/TableCaree/occupations/occupation");
            List<DateTime> _dateDebutOccupee = new List<DateTime>();
            List<DateTime> _dateFinOccupee = new List<DateTime>();

            //parcours chaque noeuds "occupation"
            foreach (XmlNode occNode in occupationsNodes)
            {
                XmlNode dateDebutOccupee = occNode.SelectSingleNode("dateDebutOccupee");
                XmlNode dateFinOccupee = occNode.SelectSingleNode("dateFinOccupee");

                if (dateDebutOccupee != null)
                {
                DateTime datedebut = Convert.ToDateTime(dateDebutOccupee.InnerText);
                _dateDebutOccupee.Add(datedebut);
                DateTime datefin = Convert.ToDateTime(dateFinOccupee.InnerText);
                _dateFinOccupee.Add(datefin);

                }

            }

            //CREATION DES TABLES CAREES
            //elles se créent à partir de la lecture du fichier xml, comme ça le logiciel s'adapte à chaque restaurant disposant de ces trois types de tables
            for (int i = 0; i < nbTableCarree; i++)
            {
                TableCarree table = new TableCarree();

                if (i < _dateDebutOccupee.Count)
                {
                    DateTime hdebut = new DateTime();
                    hdebut = _dateDebutOccupee[i];
                    DateTime hfin = new DateTime();
                    hfin = _dateFinOccupee[i];
                    Occupation occ = new Occupation(hdebut, hfin);
                    table.PlanningResa.Add(occ);

                }
                //ajout des tables lues à la liste de tables de la salle
                this.tables.Add(table);
            }

            //Lecture des informations concernants les Tables Rectangulaires
            XmlNodeList occupationNodes = doc.SelectNodes("//Restaurant/Tables/TableRectangulaires/TableRectangulaire/occupations/occupation");
            //parcours chaque noeuds "occupation"
            foreach (XmlNode occNode in occupationNodes)
            {
                XmlNode dateDebutOccupee = occNode.SelectSingleNode("dateDebutOccupee");
                XmlNode dateFinOccupee = occNode.SelectSingleNode("dateFinOccupee");

                if (dateDebutOccupee != null)
                {

                    DateTime datedebut = Convert.ToDateTime(dateDebutOccupee.InnerText);
                    _dateDebutOccupee.Add(datedebut);
                    DateTime datefin = Convert.ToDateTime(dateFinOccupee.InnerText);
                    _dateFinOccupee.Add(datefin);
                }
            }
            for (int i = 0; i < nbTableRect; i++)
            {
                TableRectangulaire table = new TableRectangulaire();

                if (i<_dateDebutOccupee.Count)
                {
                    DateTime hdebut = new DateTime();
                hdebut = _dateDebutOccupee[i];
                DateTime hfin = new DateTime();
                hfin = _dateFinOccupee[i];
                Occupation occ = new Occupation(hdebut, hfin);
                table.PlanningResa.Add(occ);
                }

                //ajout des tables lues à la liste de tables de la salle
                this.tables.Add(table);
            }

            //Lecture des informations concernants les Tables Rondes
            XmlNodeList occupNodes = doc.SelectNodes("//Restaurant/Tables/TableRondes/TableRonde/occupations/occupation");
            //parcours chaque noeuds "occupation"
            foreach (XmlNode occNode in occupNodes)
            {
                XmlNode dateDebutOccupee = occNode.SelectSingleNode("dateDebutOccupee");
                XmlNode dateFinOccupee = occNode.SelectSingleNode("dateFinOccupee");

                if (dateDebutOccupee != null)
                {

                    DateTime datedebut = Convert.ToDateTime(dateDebutOccupee.InnerText);
                    _dateDebutOccupee.Add(datedebut);
                    DateTime datefin = Convert.ToDateTime(dateFinOccupee.InnerText);
                    _dateFinOccupee.Add(datefin);
                }
            }
            for (int i = 0; i < nbTableRonde; i++)
            {
                TableRonde table = new TableRonde();

                if (i < _dateDebutOccupee.Count)
                {
                    DateTime hdebut = new DateTime();
                    hdebut = _dateDebutOccupee[i];
                    DateTime hfin = new DateTime();
                    hfin = _dateFinOccupee[i];
                    Occupation occ = new Occupation(hdebut, hfin);
                    table.PlanningResa.Add(occ);
                }
                //ajout des tables lues à la liste de tables de la salle
                this.tables.Add(table);
            }
        }
Exemplo n.º 2
0
        }// fin creationTablesXml

        public void creationReservationXml()
        {
            //chargement du document
            XmlDocument doc = new XmlDocument();

            doc.Load("restaurant.xml");

            //recherche du noeud "reservation"
            XmlNodeList     itemNodes   = doc.SelectNodes("//Restaurant/Reservations/Reservation");
            List <int>      _noTable    = new List <int>();
            List <string>   _nomClient  = new List <string>();
            List <int>      _numClient  = new List <int>();
            List <int>      _nbConvive  = new List <int>();
            List <string>   _nomFormule = new List <string>();
            List <DateTime> _dateResa   = new List <DateTime>();

            //parcourt tous les noeuds "reservation" du document
            foreach (XmlNode itemNode in itemNodes)
            {
                XmlNode noTable    = itemNode.SelectSingleNode("tableResa");
                XmlNode nomClient  = itemNode.SelectSingleNode("nomClient");
                XmlNode numClient  = itemNode.SelectSingleNode("numClient");
                XmlNode dateResa   = itemNode.SelectSingleNode("dateResa");
                XmlNode nbConvive  = itemNode.SelectSingleNode("nbConvive");
                XmlNode nomFormule = itemNode.SelectSingleNode("formuleResa");

                if (nomClient != null)
                {
                    _nomFormule.Add(nomFormule.InnerText);
                    int numclient = int.Parse(numClient.InnerText);
                    _numClient.Add(numclient);
                    _nomClient.Add(nomClient.InnerText);
                    int notable = int.Parse(noTable.InnerText);
                    _noTable.Add(notable);
                    int nbconvive = int.Parse(nbConvive.InnerText);
                    _nbConvive.Add(nbconvive);
                    DateTime dateresa = Convert.ToDateTime(dateResa.InnerText);
                    _dateResa.Add(dateresa);
                }
            }

            //CREATION RESERVATIONS DANS LE PROGRAMME
            for (int i = 0; i < _nomClient.Count(); i++)
            {
                Reservation newResa        = new Reservation();
                Formule     formuleChoisie = new Formule();
                int         j = 0;
                while (j < formules.Count)
                {
                    for (int k = 0; k < formules.Count; k++)
                    {
                        if (_nomFormule[i].Equals(formules[k].NomFormule))
                        {
                            formuleChoisie = formules[k];
                        }
                    }
                    j++;
                }

                j = 0;
                while (j < tables.Count)
                {
                    if (j == _noTable[i])
                    {
                        if (tables[j].NbPlaceMax == 4)
                        {
                            TableCarree tableResa = new TableCarree();
                            tableResa = tables[j] as TableCarree;
                            newResa   = new Reservation(tableResa, _nomClient[i], _numClient[i], _dateResa[i], _nbConvive[i], formuleChoisie);
                        }
                        else
                        {
                            if (tables[j].NbPlaceMax == 6)
                            {
                                TableRectangulaire tableResa = new TableRectangulaire();
                                tableResa = tables[j] as TableRectangulaire;
                                newResa   = new Reservation(tableResa, _nomClient[i], _numClient[i], _dateResa[i], _nbConvive[i], formuleChoisie);
                            }
                            else
                            {
                                TableRonde tableResa = new TableRonde();
                                tableResa = tables[j] as TableRonde;
                                newResa   = new Reservation(tableResa, _nomClient[i], _numClient[i], _dateResa[i], _nbConvive[i], formuleChoisie);
                            }
                        }
                    }
                    j++;
                }

                this.reservations.Add(newResa);
            }
        } //fin creationReservationXML
Exemplo n.º 3
0
        public void creationReservationXml()
        {
            //chargement du document
            XmlDocument doc = new XmlDocument();
            doc.Load("restaurant.xml");

            //recherche du noeud "reservation"
            XmlNodeList itemNodes = doc.SelectNodes("//Restaurant/Reservations/Reservation");
            List<int> _noTable = new List<int>();
            List<string> _nomClient = new List<string>();
            List<int> _numClient = new List<int>();
            List<int> _nbConvive = new List<int>();
            List<string> _nomFormule = new List<string>();
            List<DateTime> _dateResa = new List<DateTime>();
            //parcourt tous les noeuds "reservation" du document
            foreach (XmlNode itemNode in itemNodes)
            {
                XmlNode noTable = itemNode.SelectSingleNode("tableResa");
                XmlNode nomClient = itemNode.SelectSingleNode("nomClient");
                XmlNode numClient = itemNode.SelectSingleNode("numClient");
                XmlNode dateResa = itemNode.SelectSingleNode("dateResa");
                XmlNode nbConvive = itemNode.SelectSingleNode("nbConvive");
                XmlNode nomFormule = itemNode.SelectSingleNode("formuleResa");

                if (nomClient != null)
                {

                    _nomFormule.Add(nomFormule.InnerText);
                    int numclient = int.Parse(numClient.InnerText);
                    _numClient.Add(numclient);
                    _nomClient.Add(nomClient.InnerText);
                    int notable = int.Parse(noTable.InnerText);
                    _noTable.Add(notable);
                    int nbconvive = int.Parse(nbConvive.InnerText);
                    _nbConvive.Add(nbconvive);
                    DateTime dateresa = Convert.ToDateTime(dateResa.InnerText);
                    _dateResa.Add(dateresa);

                }
            }

            //CREATION RESERVATIONS DANS LE PROGRAMME
            for (int i = 0; i < _nomClient.Count(); i++)
            {

                Reservation newResa = new Reservation() ;
                Formule formuleChoisie=new Formule();
                int j=0;
                while (j<formules.Count)
                    {
                        for (int k = 0; k < formules.Count; k++)
                        {
                            if (_nomFormule[i].Equals(formules[k].NomFormule))
                            {
                                formuleChoisie=formules[k];
                            }
                        }
                        j++;
                    }

                j = 0;
                while (j < tables.Count)
                    {

                        if (j==_noTable[i])
                         {
                            if (tables[j].NbPlaceMax==4)
                                {
                                    TableCarree tableResa = new TableCarree();
                                    tableResa=tables[j] as TableCarree;
                                    newResa = new Reservation(tableResa, _nomClient[i], _numClient[i], _dateResa[i], _nbConvive[i], formuleChoisie);

                                }
                            else
                            {
                                if (tables[j].NbPlaceMax == 6)
                                {
                                    TableRectangulaire tableResa = new TableRectangulaire();
                                    tableResa = tables[j] as TableRectangulaire;
                                    newResa = new Reservation(tableResa, _nomClient[i], _numClient[i], _dateResa[i], _nbConvive[i], formuleChoisie);

                                }
                                else
                                {
                                    TableRonde tableResa = new TableRonde();
                                    tableResa = tables[j] as TableRonde;
                                    newResa = new Reservation(tableResa, _nomClient[i], _numClient[i], _dateResa[i], _nbConvive[i], formuleChoisie);

                                }

                            }

                         }
                j++;
                    }

                this.reservations.Add(newResa);
            }
        }
Exemplo n.º 4
0
        }// fin creationFormulesXml

        public void creationTablesXml()
        {
            //le logiciel lit le fichier xml correspondant au restaurant
            XmlDocument doc = new XmlDocument();

            doc.Load("restaurant.xml");

            //Comptage du nombre de tables en fonction de chaque type(carrées, rectangulaires et rondes)
            XmlNodeList tablecarreeNodes = doc.SelectNodes("//Restaurant/Tables/TableCarees/TableCaree");
            XmlNodeList tablerectNodes   = doc.SelectNodes("//Restaurant/Tables/TableRectangulaires/TableRectangulaire");
            XmlNodeList tablerondeNodes  = doc.SelectNodes("//Restaurant/Tables/TableRondes/TableRonde");
            int         nbTableCarree    = 0;
            int         nbTableRect      = 0;
            int         nbTableRonde     = 0;

            foreach (XmlNode tablecaree in tablecarreeNodes)
            {
                nbTableCarree++;
            }
            foreach (XmlNode tablerect in tablerectNodes)
            {
                nbTableRect++;
            }
            foreach (XmlNode tableronde in tablerondeNodes)
            {
                nbTableRonde++;
            }

            //Lecture des informations concernants les Tables Carrées
            XmlNodeList     occupationsNodes  = doc.SelectNodes("//Restaurant/Tables/TableCarees/TableCaree/occupations/occupation");
            List <DateTime> _dateDebutOccupee = new List <DateTime>();
            List <DateTime> _dateFinOccupee   = new List <DateTime>();

            //parcours chaque noeuds "occupation"
            foreach (XmlNode occNode in occupationsNodes)
            {
                XmlNode dateDebutOccupee = occNode.SelectSingleNode("dateDebutOccupee");
                XmlNode dateFinOccupee   = occNode.SelectSingleNode("dateFinOccupee");

                if (dateDebutOccupee != null)
                {
                    DateTime datedebut = Convert.ToDateTime(dateDebutOccupee.InnerText);
                    _dateDebutOccupee.Add(datedebut);
                    DateTime datefin = Convert.ToDateTime(dateFinOccupee.InnerText);
                    _dateFinOccupee.Add(datefin);
                }
            }

            //CREATION DES TABLES CAREES
            //elles se créent à partir de la lecture du fichier xml, comme ça le logiciel s'adapte à chaque restaurant disposant de ces trois types de tables
            for (int i = 0; i < nbTableCarree; i++)
            {
                TableCarree table = new TableCarree();

                if (i < _dateDebutOccupee.Count)
                {
                    DateTime hdebut = new DateTime();
                    hdebut = _dateDebutOccupee[i];
                    DateTime hfin = new DateTime();
                    hfin = _dateFinOccupee[i];
                    Occupation occ = new Occupation(hdebut, hfin);
                    table.PlanningResa.Add(occ);
                }
                //ajout des tables lues à la liste de tables de la salle
                this.tables.Add(table);
            }


            //Lecture des informations concernants les Tables Rectangulaires
            XmlNodeList occupationNodes = doc.SelectNodes("//Restaurant/Tables/TableRectangulaires/TableRectangulaire/occupations/occupation");

            //parcours chaque noeuds "occupation"
            foreach (XmlNode occNode in occupationNodes)
            {
                XmlNode dateDebutOccupee = occNode.SelectSingleNode("dateDebutOccupee");
                XmlNode dateFinOccupee   = occNode.SelectSingleNode("dateFinOccupee");

                if (dateDebutOccupee != null)
                {
                    DateTime datedebut = Convert.ToDateTime(dateDebutOccupee.InnerText);
                    _dateDebutOccupee.Add(datedebut);
                    DateTime datefin = Convert.ToDateTime(dateFinOccupee.InnerText);
                    _dateFinOccupee.Add(datefin);
                }
            }
            for (int i = 0; i < nbTableRect; i++)
            {
                TableRectangulaire table = new TableRectangulaire();

                if (i < _dateDebutOccupee.Count)
                {
                    DateTime hdebut = new DateTime();
                    hdebut = _dateDebutOccupee[i];
                    DateTime hfin = new DateTime();
                    hfin = _dateFinOccupee[i];
                    Occupation occ = new Occupation(hdebut, hfin);
                    table.PlanningResa.Add(occ);
                }

                //ajout des tables lues à la liste de tables de la salle
                this.tables.Add(table);
            }

            //Lecture des informations concernants les Tables Rondes
            XmlNodeList occupNodes = doc.SelectNodes("//Restaurant/Tables/TableRondes/TableRonde/occupations/occupation");

            //parcours chaque noeuds "occupation"
            foreach (XmlNode occNode in occupNodes)
            {
                XmlNode dateDebutOccupee = occNode.SelectSingleNode("dateDebutOccupee");
                XmlNode dateFinOccupee   = occNode.SelectSingleNode("dateFinOccupee");

                if (dateDebutOccupee != null)
                {
                    DateTime datedebut = Convert.ToDateTime(dateDebutOccupee.InnerText);
                    _dateDebutOccupee.Add(datedebut);
                    DateTime datefin = Convert.ToDateTime(dateFinOccupee.InnerText);
                    _dateFinOccupee.Add(datefin);
                }
            }
            for (int i = 0; i < nbTableRonde; i++)
            {
                TableRonde table = new TableRonde();

                if (i < _dateDebutOccupee.Count)
                {
                    DateTime hdebut = new DateTime();
                    hdebut = _dateDebutOccupee[i];
                    DateTime hfin = new DateTime();
                    hfin = _dateFinOccupee[i];
                    Occupation occ = new Occupation(hdebut, hfin);
                    table.PlanningResa.Add(occ);
                }
                //ajout des tables lues à la liste de tables de la salle
                this.tables.Add(table);
            }
        }// fin creationTablesXml