Beispiel #1
0
        private static void Import(ConsoleKey selectMenu, out bool exitMenuFiles)
        {
            if (File.Exists(Titles.FileXML))
            {
                MainMenu.CommonStorage(
                    Titles.FileXML,
                    new FactoryXML(),
                    false,
                    string.Format(Titles.CorrectImport, Environment.CurrentDirectory, Titles.FileXML),
                    string.Format(Titles.IncorrectImportWithLog, Environment.CurrentDirectory, Titles.FileXML, Titles.FileOfLog));
            }
            else
            {
                Screen.ShowText(Titles.MenuToImport);

                bool exitMenuImport = false;

                try
                {
                    while (!exitMenuImport)
                    {
                        Console.Clear();
                        Screen.ShowText(Titles.MenuToImport);
                        selectMenu = Console.ReadKey().Key;

                        switch (selectMenu)
                        {
                        case ConsoleKey.D1:
                        case ConsoleKey.NumPad1:
                        {
                            MainMenu.CommonStorage(
                                Titles.FileTXT,
                                new FactoryTXTNotError(),
                                false,
                                string.Format(Titles.CorrectImport, Environment.CurrentDirectory, Titles.FileTXT),
                                string.Format(Titles.ItemIsIncorrectInFile, Environment.CurrentDirectory, Titles.FileTXT));

                            exitMenuImport = true;
                            break;
                        }

                        case ConsoleKey.D2:
                        case ConsoleKey.NumPad2:
                        {
                            MainMenu.CommonStorage(
                                Titles.FileTXT,
                                new FactoryTXTWithError(),
                                false,
                                string.Format(Titles.CorrectImportWithLog, Environment.CurrentDirectory, Titles.FileTXT, Titles.FileOfLog),
                                string.Format(Titles.EmptyFile, Environment.CurrentDirectory, Titles.FileTXT));

                            exitMenuImport = true;
                            break;
                        }

                        case ConsoleKey.Q:
                            exitMenuImport = true;
                            break;

                        default:
                            break;
                        }
                    }
                }
                catch (FileNotFoundException ex)
                {
                    Console.Clear();
                    Screen.ShowText(ex.Message);
                }
            }

            exitMenuFiles = true;
        }
Beispiel #2
0
        private static void SaveToFile(out bool exitMenuFiles)
        {
            if (Catalog.IsNotEmpty)
            {
                bool exitToUp = false;
                Screen.ShowText(Titles.SavedTypeMunu);
                ConsoleKey savedType = ConsoleKey.Q;

                while (!exitToUp)
                {
                    Console.Clear();
                    Screen.ShowText(Titles.SavedTypeMunu);
                    savedType = Console.ReadKey().Key;

                    switch (savedType)
                    {
                    case ConsoleKey.D1:
                    case ConsoleKey.NumPad1:
                    {
                        MainMenu.CommonStorage(
                            Titles.FileTXT,
                            new FactoryTXTNotError(),
                            true,
                            string.Format(Titles.MessageOfSaveFile, Environment.CurrentDirectory, Titles.FileTXT),
                            string.Format(Titles.ErrorOfSaveFile, Environment.CurrentDirectory, Titles.FileTXT));

                        exitToUp = true;
                        break;
                    }

                    case ConsoleKey.D2:
                    case ConsoleKey.NumPad2:
                    {
                        MainMenu.CommonStorage(
                            Titles.FileXML,
                            new FactoryXML(),
                            true,
                            string.Format(Titles.MessageOfSaveFile, Environment.CurrentDirectory, Titles.FileXML),
                            string.Format(Titles.ErrorOfSaveFile, Environment.CurrentDirectory, Titles.FileXML));

                        exitToUp = true;
                        break;
                    }

                    case ConsoleKey.Q:
                        exitToUp = true;
                        break;

                    default:
                        break;
                    }
                }
            }
            else
            {
                Screen.ShowText(Titles.EmptyCatalog);
                Console.ReadKey();
            }

            exitMenuFiles = true;
        }