Esempio n. 1
0
        public void AddUpdatedOrderToList(Order updatedOrder)
        {
            SalesDayOrderList.Add(updatedOrder);



            return;
        }
Esempio n. 2
0
        public void AddUpdatedOrderToList(Order updatedOrder)
        {
            SalesDayOrderList.Add(updatedOrder);
            WriteListToFile(updatedOrder.OrderDate);


            return;
        }
Esempio n. 3
0
        //** method param is a filename that has previously been
        //verified to exist in the file system.
        //method extracts a date from file format "Orders_06132020.txt"
        // and converts it to a useable format "06/13/2020"
        //this allows a dateTime object to be parsed from the
        //string input and later saved to the OrderDate
        //field in the target object

        //will take the orders from the file
        // create a local copy and add it to SalesDayOrderList

        //changed to public for testing
        public void ReadOrderByDate(string filename)
        {
            //ex: Orders_06132020.txt

            ProductRepository p = new ProductRepository();

            // will need to extract date from filename
            string s = filename.Remove(0, 7);

            string[] stringArray   = s.Split('.');
            string   date          = stringArray[0];
            string   formattedDate = date.Substring(0, 2) + "/" + date.Substring(2, 2) + "/" + date.Substring(4);


            //this will read one file and add all orders in the file to the
            //SalesDayOrderList
            try
            {
                string[] rows = File.ReadAllLines(_folderpath + filename);
                for (int i = 1; i < rows.Length; i++)
                {
                    string[] columns = rows[i].Split(',');
                    Order    o       = new Order();
                    o.OrderDate              = DateTime.Parse(formattedDate);
                    o.OrderNumber            = Int32.Parse(columns[0]);
                    o.CustomerName           = columns[1];
                    o.State                  = ConvertToStateEnum(columns[2]); //convert to enum
                    o.TaxRate                = Decimal.Parse(columns[3]);
                    o.ProductType            = columns[4];
                    o.Area                   = Decimal.Parse(columns[5]);
                    o.CostPerSquareFoot      = Decimal.Parse(columns[6]);
                    o.LaborCostPerSquareFoot = Decimal.Parse(columns[7]);
                    o.MaterialCost           = Decimal.Parse(columns[8]);
                    o.LaborCost              = Decimal.Parse(columns[9]);
                    o.Tax     = Decimal.Parse(columns[10]);
                    o.Total   = Decimal.Parse(columns[11]);
                    o.Product = p.ProductList.Where(x => x.ProductType == o.ProductType).First();

                    SalesDayOrderList.Add(o);
                }
            }

            catch (Exception e)
            {
                Console.WriteLine("There was a error the File System (ReadOrderFile), Contact IT");
                Console.WriteLine(e.Message);
                Console.WriteLine("Press Any Key to Exit");
                Console.ReadKey();
                return;
                //System.Environment.Exit(0);
            }
        }
Esempio n. 4
0
 public void SaveAddedOrder(Order o)
 {
     SalesDayOrderList.Add(o);
 }