Beispiel #1
0
        static void ModifyRepair()
        {
            int    input = 0;
            int    id;
            int    inventoryID;
            string whatToRepair;
            int    checkID;
            int    validId;

            do
            {
                try
                {
                    input = int.Parse(GetInput("•Press 1 to list all repair\n" +
                                               "•Press 2 to add a new repair\n" +
                                               "•Press 3 to update repair\n" +
                                               "•Press 4 to delete repair\n" +
                                               "•Press 5 to return to main menu"));

                    switch (input)
                    {
                    case 1:
                        CRUDonRepair.PrintRepairs();
                        break;

                    case 2:
                        do
                        {
                            checkID = int.Parse(GetInput("•Press 1 to list all inventory to show ID for inserting\n" +
                                                         "•Press 2 to continue\n"
                                                         ));
                            switch (checkID)
                            {
                            case 1:
                                CRUDonInventory.PrintInventories();
                                break;

                            case 2:
                                break;

                            default:
                                Console.WriteLine("input must be a number between 1-2");
                                break;
                            }
                        } while (checkID != 2);

                        do
                        {
                            inventoryID = int.Parse(GetInput("Enter inventory ID for repair:"));
                            validId     = CRUDonInventory.CheckInventoryId(inventoryID);
                            if (validId == 0)
                            {
                                Console.WriteLine("Id entered is not valid");
                            }
                        } while (validId == 0);


                        whatToRepair = GetInput("Enter what To Repair:");
                        CRUDonRepair.InsertRepairs(inventoryID, whatToRepair);

                        break;

                    case 3:
                        do
                        {
                            checkID = int.Parse(GetInput("•Press 1 to list all inventory to show ID for updating\n" +
                                                         "•Press 2 to continue\n"
                                                         ));
                            switch (checkID)
                            {
                            case 1:
                                CRUDonInventory.PrintInventories();
                                break;

                            case 2:
                                break;

                            default:
                                Console.WriteLine("input must be a number between 1-2");
                                break;
                            }
                        } while (checkID != 2);

                        do
                        {
                            id      = int.Parse(GetInput("Enter repair Id:"));
                            validId = CRUDonRepair.CheckRepairId(id);
                            if (validId == 0)
                            {
                                Console.WriteLine("Id entered is not valid");
                            }
                        } while (validId == 0);


                        do
                        {
                            inventoryID = int.Parse(GetInput("Enter inventory ID for repair:"));
                            validId     = CRUDonInventory.CheckInventoryId(inventoryID);
                            if (validId == 0)
                            {
                                Console.WriteLine("Id entered is not valid");
                            }
                        } while (validId == 0);
                        whatToRepair = GetInput("Enter what To Repair:");

                        CRUDonRepair.UpdateRepairs(id, inventoryID, whatToRepair);

                        break;

                    case 4:
                        do
                        {
                            id      = int.Parse(GetInput("Enter repair Id:"));
                            validId = CRUDonRepair.CheckRepairId(id);
                            if (validId == 0)
                            {
                                Console.WriteLine("Id entered is not valid");
                            }
                        } while (validId == 0);
                        CRUDonRepair.DeleteRepairs(id);
                        break;

                    case 5:
                        break;

                    default:
                        Console.WriteLine("input must be a number between 1-5");
                        break;
                    }
                }
                catch (FormatException)
                {
                    Console.WriteLine("input must be an integer");
                }
            } while (input != 5);
        }
Beispiel #2
0
        static void ModifyInventory()
        {
            int     input = 0;
            int     id;
            int     vehicleID;
            int     numberOnHand;
            decimal price;
            decimal cost;
            int     checkID;
            int     validId;

            do
            {
                try
                {
                    input = int.Parse(GetInput("•Press 1 to list all inventory\n" +
                                               "•Press 2 to view inventory for a vehicle\n" +
                                               "•Press 3 to add a new inventory\n" +
                                               "•Press 4 to update inventory\n" +
                                               "•Press 5 to delete inventory\n" +
                                               "•Press 6 to return to main menu"));

                    switch (input)
                    {
                    case 1:
                        CRUDonInventory.PrintInventories();
                        break;

                    case 2:
                        do
                        {
                            id      = int.Parse(GetInput("Enter vehicle Id:"));
                            validId = CRUDonVehicles.CheckVehicleId(id);
                            if (validId == 0)
                            {
                                Console.WriteLine("Id entered is not valid");
                            }
                        } while (validId == 0);

                        CRUDonInventory.PrintInventoriesByVehicleID(id);

                        break;

                    case 3:
                        do
                        {
                            checkID = int.Parse(GetInput("•Press 1 to list all vehicles to show ID for inserting\n" +
                                                         "•Press 2 to continue\n"
                                                         ));
                            switch (checkID)
                            {
                            case 1:
                                CRUDonVehicles.PrintVehicles();
                                break;

                            case 2:
                                break;

                            default:
                                Console.WriteLine("input must be a number between 1-2");
                                break;
                            }
                        } while (checkID != 2);


                        do
                        {
                            vehicleID = int.Parse(GetInput("Enter vehicle ID for inventory:"));
                            validId   = CRUDonVehicles.CheckVehicleId(vehicleID);
                            if (validId == 0)
                            {
                                Console.WriteLine("Id entered is not valid");
                            }
                        } while (validId == 0);

                        numberOnHand = int.Parse(GetInput("Enter number On Hand:"));
                        price        = decimal.Parse(GetInput("Enter price:"));
                        cost         = decimal.Parse(GetInput("Enter cost:"));
                        CRUDonInventory.InsertInventories(vehicleID, numberOnHand, price, cost);

                        break;

                    case 4:
                        do
                        {
                            checkID = int.Parse(GetInput("•Press 1 to list all vehicles to show ID for updating\n" +
                                                         "•Press 2 to continue\n"
                                                         ));
                            switch (checkID)
                            {
                            case 1:
                                CRUDonVehicles.PrintVehicles();
                                break;

                            case 2:
                                break;

                            default:
                                Console.WriteLine("input must be a number between 1-2");
                                break;
                            }
                        } while (checkID != 2);

                        do
                        {
                            id      = int.Parse(GetInput("Enter inventory Id:"));
                            validId = CRUDonInventory.CheckInventoryId(id);
                            if (validId == 0)
                            {
                                Console.WriteLine("Id entered is not valid");
                            }
                        } while (validId == 0);


                        do
                        {
                            vehicleID = int.Parse(GetInput("Enter vehicle ID for inventory:"));
                            validId   = CRUDonVehicles.CheckVehicleId(vehicleID);
                            if (validId == 0)
                            {
                                Console.WriteLine("Id entered is not valid");
                            }
                        } while (validId == 0);

                        numberOnHand = int.Parse(GetInput("Enter number On Hand:"));
                        price        = decimal.Parse(GetInput("Enter price:"));
                        cost         = decimal.Parse(GetInput("Enter cost:"));
                        CRUDonInventory.UpdateInventories(id, vehicleID, numberOnHand, price, cost);

                        break;

                    case 5:
                        do
                        {
                            id      = int.Parse(GetInput("Enter inventory Id:"));
                            validId = CRUDonInventory.CheckInventoryId(id);
                            if (validId == 0)
                            {
                                Console.WriteLine("Id entered is not valid");
                            }
                        } while (validId == 0);
                        CRUDonInventory.DeleteInventories(id);
                        break;

                    case 6:
                        break;

                    default:
                        Console.WriteLine("input must be a number between 1-6");
                        break;
                    }
                }
                catch (FormatException)
                {
                    Console.WriteLine("input must be a number");
                }
            } while (input != 6);
        }