public static void AddPlaza(Plaza p) { plazas.Add(p); // Creamos el boton de diseño System.Windows.Forms.Button b = new System.Windows.Forms.Button(); b.Location = new System.Drawing.Point(p.X, p.Y); if (p.isBarra) { b.Size = new System.Drawing.Size(32, 32); } else { b.Size = new System.Drawing.Size(40, 40); } b.Text = ""; b.Name = "BotonDiseño" + plazas.IndexOf(p).ToString(); b.BackColor = System.Drawing.Color.SlateBlue; botonesDiseño.Add(b); b = new System.Windows.Forms.Button(); b.Location = new System.Drawing.Point(p.X, p.Y); if (p.isBarra) { b.Size = new System.Drawing.Size(32, 32); } else { b.Size = new System.Drawing.Size(40, 40); } b.Text = ""; b.Name = "BotonTPV" + plazas.IndexOf(p).ToString(); botonesTPV.Add(b); ActualizarBotones(); }
public static void ActivarPlaza(int codigo) { foreach (object o in plazas) { Plaza p = ((Plaza)o); if (p.Cod == codigo) { int i = plazas.IndexOf(p); ((Plaza)o).Activar(); ((System.Windows.Forms.Button)botonesTPV[i]).Enabled = false; ((System.Windows.Forms.Button)botonesTPV[i]).BackColor = System.Drawing.Color.DimGray; return; } } }
private void botonNuevoPuntoBarra_Click(object sender, System.EventArgs e) { Plaza p = new Plaza(); p.Cod = GestorPlazas.NewCod++; p.isBarra = true; p.X = 0; p.Y = 0; GestorPlazas.AddPlaza(p); int i = GestorPlazas.getNumPlazas() - 1; this.panelDiseño.Controls.Add(GestorPlazas.getBotonDiseño(i)); GestorPlazas.getBotonDiseño(i).MouseDown += new System.Windows.Forms.MouseEventHandler(botonesDiseño_MouseDown); GestorPlazas.getBotonDiseño(i).MouseMove += new System.Windows.Forms.MouseEventHandler(botonesDiseño_MouseMove); GestorPlazas.getBotonDiseño(i).Click += new System.EventHandler(botonesDiseño_Click); }
public static void StartModoSacarMesa() { for (int i = 0; i < plazas.Count; i++) { Plaza p = ((Plaza)plazas[i]); if (p.isGuardada) { ((System.Windows.Forms.Button)botonesTPV[i]).Visible = true; ((System.Windows.Forms.Button)botonesTPV[i]).BackColor = System.Drawing.Color.SlateBlue; } else { ((System.Windows.Forms.Button)botonesTPV[i]).Enabled = false; ((System.Windows.Forms.Button)botonesTPV[i]).BackColor = System.Drawing.Color.DimGray; } } }
public static void Load() { Clear(); System.IO.FileStream file = new System.IO.FileStream("C:\\TPV\\plazas.dat", System.IO.FileMode.Open); newCod = Util.LoadInt(file); int l = Util.LoadInt(file); if (l != 0) { Plaza p; for (int i = 0; i < l; i++) { p = new Plaza(); p.Load(file); AddPlaza(p); } } file.Close(); }
public static bool GuardarPlaza(int codigo) { // Guardamos la plaza foreach (object o in plazas) { Plaza p = ((Plaza)o); if (p.Cod == codigo) { if (p.Guardar()) { // Ahora que ya hemos conseguido guardar la plaza, cambiamos los botones int index = plazas.IndexOf(p); ((System.Windows.Forms.Button)botonesTPV[index]).Visible = false; return(true); } else { return(false); } } } return(false); }
public static void ActualizarBotones() { for (int i = 0; i < plazas.Count; i++) { Plaza p = ((Plaza)plazas[i]); if (p.isGuardada) { ((System.Windows.Forms.Button)botonesTPV[i]).Visible = false; } else if (p.isJuntada) { ((System.Windows.Forms.Button)botonesTPV[i]).Visible = true; ((System.Windows.Forms.Button)botonesTPV[i]).BackColor = System.Drawing.Color.Gray; } else if (p.isActiva) { ((System.Windows.Forms.Button)botonesTPV[i]).Visible = true; if (p.isTerminada()) { ((System.Windows.Forms.Button)botonesTPV[i]).BackColor = System.Drawing.Color.OrangeRed; } else if (p.isTicada()) { ((System.Windows.Forms.Button)botonesTPV[i]).BackColor = System.Drawing.Color.Yellow; } else if (p.isOcupada()) { ((System.Windows.Forms.Button)botonesTPV[i]).BackColor = System.Drawing.Color.SlateBlue; } else { ((System.Windows.Forms.Button)botonesTPV[i]).BackColor = System.Drawing.Color.Lime; } } } }
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 static void Load() { Clear(); System.IO.FileStream file = new System.IO.FileStream("C:\\TPV\\plazas.dat", System.IO.FileMode.Open); newCod = Util.LoadInt(file); int l = Util.LoadInt(file); if ( l != 0 ) { Plaza p ; for ( int i = 0 ; i < l ; i++ ) { p = new Plaza(); p.Load(file); AddPlaza(p); } } file.Close(); }
public static void AddPlaza(Plaza p) { plazas.Add(p); // Creamos el boton de diseño System.Windows.Forms.Button b = new System.Windows.Forms.Button(); b.Location = new System.Drawing.Point(p.X,p.Y); if ( p.isBarra ) { b.Size = new System.Drawing.Size(32,32); } else { b.Size = new System.Drawing.Size(40,40); } b.Text = "" ; b.Name = "BotonDiseño" + plazas.IndexOf(p).ToString() ; b.BackColor = System.Drawing.Color.SlateBlue ; botonesDiseño.Add(b); b = new System.Windows.Forms.Button(); b.Location = new System.Drawing.Point(p.X, p.Y); if ( p.isBarra ) { b.Size = new System.Drawing.Size(32,32); } else { b.Size = new System.Drawing.Size(40,40); } b.Text = "" ; b.Name = "BotonTPV" + plazas.IndexOf(p).ToString() ; botonesTPV.Add(b); ActualizarBotones(); }
private void botonNuevoPuntoBarra_Click(object sender, System.EventArgs e) { Plaza p = new Plaza(); p.Cod = GestorPlazas.NewCod++ ; p.isBarra = true ; p.X = 0 ; p.Y = 0 ; GestorPlazas.AddPlaza(p); int i = GestorPlazas.getNumPlazas()-1; this.panelDiseño.Controls.Add(GestorPlazas.getBotonDiseño(i)); GestorPlazas.getBotonDiseño(i).MouseDown += new System.Windows.Forms.MouseEventHandler(botonesDiseño_MouseDown); GestorPlazas.getBotonDiseño(i).MouseMove += new System.Windows.Forms.MouseEventHandler(botonesDiseño_MouseMove); GestorPlazas.getBotonDiseño(i).Click += new System.EventHandler(botonesDiseño_Click); }