Пример #1
0
        private void UpdateList(List <CategoriaProducto> nuevaLista)
        {
            contenedorTarjetas.Controls.Clear();

            if (nuevaLista == null)
            {
                MessageBox.Show("Revisa tu coneccion"); return;
            }

            foreach (CategoriaProducto categoria in nuevaLista)
            {
                TarjetaCategoriaComida tarjeta = new TarjetaCategoriaComida(categoria, this)
                {
                    FontSize = 18
                };
                tarjeta.MouseClick += (sender, e) => {
                    if (e.Button == MouseButtons.Right)
                    {
                        return;
                    }
                    List <Producto> productos = ControlProductos.Instance.GetLista(categoria);

                    if (productos == null)
                    {
                        MessageBox.Show("Revisa tu coneccion"); return;
                    }

                    ProductosPorCategoria productosPorCategoria = new ProductosPorCategoria(Maximized, categoria, productos);
                    productosPorCategoria.Text = categoria.nombre_categoria;
                    productosPorCategoria.Show(this);
                };
                contenedorTarjetas.Controls.Add(tarjeta);
                tarjeta.ContextMenuStrip = materialContextMenuStrip1;
            }
        }
Пример #2
0
        public override bool Equals(object obj)
        {
            if (!(obj is TarjetaCategoriaComida))
            {
                return(false);
            }
            TarjetaCategoriaComida otra = (TarjetaCategoriaComida)obj;

            return(this.Categoria.Equals(otra.categoria));
        }
Пример #3
0
        private void toolStripMenuItemEliminar_Click(object sender, EventArgs e)
        {
            // TODO Mostrar advertencia
            TarjetaCategoriaComida tarjeta = GetSender(sender);

            if (ControlCategorias.Instance.Eliminar(tarjeta.Categoria))
            {
                MessageBox.Show("Categoria Eliminada Correctamente", "COMPLETADO");
                UpdateList();
            }
            else
            {
                MessageBox.Show("Categoria Sin Eliminar ", "ERROR");
            }
        }
Пример #4
0
        private TarjetaCategoriaComida GetSender(object sender)
        {
            ToolStripMenuItem menuItem = sender as ToolStripMenuItem;

            if (menuItem != null)
            {
                ContextMenuStrip calendarMenu = menuItem.Owner as ContextMenuStrip;

                if (calendarMenu != null)
                {
                    Control controlSelected        = calendarMenu.SourceControl;
                    TarjetaCategoriaComida tarjeta = controlSelected as TarjetaCategoriaComida;
                    return(tarjeta);
                }
            }
            return(null);
        }