Esempio n. 1
0
        public static void adminMenu()
        {
            do
            {
                Console.WriteLine(Environment.NewLine + "----------" + Environment.NewLine + "ADMIN MENU" + Environment.NewLine);
                Console.WriteLine("Type C to | Manage Customers" + Environment.NewLine + "Type B to | Manage Books" + Environment.NewLine + "Type L to | Manage Loans" + Environment.NewLine + "Type U to | Manage Logins" + Environment.NewLine + "Type X to | Exit the Software" + Environment.NewLine);
                Console.Write("What would you like to do? ");     //Displays Admin options to the user
                string userChoice = Console.ReadLine().ToUpper(); //stores admin choice
                int    j          = adminChoice(userChoice);

                switch (j) //checks options for admin menu
                {
                case 1:
                    CustomerDetails.customerMenu();     //Loads Class to manage customers
                    break;

                case 2:
                    BookDetails.bookMenu();     //Loads Class to manage books
                    break;

                case 3:
                    LoanDetails.loanMenu();     //Loads Class to manage loans
                    break;

                case 4:
                    LoginDetails.loginMenu();     //Loads class to manage Logins
                    break;

                case 5:
                    Environment.Exit(1);     //Exit the software
                    break;
                }
            } while (constantMenu == false);
        }
Esempio n. 2
0
        static bool addLoan() //Method to add a new loan to the system
        {
            Console.Write("Book being Loaned: ");
            string loanBook = Console.ReadLine().ToUpper();   //Book to be loaned
            bool   loaned   = BookDetails.isLoaned(loanBook); //checks if book is currently loaned

            string[] loanCustomer = new string[2];
            Console.WriteLine("Who is Loaning the book?");
            Console.Write("First Name: ");
            loanCustomer[0] = Console.ReadLine().ToUpper();
            Console.Write("Surname: ");
            loanCustomer[1] = Console.ReadLine().ToUpper();
            bool customerMatch = CustomerDetails.lookupCustomer(loanCustomer); //Checks if customer is registered on the system

            string   currentEmployee = LoginDetails.currentUser();             //Saves current user as employee loaning the book
            DateTime loanOut;

            loanOut = DateTime.Now; //Sets current date as when the book is loaned
            string loanoutString = loanOut.ToShortDateString();

            DateTime loanIn       = loanOut.AddDays(21); //Generates a date for when the book needs to be returned
            string   loaninString = loanIn.ToShortDateString();

            string newID = Guid.NewGuid().ToString(); //Generates a unique 5 digit ID for the loan as refrence

            char[] idCharacters = newID.Take(5).ToArray();
            newID = new string(idCharacters);

            if (loaned)                                              //if the book is already loaned
            {
                Console.WriteLine("Error | Book is Already Loaned"); //Display error message and abort the method
                return(false);
            }
            if (customerMatch == false)                               //If loan customer is not registered on the system
            {
                Console.WriteLine("Error | Customer not Registered"); //Display error message and abort the loan
                return(false);
            }

            string[] loanString = new string[] { loanBook, loanCustomer[1], loanCustomer[0], currentEmployee, loanoutString, loaninString };
            loanRecords.Add(newID, loanString); //Add new loan to the system
            loanedBooks.Add(loanBook);          //Add loaned book to list of books currently loaned
            Console.WriteLine("Book Succesfully Loaned");
            return(true);
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            bool loginState = false;           //Welcomes the user to the system

            Console.WriteLine(Environment.NewLine + "Welcome to the Library Internal System  |  Please Log in" + Environment.NewLine);
            do
            {
                loginInput.Clear();
                Console.Write("Username: "******"Password: "******"");
                loginInput.Add(usernameInput, passwordInput);         //passes inputs to method to check them against those stored in the system
                loginState = LoginDetails.loginCheck(loginInput);     //passes inputs to method to check them against those stored in the system
            } while (loginState == false);                            //Loops until recognised Login is entered
            Console.WriteLine("Welcome Admin" + Environment.NewLine); //Personalised Welcome Message
            AdminControl.adminMenu();                                 //Loads user into Admin Menu
            Console.ReadLine();
        }