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