Beispiel #1
0
 void ChangeSotr(Sotrudnik change)
 {
     Console.WriteLine("Enter the FIO");
     change.FIO = Console.ReadLine();
     Console.WriteLine("Enter the age");
     change.Age = Console.Read();
     Console.WriteLine("Enter the Department");
     change.Department = Console.ReadLine();
     Console.WriteLine("Enter the Position");
     change.Position = Console.ReadLine();
     SerializeS(change);
 }
Beispiel #2
0
        public Sotrudnik newsSotrudni()
        {
            Sotrudnik newsotr = new Sotrudnik();

            Console.WriteLine("Enter the FIO");
            newsotr.FIO = Console.ReadLine();
            Console.WriteLine("Enter the ID");
            newsotr.ID = Int32.Parse(Console.ReadLine());
            Console.WriteLine("Enter the age");
            newsotr.Age = Int32.Parse(Console.ReadLine());
            Console.WriteLine("Enter the Department");
            newsotr.Department = Console.ReadLine();
            Console.WriteLine("Enter the Position");
            newsotr.Position = Console.ReadLine();
            return(newsotr);
        }
Beispiel #3
0
        public void DeserializeS(Sotrudnik sotrudnik)
        {
            try
            {
                XmlSerializer formatter = new XmlSerializer(typeof(Sotrudnik));
                using (FileStream fs = new FileStream($"sotrudnik{ID}.xml", FileMode.OpenOrCreate))
                {
                    Sotrudnik ChangeSotrudnik = (Sotrudnik)formatter.Deserialize(fs);

                    Console.WriteLine("Объект десериализован");
                    ChangeSotrudnik.PrintS();
                    ChangeSotr(ChangeSotrudnik);
                }
            }
            catch (Exception)
            {
                Console.WriteLine("Error  Deserialization");
            }
        }
Beispiel #4
0
        public void SerializeS(Sotrudnik sotrudnik)
        {
            try
            {
                XmlSerializer formatter = new XmlSerializer(typeof(Sotrudnik));


                using (FileStream fs = new FileStream($"Sotrudnik{ID}.xml", FileMode.OpenOrCreate))
                {
                    formatter.Serialize(fs, sotrudnik);

                    Console.WriteLine("Объект сериализован");
                }
            }
            catch (Exception)
            {
                Console.WriteLine("Error  Serialization");
            }
        }