/* * public static void Main(string[] args) * { * CreateNumber firsthnum = new CreateNumber(Convert.ToInt32(Console.ReadLine())); * * }*/ public static void Main(string[] args) { var userMenu = new Menu(); var ioSystem = new IoManager(); //userMenu.OperatorMenu(); ioSystem.Print("Hello!"); ioSystem.input(); }
public static void MainMenu() { var ioManager = new IoManager(); while (true) { ioManager.WriteStepMessage("Menu:"); ioManager.WriteStepMessage("For work with Data base write: DBO"); ioManager.WriteStepMessage("For work with Taxi Park write: PARK"); string menuResponse = ioManager.ReadMenuStep(); if (menuResponse == "EXITE") { Environment.Exit(0); } else if (menuResponse == "DBO") { ioManager.WriteStepMessage("Connection check:"); DBOWorker.DBOConnect(); DBOMenu(); } else if (menuResponse == "PARK") { try { var worker = new CarWorker(); worker.ParkMenu(); } catch (Exception ex) { ioManager.Write("Somthing went wrong..." + ex.Message); ioManager.Read(); } ioManager.Read(); } else { ioManager.WriteStepMessage("There is no such command. Try again or write Exite for close programm"); } } }
public static void DBOMenu() { var dboIoManager = new IoManager(); dboIoManager.WriteStepMessage("Data Base Menu:"); dboIoManager.DBOSubMenu(); while (true) { string dboMenuResponse = dboIoManager.ReadMenuStep(); if (dboMenuResponse == "EXITE") { dboIoManager.Write("Connection Closed"); break; } else if (dboMenuResponse == "ADD") { DBOWorker.CarInsert(); } else if (dboMenuResponse == "DELETE") { DBOWorker.CarDelete(); } else if (dboMenuResponse == "CARS") { DBOWorker.SqlInsertMenu(); } else if (dboMenuResponse == "SELECT") { DBOWorker.GetCar(); } else if (dboMenuResponse == "UPDATE") { DBOWorker.CarPriceUpdate(); } else { dboIoManager.Write("There is no such command... Try again or write EXITE for return to Main menu. "); } } }
public static void SerializeBin(IEnumerable <Car> cars) { var ioManager = new IoManager(); FileStream fs = new FileStream("DataFile.dat", FileMode.Create); BinaryFormatter formatter = new BinaryFormatter(); try { formatter.Serialize(fs, cars); } catch (SerializationException e) { Console.WriteLine("Failed to serialize. Reason: " + e.Message); throw; } finally { fs.Close(); } }
public static void DeserializeBin() { var binIoManager = new IoManager(); IEnumerable <Car> cars = null; FileStream fs = new FileStream("DataFile.dat", FileMode.Open); try { BinaryFormatter formatter = new BinaryFormatter(); cars = (List <Car>)formatter.Deserialize(fs); } catch (SerializationException e) { Console.WriteLine("Failed to deserialize. Reason: " + e.Message); throw; } finally { fs.Close(); } binIoManager.ShowTable(cars); }
public void ParkMenu() { var parkIoManager = new IoManager(); try { var carPark = GetDefaultCarPark(); parkIoManager.WriteStepMessage("Park Menu"); parkIoManager.ParkMenu(); while (true) { string menuStepResp = parkIoManager.ReadMenuStep(); parkIoManager.Write(menuStepResp); if (menuStepResp == "CREATE") { parkIoManager.WriteStepMessage("Taxi park is created:"); parkIoManager.ShowTable(carPark.Cars); } else if (menuStepResp == "PRICE") { parkIoManager.WriteStepMessage("Car park price:"); parkIoManager.WritePrice(carPark.GetPrice()); } else if (menuStepResp == "SORT") { parkIoManager.WriteStepMessage("Cars sorted by Fuel Consumption:"); parkIoManager.ShowTable(carPark.Cars.OrderBy(car => car.FuelConsumption)); } else if (menuStepResp == "SEARCH") { ShowSerchResultByYear(carPark.Cars); } else if (menuStepResp == "SAVEBIN") { ReadWriteDataManager.SerializeBin(carPark.Cars); } else if (menuStepResp == "OPENBIN") { if (!File.Exists(@"D:\\lol.xml")) { throw new OpenFileException("File doesn't exist..."); } ReadWriteDataManager.DeserializeBin(); } else if (menuStepResp == "XML") { parkIoManager.WriteStepMessage("XML fail is created:"); ReadWriteDataManager.SerializeXml(carPark); } else if (menuStepResp == "OPENXML") { if (!File.Exists(@"D:\\lol.xml")) { throw new OpenFileException("File doesn't exist..."); } var result = ReadWriteDataManager.DeserializeXml(); parkIoManager.ShowTable(result.Cars); } else if (menuStepResp == "EXIT") { break; } else { parkIoManager.Write("There is no such command... Try again or write EXITE for return to Main menu. "); } } } catch (Exception ex) { parkIoManager.Write("Somthing went wrong...\n" + ex); } }
public void OperatorMenu() { var ioManger = new IoManager(); ioManger.Print("Enter num"); }