public List<Order> GetAllOrders(string fileName)
        {
            List<Order> orders = new List<Order>();

            var reader = File.ReadAllLines(fileName);

            for (int i = 1; i < reader.Length; i++)
            {
                var columns = reader[i].Split(',');

                var order = new Order();
                //OrderNumber,CustomerName,State,TaxRate,ProductType,Area,CostPerSquareFoot,LaborCostPerSquareFoot,
                //MaterialCost,TotalLaborCost,TotalTax,Total

                order.OrderNumber = columns[0];
                order.CustomerName = columns[1];
                order.State = columns[2];
                order.TaxRate = decimal.Parse(columns[3]);
                order.ProductType = columns[4];
                order.Area = decimal.Parse(columns[5]);
                order.CostPerSquareFoot = decimal.Parse(columns[6]);
                order.LaborCostPerSquareFoot = decimal.Parse(columns[7]);
                order.MaterialCost = decimal.Parse(columns[8]);
                order.TotalLaborCost = decimal.Parse(columns[9]);
                order.TotalTax = decimal.Parse(columns[10]);
                order.Total = decimal.Parse(columns[11]);

                orders.Add(order);
            }
            return orders;
        }
Beispiel #2
0
 public static void ShowConfirmAddOrder(Order order)
 {
     Console.Clear();
     Console.WriteLine("********************************************************************************");
     Console.WriteLine("*                      Confirm Add Order ");
     Console.WriteLine("********************************************************************************");
     Console.WriteLine("");
     Console.WriteLine(FormatedOrder(order));
     Console.WriteLine("");
 }
Beispiel #3
0
 public static void ShowAddOrderConfirmation(Order order)
 {
     Console.Clear();
     Console.WriteLine("********************************************************************************");
     Console.WriteLine("*                    Order Added Successfully ");
     Console.WriteLine("********************************************************************************");
     Console.WriteLine("");
     Console.WriteLine("You successfully added the order.");
     Console.WriteLine("");
     Console.WriteLine("----------------------------------");
     Console.WriteLine("");
     Console.WriteLine(FormatedOrder(order));
     Console.WriteLine("");
 }
 public static string FormatedOrder(Order order)
 {
     return string.Format("Order Number:                   {0}" +
                           "\nCustomer Name:                  {1}" +
                           "\nProduct Type:                   {2}" +
                           "\nState Abbreviation:             {3}" +
                           "\nArea:                           {11}" +
                           "\nCost Per Square Foot:           {4:C}" +
                           "\nLabor Cost Per Square Foot:     {5:C}" +
                           "\nMaterial Cost:                  {6:C}" +
                           "\nLabor Cost:                     {7:C}" +
                           "\nTax Rate:                       {8:P}" +
                           "\nTax:                            {9:C}" +
                           "\nTotal:                          {10:C}",
                           order.OrderNumber, order.CustomerName, order.ProductType, order.StateAbbreviation, order.CostPerSquareFoot,
                           order.LaborCostPerSquareFoot, order.MaterialCost, order.TotalLaborCost, order.TaxRate /100, order.TotalTax, order.Total, order.Area);
 }
        public List<Order> ListAll(DateTime orderDate)
        {
            var fullPath = string.Format(@"{0}_{1}.txt", FilePath, orderDate.ToString("MMddyyyy"));

            if (File.Exists(fullPath))
            {
                var orders = new List<Order>();
                var reader = File.ReadAllLines(fullPath);
                for (int i = 1; i < reader.Length; i++)
                {
                    var columns = reader[i].Split(',');

                    var order = new Order();

                    order.OrderNumber = int.Parse(columns[0]);
                    order.CustomerName = columns[1];
                    order.StateAbbreviation = columns[2];
                    order.TaxRate = decimal.Parse(columns[3]);
                    order.ProductType = columns[4];
                    order.Area = decimal.Parse(columns[5]);
                    order.CostPerSquareFoot = decimal.Parse(columns[6]);
                    order.LaborCostPerSquareFoot = decimal.Parse(columns[7]);
                    order.MaterialCost = decimal.Parse(columns[8]);
                    order.LaborCost = decimal.Parse(columns[9]);
                    order.Tax = decimal.Parse(columns[10]);
                    order.Total = decimal.Parse(columns[11]);

                    orders.Add(order);
                }

                return orders;

            }
            else
            {
                return null;
            }
        }
        public List<Order> ListAll(DateTime orderDate)
        {
            List<Order> orders = new List<Order>();

            string orderFilePath = GenerateFilePathString(orderDate);

            if (File.Exists(orderFilePath))
            {
                var reader = File.ReadAllLines(orderFilePath);

                for (int i = 1; i < reader.Length; i++)
                {
                    var columns = reader[i].Split(',');

                    var order = new Order();
                    //OrderNumber,CustomerName,State,TaxRate,ProductType,Area,CostPerSquareFoot,LaborCostPerSquareFoot,
                    //MaterialCost,TotalLaborCost,TotalTax,Total

                    order.OrderNumber = int.Parse(columns[0]);
                    order.CustomerName = columns[1];
                    order.StateAbbreviation = columns[2];
                    order.TaxRate = decimal.Parse(columns[3]);
                    order.ProductType = columns[4];
                    order.Area = decimal.Parse(columns[5]);
                    order.CostPerSquareFoot = decimal.Parse(columns[6]);
                    order.LaborCostPerSquareFoot = decimal.Parse(columns[7]);
                    order.MaterialCost = decimal.Parse(columns[8]);
                    order.TotalLaborCost = decimal.Parse(columns[9]);
                    order.TotalTax = decimal.Parse(columns[10]);
                    order.Total = decimal.Parse(columns[11]);

                    orders.Add(order);
                }
                return orders;
            }
            return null;
        }
 public static void ShowRemoveOrderConfirmation(Order order)
 {
     Console.Clear();
     Console.WriteLine("********************************************************************************");
     Console.WriteLine("*                    Order Removed Successfully ");
     Console.WriteLine("********************************************************************************");
     Console.WriteLine("");
     Console.WriteLine("You successfully removed the following order.");
     Console.WriteLine("");
     Console.WriteLine("----------------------------------");
     Console.WriteLine("");
     Console.WriteLine(FormatedOrder(order));
     Console.WriteLine("");
 }