// Enter login pass method public void LogPass(LibShelf libshelf) { bool incnum = false; string login, pass; Console.Write("Enter login:"******"\nEnter password:"); pass = Console.ReadLine(); for (int i = 0; i < users.Length; i++) { if (login == users[i].name && pass == users[i].pass && users[i].isadmin) { AdminMenu(libshelf, i); incnum = true; break; } else if (login == users[i].name && pass == users[i].pass && !users[i].isadmin) { UserMet(libshelf, i); incnum = true; break; } } if (incnum != true) { Program.IncNum(); } }
static void Main(string[] args) { LibShelf libshelf = new LibShelf(); Users usersarr = new Users(); while (true) { Console.Clear(); Console.WriteLine("--- MAIN MENU ---\n\n" + "1 - Log in.\n" + "2 - Register.\n" + "3 - Quit.\n"); Console.CursorVisible = false; ConsoleKey key = Console.ReadKey(true).Key; Console.CursorVisible = true; if (key == ConsoleKey.D1) { usersarr.LogPass(libshelf); } else if (key == ConsoleKey.D2) { usersarr.AddUsers(); } else if (key == ConsoleKey.D3) { break; } } }
//Method admin menu public void AdminMenu(LibShelf libshelf, int indus) { while (true) { //Menu admin Console.Clear(); Console.WriteLine("--- ADMIN MENU ---\n\n" + "1 - List of books.\n" + "2 - Add book.\n" + "3 - Delete book.\n" + "4 - List of books taken.\n" + "5 - List of user history.\n" + "6 - Make the user admin/not admin.\n" + "7 - Quit to main menu.\n"); Console.CursorVisible = false; ConsoleKey key = Console.ReadKey(true).Key; Console.CursorVisible = true; // Goto list of books if (key == ConsoleKey.D1) { Console.Clear(); Console.WriteLine("--- LIST OF BOOKS ---\n"); libshelf.PrintLib(users[indus].isadmin); Console.WriteLine("\nPress any key to quit."); Console.ReadKey(); } // Add book else if (key == ConsoleKey.D2) { Console.Clear(); Console.WriteLine("--- ADD OF BOOKS ---\n"); libshelf.AddBooks(); Console.WriteLine("\nPress any key to quit."); Console.ReadKey(); } // Delete book else if (key == ConsoleKey.D3) { Console.Clear(); Console.WriteLine("--- DELETE BOOKS ---\n"); libshelf.DelBooks(users[indus].isadmin); } // List of books taken else if (key == ConsoleKey.D4) { Console.Clear(); Console.WriteLine("--- LIST OF BOOKS TAKEN ---\n"); libshelf.ListTake(users[indus].isadmin); Console.WriteLine("\nPress any key to quit."); Console.ReadKey(); } // List of user history else if (key == ConsoleKey.D5) { while (true) { bool choice = false; Console.Clear(); Console.WriteLine("--- LIST OF USER HISTORY ---\n"); Console.Write("Enter name user:"******"--- LIST OF USER HISTORY ---\n"); Console.WriteLine("Name:{0}", users[i].name); users[i].PrintUserHis(); choice = true; break; } } if (choice == true) { Console.WriteLine("\nPress any key to quit."); Console.ReadKey(); break; } else { Program.IncNum(); } } } //Goto make the user admin/not admin else if (key == ConsoleKey.D6) { Console.Clear(); Console.WriteLine("--- MAKE THE ADMIN/USER STATUS ---\n"); AdminNotadmin(); Console.WriteLine("\nPress any key to quit."); Console.ReadKey(); } // Goto Quit to main menu else if (key == ConsoleKey.D7) { Console.Clear(); break; } } }
// User menu public void UserMet(LibShelf libshelf, int indus) { while (true) { // Menu user Console.Clear(); Console.WriteLine("--- USER MENU ---\n\n" + "1 - List of book.\n" + "2 - Return the book.\n" + "3 - Take off book.\n" + "4 - Quit to main menu.\n"); Console.CursorVisible = false; ConsoleKey key = Console.ReadKey(true).Key; Console.CursorVisible = true; // Goto list of book if (key == ConsoleKey.D1) { Console.Clear(); Console.WriteLine("--- MENU LIST OF BOOKS ---\n"); libshelf.PrintLib(users[indus].isadmin); Console.WriteLine("\nPress any key to quit."); Console.ReadKey(); } // Goto return the book if (key == ConsoleKey.D2) { Console.Clear(); Console.WriteLine("--- MENU RETURN BOOKS ---\n"); users[indus].ListBooksUser(); int idbook = users[indus].ReturnBook(); if (idbook == -1) { Program.IncNum(); } else { libshelf.ReturnBooks(idbook); Console.WriteLine("\nBook is returned.\n\nPress any key to quit."); Console.ReadKey(); } } // Goto take off book else if (key == ConsoleKey.D3) { Console.Clear(); Console.WriteLine("--- MENU TAKE BOOKS ---\n"); users[indus].ListBooksUser(); Book book = libshelf.TakeBooks(); if (book == null) { Program.IncNum(); } else { users[indus].TakeBook(book); } } // Goto quit to main menu else if (key == ConsoleKey.D4) { Console.Clear(); break; } } }