private void listViewClient_SelectedIndexChanged(object sender, EventArgs e) { if (listViewClient.SelectedItems.Count == 1) { ClientSet clientSet = listViewClient.SelectedItems[0].Tag as ClientSet; textBoxFIO.Text = clientSet.FIO; textBoxAdres.Text = clientSet.Adres; textBoxPhone.Text = clientSet.Phone; } else { textBoxFIO.Text = ""; textBoxAdres.Text = ""; textBoxPhone.Text = ""; } }
private void buttonDel_Click(object sender, EventArgs e) { try { if (listViewClient.SelectedItems.Count == 1) { ClientSet clientSet = listViewClient.SelectedItems[0].Tag as ClientSet; Program.shDb.ClientSet.Remove(clientSet); Program.shDb.SaveChanges(); ShowClient(); } textBoxFIO.Text = ""; textBoxAdres.Text = ""; textBoxPhone.Text = ""; } catch { MessageBox.Show("Невозможно удалить, эта запись используется", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }