private void botonConsultar_Click(object sender, EventArgs e) { TipoClasificacionNavioService tipoService = new TipoClasificacionNavioService(); DataTable tabla = new DataTable(); List <TipoClasificacionNavio> tiposNavios = new List <TipoClasificacionNavio>(); if (txt_tipoNavio.Text == "" && chk_todos.Checked == false) { MessageBox.Show("No se cargó ningún dato", "importante", MessageBoxButtons.OK, MessageBoxIcon.Stop); txt_tipoNavio.Focus(); } if (txt_tipoNavio.Text != "" && chk_todos.Checked == false) { tiposNavios = tipoService.GetByName(txt_tipoNavio.Text); if (tiposNavios.Count == 0) { MessageBox.Show("No se encontró ningún tipo de clasificacion con ese nombre."); } } if (chk_todos.Checked == true) { tiposNavios = tipoService.GetAll(); } cargar_grilla(tiposNavios); }
private void botonEliminar_Click(object sender, EventArgs e) { TipoClasificacionNavioService tipoService = new TipoClasificacionNavioService(); int tipoId = -1; tipoId = Convert.ToInt32(this.dgv1.CurrentRow.Cells["ID"].Value.ToString()); if (tipoId != -1) { try { tipoService.DeleteTipoNavioById(tipoId); }catch (OleDbException exception) { if (exception.ErrorCode == -2147217873) { MessageBox.Show("No puede eliminar el tipo de navio ya que existen navíos con esta clasificación.", "Importante", MessageBoxButtons.OK, MessageBoxIcon.Stop); } } } }