Exemplo n.º 1
0
        //ver Comanda
        private void button4_Click(object sender, EventArgs e)
        {
            Int32 selectedRowCount =
                dgComanda.Rows.GetRowCount(DataGridViewElementStates.Selected);

            if (selectedRowCount == 1)
            {
                int id_comanda = 0;
                int mesa       = 0;
                int mozo       = 0;
                int estado     = 0;
                for (int i = 0; i < selectedRowCount; i++)
                {
                    id_comanda = Convert.ToInt32(dgComanda.SelectedRows[i].Cells["colComanda"].Value);
                    mesa       = Convert.ToInt32(dgComanda.SelectedRows[i].Cells["colMesa"].Value);
                    mozo       = Convert.ToInt32(dgComanda.SelectedRows[i].Cells["colMozo"].Value);
                    estado     = Convert.ToInt32(dgComanda.SelectedRows[i].Cells["col_IdEstado"].Value);
                }

                //recorre la lista de form abiertos por la alicación y devuelve el form Frm_mozo si lo encuentra
                Form frm;


                frm = new FrmTicket(Frm_Principal.fechaSistema, mozo, mesa, id_comanda, estado);
                frm.Show();
                frm.WindowState = FormWindowState.Normal;
            }
            else
            {
                Funciones.mError(this, "Por favor seleccione una comanda");
            }
        }
        private void btnAceptar_Click(object sender, EventArgs e)
        {
            Comanda c          = null;
            int     id_mozo    = 0;
            int     num_mesa   = 0;
            int     total      = 0;
            int     baja       = 1;
            int     puesto     = 1;
            int     id_comanda = Comanda.ultimo_id_comanda();

            if (txtnumMesa.Value > 0)
            {
                try
                {
                    id_mozo  = Convert.ToInt32(comb_Mozo.SelectedValue);
                    num_mesa = Convert.ToInt32(txtnumMesa.Value);
                    if (!Detalle_comanda.verificarComandaAbierta(num_mesa, 1, fecha.Value, fecha.Value))
                    {
                        c = new Comanda(id_comanda, puesto, fecha.Value, id_mozo, num_mesa, total, baja);
                    }
                    else
                    {
                        Funciones.mError(this, "Esta mesa se encuentra abierta");

                        this.Close();
                        // aca deberia abrir la comanda
                    }
                }
                catch (Exception ex)
                {
                    Funciones.mError(this, ex.Message);
                }

                //VALIDAR SI LA COMANDA YA NO ESTA ABIERTA PARA ESA MESA.

                if (c != null)
                {
                    if (c.insertComanda())
                    {
                        //recorre la lista de form abiertos por la alicación y devuelve el form Frm_mozo si lo encuentra
                        Form frm = Application.OpenForms.OfType <Form>().Where(Pre => Pre.Name == "FrmTicket").SingleOrDefault();

                        //codigo para validar si el formulario no esta abierto con anterioridad, si no lo abre
                        if (frm != null)
                        {
                            frm.Select();
                            frm.Show();
                            frm.WindowState = FormWindowState.Normal;
                        }
                        else
                        {
                            frm = new FrmTicket(Frm_Principal.fechaSistema, id_mozo, num_mesa, id_comanda, 1);
                            frm.Show();
                            frm.WindowState   = FormWindowState.Normal;
                            this.DialogResult = DialogResult.OK;
                            this.Close();
                        }
                    }
                    else
                    {
                        Funciones.mError(this, "Error al generar la comanda");
                    }
                }
            }
        }