Exemple #1
0
        public CarnetEntretienStatus EnregistrerCarnetSous(string filename)
        {
            CarnetEntretienStatus status = CarnetEntretienStatus.Success;

            XmlDocument    xmlDoc = new XmlDocument();
            XmlDeclaration dec    = xmlDoc.CreateXmlDeclaration("1.0", "UTF-8", "");

            xmlDoc.AppendChild(dec);

            XmlNode rootNode = xmlDoc.CreateElement("EntretienDB");

            xmlDoc.AppendChild(rootNode);

            XmlNode      userNode  = xmlDoc.CreateElement("Vehicule");
            XmlAttribute attribute = xmlDoc.CreateAttribute("Marque");

            attribute.Value = vehicule.Marque;
            userNode.Attributes.Append(attribute);
            attribute       = xmlDoc.CreateAttribute("Modele");
            attribute.Value = vehicule.Modele;
            userNode.Attributes.Append(attribute);
            userNode.InnerText = vehicule.Immatriculation;
            rootNode.AppendChild(userNode);

            XmlNode EntretienNode = xmlDoc.CreateElement("EntretienList");

            rootNode.AppendChild(EntretienNode);

            foreach (Entretien e in entretiens)
            {
                XmlNode      ficheNode = xmlDoc.CreateElement("Entretien");
                XmlAttribute attr      = xmlDoc.CreateAttribute("Kilometrage");
                attr.Value = e.Kilometrage;
                ficheNode.Attributes.Append(attr);
                attr       = xmlDoc.CreateAttribute("Titre");
                attr.Value = e.Titre;
                ficheNode.Attributes.Append(attr);
                ficheNode.InnerText = e.Date;
                EntretienNode.AppendChild(ficheNode);
            }

            xmlDoc.Save(filename);

            return(status);
        }
Exemple #2
0
        public CarnetEntretienStatus CreerCarnetVide(string filename)
        {
            CarnetEntretienStatus status = CarnetEntretienStatus.Success;

            vehicule   = new Vehicule();
            entretiens = new Entretien[1];

            XmlDocument    doc = new XmlDocument();
            XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", "UTF-8", "");

            doc.AppendChild(dec);

            XmlNode mainNode = doc.CreateNode(XmlNodeType.Document, "EntretienDB", "");

            doc.AppendChild(mainNode);
            doc.Save(filename);

            return(status);
        }