public static void MainMenu() { Console.WriteLine(); OutputHandling.Message("1 - Print Books Published In 2010"); OutputHandling.Message("2 - Print Books Published in Max Year"); OutputHandling.Message("3 - Print Top 10 Books"); OutputHandling.Message("4 - Exit"); ConsoleKeyInfo cki = Console.ReadKey(true); if (cki.Key.Equals(ConsoleKey.D1) || cki.Key.Equals(ConsoleKey.NumPad1)) { PrintBooksPublishedIn2010(BooksCrud.BooksPublishedIn2010()); } else if (cki.Key.Equals(ConsoleKey.D2) || cki.Key.Equals(ConsoleKey.NumPad2)) { PrintBookMaxYear(BooksCrud.BooksPublishedInMaxYear()); } else if (cki.Key.Equals(ConsoleKey.D3) || cki.Key.Equals(ConsoleKey.NumPad3)) { PrintTop10Books(BooksCrud.GetTop10PBooks()); } else if (cki.Key.Equals(ConsoleKey.D4) || cki.Key.Equals(ConsoleKey.NumPad4)) { ProgramFlowHandling.Exit("Program will now exit..."); dbBooksConn.Dispose(); } else { MainMenu(); } }
public static void MainMenuInput(ref decimal balance) { Console.WriteLine(); ConsoleKeyInfo cki = Console.ReadKey(true); if (cki.Key.Equals(ConsoleKey.C)) { CheckBalance(balance); } else if (cki.Key.Equals(ConsoleKey.D)) { Deposit(ref balance); } else if (cki.Key.Equals(ConsoleKey.W)) { Withdraw(ref balance); } else if (cki.Key.Equals(ConsoleKey.E)) { ProgramFlowHandling.Exit("Thank you for choosing WANTSOME BANK! Retrieve your card from the ATM Machine"); } else { ATMInput.MainMenuInput(ref balance); } }
public static void GetPublisherIdId() { int publisherId = InputHandling.ReadValue("Publisher Id to delete: "); BooksCrud.DeletePublisher(publisherId); OutputHandling.Question("Do you want to delete another publisher? Y / N"); if (InputHandling.QuestionOptions()) { GetPublisherIdId(); } else { ProgramFlowHandling.Exit("Thank you... bye!"); dbBooksConn.Dispose(); } }
public static void MainMenu() { Console.WriteLine(); OutputHandling.Message("1 - Print Number Of Publishers"); OutputHandling.Message("2 - Print Top 10 Publishers"); OutputHandling.Message("3 - Print Number Of Books Per Publisher"); OutputHandling.Message("4 - Print Total Book Cost For A Publisher"); OutputHandling.Message("5 - Exit"); ConsoleKeyInfo cki = Console.ReadKey(true); if (cki.Key.Equals(ConsoleKey.D1) || cki.Key.Equals(ConsoleKey.NumPad1)) { PrintNumberOfRows(); } else if (cki.Key.Equals(ConsoleKey.D2) || cki.Key.Equals(ConsoleKey.NumPad2)) { PrintTop10Publishers(); } else if (cki.Key.Equals(ConsoleKey.D3) || cki.Key.Equals(ConsoleKey.NumPad3)) { PrintNumberOfBooksPerPublisher(); } else if (cki.Key.Equals(ConsoleKey.D4) || cki.Key.Equals(ConsoleKey.NumPad4)) { PrintTotalBookCostOfPublisher(); } else if (cki.Key.Equals(ConsoleKey.D5) || cki.Key.Equals(ConsoleKey.NumPad5)) { ProgramFlowHandling.Exit("Program will now exit..."); dbBooksConn.Dispose(); } else { MainMenu(); } }
public static void MainMenu() { Console.WriteLine(); OutputHandling.Message("1 - Add a book"); OutputHandling.Message("2 - Print book info"); OutputHandling.Message("3 - Update book info"); OutputHandling.Message("4 - Delete book from database"); OutputHandling.Message("5 - Exit"); ConsoleKeyInfo cki = Console.ReadKey(true); if (cki.Key.Equals(ConsoleKey.D1) || cki.Key.Equals(ConsoleKey.NumPad1)) { Console.Clear(); string title = InputHandling.ReadString("Book Title: "); int pId = InputHandling.ReadValue("PublisherId: "); int year = InputHandling.ReadValue("Year: "); int price = InputHandling.ReadValue("Price: "); BooksCrud.InsertBook(title, pId, year, price); MainMenu(); } else if (cki.Key.Equals(ConsoleKey.D2) || cki.Key.Equals(ConsoleKey.NumPad2)) { Console.Clear(); int bId = InputHandling.ReadValue("Book Id:"); SqlParameter bookId = new SqlParameter { Value = bId, SqlDbType = SqlDbType.Int, ParameterName = "bookId" }; EnumerableRowCollection <DataRow> bookInfo = BooksCrud.ReadBook(bookId); foreach (DataRow row in bookInfo) { Console.WriteLine($"Id: {row[0]}"); Console.WriteLine($"Title: {row[1]}"); Console.WriteLine($"Publisher: {row[2]}"); Console.WriteLine($"Year: {row[3]}"); Console.WriteLine($"Price: {row[4]}"); } MainMenu(); } else if (cki.Key.Equals(ConsoleKey.D3) || cki.Key.Equals(ConsoleKey.NumPad3)) { Console.Clear(); int bId = InputHandling.ReadValue("Book Id:"); UpdateMenu(bId); MainMenu(); } else if (cki.Key.Equals(ConsoleKey.D4) || cki.Key.Equals(ConsoleKey.NumPad4)) { int bId = InputHandling.ReadValue("Book Id:"); SqlParameter bookId = new SqlParameter { Value = bId, SqlDbType = SqlDbType.Int, ParameterName = "bookId" }; BooksCrud.DeleteBook(bookId); MainMenu(); } else if (cki.Key.Equals(ConsoleKey.D5) || cki.Key.Equals(ConsoleKey.NumPad5)) { ProgramFlowHandling.Exit("Program will now exit..."); dbBooksConn.Dispose(); } else { MainMenu(); } }