public void Write(string path, SaveManager man)
 {
     man.WriteLine($"Наименование категории: {GetNumberOfKat()}");
     man.WriteLine($"Процент надбавки к цене запчасти: {getProc()}");
 }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            List <Owner>   owner   = new List <Owner>();
            List <Agency>  agency  = new List <Agency>();
            List <Object1> object1 = new List <Object1>();
            List <Lodger>  lodger  = new List <Lodger>();

            Object1.InputObject1(ref object1);

            LoadManager loader1 = new LoadManager("object1.txt");

            loader1.BeginRead();
            while (loader1.IsLoading)
            {
                object1.Add(loader1.Read(new Object1.Loader()) as Object1);
            }
            loader1.EndRead();

            LoadManager loader2 = new LoadManager("Owner.txt");

            loader2.BeginRead();
            while (loader2.IsLoading)
            {
                owner.Add(loader2.Read(new Owner.Loader()) as Owner);
            }
            loader2.EndRead();

            FileStream file1 = new FileStream("object1.txt", FileMode.Create);
            FileStream file2 = new FileStream("Owner.txt", FileMode.Create);
            FileStream file3 = new FileStream("Agency.txt", FileMode.Create);
            FileStream file4 = new FileStream("Lodger.txt", FileMode.Create);

            file1.Close();
            file2.Close();
            file3.Close();
            file1.Close();
            SaveManager first = new SaveManager("object1.txt");

            foreach (var x in object1)
            {
                first.WriteObject(x);
            }

            SaveManager ownerInFle = new SaveManager("Owner.txt");

            foreach (var x in owner)
            {
                ownerInFle.WriteObject(x);
            }

            SaveManager agencyInFle = new SaveManager("Agency.txt");

            foreach (var x in owner)
            {
                agencyInFle.WriteObject(x);
            }

            SaveManager ownelodgerInFle = new SaveManager("Lodger.txt");

            foreach (var x in owner)
            {
                ownelodgerInFle.WriteObject(x);
            }



            Owner.InputOwner(ref owner);
            Agency.InputAgency(ref agency);
            Lodger.InputLodger(ref lodger);
            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            int   count;
            int   answer;
            int   globalAnswer = 0;
            bool  returnWhile  = true;
            Files file         = new Files();

            SaveManager save = new SaveManager("DIR");

            while (returnWhile)
            {
                Console.WriteLine("Выберете что сделать" +
                                  "\n 1 - Прочитать значение из файла \n 2 - Записать новые значения \n 0 - ВЫХОД");
                globalAnswer = int.Parse(Console.ReadLine());
                switch (globalAnswer)
                {
                case 1:
                    //Чтение из файлов
                    file.createDirectory();
                    readFile(new LoadManager("DIR"));
                    break;

                case 2:
                    Console.WriteLine("Введите кол - во запчастей: ");
                    do
                    {
                        count = int.Parse(Console.ReadLine());
                        if (count <= 0)
                        {
                            Console.WriteLine("Введено неверное число, попробуйте заново");
                        }
                    } while (count <= 0);

                    Zap[] zap = new Zap[count];
                    for (int i = 0; i < count; i++)
                    {
                        zap[i] = new Zap();
                        Console.WriteLine("----------------------------------------");
                    }
                    Console.WriteLine("Что вы хотите сделать? \n 1 - Изменить введеную ифнормациию \n 2 - Добавить информацию \n 3 - Удалить ифнормацию \n 0 - ПРОДОЛЖИТЬ ");
                    answer = int.Parse(Console.ReadLine());
                    do
                    {
                        switch (answer)
                        {
                        //Изменение информации
                        case 1:
                            do
                            {
                                answer = ChangeInfo.changeObject(zap);
                            } while (answer != 0);
                            break;

                        //Добавление ифнормации
                        case 2:
                            do
                            {
                                answer = ChangeInfo.AddObject(zap);
                            } while (answer != 0);
                            break;

                        //Удаление информации
                        case 3:
                            do
                            {
                                answer = ChangeInfo.DeleteObject(zap);
                            } while (answer != 0);
                            break;
                        }
                    } while (answer != 0);

                    //Запись в файл
                    writeInFile(count, zap, save);
                    break;

                default:
                    returnWhile = false;
                    break;
                }
            }
        }