Beispiel #1
0
        private void botonesMesa_Click(object sender, System.EventArgs e)
        {
            if (modoDeOperacion == ModoNormal)
            {
                Plaza p = GestorPlazas.getPlaza((System.Windows.Forms.Button)sender);
                if (!p.isJuntada)
                {
                    for (int i = 0; i < GestorPlazas.NewCod - 1; i++)
                    {
                        GestorPlazas.getBotonTPV(i).Text = "";
                    }
                    ((Button)sender).Text = "X";
                    GestorPlazas.getPlaza((System.Windows.Forms.Button)sender).ResetSeleccion();
                    SeleccionarMesa(p.Cod);
                }
            }
            else if (modoDeOperacion == ModoSacarMesa)
            {
                Plaza p = GestorPlazas.getPlaza((System.Windows.Forms.Button)sender);
                GestorPlazas.ActivarPlaza(p.Cod);
                GestorPlazas.Save();
            }
            else if (modoDeOperacion == ModoTraspasar)
            {
                // Vamos a traspasar cosas
                int  cuenta         = 0;
                bool traspasadoTodo = false;
                for (int i = 0; i < GestorPlazas.getPlaza(mesaSeleccionada).NumLineas; i++)
                {
                    Linea l = ((Linea)GestorPlazas.getPlaza(mesaSeleccionada).Lineas[i]);
                    if (l.Seleccionado)
                    {
                        cuenta++;
                        GestorPlazas.getPlaza((System.Windows.Forms.Button)sender).AddLinea(l);
                        GestorPlazas.getPlaza(mesaSeleccionada).EliminarLinea(i);
                        i--;
                    }
                }
                if (cuenta == 0)
                {
                    // Traspasamos todo
                    traspasadoTodo = true;
                    for (int i = 0; i < GestorPlazas.getPlaza(mesaSeleccionada).NumLineas; i++)
                    {
                        Linea l = ((Linea)GestorPlazas.getPlaza(mesaSeleccionada).Lineas[i]);
                        GestorPlazas.getPlaza((System.Windows.Forms.Button)sender).AddLinea(l);
                        GestorPlazas.getPlaza(mesaSeleccionada).EliminarLinea(i);
                        i--;
                    }
                }
                GestorPlazas.getPlaza((System.Windows.Forms.Button)sender).Activar();

                GestorPlazas.ActualizarBotones();
                GestorPlazas.Save();

                // Reponemos el modo de operacion
                modoDeOperacion = ModoNormal;

                panelFamilias.Enabled  = true;
                panelArticulos.Enabled = true;
                panelLineas.Enabled    = true;

                panelGeneral.Visible    = true;
                panelOpsConMesa.Visible = true;
                panelTraspasar.Visible  = false;

                if (traspasadoTodo)
                {
                    // Elegimos la nueva mesa
                    SeleccionarMesa(GestorPlazas.getPlaza((System.Windows.Forms.Button)sender).Cod);
                }

                ActualizarPanelConMesa();
            }
            else if (modoDeOperacion == ModoJuntar)
            {
                // Traspasamos todo
                for (int i = 0; i < GestorPlazas.getPlaza(mesaSeleccionada).NumLineas; i++)
                {
                    Linea l = ((Linea)GestorPlazas.getPlaza(mesaSeleccionada).Lineas[i]);
                    GestorPlazas.getPlaza((System.Windows.Forms.Button)sender).AddLinea(l);
                }
                GestorPlazas.getPlaza(mesaSeleccionada).Clear();
                GestorPlazas.getPlaza(mesaSeleccionada).Juntar(GestorPlazas.getPlaza((System.Windows.Forms.Button)sender).Cod);

                GestorPlazas.ActualizarBotones();
                GestorPlazas.Save();

                // Reponemos el modo de operacion
                modoDeOperacion = ModoNormal;

                panelFamilias.Enabled  = true;
                panelArticulos.Enabled = true;
                panelLineas.Enabled    = true;

                panelGeneral.Visible    = true;
                panelOpsSinMesa.Visible = true;
                panelJuntar.Visible     = false;

                // Elegimos la nueva mesa
                SeleccionarMesa(GestorPlazas.getPlaza((System.Windows.Forms.Button)sender).Cod);

                ActualizarPanelConMesa();
            }
            else if (modoDeOperacion == ModoSeparar)
            {
                GestorPlazas.getPlaza((System.Windows.Forms.Button)sender).Activar();
                GestorPlazas.ActualizarBotones();
                GestorPlazas.Save();

                modoDeOperacion = ModoNormal;

                panelFamilias.Enabled  = true;
                panelArticulos.Enabled = true;
                panelLineas.Enabled    = true;

                panelGeneral.Visible    = true;
                panelOpsSinMesa.Visible = true;
                panelSeparar.Visible    = false;

                ActualizarPanelConMesa();
            }
        }