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