private void btnDelete_Click(object sender, EventArgs e) { if (dataGridViewPersonel.SelectedRows.Count == 0) { MessageBox.Show("Silinecek satırı Seçiniz"); return; } Personel p = (Personel)dataGridViewPersonel.SelectedRows[0].DataBoundItem; HotelRepository.personels.Remove(p); dataGridViewPersonel.DataSource = null; dataGridViewPersonel.DataSource = HotelRepository.personels; }
private void btnSave_Click(object sender, EventArgs e) { if (id == -1) { Personel p = new Personel(txtName.Text, txtSurname.Text); HotelRepository.personels.Add(p); } else { Personel p = HotelRepository.personels.Where(c => c.Id == id).FirstOrDefault(); p.Name = txtName.Text; p.SurName = txtSurname.Text; } Close(); }
private void BtnEdit_Click(object sender, EventArgs e) { if (dataGridViewPersonel.SelectedRows.Count == 0) { MessageBox.Show("Editlenecek satırı Seçiniz"); return; } Personel p = (Personel)dataGridViewPersonel.SelectedRows[0].DataBoundItem; AddPersonel frm = new AddPersonel(p); frm.ShowDialog(); dataGridViewPersonel.DataSource = null; dataGridViewPersonel.DataSource = HotelRepository.personels; }