private void button4_Click(object sender, EventArgs e) { StatusAdv statusAdv = new StatusAdv(); statusAdv.Status = textBox2.Text; Program.sinDB.StatusAdv.Add(statusAdv); Program.sinDB.SaveChanges(); ShowListsStatus(); }
private void button3_Click(object sender, EventArgs e) { try { if (listView2.SelectedItems.Count == 1) { StatusAdv statusAdv = listView1.SelectedItems[0].Tag as StatusAdv; Program.sinDB.StatusAdv.Remove(statusAdv); Program.sinDB.SaveChanges(); ShowListsStatus(); textBox2.Text = ""; } else { textBox2.Text = ""; } } catch { MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }