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