private void button1_Click(object sender, EventArgs e) { StaffSet staffSet = new StaffSet(); staffSet.FirstName = textBoxFirstName.Text; staffSet.LastName = textBoxLastName.Text; staffSet.MiddleName = textBoxMiddleName.Text; staffSet.Phone = textBoxPhone.Text; staffSet.Email = textBoxEmail.Text; staffSet.Persent = textBoxPersent.Text; Program.asdf.StaffSet.Add(staffSet); Program.asdf.SaveChanges(); ShowStaff(); }
private void button2_Click(object sender, EventArgs e) { if (listViewStaff.SelectedItems.Count == 1) { StaffSet staffSet = listViewStaff.SelectedItems[0].Tag as StaffSet; staffSet.FirstName = textBoxFirstName.Text; staffSet.LastName = textBoxLastName.Text; staffSet.MiddleName = textBoxMiddleName.Text; staffSet.Phone = textBoxPhone.Text; staffSet.Email = textBoxEmail.Text; staffSet.Persent = textBoxPersent.Text; Program.asdf.SaveChanges(); ShowStaff(); } }
private void listViewStaff_SelectedIndexChanged(object sender, EventArgs e) { if (listViewStaff.SelectedItems.Count == 1) { StaffSet staffSet = listViewStaff.SelectedItems[0].Tag as StaffSet; textBoxFirstName.Text = staffSet.FirstName; textBoxLastName.Text = staffSet.LastName; textBoxMiddleName.Text = staffSet.MiddleName; textBoxPhone.Text = staffSet.Phone; textBoxEmail.Text = staffSet.Email; textBoxPersent.Text = staffSet.Persent; } else { textBoxFirstName.Text = ""; textBoxLastName.Text = ""; textBoxMiddleName.Text = ""; textBoxPhone.Text = ""; textBoxEmail.Text = ""; textBoxPersent.Text = ""; } }
private void button3_Click(object sender, EventArgs e) { try { if (listViewStaff.SelectedItems.Count == 1) { StaffSet staffSet = listViewStaff.SelectedItems[0].Tag as StaffSet; Program.asdf.StaffSet.Remove(staffSet); Program.asdf.SaveChanges(); ShowStaff(); } textBoxFirstName.Text = ""; textBoxLastName.Text = ""; textBoxMiddleName.Text = ""; textBoxPhone.Text = ""; textBoxEmail.Text = ""; textBoxPersent.Text = ""; } catch { MessageBox.Show("Невозможно удалить, запись используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }