private void cmd_eliminar_Click(object sender, EventArgs e) { CamaroteService camaroteService = new CamaroteService(); int id = -1; id = Convert.ToInt32(this.dgv3.CurrentRow.Cells["ID"].Value.ToString()); if (id != -1) { camaroteService.DeleteById(id); MessageBox.Show("Se eliminó con éxito"); } }
private void cmd_buscar_Click(object sender, EventArgs e) { CamaroteService camaroteService = new CamaroteService(); DataTable tabla = new DataTable(); List <Camarote> camarotesList = new List <Camarote>(); if (cmb_navio.SelectedIndex == -1 && txt_nroCamarote.Text == "" && txt_nroCubierta.Text == "" && chbx.Checked == false) { MessageBox.Show("No se cargó ningún dato", "Mensaje", MessageBoxButtons.OK); } if (cmb_navio.SelectedIndex != -1 && txt_nroCamarote.Text != "" && txt_nroCubierta.Text != "" && chbx.Checked == false) { Camarote camarote = camaroteService.GetByPrimaryKey(Convert.ToInt32(cmb_navio.SelectedValue), Convert.ToInt32(txt_nroCubierta.Text), Convert.ToInt32(txt_nroCamarote.Text)); if (camarote == null) { MessageBox.Show("No se encontró ningún camarote con esos datos", " Mensaje", MessageBoxButtons.OK); } else { camarotesList.Add(camarote); } } if (chbx.Checked == true) { camarotesList = camaroteService.GetAll(); if (camarotesList.Count == 0) { MessageBox.Show("No se encontró ningún camarote", " Mensaje", MessageBoxButtons.OK); } } cargar_grilla(camarotesList); }