Ejemplo n.º 1
0
        private void bnDelete_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("¿Seguro de eliminar esta inspección?", "Confirmación", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (dialogResult == DialogResult.Yes)
            {
                int currentRow = dgvInspection.SelectedRows[0].Index;
                int id         = (int)dgvInspection.Rows[currentRow].Cells[0].Value;

                Inspection inspection = rentACarEntities.Inspections.Where(i => i.Id == id).FirstOrDefault();
                rentACarEntities.Entry(inspection).State = System.Data.Entity.EntityState.Modified;
                inspection.Status = false;
                rentACarEntities.SaveChanges();
                MessageBox.Show("La inspección fue eliminada correctamente.", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
                BindGridView();
            }
        }