예제 #1
0
 private void buttonEdit_Click(object sender, EventArgs e)
 {
     if (listViewStudent.SelectedItems.Count == 1)
     {
         StudentSet student = listViewStudent.SelectedItems[0].Tag as StudentSet;
         student.idGroup   = Convert.ToInt32(comboBoxGroup.SelectedItem.ToString().Split('.')[0]);
         student.FirstName = textBoxFirstName.Text;
         student.LastName  = textBoxLastName.Text;
         Program.dean.SaveChanges();
         ShowStudent();
     }
 }
예제 #2
0
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     if (comboBoxGroup.SelectedItem != null && textBoxFirstName.Text != "" && textBoxLastName.Text != "")
     {
         StudentSet student = new StudentSet();
         student.idGroup   = Convert.ToInt32(comboBoxGroup.SelectedItem.ToString().Split('.')[0]);
         student.FirstName = textBoxFirstName.Text;
         student.LastName  = textBoxLastName.Text;
         Program.dean.StudentSet.Add(student);
         Program.dean.SaveChanges();
         ShowStudent();
     }
 }
예제 #3
0
 private void listViewStudent_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewStudent.SelectedItems.Count == 1)
     {
         StudentSet student = listViewStudent.SelectedItems[0].Tag as StudentSet;
         comboBoxGroup.SelectedIndex = comboBoxGroup.FindString(student.idGroup.ToString());
         textBoxFirstName.Text       = student.FirstName;
         textBoxLastName.Text        = student.LastName;
     }
     else
     {
         comboBoxGroup.SelectedItem = null;
         textBoxFirstName.Text      = "";
         textBoxLastName.Text       = "";
     }
 }
예제 #4
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (listViewStudent.SelectedItems.Count == 1)
         {
             StudentSet student = listViewStudent.SelectedItems[0].Tag as StudentSet;
             Program.dean.StudentSet.Remove(student);
             Program.dean.SaveChanges();
             ShowStudent();
         }
         comboBoxGroup.SelectedItem = null;
         textBoxFirstName.Text      = "";
         textBoxLastName.Text       = "";
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }