Exemple #1
0
        public void DisplayOrderInformation()
        {
            for (int i = 0; i < _currentOrderList.Count; i++)
            {
                Console.WriteLine();
                Console.WriteLine("           Order Information");
                Console.WriteLine("---------------------------------------");
                Console.Write("Order Number:".PadRight(25));
                Console.WriteLine("{0} ", _currentOrderList[i].OrderNumber);

                Console.Write("Date:".PadRight(25));
                Console.WriteLine("{0}", _currentOrderList[i].DateTime);

                Console.Write("Customer Name:".PadRight(25));
                Console.WriteLine("{0}", _currentOrderList[i].CustomerName);

                StateOperations state  = new StateOperations();
                var             states = state.GetStateByName(_currentOrderList[i].State);

                if (states != null)
                {
                    Console.Write("State Name:".PadRight(25));
                    Console.WriteLine("{0}", states.StateName);

                    Console.Write("State Abbreviation:".PadRight(25));
                    Console.WriteLine("{0}", states.StateAbbreviation);

                    Console.Write("Tax Rate:".PadRight(25));
                    Console.WriteLine("{0:p}", (states.TaxRate / 100));
                }

                //Console.Write("State Name:".PadRight(25));
                //Console.WriteLine("{0}", _currentOrderList[i].State);

                //Console.Write("Tax Rate:".PadRight(25));
                //Console.WriteLine("{0:p}", (_currentOrderList[i].TaxRate / 100));

                ProductOperations product = new ProductOperations();
                var products = product.GetProductByName(_currentOrderList[i].ProductType);

                if (product != null)
                {
                    Console.Write("Product Type:".PadRight(25));
                    Console.WriteLine("{0}", products.ProductType);

                    Console.Write("Material Cost Per SQ:".PadRight(25));
                    Console.WriteLine("{0:c}", products.MaterialCostPerSqFoot);

                    Console.Write("Labor Cost Per SQ:".PadRight(25));
                    Console.WriteLine("{0:C}", products.LaborCostPerSqFoot);
                }

                //Console.Write("Product Type:".PadRight(25));
                //Console.WriteLine("{0}", _currentOrderList[i].ProductType);

                //Console.Write("Material Cost Per SQ:".PadRight(25));
                //Console.WriteLine("{0:c}", _currentOrderList[i].MaterialCostPerSqFt);

                //Console.Write("Labor Cost Per SQ:".PadRight(25));
                //Console.WriteLine("{0:C}", _currentOrderList[i].LaborCostPerSqFt);

                Console.Write("Area:".PadRight(25));
                Console.WriteLine("{0}", _currentOrderList[i].Area);

                decimal totalMaterialCost = _currentOrderList[i].Area * products.MaterialCostPerSqFoot;
                decimal toatlLaborCost    = _currentOrderList[i].Area * products.LaborCostPerSqFoot;
                decimal totalTaxCost      = ((states.TaxRate / 100) * (totalMaterialCost + toatlLaborCost));
                decimal totalOrderCost    = totalTaxCost + toatlLaborCost + totalMaterialCost;


                Console.Write("Total Material Cost:".PadRight(25));
                Console.WriteLine("{0:c}", totalMaterialCost);

                Console.Write("Total Labor Cost:".PadRight(25));
                Console.WriteLine("{0:c}", toatlLaborCost);

                Console.Write("Total Tax Cost:".PadRight(25));
                Console.WriteLine("{0:c}", totalTaxCost);

                Console.Write("Total:".PadRight(25));
                Console.WriteLine("{0:c}", totalOrderCost);
            }
        }
Exemple #2
0
        public void Execute()
        {
            //bool correctData = false;
            //do
            //{
            string  name        = GetNameForOrder();
            string  state       = GetStateForOrder();
            string  productType = GetProductTypeForOrder();
            decimal area        = GetAreaForOrder();


            ProductOperations po = new ProductOperations();
            OrderOperations   addOrderOperations = new OrderOperations(OrderRepositoryFactory.CreateOrderRepository());
            StateOperations   so = new StateOperations();
            State             stateInformation    = new State();
            Product           ProductInfornmation = po.GetProductByName(productType);

            stateInformation = so.GetStateByName(state);


            decimal MaterialCost = area * ProductInfornmation.MaterialCostPerSqFoot;
            decimal LaborCost    = area * ProductInfornmation.LaborCostPerSqFoot;
            decimal TaxTotal     = (LaborCost + MaterialCost) * (stateInformation.TaxRate / 100);
            decimal OrderTotal   = MaterialCost + LaborCost + TaxTotal;


            Order newOrder = new Order()
            {
                //    OrderNumber = newOrderNumber,
                CustomerName        = name,
                DateTime            = DateTime.Now.ToShortDateString(),
                State               = state,
                TaxRate             = stateInformation.TaxRate,
                ProductType         = ProductInfornmation.ProductType,
                Area                = area,
                MaterialCostPerSqFt = ProductInfornmation.MaterialCostPerSqFoot,
                LaborCostPerSqFt    = ProductInfornmation.LaborCostPerSqFoot,
                TotalMaterialCost   = MaterialCost,
                TotalLaborCost      = LaborCost,
                TotalTaxCost        = TaxTotal,
                TotalOrderCost      = OrderTotal
            };

            bool   isValid = false;
            string confirm = "";

            while (!isValid)
            {
                DisplayNewOrder(MaterialCost, LaborCost, TaxTotal, OrderTotal, newOrder);

                Console.WriteLine();
                Console.WriteLine("Is all the information correct?");
                Console.WriteLine("Enter (Y) or (N)");

                confirm = Console.ReadLine().ToUpper();

                if (string.IsNullOrEmpty(confirm))
                {
                    isValid = false;
                    Console.WriteLine("Please enter (Y) or (N)");
                    Console.WriteLine("Press ENTER to continue");
                    Console.ReadLine();
                }
                else if ((confirm != "N") && (confirm != "Y"))
                {
                    isValid = false;
                    Console.WriteLine("{0} is not a \"Y\" or \"N\"", confirm);
                    Console.WriteLine("Press ENTER to continue");
                    Console.ReadLine();
                }
                else
                {
                    isValid = true;
                }
            }


            if (confirm == "Y")
            {
                var test = addOrderOperations.CreateNewOrder(newOrder);
                if (test.IsValid)
                {
                    Console.Clear();
                    Console.WriteLine();
                    Console.WriteLine("your order was added");
                    Console.WriteLine();
                    Console.WriteLine("The order number is {0}", newOrder.OrderNumber);
                    Console.WriteLine("The date of the order is {0}", newOrder.DateTime);
                    Console.WriteLine();
                    Console.WriteLine("Press ENTER to Continue.");
                    Console.ReadLine();
                }
            }
        }