private void btn_Add_Click(object sender, EventArgs e) { teachers teacher = new teachers(); teacher.Surname = tb_surname.Text; teacher.Name = tb_name.Text; teacher.patronymic = tb_patronymic.Text; teacher.iditems = cb_item.Text; Program.school.teachers.Add(teacher); Program.school.SaveChanges(); ShowTeachercs(); }
private void btn_Del_Click(object sender, EventArgs e) { if (ListViewTeachers.SelectedItems.Count == 1) { teachers teacher = ListViewTeachers.SelectedItems[0].Tag as teachers; teacher.Surname = tb_surname.Text; teacher.Name = tb_name.Text; teacher.patronymic = tb_patronymic.Text; teacher.iditems = cb_item.Text; Program.school.SaveChanges(); ShowTeachercs(); } }
private void btn_Edit_Click(object sender, EventArgs e) { try { if (ListViewTeachers.SelectedItems.Count == 1) { teachers teacher = ListViewTeachers.SelectedItems[0].Tag as teachers; Program.school.teachers.Remove(teacher); Program.school.SaveChanges(); } tb_surname.Text = ""; tb_name.Text = ""; tb_patronymic.Text = ""; cb_item.Text = ""; } catch { MessageBox.Show("Невозможно удалить запись"); } ShowTeachercs(); }