Ejemplo n.º 1
0
        /*protected override void OnFormClosing(FormClosingEventArgs e)
        {
            base.OnFormClosing(e);

            if (e.CloseReason == CloseReason.WindowsShutDown) return;

            // Confirmacion para cerrar la ventana
            switch (MessageBox.Show(this, "¿Estas seguro que deseas salir?", "Cerrar", MessageBoxButtons.YesNo))
            {
                case DialogResult.No:
                    e.Cancel = true;
                    break;
                default:
                    break;
            }
        }*/
        private void ComandaUI_Load(object sender, EventArgs e)
        {
            dgProdComanda.Columns[0].HeaderText = "NOMBRE";
            dgProdComanda.Columns[0].Width = 140;
            dgProdComanda.Columns[1].HeaderText = "CANTIDAD";
            dgProdComanda.Columns[2].HeaderText = "PRECIO";

            if(idComanda != null)
            {
                ComandaConnect cc = new ComandaConnect();
                List<string[]> datosProdCom= cc.SelectProdComanda(idComanda);
                string idProd;
                string nomProd;
                int cantProd, precioProd, precioProdDesc, precio;

                int cantProdCom = datosProdCom.Count;

                for (int i = 0; i < cantProdCom; i++ )
                {
                    idProd = datosProdCom[i][0];
                    int.TryParse(datosProdCom[i][1], out cantProd);

                    List<string> datosProd = cc.SelectProductoFull(idProd);

                    nomProd = datosProd[1];
                    int.TryParse(datosProd[2].ToString().Substring(0, datosProd[2].ToString().Length - 3) , out precioProd);
                    int.TryParse(datosProd[3].ToString().Substring(0, datosProd[3].ToString().Length - 3), out precioProdDesc);

                    Console.WriteLine("precioProd: "+precioProd+" cantProd: "+cantProd);
                    precio = cantProd*precioProd;

                    dgProdComanda.Rows.Add();
                    dgProdComanda.Rows[i].DefaultCellStyle.BackColor = Color.LightGreen;
                    dgProdComanda.Rows[i].DefaultCellStyle.Font = new Font(FontFamily.GenericSansSerif, 12.0F, FontStyle.Regular);
                    dgProdComanda.Rows[i].Cells[0].Value = nomProd;
                    dgProdComanda.Rows[i].Cells[1].Value = cantProd;
                    dgProdComanda.Rows[i].Cells[2].Value = precio;
                    fila++;
                    total += precio;
                }
                label3.Text = total + "";
                dgProdComanda.Update();
            }
        }
Ejemplo n.º 2
0
        private void buttonIngresar_Click(object sender, EventArgs e)
        {
            if(buttonIngresar.Text.Equals("ENVIAR"))
            {
                if(idComanda == null)
                {
                    DatosComanda datos = DatosComanda.Instance();
                    ComandaConnect cc = new ComandaConnect();
                    string rutgarzon = cc.SelectRutGarzon(nombreGarzon);
                    //agrega la comanda
                    string comanda = cc.InsertComanda(rutgarzon, mesa);
                    string nombre, cantidad, idprod;
                    int cantProductos = dgProdComanda.Rows.Count;

                    for (int i = 0; i < cantProductos; i++)
                    {
                        nombre = dgProdComanda.Rows[i].Cells[0].Value.ToString();
                        Console.WriteLine("nomprod:" + nombre);
                        idprod = cc.SelectIDProducto(nombre);
                        Console.WriteLine("idprod: " + idprod);
                        cantidad = dgProdComanda.Rows[i].Cells[1].Value.ToString();
                        cc.InsertProdComanda(comanda, idprod, cantidad, "comanda");
                        Console.WriteLine(i);
                    }

                    CompleteEvents.RaiseEvent(mesa, comanda, nombreGarzon);
                    //enviar informacion a la mierda de mesas
                    this.Close();
                }
                else
                {
                    string idprod, nombreProd;

                    Console.WriteLine("hay COmanda: "+idComanda);
                    ComandaConnect cc = new ComandaConnect();
                    int cantProductos = dgProdComanda.Rows.Count;
                    for (int i = 0; i < cantProductos; i++)
                    {
                        if(dgProdComanda.Rows[i].DefaultCellStyle.BackColor != Color.LightGreen)
                        {
                            Console.WriteLine("fila");
                            nombreProd = dgProdComanda.Rows[i].Cells[0].Value.ToString();
                            idprod = cc.SelectIDProducto(nombreProd);
                            cantidad = dgProdComanda.Rows[i].Cells[1].Value.ToString();
                            cc.InsertProdComanda(idComanda, idprod, cantidad, "comanda");
                        }

                    }
                    this.Close();

                }

            }
            else
            {
                this.Close();
            }
        }