コード例 #1
0
        public static List <Taxes> LoadTaxes()
        {
            List <Taxes> results = new List <Taxes>();

            try
            {
                using (StreamReader sr = new StreamReader("Taxes.txt")) //StreamReader is to read one line at a time
                {
                    string row = sr.ReadLine();
                    while ((row = sr.ReadLine()) != null) //sr.Readline is to read the line and put it back on row to see if it's not null
                    {
                        Taxes c = OrderMapper.ToTaxes(row);
                        results.Add(c);
                    }
                }
            }
            catch (Exception)
            {
                Console.WriteLine("This is not a valid date");
            }

            return(results);
        }
コード例 #2
0
        public List <Orders> LoadOrders(DateTime date)
        {
            List <Orders> results = new List <Orders>();

            _orderPath = "Orders_" + date.Month.ToString("d2") + date.Day.ToString("d2") + date.Year + ".txt";

            if (!File.Exists(_orderPath))
            {
                File.Create(_orderPath).Close();

                return(results);
            }

            using (StreamReader sr = new StreamReader(_orderPath))
            {
                string row = sr.ReadLine();
                while ((row = sr.ReadLine()) != null)
                {
                    Orders c = OrderMapper.ToOrder(row, date);
                    results.Add(c);
                }
            }
            return(results);
        }