Exemplo n.º 1
0
        private Order ProcessEditOrder(Order order)
        {
            var ops      = new OrderOperations();
            var response = ops.EditOrder(order);

            if (!response.Success)
            {
                Console.Clear();
                Console.WriteLine("╔═══════════════════════════════╗");
                Console.WriteLine("║            Error!             ║");
                Console.WriteLine("╚═══════════════════════════════╝");
                Console.WriteLine(response.Message);
                Console.WriteLine();
                Console.ReadLine();
            }

            return(response.OrderInfo);
        }
Exemplo n.º 2
0
        private static void PromptEditOrder(Order oldOrder = null)
        {
            if (oldOrder == null) //prompt to choose order. They might have passed in an order from the promptdisplayorders method.
            {
                DateTime?date = PromptForValidOrderDate();
                if (date == null) //there are no orders in the system.
                {
                    return;
                }
                List <Order> potentialOrders = OrderOperations.GetOrdersByDate((DateTime)date);
                oldOrder = SelectFromOrders(potentialOrders);
            }

            Order orderToEdit = new Order()
            {
                Date                   = oldOrder.Date,
                Number                 = oldOrder.Number,
                CustomerName           = oldOrder.CustomerName,
                State                  = oldOrder.State,
                TaxPercent             = oldOrder.TaxPercent,
                ProductType            = oldOrder.ProductType,
                Area                   = oldOrder.Area,
                CostPerSquareFoot      = oldOrder.CostPerSquareFoot,
                LaborCostPerSquareFoot = oldOrder.LaborCostPerSquareFoot,
                MaterialCost           = oldOrder.MaterialCost,
                LaborCost              = oldOrder.LaborCost,
                Tax   = oldOrder.Tax,
                Total = oldOrder.Total
            };

            orderToEdit = EditOrder(orderToEdit);
            //if Edit order returns null, they chose to cancel and go back to main menu
            if (orderToEdit != null)
            {
                OrderOperations.EditOrder(oldOrder, orderToEdit);

                DisplayOrder(orderToEdit, oldOrder);
                Console.ForegroundColor = SuccessColor;
                Console.WriteLine("\tOrder successfully changed.");
                PressEnterToContinueToMain();
            }
        }
Exemplo n.º 3
0
        public void EditEntries()
        {
            OrderOperations orderOperations = new OrderOperations();
            Validate        validate        = new Validate();
            bool            goodDate        = false;

            Console.WriteLine("EDIT ORDER");
            Console.WriteLine();

            do
            {
                string OrderDate   = validate.PromptforDate("Please enter the date of the order you want to change MM/DD/YYYY");
                int    orderNumber = Convert.ToInt32(validate.PromptforDecimal("Please enter your order number"));

                goodDate = orderOperations.FindOrder(OrderDate, orderNumber);

                if (goodDate == true)
                {
                    Console.WriteLine("What would you like to change, Customer Name, State, Area, or Product?"); //propertyEdit
                    propertyEdit = Console.ReadLine().ToUpper();                                                 //valid info continue, one of these

                    if ((propertyEdit == "CUSTOMER NAME" || propertyEdit == "STATE" || propertyEdit == "AREA" || propertyEdit == "AREA" || propertyEdit == "PRODUCT"))
                    {
                        if (propertyEdit == "CUSTOMER NAME")
                        {
                            Console.WriteLine("What would you like to change it to?");
                            userInput = Console.ReadLine().ToUpper();
                        }

                        if (propertyEdit == "STATE")
                        {
                            userInput = validate.PromptforState("What would you like to change it to? IN, OH, PA, or MI");
                        }

                        if (propertyEdit == "AREA")
                        {
                            decimal userArea;

                            userArea  = validate.PromptforDecimal("What would you like to change it to?");
                            userInput = userArea.ToString();
                        }

                        if (propertyEdit == "PRODUCT")
                        {
                            userInput = validate.PromptforProduct("What would you like to change it to? Wood, Tile, Carpet, or Laminate");
                        }
                    }
                    else
                    {
                        Console.WriteLine("That was not a valid choice, please try again!");
                    }
                    orderOperations.EditOrder(OrderDate, propertyEdit, userInput);

                    Console.Clear();
                    Console.WriteLine("Your order has been successfully updated! Press Enter to continue!");
                    string edits = Console.ReadLine().ToUpper();
                }

                else
                {
                    Console.WriteLine("That is not a valid order, please try again!");
                }
            } while (!goodDate);
        }