private void buttonDel_Click(object sender, EventArgs e) { try { if (listViewFizL.SelectedItems.Count == 1) { FizL fizL = listViewFizL.SelectedItems[0].Tag as FizL; Program.qwer.FizL.Remove(fizL); Program.qwer.SaveChanges(); ShowFizL(); } textBoxINN.Text = ""; textBoxFirstName.Text = ""; textBoxLastName.Text = ""; textBoxMiddleName.Text = ""; comboBoxGender.Text = ""; textBoxEmail.Text = ""; comboBoxMenager.Text = ""; } catch { MessageBox.Show("Невозможно удалить, запись используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void buttonAdd_Click(object sender, EventArgs e) { FizL fizL = new FizL(); fizL.INN = textBoxINN.Text; fizL.FirstName = textBoxFirstName.Text; fizL.LastName = textBoxLastName.Text; fizL.MiddleName = textBoxMiddleName.Text; fizL.Gender = comboBoxGender.Text; fizL.E_mail = textBoxEmail.Text; fizL.IDMenager = Convert.ToInt32(comboBoxMenager.SelectedItem.ToString().Split('.')[0]); Program.qwer.FizL.Add(fizL); Program.qwer.SaveChanges(); ShowFizL(); }
private void buttonEdit_Click(object sender, EventArgs e) { if (listViewFizL.SelectedItems.Count == 1) { FizL fizL = listViewFizL.SelectedItems[0].Tag as FizL; fizL.INN = textBoxINN.Text; fizL.FirstName = textBoxFirstName.Text; fizL.LastName = textBoxLastName.Text; fizL.MiddleName = textBoxMiddleName.Text; fizL.Gender = comboBoxGender.Text; fizL.E_mail = textBoxEmail.Text; fizL.IDMenager = Convert.ToInt32(comboBoxMenager.SelectedItem.ToString().Split('.')[0]); Program.qwer.SaveChanges(); ShowFizL(); } }
private void listViewFizL_SelectedIndexChanged(object sender, EventArgs e) { if (listViewFizL.SelectedItems.Count == 1) { FizL fizL = listViewFizL.SelectedItems[0].Tag as FizL; textBoxINN.Text = fizL.INN; textBoxFirstName.Text = fizL.FirstName; textBoxLastName.Text = fizL.LastName; textBoxMiddleName.Text = fizL.MiddleName; comboBoxGender.Text = fizL.Gender; textBoxEmail.Text = fizL.E_mail; comboBoxMenager.Text = fizL.IDMenager.ToString(); } else { textBoxINN.Text = ""; textBoxFirstName.Text = ""; textBoxLastName.Text = ""; textBoxMiddleName.Text = ""; comboBoxGender.Text = ""; textBoxEmail.Text = ""; comboBoxMenager.Text = ""; } }