Пример #1
0
        public static void ReadStContainerFromFile(string path, StudentContainer readContainer)
        {
            try
            {
                using (StreamReader sr = new StreamReader(path, System.Text.Encoding.Default))
                {
                    string line;
                    while ((line = sr.ReadLine()) != null)
                    {
                        var infoStudent = line.Split(new char[] { '|' });

                        readContainer.AddStudent(new Student(infoStudent[0],
                                                             infoStudent[1],
                                                             infoStudent[2],
                                                             DateTime.Parse(infoStudent[3]),
                                                             DateTime.Parse(infoStudent[4]),
                                                             char.Parse(infoStudent[5]),
                                                             infoStudent[6],
                                                             infoStudent[7],
                                                             double.Parse(infoStudent[8])));
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Пример #2
0
 public static void ShowAll(StudentContainer printedContainer)
 {
     foreach (var i in printedContainer)
     {
         OutputStudent(i);
     }
 }
Пример #3
0
 public static void WriteStContainerToFile(string path, StudentContainer writtenContainer)
 {
     try
     {
         using (StreamWriter sw = new StreamWriter(path, false, System.Text.Encoding.Default))
         {
             foreach (var i in writtenContainer)
             {
                 sw.WriteLine(i.ToInfoString());
             }
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
 }
Пример #4
0
        public static void Start()
        {
            const string path   = @"C:\Users\Дмитрий Соколенко\source\repos\DotNet\sokolenko03DN\file.txt";
            var          pigsty = new StudentContainer();
            char         choice = 'a';

            Console.WriteLine("Hello World! Our copany introduces the next level of data base - AllBase");
            Console.WriteLine("The array of Student object is created, my lord.");

            Io.ReadStContainerFromFile(path, pigsty);

            while (choice != '0')
            {
                PrintMenu();
                Console.Write("Make a choice: ");
                choice = Io.InputChar();

                switch (choice)
                {
                case '1':
                    Io.ShowAll(pigsty);
                    break;

                case '2':
                    pigsty.AddStudent(Io.InputStudent());
                    break;

                case '3':
                    if (pigsty.Size() > 0)
                    {
                        Console.Write("Input the index: ");
                        pigsty.DeleteStudent(Io.InputInt());
                    }
                    else
                    {
                        Console.Write("Container is empty");
                    }
                    break;

                case '4':
                    if (pigsty.Size() > 0)
                    {
                        Console.Write("Input the index: ");
                        pigsty.ShowByIndex(Io.InputInt());
                    }
                    else
                    {
                        Console.Write("Container is empty");
                    }
                    break;

                case '5':
                    if (pigsty.Size() > 0)
                    {
                        Console.Write("Input the index: ");
                        pigsty.EditByIndex(Io.InputInt());
                    }
                    else
                    {
                        Console.Write("Container is empty");
                    }
                    break;
                }
            }

            Io.WriteStContainerToFile(path, pigsty);
        }