Exemple #1
0
        public void ProcessAddOrder(Order order)
        {
            var ops      = new OrderOperations();
            var response = ops.AddOrder(order);

            if (!response.Success)
            {
                Console.Clear();
                Console.WriteLine("╔═══════════════════════════════╗");
                Console.WriteLine("║            Error!             ║");
                Console.WriteLine("╚═══════════════════════════════╝");
                Console.WriteLine(response.Message);
                Console.ReadLine();
            }
            else
            {
                Console.Clear();
                Console.WriteLine("╔═══════════════════════════════╗");
                Console.WriteLine("║            Success!           ║");
                Console.WriteLine("╚═══════════════════════════════╝");
                Console.WriteLine($"You successfully added Order: {response.OrderInfo.OrderNumber}");
                Console.WriteLine();
                Console.WriteLine("Press Enter to return to the menu.");
                Console.ReadLine();
                MainMenu menu = new MainMenu();
                menu.Display();
            }
        }
Exemple #2
0
        private static void PromptAddOrder()
        {
            string      customerName = "";
            string      state        = "";
            ProductType productType  = null;
            decimal     area         = 0M;

            while (string.IsNullOrEmpty(customerName))
            {
                OffsetTop();
                Console.ForegroundColor = PromptColor;
                Console.Write("\tEnter the customer name: ");
                Console.ForegroundColor = EmphasisColor;
                customerName            = Console.ReadLine();
                Console.ResetColor();
                Console.Clear();
            }

            state       = PromptForValidState("Enter the customer state: ", true);
            productType = PromptForValidProductType("Enter the product type: ", true);
            area        = PromptForValidArea(productType, true);

            Order orderToAdd = new Order()
            {
                CustomerName = customerName,
                State        = state,
                ProductType  = productType.Type,
                Area         = area
            };

            //calculate remaining fields and assign order number
            orderToAdd = OrderOperations.CalculateRemainingOrderFields(orderToAdd);
            orderToAdd = OrderOperations.AssignOrderNumber(orderToAdd);
            if (PromptConfirmOrder(orderToAdd, "Would you like to add the order? "))
            {
                OrderOperations.AddOrder(orderToAdd);
                Console.Clear();
                DisplayOrder(orderToAdd);
                Console.ForegroundColor = SuccessColor;
                Console.WriteLine("\tOrder added successfully.");
                Console.WriteLine();
                PressEnterToContinueToMain();
            }
            else
            {
                Console.Clear();
                orderToAdd = EditOrder(orderToAdd); //TODO: Check what happens if an error occurs during edit?
                if (orderToAdd != null)             //if it's null, they chose to cancel and return to the main menu
                {
                    OrderOperations.AddOrder(orderToAdd);
                    DisplayOrder(orderToAdd);
                    Console.ForegroundColor = SuccessColor;
                    Console.WriteLine("\tOrder added successfully.");
                    PressEnterToContinueToMain();
                }
                Console.Clear();
            }
        }
Exemple #3
0
        private void AddOrderToListMethod()
        {
            Console.WriteLine("asdasdasd");
            Console.WriteLine("start");
            //Problem z dodawaniem zamówienia po raz pierwszy. Gdy Id = 1 nie chce dodać zamowienia. Za drugim razem gdy dodaje zamowienie i id zmieni sie na 2 to wszystko działa. Do naprawienia.


            Console.WriteLine($"{CurrentOrder.OrderCreate}, {CurrentOrder.DispatchDate}, {SelectedCustomer.Id}, lista : {CurrentOrderDetailList}, suma zamowienia:{CurrentOrder.TotalAmount}, status : {Enum.OrderStatus.Statuses.Nowe.ToString()}");

            try
            {
                var isAdded = orderOperationsObj.AddOrder(CurrentOrder.OrderCreate, CurrentOrder.DispatchDate, SelectedCustomer, TotalOrderValue, Enum.OrderStatus.Statuses.Nowe, CurrentOrder.DeliveryName, CurrentOrder.DeliveryStreet, CurrentOrder.DeliveryPostcode, CurrentOrder.DeliveryCity, CurrentOrder.DeliveryCountry);
                Console.WriteLine($"{orderOperationsObj.GetLastOrderIndex()}");
                orderOperationsObj.UpdateOrderIdInDetailList(CurrentOrderDetailList);
                LoadCurrentOrderDetalList();
                SelectedCustomer        = null;
                SelectedProductQuantity = 0;
                SelectedProductPrice    = 0;

                SameDeliveryAddressAsCustomerDetails(false);
                IsCheckedCheckbox = false;
                for (int i = 0; i < ProductSizesTable.Length; i++)
                {
                    ProductSizesTable[i] = 0;
                }



                if (isAdded)
                {
                    Console.WriteLine("Dodano zamówienie");
                    Message = "Dodano zamówienie";
                    Console.WriteLine($"Ostatni indeks zamowienia : {orderOperationsObj.GetLastOrderIndex()}");
                }
                else
                {
                    Console.WriteLine("Nie dodano zamówienia");
                    Message = "Nie dodano zamówienia";
                }
            }
            catch (Exception ex)
            {
                Message = ex.Message;
            }
        }