private void buttonAdd_Click(object sender, EventArgs e) { YourL yourL = new YourL(); yourL.INN = textBoxINN.Text; yourL.Name = textBoxName.Text; yourL.Adress = textBoxAdress.Text; yourL.E_mail = textBoxEmail.Text; yourL.IDMenager = Convert.ToInt32(comboBoxMenager.SelectedItem.ToString().Split('.')[0]); Program.qwer.YourL.Add(yourL); Program.qwer.SaveChanges(); ShowYourL(); }
private void buttonEdit_Click(object sender, EventArgs e) { if (listViewYourL.SelectedItems.Count == 1) { YourL yourL = listViewYourL.SelectedItems[0].Tag as YourL; yourL.INN = textBoxINN.Text; yourL.Name = textBoxName.Text; yourL.Adress = textBoxAdress.Text; yourL.E_mail = textBoxEmail.Text; yourL.IDMenager = Convert.ToInt32(comboBoxMenager.SelectedItem.ToString().Split('.')[0]); Program.qwer.SaveChanges(); ShowYourL(); } }
private void listViewYourL_SelectedIndexChanged(object sender, EventArgs e) { if (listViewYourL.SelectedItems.Count == 1) { YourL yourL = listViewYourL.SelectedItems[0].Tag as YourL; textBoxINN.Text = yourL.INN; textBoxName.Text = yourL.Name; textBoxAdress.Text = yourL.Adress; textBoxEmail.Text = yourL.E_mail; comboBoxMenager.Text = yourL.IDMenager.ToString(); } else { textBoxINN.Text = ""; textBoxName.Text = ""; textBoxAdress.Text = ""; textBoxEmail.Text = ""; comboBoxMenager.Text = ""; } }
private void buttonDel_Click(object sender, EventArgs e) { try { if (listViewYourL.SelectedItems.Count == 1) { YourL yourL = listViewYourL.SelectedItems[0].Tag as YourL; Program.qwer.YourL.Remove(yourL); Program.qwer.SaveChanges(); ShowYourL(); } textBoxINN.Text = ""; textBoxName.Text = ""; textBoxAdress.Text = ""; textBoxEmail.Text = ""; comboBoxMenager.Text = ""; } catch { MessageBox.Show("Невозможно удалить, запись используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }