private void buttonEdit_Click(object sender, EventArgs e) { if (listView.SelectedItems.Count == 1) { AgentsSet agentsSet = listView.SelectedItems[0].Tag as AgentsSet; agentsSet.FirstName = textBoxName.Text; agentsSet.MiddleName = textBoxMiddleName.Text; agentsSet.LastName = textBoxLastName.Text; agentsSet.DealShare = textBoxDealShare.Text; Program.RPE.SaveChanges(); ShowlistView(); } else { textBoxName.Text = ""; textBoxMiddleName.Text = ""; textBoxLastName.Text = ""; textBoxDealShare.Text = ""; } }
private void buttonDel_Click(object sender, EventArgs e) { try { if (listView.SelectedItems.Count == 1) { AgentsSet agentsSet = listView.SelectedItems[0].Tag as AgentsSet; Program.RPE.AgentsSet.Remove(agentsSet); Program.RPE.SaveChanges(); ShowlistView(); } textBoxDealShare.Text = ""; textBoxLastName.Text = ""; textBoxMiddleName.Text = ""; textBoxName.Text = ""; } catch { MessageBox.Show("Невозможно удалить, эта запись используется.", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }