Beispiel #1
0
        public static void PlaceOrder()
        {
            ProductHandler.PrintProductTypes();
            Console.WriteLine("Fill the information below about the order:");
            string ID     = ProductHandler.ValidatedID();
            int    amount = 0;

            bool validUserInput = false;

            while (validUserInput == false)
            {
                try
                {
                    Console.Write("Enter the amount of products to order: ");
                    amount         = int.Parse(Console.ReadLine()); // now bh = employee`s body heat
                    validUserInput = true;
                }
                catch
                {
                    Console.Clear();
                    Console.WriteLine("Wrong input!"); Console.WriteLine();
                }
            }
            ProductType pt = ProductHandler.GetProductTypeByID(ID);

            if (pt is null)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Product not found");
                Console.ForegroundColor = ConsoleColor.White;
                return;
            }
            Random rand    = new Random();
            int    orderID = rand.Next(1, 999);

            Console.Clear();
            Console.WriteLine(); Console.WriteLine();
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine($"Order placed! Your order ID is: {orderID}");
            Console.ForegroundColor = ConsoleColor.White;
            ProductOrder PO_temp = new ProductOrder(pt, amount, orderID.ToString());

            Inventory.Instance.AddOrderToDB(PO_temp);
        }
Beispiel #2
0
        public static void ChangeStatusToShipment()
        {
            ShowOrders();
            ProductOrder PO = ProductHandler.GetOrderByID();

            if (PO is null)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Product order not found");
                Console.ForegroundColor = ConsoleColor.White;
                return;
            }
            if (PO.OrderStatus == "Shipment")
            {
                AddToInventory(PO.productType.ID, PO.OrderAmount);
                Inventory.Instance.RemoveFromOrderDB(PO);
                return;
            }
            else
            {
                PO.OrderStatus = "Shipment";
            }
        }
Beispiel #3
0
        public static void AddToInventory(string ProductTypeID, int Amount)
        {
            ProductType pt = ProductHandler.GetProductTypeByID(ProductTypeID);

            Inventory.Instance.AddToInventory(pt, Amount);
        }
Beispiel #4
0
        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();
            }
        }