public void savescince(Scince scince, string file)
 {
     System.IO.File.AppendAllText(file, scince.getfam());
     System.IO.File.AppendAllText(file, "\n");
     System.IO.File.AppendAllText(file, scince.getname());
     System.IO.File.AppendAllText(file, "\n");
     System.IO.File.AppendAllText(file, scince.getotch());
     System.IO.File.AppendAllText(file, "\n");
     System.IO.File.AppendAllText(file, scince.getuchstep());
     System.IO.File.AppendAllText(file, "\n");
     System.IO.File.AppendAllText(file, scince.getid().ToString());
     System.IO.File.AppendAllText(file, "\n");
     System.IO.File.AppendAllText(file, scince.getnameorg());
     System.IO.File.AppendAllText(file, "\n");
     System.IO.File.AppendAllText(file, scince.getcountryorg());
     System.IO.File.AppendAllText(file, "\n");
     System.IO.File.AppendAllText(file, scince.getcityorg());
     System.IO.File.AppendAllText(file, "\n");
     System.IO.File.AppendAllText(file, scince.gettheme());
     System.IO.File.AppendAllText(file, "\n");
     System.IO.File.AppendAllText(file, scince.gettypeofpart());
     System.IO.File.AppendAllText(file, "\n");
     System.IO.File.AppendAllText(file, scince.getpubl().ToString());
     System.IO.File.AppendAllText(file, "\n");
     System.IO.File.AppendAllText(file, scince.gethour().ToString());
     System.IO.File.AppendAllText(file, "\n");
     System.IO.File.AppendAllText(file, scince.getmin().ToString());
 }
Example #2
0
        }                 //Констурктор класса Save

        public void savetofile(Scince scince, Сonf conf, int n, string file)
        {
            SaveConf   sc = new SaveConf();
            SaveScince ss = new SaveScince();

            if (fs == 0)
            {
                fs = 1;
                System.IO.File.WriteAllText(file, "");
                System.IO.File.AppendAllText(file, n.ToString());
                System.IO.File.AppendAllText(file, "\n");
            }
            sc.saveconf(conf, file);
            ss.savescince(scince, file);

            /*System.IO.File.AppendAllText(file, "\n");
             * System.IO.File.AppendAllText(file, conf.getnameconf());
             * System.IO.File.AppendAllText(file, "\n");
             * System.IO.File.AppendAllText(file, conf.getplaceconf());
             * System.IO.File.AppendAllText(file, "\n");
             * System.IO.File.AppendAllText(file, conf.getd().ToString());
             * System.IO.File.AppendAllText(file, "\n");
             * System.IO.File.AppendAllText(file, conf.getmon().ToString());
             * System.IO.File.AppendAllText(file, "\n");
             * System.IO.File.AppendAllText(file, conf.gety().ToString());
             * System.IO.File.AppendAllText(file, "\n");
             * System.IO.File.AppendAllText(file, conf.geth().ToString());
             * System.IO.File.AppendAllText(file, "\n");
             * System.IO.File.AppendAllText(file, conf.getm().ToString());
             * System.IO.File.AppendAllText(file, "\n");
             * System.IO.File.AppendAllText(file, scince.getfam());
             * System.IO.File.AppendAllText(file, "\n");
             * System.IO.File.AppendAllText(file, scince.getname());
             * System.IO.File.AppendAllText(file, "\n");
             * System.IO.File.AppendAllText(file, scince.getotch());
             * System.IO.File.AppendAllText(file, "\n");
             * System.IO.File.AppendAllText(file, scince.getuchstep());
             * System.IO.File.AppendAllText(file, "\n");
             * System.IO.File.AppendAllText(file, scince.getid().ToString());
             * System.IO.File.AppendAllText(file, "\n");
             * System.IO.File.AppendAllText(file, scince.getnameorg());
             * System.IO.File.AppendAllText(file, "\n");
             * System.IO.File.AppendAllText(file, scince.getcountryorg());
             * System.IO.File.AppendAllText(file, "\n");
             * System.IO.File.AppendAllText(file, scince.getcityorg());
             * System.IO.File.AppendAllText(file, "\n");
             * System.IO.File.AppendAllText(file, scince.gettheme());
             * System.IO.File.AppendAllText(file, "\n");
             * System.IO.File.AppendAllText(file, scince.gettypeofpart());
             * System.IO.File.AppendAllText(file, "\n");
             * System.IO.File.AppendAllText(file, scince.getpubl().ToString());
             * System.IO.File.AppendAllText(file, "\n");
             * System.IO.File.AppendAllText(file, scince.gethour().ToString());
             * System.IO.File.AppendAllText(file, "\n");
             * System.IO.File.AppendAllText(file, scince.getmin().ToString());*/
        }
Example #3
0
        static void Main(string[] args)
        {
            Load   load = new Load(); //Создание объектов классов загрузки, сохранение и конференции
            Save   save = new Save(); //
            Сonf   conf = new Сonf(); //
            string file = "";
            string a;
            int    n = 0;

            conf.confreadinfo(); //Метод ввода данных о конференции
            conf.info();         //Метод вывода данных о конференции
            Console.Write("Введите количество учёных: ");
            n = int.Parse(Console.ReadLine());
            Scince[] scince = new Scince[n]; //Создание массива учёных
            for (int i = 0; i < n; i++)
            {
                scince[i] = new Scince(); //Создание объекта класса Scince в каждом элементе массива
                scince[i].readinfo();     //Метод ввода данных об учёном
            }
            for (int i = 0; i < n; i++)
            {
                scince[i].info(); //Метод вывода данных об учёном
            }
            Console.Write("Сохранить данные в файл? (д/н) ");
            a = Console.ReadLine();
            if (a == "д")
            {
                Console.Write("Введите имя файла");
                file = Console.ReadLine();
                System.IO.File.Create(file).Close(); //Создание файла
                for (int i = 0; i < n; i++)
                {
                    save.savetofile(scince[i], conf, n, file);   //Метод сохоанения данных в файл
                }
                Console.WriteLine("Сохранено");
            }
            if (System.IO.File.Exists(file)) //Проверка существует ли файл
            {
                Console.Write("Загрузить данные из файла? (д/н) ");
                a = Console.ReadLine();
                if (a == "д")
                {
                    StreamReader sr = new StreamReader(file); //Считывание количества учёных в файле
                    n = int.Parse(sr.ReadLine());             //
                    sr.Close();                               //
                    scince = new Scince[n];                   //Создание нового массива учёных
                    for (int i = 0; i < n; i++)               //
                    {                                         //
                        scince[i] = new Scince();             //Создание объекта класса Scince в каждом элементе массива
                    }                                         //
                    load.loadfile(n, scince, conf);           //метод загрузки данных из файла
                    Console.WriteLine("Загружено");
                }
            }
            else
            {
                Console.WriteLine("Для выхода нажмите на любую клавишу . . . ");
                Console.ReadKey();
                Environment.Exit(0); //Выход из программы если нет ранее сохранённого файла
            }
            conf.info();
            for (int i = 0; i < n; i++)
            {
                scince[i].info(); //Вывод информации послезагрузки из файла
            }
            Console.WriteLine("Для выхода нажмите на любую клавишу . . . ");
            Console.ReadKey();
        }