Esempio n. 1
0
        static void Load(string type)
        {
            team.Clear();
            switch (type)
            {
            case "Xml": team.LoadXml(); break;

            case "Bin": team.LoadBinary(); break;

            case "Json": team.LoadJson(); break;

            case "Txt": team.LoadTxt(); break;
            }
            foreach (var item in team)
            {
                if (item.GetType() == typeof(Commercial))
                {
                    Console.WriteLine("Matricule : {0}, Nom : {1}, Prenom : {2}, Chiffre d'affaire : {3}, Commission : {4}", item.Matricule, item.Nom, item.Prenom, ((Commercial)item).ChiffreAffaire, ((Commercial)item).Commission);
                }
                else
                {
                    Console.WriteLine("Matricule : {0}, Nom : {1}, Prenom : {2}", item.Matricule, item.Nom, item.Prenom);
                }
            }
            Console.ReadLine();
        }
Esempio n. 2
0
        public static void Serialisationv1()
        {
            #region Initialisation
            Salaries listesal = new Salaries();
            listesal.Add(new Salarie(new DateTime(1993, 11, 10), "12gty93", "CHESNE", "Sarah", 25000, 0.2));
            listesal.Add(new Salarie(new DateTime(1998, 08, 27), "12gty98", "CHESNE", "Emilie", 23000, 0.2));
            #endregion

            #region Exercice 2.1 CSV
            listesal.SaveText(@"C:\Users\CDI\Documents\Visual Studio 2015\Projects\PersitanceObjet\Salarie.csv");
            Salaries listesal2 = new Salaries();


            listesal2.LoadText(@"C:\Users\CDI\Documents\Visual Studio 2015\Projects\PersitanceObjet\Salarie.csv");
            foreach (Salarie sal in listesal2)
            {
                Console.WriteLine(sal.ToString());
            }
            #endregion

            #region XML
            listesal.SaveXML(@"C:\Users\CDI\Documents\Visual Studio 2015\Projects\PersitanceObjet\Salarie.xml");
            Salaries listesal3 = new Salaries();

            listesal3.LoadXML(@"C:\Users\CDI\Documents\Visual Studio 2015\Projects\PersitanceObjet\Salarie.xml");
            foreach (Salarie sal2 in listesal3)
            {
                Console.WriteLine(sal2.ToString());
            }
            #endregion

            #region Binaire

            listesal.SaveBinary(@"C:\Users\CDI\Documents\Visual Studio 2015\Projects\PersitanceObjet\Salarie.dat");
            Salaries listesal4 = new Salaries();
            listesal4.LoadBinary(@"C:\Users\CDI\Documents\Visual Studio 2015\Projects\PersitanceObjet\Salarie.dat");
            foreach (Salarie sal3 in listesal4)
            {
                Console.WriteLine(sal3.ToString());
            }
            #endregion

            

        }
Esempio n. 3
0
        static void TesterSalariesBinaire()
        {
            Salaries ListeSalaries = new Salaries();

            ListeSalaries.Add(new Salarie()
            {
                Matricule     = "12XXX34",
                Nom           = "Hemar",
                Prenom        = "Mylene",
                DateNaissance = new DateTime(1988, 02, 20),
                SalaireBrut   = 2000,
                TxCS          = 0.20
            });
            ListeSalaries.Add(new Salarie("12XXX35", "Groot", "JeSAppelle", new DateTime(2000, 03, 19), 2500, 0.30));
            ListeSalaries.SaveBinary(@"C:\Users\CDI\Documents\Visual Studio 2015\Projects\Persistance");
            ListeSalaries.LoadBinary(@"C:\Users\CDI\Documents\Visual Studio 2015\Projects\Persistance");
            foreach (Salarie item in ListeSalaries)
            {
                Console.WriteLine(item.ToString());
            }
            Console.ReadLine();
        }