private void buttonAdd_Click(object sender, EventArgs e)
        {
            PosetitelSet pos = new PosetitelSet();

            pos.Name       = textBoxName.Text;
            pos.Surname    = textBoxSurname.Text;
            pos.Patronymic = textBoxPatronymic.Text;
            pos.Phone      = textBoxPhone.Text;
            Program.CGDb.PosetitelSet.Add(pos);
            Program.CGDb.SaveChanges();
            ShowPosetitel();
        }
 private void buttonEdit_Click(object sender, EventArgs e)
 {
     if (listViewPoset.SelectedItems.Count == 1)
     {
         PosetitelSet pos = listViewPoset.SelectedItems[0].Tag as PosetitelSet;
         pos.Name       = textBoxName.Text;
         pos.Surname    = textBoxSurname.Text;
         pos.Patronymic = textBoxPatronymic.Text;
         pos.Phone      = textBoxPhone.Text;
         Program.CGDb.SaveChanges();
         ShowPosetitel();
     }
 }
 private void listViewPoset_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewPoset.SelectedItems.Count == 1)
     {
         PosetitelSet pos = listViewPoset.SelectedItems[0].Tag as PosetitelSet;
         textBoxName.Text       = pos.Name;
         textBoxSurname.Text    = pos.Surname;
         textBoxPatronymic.Text = pos.Patronymic;
         textBoxPhone.Text      = pos.Phone;
     }
     else
     {
         textBoxName.Text       = "";
         textBoxSurname.Text    = "";
         textBoxPatronymic.Text = "";
         textBoxPhone.Text      = "";
     }
 }
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (listViewPoset.SelectedItems.Count == 1)
         {
             PosetitelSet pos = listViewPoset.SelectedItems[0].Tag as PosetitelSet;
             Program.CGDb.PosetitelSet.Remove(pos);
             Program.CGDb.SaveChanges();
             ShowPosetitel();
         }
         textBoxName.Text       = "";
         textBoxSurname.Text    = "";
         textBoxPatronymic.Text = "";
         textBoxPhone.Text      = "";
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }