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(); } }
public TpvForm() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // // Recargamos GestorFamilias.Load(); GestorArticulos.Load(); GestorPlazas.Load(); // Requiere que los articulos se hayan cargado panelVenta.Visible = true; panelOpsSinMesa.Visible = true; panelOpsConMesa.Visible = false; panelSacarMesa.Visible = false; panelGeneral.Visible = true; panelTraspasar.Visible = false; panelJuntar.Visible = false; modoDeOperacion = ModoNormal; // Creamos los botones del panel de familias int numBotonesFamiliaFila = panelFamilias.ClientSize.Width / 64; int numBotonesFamiliaColumna = panelFamilias.ClientSize.Height / 64; int numBotonesFamilia = numBotonesFamiliaFila * numBotonesFamiliaColumna; botonFamilia = new System.Windows.Forms.Button[numBotonesFamilia]; for (int i = 0; i < numBotonesFamilia; i++) { botonFamilia[i] = new System.Windows.Forms.Button(); botonFamilia[i].Size = new System.Drawing.Size(64, 64); botonFamilia[i].Left = (i % numBotonesFamiliaFila) * 64; botonFamilia[i].Top = (i / numBotonesFamiliaFila) * 64; botonFamilia[i].TextAlign = System.Drawing.ContentAlignment.BottomCenter; botonFamilia[i].Visible = false; panelFamilias.Controls.Add(botonFamilia[i]); } int numBotonesArticulosFila = panelArticulos.ClientSize.Width / 64; int numBotonesArticulosColumna = panelArticulos.ClientSize.Height / 64; int numBotonesArticulos = numBotonesArticulosFila * numBotonesArticulosColumna; botonArticulo = new System.Windows.Forms.Button[numBotonesArticulos]; codBotonArticulo = new int[numBotonesArticulos]; for (int i = 0; i < numBotonesArticulos; i++) { botonArticulo[i] = new System.Windows.Forms.Button(); botonArticulo[i].Size = new System.Drawing.Size(64, 64); botonArticulo[i].Left = (i % numBotonesArticulosFila) * 64; botonArticulo[i].Top = (i / numBotonesArticulosFila) * 64; botonArticulo[i].TextAlign = System.Drawing.ContentAlignment.BottomCenter; botonArticulo[i].Visible = false; botonArticulo[i].Click += new System.EventHandler(this.botonArticulo_Click); panelArticulos.Controls.Add(botonArticulo[i]); } // Rellenamos los botones de las familia for (int i = 0; i < GestorFamilias.Familias.Count; i++) { botonFamilia[i].Image = Image.FromFile(((Familia)GestorFamilias.Familias[i]).Image); botonFamilia[i].Text = ((Familia)GestorFamilias.Familias[i]).Name; botonFamilia[i].Visible = true; } // Rellenamos los botones de los articulos for (int i = 0; i < GestorArticulos.Articulos.Count; i++) { botonArticulo[i].Image = Image.FromFile(((Articulo)GestorArticulos.Articulos[i]).Image); botonArticulo[i].Text = ((Articulo)GestorArticulos.Articulos[i]).Name; botonArticulo[i].Visible = true; codBotonArticulo[i] = ((Articulo)GestorArticulos.Articulos[i]).Cod; } // Ponemos los botones de las plazas for (int i = 0; i < GestorPlazas.getNumPlazas(); i++) { panelVenta.Controls.Add(GestorPlazas.getBotonTPV(i)); GestorPlazas.getBotonTPV(i).Click += new System.EventHandler(botonesMesa_Click); } mesaSeleccionada = -1; }