private void ReloadStudents() { lstStudents.Items.Clear(); foreach (var student in StudentManager.GetAll()) { var studentItem = new ListViewItem { Text = student.Id.ToString(), Tag = student }; studentItem.SubItems.Add(student.FirstName); studentItem.SubItems.Add(student.LastName); studentItem.SubItems.Add(student.Email); studentItem.SubItems.Add(student.Telephone); studentItem.SubItems.Add(student.Birthday.ToShortDateString()); lstStudents.Items.Add(studentItem); } }
private void btnExportStudents_Click(object sender, EventArgs e) { string fileName = "Students.txt"; string seperator = "==========================================================================================="; var students = StudentManager.GetAll(); using (var writer = new StreamWriter(fileName, false)) { for (int i = 0; i < students.Length; i++) { if (i > 1) { writer.WriteLine(seperator); } writer.WriteLine(students[i].GetInfoText()); } } MessageBox.Show($"Exported all students info to file {fileName}", "Exported Students Info", MessageBoxButtons.OK, MessageBoxIcon.Information); }