public bool EliminarServicio(int idServicio) { try { return(_servicioDAL.EliminarServicio(idServicio)); } catch (Exception) { throw; } }
private void mtBorrar_Click(object sender, EventArgs e) { try { //validacion de campos if ( !String.IsNullOrEmpty(txtNombreServicio.Text.Trim()) && !String.IsNullOrEmpty(txtPrecio.Text.Trim()) && !String.IsNullOrEmpty(txtCodigo.Text.Trim()) && !String.IsNullOrEmpty(txtID.Text.Trim()) ) { //validacion de campo ID if (!String.IsNullOrEmpty(txtID.Text)) { _servicio = _servicioDAL.ObtenerServicio(Convert.ToInt32(txtID.Text)); if (_servicio.ServicioID == Convert.ToInt32(txtID.Text)) { _servicioDAL.EliminarServicio(_servicio.ServicioID); CargaDatos(); LimpiarCajasDeTextos(); MetroFramework.MetroMessageBox.Show(this, "Eliminacion de dato exitosamente", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MetroFramework.MetroMessageBox.Show(this, "Por favor seleccionar un usuario con identificador", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MetroFramework.MetroMessageBox.Show(this, "Por favor usar el boton Refrescar", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MetroFramework.MetroMessageBox.Show(this, "Completar todos los campos", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { MetroFramework.MetroMessageBox.Show(this, ex.Message, "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error); } }