Ejemplo n.º 1
0
        private void ShowInvoice(Order order)
        {
            Console.Clear();
            UserIO.PrintRed($"Order nr:{order.Id}  -  placed on: {order.Date}");
            Console.WriteLine();

            string name      = "";
            string size      = "";
            string crust     = "";
            string quantity  = "";
            string itemPrice = "";

            Console.ForegroundColor = ConsoleColor.Yellow;
            UserIO.PrintPretty("Name", 15, "Size", 30, "Crust", 45, "Quantity", 60, "ItemPrice", true);
            Console.ResetColor();
            Console.WriteLine();

            for (int i = 0; i < order.ItemsArray.Length; i++)
            {
                int pizzaId = order.ItemsArray[i][0];
                name      = Convert.ToString(Pizza_Manager.GlobalPizzas[pizzaId].Name);
                size      = Convert.ToString((PizzaSize)order.ItemsArray[i][1]);
                crust     = Convert.ToString((PizzaCrust)order.ItemsArray[i][2]);
                quantity  = Convert.ToString(order.ItemsArray[i][3]);
                itemPrice = Convert.ToString(order.ItemPriceArray[i]);

                UserIO.PrintPretty(name, 15, size, 30, crust, 45, quantity, 60, itemPrice, true);
            }

            Console.WriteLine();
            UserIO.PrintYellow($"Total items: {order.ItemCount}");
            UserIO.PrintGreen($"Total price: {order.TotalPrice}");
            Console.WriteLine();
            UserIO.PrintDarkRed("Press enter to go back");
        }
Ejemplo n.º 2
0
        private void ShowBalanceForDay(int day)
        {
            //Loop true all orders and add the prices. fill 2 lists: one with all used ingredients (id),
            //the other with times they where used (quantity * size) 1=small 2=med 3=large
            double     earningsDay     = 0;
            int        itemsDay        = 0;
            List <int> ingredientId    = new List <int>();
            List <int> ingredientCount = new List <int>();

            foreach (var order in SortedByDay[day])
            {
                earningsDay += order.TotalPrice;
                itemsDay    += order.ItemCount;

                for (int i = 0; i < order.ItemsArray.Length; i++)
                {
                    int pizzaId       = order.ItemsArray[i][0];
                    int pizzaSize     = order.ItemsArray[i][1];
                    int pizzaQuantity = order.ItemsArray[i][3];
                    //Console.WriteLine(pizzaId);

                    int[] pizzaIngr = Pizza_Manager.GlobalPizzas[pizzaId].Ingredients;

                    //loop over pizza ingredients
                    for (int j = 0; j < pizzaIngr.Length; j++)
                    {
                        //if id is not in list, ad to list, else add count to existing
                        if (!ingredientId.Contains(pizzaIngr[j]))
                        {
                            ingredientId.Add(pizzaIngr[j]);
                            ingredientCount.Add(pizzaSize * pizzaQuantity);
                        }
                        else
                        {
                            int index = ingredientId.IndexOf(pizzaIngr[j]);
                            ingredientCount[index] += pizzaSize * pizzaQuantity;
                        }
                    }
                }
            }
            IngredientManager ingredientManager = new IngredientManager();

            Ingredient_Manager = ingredientManager;

            //Display obtained info

            Console.Clear();
            UserIO.PrintRed($"Balance for Day {SortedByDay[day][0].Date.ToString("d")}");
            Console.WriteLine();
            Console.ForegroundColor = ConsoleColor.Yellow;
            UserIO.PrintPretty("Ingredient used", 20, "Times used");
            Console.WriteLine();
            Console.ResetColor();

            for (int i = 0; i < ingredientId.Count; i++)
            {
                UserIO.PrintPretty($"{ Ingredient_Manager.GetOneIngredient(ingredientId[i]) }", 20, $"{ ingredientCount[i] }");
            }
            Console.WriteLine();
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine($"Total Items sold: {itemsDay}");
            UserIO.PrintGreen($"Total income: {earningsDay} EUR");
            Console.WriteLine();

            UserIO.PrintDarkRed("Press enter to go back");

            Console.ReadLine();
        }