コード例 #1
0
        //Exporter la liste des clients au format XML
        public static bool ExporterXml()
        {
            List <Client> listeDAL = BDD.AfficheListeClient();

            List <ClientBOL> listeBOL = new List <ClientBOL>();

            foreach (Client c in listeDAL)
            {
                ClientBOL client1 = new ClientBOL
                {
                    Id            = c.Id,
                    Nom           = c.Nom,
                    Prenom        = c.Prenom,
                    CarteFidelite = c.CarteFidelite,
                    Societe       = c.Societe,
                    Civilite      = c.Civilite
                };

                listeBOL.Add(client1);
            }


            XmlSerializer xmlserialise = new XmlSerializer(typeof(List <ClientBOL>),
                                                           new XmlRootAttribute("ListeClients"));

            using (var sw = new StreamWriter(@"..\..\XML_Liste_Client.xml"))
            {
                xmlserialise.Serialize(sw, listeBOL);
            }
            return(true);
        }
コード例 #2
0
        // Envoie la liste de tous les clients
        public static List <ClientBOL> GetClients()
        {
            List <Client>    liste    = BDD.AfficheListeClient();
            List <ClientBOL> listeBOL = new List <ClientBOL>();

            foreach (Client c in liste)
            {
                ClientBOL client1 = new ClientBOL();
                client1.Id            = c.Id;
                client1.Nom           = c.Nom;
                client1.Prenom        = c.Prenom;
                client1.CarteFidelite = c.CarteFidelite;
                client1.Societe       = c.Societe;
                client1.Civilite      = c.Civilite;

                listeBOL.Add(client1);
            }

            return(listeBOL);
        }