示例#1
0
        static void RemoveMember(ToolLibrarySystem toolLibrarySystem)
        {
            Console.Clear();
            Console.Write("Enter member First name");
            Console.WriteLine("");
            String fname = Console.ReadLine();

            Console.Write("Enter member Last name");
            Console.WriteLine("");
            String lname = Console.ReadLine();

            Console.Write("Enter member mobile number");
            Console.WriteLine("");
            String mobile = Console.ReadLine();

            Console.Write("Enter member pin");
            Console.WriteLine("");
            String pin          = Console.ReadLine();
            Member deleteMember = new Member(fname, lname, mobile, pin);

            toolLibrarySystem.delete(deleteMember);
            MainMenu(toolLibrarySystem);
        }
示例#2
0
        public static void RunCommand(int[] selection)
        {
            int staff, menuSelection1, menuSelection2;

            int[]  changeTool;
            bool   remove, noQuantity;
            iTool  returnedTool;
            string toolTypeStr;

            menuSelection1 = 0;
            staff          = menuSelection2 = 1;
            iToolLibrarySystem funcs = new ToolLibrarySystem();

            if (selection[menuSelection1] == staff)//staff
            {
                switch (selection[menuSelection2])
                {
                case (int)StaffCommands.AddNewTool:
                    navigateToolMenu(out toolTypeStr, funcs);
                    returnedTool = CreateNewTool();
                    funcs.add(returnedTool);
                    funcs.displayTools(toolTypeStr);
                    break;

                case (int)StaffCommands.AddExisitingTool:
                    navigateToolMenu(out toolTypeStr, funcs);
                    changeTool = PickTool();
                    if (changeTool != null)
                    {
                        returnedTool = currentToolType.toArray()[changeTool[0] - 1];
                        funcs.add(returnedTool, changeTool[1]);
                    }

                    funcs.displayTools(toolTypeStr);
                    break;

                case (int)StaffCommands.RemoveTool:
                    navigateToolMenu(out toolTypeStr, funcs);
                    bool removeExisting = true;
                    changeTool = PickTool(removeExisting);
                    if (changeTool != null)
                    {
                        returnedTool = currentToolType.toArray()[changeTool[0] - 1];
                        if (returnedTool.Quantity == changeTool[1])
                        {
                            funcs.delete(returnedTool);
                        }
                        else
                        {
                            funcs.delete(returnedTool, changeTool[1]);
                        }
                    }
                    funcs.displayTools(toolTypeStr);
                    break;

                case (int)StaffCommands.RegisterMember:
                    printMembers();
                    iMember newMember = CreateMember();
                    funcs.add(newMember);
                    printMembers();
                    Console.Write("Press any Key to continue...");
                    Console.ReadKey();
                    break;

                case (int)StaffCommands.RemoveMember:
                    printMembers();
                    iMember removeMember = PickMember();
                    funcs.delete(removeMember);
                    printMembers();
                    Console.Write("Press any Key to continue...");
                    Console.ReadKey();
                    break;

                case (int)StaffCommands.ContactNumMember:
                    getContact();
                    break;

                default:
                    Console.WriteLine("Error: switch failed :(");
                    break;
                }
            }
            else //member
            {
                switch (selection[menuSelection2])
                {
                case (int)MemberCommands.DisplayAllToolsType:
                    navigateToolMenu(out toolTypeStr, funcs);
                    break;

                case (int)MemberCommands.BorrowTool:
                    navigateToolMenu(out toolTypeStr, funcs);
                    remove     = false;
                    noQuantity = true;
                    changeTool = PickTool(remove, noQuantity);
                    if (changeTool != null)
                    {
                        funcs.borrowTool(Program.aCollection.CurrentMember,
                                         currentToolType.toArray()[changeTool[0] - 1]);
                    }
                    funcs.displayTools(toolTypeStr);
                    break;

                case (int)MemberCommands.ReturnTool:
                    funcs.displayBorrowingTools(Program.aCollection.CurrentMember);
                    remove     = false;
                    noQuantity = true;
                    Member replace = (Member)Program.aCollection.CurrentMember;
                    changeTool = PickTool(remove, noQuantity, Program.aCollection.CurrentMember.Tools.Length);
                    if (changeTool != null)
                    {
                        funcs.returnTool(Program.aCollection.CurrentMember,
                                         replace.ToolsBorrowed[changeTool[0] - 1]);
                    }
                    funcs.displayBorrowingTools(Program.aCollection.CurrentMember);
                    break;

                case (int)MemberCommands.ListToolsRenting:
                    funcs.displayBorrowingTools(Program.aCollection.CurrentMember);
                    break;

                case (int)MemberCommands.DisplayTopThree:
                    funcs.displayTopTHree();
                    break;

                default:
                    Console.WriteLine("Error: switch failed :(");
                    break;
                }
            }
        }