private void btnDelete_Click(object sender, EventArgs e) { if (MessageBox.Show("¿Estás seguro que quieres eliminar el registro?", "", MessageBoxButtons.YesNo) == DialogResult.Yes) { combustible.IdTipoCombustible = (int)dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells[0].Value; using (RentCarEntities db = new RentCarEntities()) { combustible = db.TIPOCOMBUSTIBLE.Where(x => x.IdTipoCombustible == combustible.IdTipoCombustible).FirstOrDefault(); db.TIPOCOMBUSTIBLE.Remove(combustible); db.SaveChanges(); Clear(); ReFill(); MessageBox.Show("Deleted Successfully!"); } } }
private void btnEdit_Click(object sender, EventArgs e) { try { combustible.IdTipoCombustible = (int)dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells[0].Value; using (RentCarEntities db = new RentCarEntities()) { combustible = db.TIPOCOMBUSTIBLE.Where(x => x.IdTipoCombustible == combustible.IdTipoCombustible).FirstOrDefault(); txbDescripcion.Text = combustible.Despcricion; cbEstado.Text = combustible.Estado; } btnSave.Text = "Update"; } catch (Exception ex) { MessageBox.Show(ex.Message); } }