private void load_Click(object sender, EventArgs e) { try { // Create list of employees to fill LinkedList <Employee> loadedEmployees = new LinkedList <Employee>(); // Prompt user for file to load openFileDialog.ShowDialog(); // Load file contents into a string array string[] employeeCSV = System.IO.File.ReadAllLines(openFileDialog.FileName); // Convert file contents into an array of EmployeePay objects foreach (string employee in employeeCSV) { loadedEmployees.AddFirst(new Employee(employee)); } // Display employee name and formatted total pay on a different form EmployeePayData form2 = new EmployeePayData(); RichTextBox employeePayDataDisplay = (RichTextBox)form2.Controls.Find("employeePayDataDisplay", false)[0]; foreach (Employee employee in loadedEmployees) { employeePayDataDisplay.Text = employee.ToString() + "\n" + employeePayDataDisplay.Text; } form2.Show(); } catch (Exception error) { MessageBox.Show(error.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void load_Click(object sender, EventArgs e) { try { // Create list of employees to fill LinkedList<Employee> loadedEmployees = new LinkedList<Employee>(); // Prompt user for file to load openFileDialog.ShowDialog(); // Load file contents into a string array string[] employeeCSV = System.IO.File.ReadAllLines(openFileDialog.FileName); // Convert file contents into an array of EmployeePay objects foreach (string employee in employeeCSV) { loadedEmployees.AddFirst(new Employee(employee)); } // Display employee name and formatted total pay on a different form EmployeePayData form2 = new EmployeePayData(); RichTextBox employeePayDataDisplay = (RichTextBox)form2.Controls.Find("employeePayDataDisplay", false)[0]; foreach (Employee employee in loadedEmployees) { employeePayDataDisplay.Text = employee.ToString() + "\n" + employeePayDataDisplay.Text; } form2.Show(); } catch (Exception error) { MessageBox.Show(error.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }