private void buttonEdit_Click(object sender, EventArgs e) { if (textBoxAddress.Text != "" && textBoxName.Text != "") { Customers_UL_ UL = listViewUL.SelectedItems[0].Tag as Customers_UL_; UL.Name = textBoxName.Text; UL.Phone = textBoxPhone.Text; UL.Email = textBoxEmail.Text; UL.Address = textBoxAddress.Text; Program.wtfDb.SaveChanges(); showUL(); } else { MessageBox.Show("Не все данные введены!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void buttonAdd_Click(object sender, EventArgs e) { if (textBoxAddress.Text != "" && textBoxName.Text != "") { Customers_UL_ UL = new Customers_UL_(); UL.Name = textBoxName.Text; UL.Phone = textBoxPhone.Text; UL.Email = textBoxEmail.Text; UL.Address = textBoxAddress.Text; Program.wtfDb.Customers_UL_.Add(UL); Program.wtfDb.SaveChanges(); showUL(); } else { MessageBox.Show("Не все данные введены!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void listViewUL_SelectedIndexChanged(object sender, EventArgs e) { if (listViewUL.SelectedItems.Count == 1) { Customers_UL_ UL = listViewUL.SelectedItems[0].Tag as Customers_UL_; textBoxName.Text = UL.Name; textBoxPhone.Text = UL.Phone; textBoxEmail.Text = UL.Email; textBoxAddress.Text = UL.Address; } else { textBoxName.Text = ""; textBoxPhone.Text = ""; textBoxEmail.Text = ""; textBoxAddress.Text = ""; } }
private void buttonDel_Click(object sender, EventArgs e) { try { if (listViewUL.SelectedItems.Count == 1) { Customers_UL_ UL = listViewUL.SelectedItems[0].Tag as Customers_UL_; Program.wtfDb.Customers_UL_.Remove(UL); Program.wtfDb.SaveChanges(); showUL(); } textBoxName.Text = ""; textBoxPhone.Text = ""; textBoxEmail.Text = ""; textBoxAddress.Text = ""; } catch { MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }