private void buttonEdit_Click(object sender, EventArgs e) { if (listViewOrg.SelectedItems.Count == 1) { Organizations organizations = listViewOrg.SelectedItems[0].Tag as Organizations; organizations.Mail = textBoxEmail.Text; organizations.Address = textBoxAdress.Text; organizations.Name = textBoxName.Text; Program.ads.SaveChanges(); ShowOrganization(); } }
private void listViewOrg_SelectedIndexChanged(object sender, EventArgs e) { if (listViewOrg.SelectedItems.Count == 1) { Organizations organizations = listViewOrg.SelectedItems[0].Tag as Organizations; organizations.Mail = textBoxEmail.Text; organizations.Address = textBoxAdress.Text; organizations.Name = textBoxName.Text; } else { textBoxEmail.Text = ""; textBoxName.Text = ""; textBoxAdress.Text = ""; } }
private void buttonDel_Click(object sender, EventArgs e) { try { if (listViewOrg.SelectedItems.Count == 1) { Organizations organizations = listViewOrg.SelectedItems[0].Tag as Organizations; Program.ads.Organizations.Remove(organizations); Program.ads.SaveChanges(); } textBoxEmail.Text = ""; textBoxName.Text = ""; textBoxAdress.Text = ""; } catch { MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error); } ShowOrganization(); }