public void readData(DataGridView data,string period) { try { string[] lines = File.ReadAllLines("database"); foreach (string line in lines) { String[] cells = line.Split(new Char[] { '|' }); Employee emp = new Employee(cells[0], DateTime.Parse(cells[1]),cells[2]); Employee temp = new Employee(cells[0], DateTime.Parse(cells[1]),period); if (emp.getAdd() < temp.getAdd()) { emp.addToTable(data); } } } catch (IOException e) { MessageBox.Show(e.ToString() + "\n read error@!"); } }