Exemplo n.º 1
0
        /**
         * Borra un menu y todos los elementos que contiene
         */
        private void removeMenu(object sender, EventArgs e)
        {
            try {
                if (_activatedButton != null)
                {
                    long id = Lista.getMenuFromText(_activatedButton.Content.ToString()).id;

                    WrapPanelPrincipal wp = Lista.getWrapFromMenu(Lista.getMenuFromText(_activatedButton.Content.ToString()));
                    if (id != 0)
                    {
                        Conexion.deleteMenu(id);
                        Lista.removeMenu(_activatedButton.Content.ToString());

                        if (_botonesMenu.Contains(_activatedButton))
                        {
                            _botonesMenu.Remove(_activatedButton);
                        }
                        if (_botones.Contains(_activatedButton))
                        {
                            _botones.Remove(_activatedButton);
                        }
                        if (gridPrincipal.Children.Contains(wp))
                        {
                            gridPrincipal.Children.Remove(wp);
                        }
                        if (_botonesMenu.Count != 0)
                        {
                            foreach (ComboBoxItem b in _botonesMenu)
                            {
                                onClickButtonMenu(b, e);
                                break;
                            }
                        }
                        else
                        {
                            _activatedButton = null;
                        }
                        ReturnVisibility(false);
                    }
                }
                clearTextBox();
            } catch (MySqlException exc) {
                MessageBox.Show("No se ha podido conectar a la base de datos");
            }
        }