private static void BuyAProduct(ProductType pr, CashRegister cr) /// <summary> /// A method to buy a product. The buying action only record the product in product history for this cash register /// </summary> { if (InventoryHandler.BuyAProduct(pr)) { Console.WriteLine($"Product {pr.Name} bought for {pr.Price}."); cr.ProductsBought.Add(pr); } else { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine($"{pr.Name} out of stock!"); Console.ForegroundColor = ConsoleColor.White; } InventoryHandler.CheckInventoryStatus(); }
public static void AddProductToInventory() { Console.WriteLine("Enter the following information about the product"); ProductType pt = Product.GetProductTypeByID(); if (pt is null) { Console.WriteLine("Product type not found"); return; } Console.WriteLine("How much new products to add? (Numbers Only): "); string string_amount = Console.ReadLine(); int amount; try { amount = int.Parse(string_amount); } catch { Console.WriteLine("Wrong Input"); return; } InventoryHandler.AddToInventory(pt.ID, amount); Console.WriteLine($"{pt.Name} stock updated by {amount}. Current stock is {Inventory.Instance.GetInventoryInSuper()[pt]}"); }
public static void InventoryManagement() { StringBuilder sb = new StringBuilder(); sb.AppendLine(); sb.AppendLine("Welcome to inventory management menu. What would you like to do?"); sb.AppendLine("1 - Add product to inventory"); sb.AppendLine("2 - Show inventory & orders status"); sb.AppendLine("3 - Update order status"); sb.AppendLine("4 - Place an order"); sb.AppendLine("5 - Show stock alerts"); sb.AppendLine("6 - Go back to main menu"); Console.WriteLine(sb.ToString()); int choice = 7; // default value for the choice (if client`s input is wrong, program will get into the loop and give him another try) Console.Write("Your choice: "); string string_choice = Console.ReadLine(); // input for client`s choice try { choice = int.Parse(string_choice); } // trying to parse client`s choice to int catch { } // if client`s input is wrong, keeps choice as 5 while (choice != 6) { switch (choice) { case 1: ProductHandler.AddProductToInventory(); break; case 2: InventoryHandler.ShowInventoryByStatus(); break; case 3: InventoryHandler.ChangeStatusToShipment(); break; case 4: InventoryHandler.PlaceOrder(); break; case 5: InventoryHandler.CheckInventoryStatus(); break; default: break; } sb = new StringBuilder(); sb.AppendLine(); sb.AppendLine("Welcome to inventory management menu. What would you like to do?"); sb.AppendLine("1 - Add product to inventory"); sb.AppendLine("2 - Show inventory & orders status"); sb.AppendLine("3 - Update order status"); sb.AppendLine("4 - Place an order"); sb.AppendLine("5 - Show stock alerts"); sb.AppendLine("6 - Go back to main menu"); Console.WriteLine(sb.ToString()); choice = 7; // default value for the choice (if client`s input is wrong, program will get into the loop and give him another try) Console.Write("Your choice: "); string_choice = Console.ReadLine(); // input for client`s choice try { choice = int.Parse(string_choice); } // trying to parse client`s choice to int catch { } // if client`s input is wrong, keeps choice as 5 Console.Clear(); } }