示例#1
0
 private void buttonEdit_Click(object sender, EventArgs e)
 {
     if (listViewTeachers.SelectedItems.Count == 1)
     {
         TeachersSet teachersSet = listViewTeachers.SelectedItems[0].Tag as TeachersSet;
         teachersSet.FirstName  = textBoxFirstName.Text;
         teachersSet.LastName   = textBoxLastName.Text;
         teachersSet.MiddleName = textBoxMiddleName.Text;
         teachersSet.Phone      = Convert.ToInt64(textBoxPhone.Text);
         teachersSet.IdSubject  = Convert.ToInt32(comboBoxSubjects.SelectedItem.ToString().Split('.')[0]);
         Program.school.SaveChanges();
         ShowTeachers();
     }
 }
示例#2
0
 private void listViewTeachers_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewTeachers.SelectedItems.Count == 1)
     {
         TeachersSet teachersSet = listViewTeachers.SelectedItems[0].Tag as TeachersSet;
         textBoxFirstName.Text          = teachersSet.FirstName;
         textBoxLastName.Text           = teachersSet.LastName;
         textBoxMiddleName.Text         = teachersSet.MiddleName;
         textBoxPhone.Text              = Convert.ToString(teachersSet.Phone);
         comboBoxSubjects.SelectedIndex = comboBoxSubjects.FindString(teachersSet.IdSubject.ToString());
     }
     else
     {
         textBoxFirstName.Text  = "";
         textBoxLastName.Text   = "";
         textBoxMiddleName.Text = "";
         textBoxPhone.Text      = "";
         comboBoxSubjects.Text  = null;
     }
 }
示例#3
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (listViewTeachers.SelectedItems.Count == 1)
         {
             TeachersSet teachersSet = listViewTeachers.SelectedItems[0].Tag as TeachersSet;
             Program.school.TeachersSet.Remove(teachersSet);
             Program.school.SaveChanges();
             ShowTeachers();
         }
         textBoxFirstName.Text  = "";
         textBoxLastName.Text   = "";
         textBoxMiddleName.Text = "";
         textBoxPhone.Text      = "";
         comboBoxSubjects.Text  = null;
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
示例#4
0
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     try
     {
         if (textBoxFirstName.Text != "" && textBoxLastName.Text != "" && textBoxMiddleName.Text != "" &&
             textBoxPhone.Text != "" && comboBoxSubjects != null)
         {
             TeachersSet teachersSet = new TeachersSet();
             teachersSet.FirstName  = textBoxFirstName.Text;
             teachersSet.LastName   = textBoxLastName.Text;
             teachersSet.MiddleName = textBoxMiddleName.Text;
             teachersSet.Phone      = Convert.ToInt64(textBoxPhone.Text);
             teachersSet.IdSubject  = Convert.ToInt32(comboBoxSubjects.SelectedItem.ToString().Split('.')[0]);
             Program.school.TeachersSet.Add(teachersSet);
             Program.school.SaveChanges();
             ShowTeachers();
             ShowSubjects();
         }
     }
     catch
     {
         MessageBox.Show("Неправильно введены данные!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }