示例#1
0
        public void RemoveTheOrder()
        {
            OrderOperations orderOperations = new OrderOperations();

            Validate validate = new Validate();
            AddEntry display = new AddEntry();
            //bool alreadydisplayed = false;
            bool validinput = false;
            bool goodDate = false;

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

            do
            {
                OrderDate = validate.PromptforDate("Please enter the Date of the order MM/DD/YYYY");
                Console.WriteLine("Enter Order Number:");
                OrderNumber = Console.ReadLine();
                goodNumber = int.TryParse(OrderNumber, out output);
                if (validinput = (goodNumber == true))
                {
                    goodDate = (orderOperations.FindOrder(OrderDate, output));
                }
               if (goodDate == false)
                {
                    Console.WriteLine("That was not a valid order!");
                    //Console.ReadLine();
                }

            } while (!goodDate && !goodNumber);

            if (goodDate == true)
            {
                Console.WriteLine("Would you like to delete order? y/n");
                string answer;
                answer = Console.ReadLine();
                if (answer == "y")
                {
                    //string OrderDate = validate.PromptforDate("Please enter the Date MM/DD/YYYY");
                    //decimal ordnum = validate.PromptforDecimal("EnterOrder Number: ");
                    List<Order> removeO = orderOperations.LoadOrdersFromFile();
                    var remove = orderOperations.LoadOrdersFromFile();
                    var resultsr = from order in removeO
                                   where order.OrderDate != OrderDate || order.OrderNumber != output
                                   select new
                                   {
                                       order.OrderDate,
                                       order.OrderNumber,
                                       order.CustomerName,
                                       order.State,
                                       order.TaxRate,
                                       order.Tax,
                                       order.ProductType,
                                       order.Area,
                                       order.CostPerSquareFoot,
                                       order.LaborCost,
                                       order.LaborCostPerSquareFoot,
                                       order.MaterialCost,
                                       order.Total
                                   };

                    using (StreamWriter ord = new StreamWriter("Orders.txt"))
                    {
                        foreach (var order in resultsr)
                        {
                            ord.WriteLine(order.OrderDate + "," + order.OrderNumber + "," + order.CustomerName + "," + order.State + "," +
                                +order.TaxRate + "," + order.Tax + "," + order.ProductType + "," + order.Area + "," + order.CostPerSquareFoot + "," + order.LaborCost + "," + order.LaborCostPerSquareFoot + "," +
                                 order.MaterialCost + "," + order.Total);
                        }
                        Console.WriteLine("Your order has been removed!");
                        Console.ReadLine();
                    }
                }
                else
                {
                    DisplayMenu m = new DisplayMenu();
                    m.HomeMenu();
                }
            }
            else
            {
                Console.WriteLine("That is not a valid order!");
            }
        }
示例#2
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);
        }