private void btEscolhaProduto_Click(object sender, EventArgs e)
        {
            try
            {
                int cod_tamanho = new Banco().cod_tamanhoDoEscolhido(Convert.ToInt16(mtCodigo.Text), cbTamanho.Text);//cod_tamanho
                int [] conjuntoCodProduto = new int[qtdProdutos()];//codigos dos produtos
                conjuntoCodProduto = preencherCodigosProduto(conjuntoCodProduto);
                if(!codigosAceitos(conjuntoCodProduto))
                    return;
                //garantido que os codigos são aceitos
                double valor = Convert.ToDouble(mtValor.Text);//valor de entrada do produto

                try
                {
                    if (mesas.Equals(null)) { }
                }
                catch
                {
                    mesas = new string[1];
                    mesas[0] = new Banco().trazerNomeMesa(cod_venda);
                }//mesas
                int Xcod_garcon;
                if (new Banco().isVendaBalcao(cod_venda))                    Xcod_garcon = new Banco().cod_garconBalcao();
                else                     Xcod_garcon = new Banco().codGarconByNome(getGarcon());
                //garcons preenchidos
                double XquantidadeProduto = Convert.ToDouble( tbQuantidade.Text.Replace('.',',') );// quantidade do produto inserido

                Produto []produto = new Produto[conjuntoCodProduto.Length];
                double [] porcentagem = new Banco().valorPctByDescricao(cbMista.Text);
                for (int i = 0; i < conjuntoCodProduto.Length;i++ )
                {
                    produto[i] = new Produto();

                    produto[i].setLoad(conjuntoCodProduto[i] ,porcentagem[i] ,valor
                        ,cod_tamanho,new Banco().isImpressoProduto(conjuntoCodProduto[i]))  ;
                }
                int cod_completo = 1;

                if ((produto.Length==1) && (new BancoInformacao().existeProdutoNaVenda(cod_venda,produto[0].cod_produto,cod_tamanho,valor)))
                {
                    cod_completo = new BancoInformacao().codCompletoExistente(cod_venda, produto[0].cod_produto, cod_tamanho, valor);
                    new BancoInformacao().addqtdGarconCompleto(Xcod_garcon, cod_completo, XquantidadeProduto);
                }
                else {
                cod_completo =    new BancoInformacao().criarCompleto(cod_venda, Xcod_garcon, valor
                            , XquantidadeProduto, produto[0].impresso, false, produto);
                    //aqui ele deve criar um novo produto
                }

                Completa cc = new BancoVenda().getCompleta(cod_completo, false);
                cc.quantidade = XquantidadeProduto;
                cc.garconImprimir = getGarcon();
                new Banco().inserePrecoCompraEmCompleto(cod_completo, new Banco().valorCompraDoProduto(cc.produto[0].cod_produto, cc.produto[0].cod_tamanho));
                cc.segmentoImprimir = new Banco().segmentoDoProduto(Convert.ToInt16( mtCodigo.Text));
                if (tbNoticia.TextLength > 0) cc.setNoticia(tbNoticia.Text);
                if (cc.needImpress)
                {
                    listaProd[new BancoVenda().codSegmentoByProduto(cc.produto[0].cod_produto) - 1].Add(cc);
                    bool can = true;
                    for (int y = 0; y < conjGarc.ToArray().Length && can; y++)
                        if (conjGarc.ToArray()[y] == getGarcon())
                            can = !can;
                    if (can)
                        conjGarc.Add(getGarcon());
                }

               // if(MessageBox.Show("DESEJA ACRESCENTAR OUTRO ITEM","INFORMAÇÂO",
               //     MessageBoxButtons.YesNo,MessageBoxIcon.Question,MessageBoxDefaultButton.Button1
               //     ,MessageBoxOptions.DefaultDesktopOnly) == DialogResult.Yes)
            //    if (MessageBox.Show("ACRESCENTAR OUTRO ITEM??", "CONFIRME SUA OPCAO", MessageBoxButtons.YesNo) == DialogResult.Yes)
                MessageBox.Show("PRODUTO INSERIDO", "CONFIRMAÇÃO", MessageBoxButtons.OK,MessageBoxIcon.Information);
                {
                    limpaCampoCodigoProduto(); this.Focus(); mtCodigo.Visible = true; mtCodigo.Focus();
                    tbQuantidade.Text = 1.ToString("0.00");
                    this.mtCodigo_KeyPress(sender,new KeyPressEventArgs ('\r'));
                }

                    if (!(new Banco().isVendaBalcao(cod_venda)))
                    {
                        for (int j = 0; j < listaProd.Length; j++)
                            if (listaProd[j].Count > 0)
                            {
                                new Impressao(new BancoVenda().carregaVenda(cod_venda)).gerarComandaCozinha(listaProd[j].ToArray(), mesas, false);
                             //   new Impressao(true, new BancoVenda().carregaVenda(cod_venda)).novoMetodo(listaProd[j].ToArray(), mesas);
                            }
                    }
                    else
                    {
                        try
                        {
                            VendaFull f = (new BancoVenda().carregaVenda(cod_venda));
                            Pagamento rec = new Pagamento(f.cod_venda,f.subValor,f.valorComissao, f.valorSomado, f.mesa, true);
                            this.Visible = false;
                            rec.ShowDialog();
                            if (rec.encerrou)
                            {
                                for (int j = 0; j < listaProd.Length; j++)
                                    if (listaProd[j].Count > 0)
                                    {
                                       // new Impressao(new BancoVenda().carregaVenda(cod_venda)).gerarComandaInterna(listaProd[j].ToArray(), mesas);
                                        new Impressao( new BancoVenda().carregaVenda(cod_venda)).gerarComandaCozinha(listaProd[j].ToArray(), mesas,false);
                                    }

                                MessageBox.Show("VENDA REALIZADA COM SUCESSO", "ATENDIMENDO BALCAO");

                            }
                            else
                                new BancoVenda().anularVenda(cod_venda, true);

                            this.Visible = true;

                        }    catch { }
                    } this.Close();

            }
            catch { };
        }
        private void MSEncerrar_Click(object sender, EventArgs e)
        {
            try
            {
                int cod_venda = new Banco().codigoDaVendaPelaMesa(listVenda.FocusedItem.Text);
                VendaFull f = (new BancoVenda().carregaVenda(cod_venda));

                if (new BancoVenda().isImpresso(f.cod_venda) || (MessageBox.Show("COMANDA DESATUALIZADA \n DESEJA ENCERRAR MESMO ASSIM?", "Confirme sua Opcao", MessageBoxButtons.YesNo) == DialogResult.Yes))
                {

                    Pagamento rec = new Pagamento(f.cod_venda,f.subValor,f.valorComissao, f.valorSomado, f.mesa, false);
                    rec.ShowDialog();
                    if (rec.encerrou)
                    {
                        MessageBox.Show("VENDA REALIZADA COM SUCESSO");
                        carregarMesa(true);
                    }
                }
            }
            catch { }
        }
Пример #3
0
        private void btEncerrar_Click(object sender, EventArgs e)
        {
            if (new BancoVenda().isImpresso(venda.cod_venda) || (MessageBox.Show("COMANDA DESATUALIZADA \n DESEJA ENCERRAR MESMO ASSIM?", "Confirme sua Opcao", MessageBoxButtons.YesNo) == DialogResult.Yes))
                {
                    Pagamento rec = new Pagamento(  venda.cod_venda,venda.subValor,venda.valorComissao, venda.valorSomado, venda.mesa, false);

                    rec.ShowDialog();
                    if (rec.encerrou)
                    {
                        MessageBox.Show("VENDA REALIZADA COM SUCESSO","MESSAGEM",MessageBoxButtons.OK,MessageBoxIcon.Information,MessageBoxDefaultButton.Button1,MessageBoxOptions.DefaultDesktopOnly);
                        this.Close();
                    }
                }
        }