Exemple #1
0
        private void SelectItemLine(Order input)
        {
            input.Sync();

            if(input.Items != null)
            {
                Console.WriteLine("Order {0}", input.Id);
                Console.WriteLine("ID \t Name \t Quantity");

                foreach (OrderLine line in input.Items)
                {
                    Item data = stocks.Find(x => x.Id == line.ItemId);
                    Console.WriteLine("{0} \t {1} \t {2}", line.ItemId, data.Name, line.Quantity);
                }
                // Break STOP

            }
        }
Exemple #2
0
        private void AddItem(ref Order order)
        {
            bool run = true;
            while (run)
            {
                Console.Clear();
                Console.Write("Set item ID: ");
                Console.ForegroundColor = ConsoleColor.Cyan;
                string set = Console.ReadLine();
                Console.ResetColor();
                try
                {
                    int id = int.Parse(set);
                    Item item = stocks.Find(x => x.Id == id);
                    if(item != null)
                    {
                        Console.Clear();
                        int amount = 1;
                        while(true)
                        {
                            try
                            {
                                // Validate integer input
                                Console.WriteLine("Item: {0}", item.Name);
                                Console.Write("Amount: ");
                                string num = Console.ReadLine();
                                if(num == String.Empty)
                                {
                                    break;
                                }
                                else
                                {
                                    amount = int.Parse(num);
                                    break;
                                }
                            }
                            catch
                            {
                                Console.Beep(1000, 500);
                            }
                        }

                        // Record Order
                        order.Sync();

                        // Adding Item to Order's orderline
                        order.AddItem(item.Id, amount);

                    }
                    else
                    {
                        Console.Beep(600, 500);
                        Console.WriteLine("Invalid item");
                    }

                }
                catch
                {
                    Console.Beep(1000, 500);
                    Console.WriteLine("Invalid Item ID");
                }

                Console.WriteLine("\nPress ENTER to add more\nPress ESC to go back");
                while(true)
                {
                    ConsoleKey key = Console.ReadKey().Key;
                    if (key == ConsoleKey.Enter)
                    {
                        break;
                    }
                    else if(key == ConsoleKey.Escape)
                    {
                        run = false;
                        break;
                    }
                }

            }
        }