Пример #1
0
 private void addToolStripMenuItem1_Click(object sender, EventArgs e)
 {
     TeacherEditForm tForm = new TeacherEditForm(new Teacher());
     tForm.Show();
     Program.school1.Teachers.Add(tForm.teacher);
     lbTeach.Items.Clear();
     foreach (Teacher Teacher in Program.school1.Teachers)
     {
         lbStu.Items.Add(Teacher.FirstName + " " + Teacher.LastName);
     }
 }
Пример #2
0
 private void lbTeach_SelectedIndexChanged_1(object sender, EventArgs e)
 {
     if (lbTeach.SelectedIndex >= 0 && lbTeach.SelectedIndex < Program.school1.Teachers.Count())
     {
         TeacherEditForm tform = new TeacherEditForm(Program.school1.Teachers[lbTeach.SelectedIndex]);
         Program.school1.Teachers[lbTeach.SelectedIndex] = tform.teacher;
         tform.Show();
         lbTeach.Items.Clear();
         foreach (Teacher teacher in Program.school1.Teachers)
         {
             lbTeach.Items.Add(teacher.FirstName + " " + teacher.LastName);
         }
     }
     else
     {
         lbTeach.SelectedIndex = Program.school1.Teachers.Count;
         TeacherEditForm tform = new TeacherEditForm(Program.school1.Teachers[lbTeach.SelectedIndex]);
         Program.school1.Teachers[lbTeach.SelectedIndex] = tform.teacher;
         tform.Show();
         lbTeach.Items.Clear();
         foreach (Teacher teacher in Program.school1.Teachers)
         {
             lbTeach.Items.Add(teacher.FirstName + " " + teacher.LastName);
         }
     }
 }