Ejemplo n.º 1
0
 public Comanda(int codVenda, bool tre)
 {
     DataTable dtt = new Banco().carregaComanda();
     setFull2(dtt.Rows[0].ItemArray.GetValue(0).ToString());
     this.cod_venda = codVenda;
        //     this.data = fixCenter(new Banco().dataVenda(cod_venda), 2);
 }
        private void btConfirmar_Click(object sender, EventArgs e)
        {
            if (new Banco().temUsuario(tbUsuario.Text, tbSenha.Text))
            {

                cod_caixa = new Banco().cod_caixaByNome(tbUsuario.Text);
                if (new Banco().isAdm(tbUsuario.Text, tbSenha.Text))
                {

                    isAdm = true;
                    this.Close();
                }
                else
                {

                    isAdm = false;
                    this.Close();
                }

            }
            else
            {
                MessageBox.Show("Senha e/ou usuário inválidos", "Aviso Login");
                tbSenha.Clear();
                tbUsuario.Focus();
            }
        }
Ejemplo n.º 3
0
 public Comanda(int codVenda)
 {
     DataTable dtt = new Banco().carregaComanda();
     setFull(dtt.Rows[0].ItemArray.GetValue(0).ToString(), dtt.Rows[0].ItemArray.GetValue(1).ToString(),
         dtt.Rows[0].ItemArray.GetValue(2).ToString(), dtt.Rows[0].ItemArray.GetValue(3).ToString(),
         dtt.Rows[0].ItemArray.GetValue(4).ToString(), dtt.Rows[0].ItemArray.GetValue(5).ToString(),
         dtt.Rows[0].ItemArray.GetValue(6).ToString(), dtt.Rows[0].ItemArray.GetValue(7).ToString());
     this.cod_venda = codVenda;
     this.data = fixCenter(new Banco().dataVenda(cod_venda), 1);
 }
Ejemplo n.º 4
0
 //---------------------------------------------------------------------------------------
 public Venda(string mesa)
 {
     int cod_venda = new Banco().codigoDaVendaPelaMesa(mesa);
     InitializeComponent();
          venda = new BancoVenda().carregaVenda(cod_venda);
          tamanhoMTVALOR(venda);
          carregarListView(venda);
          regularTamanho(lvInfo.Width);
          double valr = Screen.PrimaryScreen.Bounds.Height / 100f;
          double yy = ((13.5-10) * valr)+10 ;
           this.Location = new Point((Screen.PrimaryScreen.Bounds.Width - this.Size.Width) / 2, (int)yy);
 }
 public string[] ordenaBolha(string[] mesa)
 {
     int[] x = new int[mesa.Length];
     x = new Banco().cod_mesa(mesa);// aqui eu tenho o vetor de codigo
     for (int i = 0; i < mesa.Length; i++)
         for (int j = 0; j < mesa.Length; j++)
             if (x[i] < x[j])
             {
                 int temp = x[i]; x[i] = x[j]; x[j] = temp;
             }
     //vetor está organizado.
     for (int i = 0; i < mesa.Length; i++)
         mesa[i] = new Banco().mesaNomeByCodigo(x[i]);
     return mesa;
 }
        public void agruparVenda()
        {
            troca = true;
            listVenda.Clear();
            listVenda.LargeImageList = imageList1;

            string[] mesa = new Banco().mesasIndisponiveis();
            for (int i = 0; i < mesa.Length; i++)
            {
                conjItem.Add(new ListViewItem(mesa[i], 4));
                listVenda.Items.Add(conjItem.Last());
            }
            listVenda.AllowColumnReorder = true;
            listVenda.FullRowSelect = true;
            listVenda.GridLines = true;
            listVenda.CheckBoxes = true;
        }
 public void alterarTamanhoDoProduto(string nome, Tamanho[] tam)
 {
     int cod_produto = new Banco().codigoProduto(nome);
     string query1 = "DELETE FROM produtotamanho WHERE cod_produto =" + cod_produto;
     DataTable dtt = new DataTable();
     NpgsqlDataAdapter sql = new NpgsqlDataAdapter(query1, Conectar());
     sql.Fill(dtt);
     for (int i = 0; i < tam.Length; i++)
     {
         string query2 = "INSERT INTO produtotamanho( cod_produto, cod_tamanho, valorproduto) VALUES ("
             + cod_produto + ",'" + tam[i].cod_tamanho2 + "' , "
             + (tam[i].valor).ToString().Replace(',', '.') + ")";
         dtt = new DataTable();
         sql = new NpgsqlDataAdapter(query2, Conectar());
         sql.Fill(dtt);
     }
 }
        //------------------------------------------------  RETIRAR PRODUTO --------------------------------------
        //------------------------------------------------ ANULAR VENDA
        public void anularVenda(int cod_venda, bool isBalcao)
        {
            string []mesas =   mesasDaVenda(cod_venda);
              for (int i = 0; i < mesas.Length; i++)
            {
                new Banco().disponibilizarMesa(codMesaPelaDescricao(mesas[i]));
              }
            DataTable compl = new DataTable();
            DataTable conjCompleto = new DataTable();
            string completos = "select cod_completo from VendaCompleta where cod_venda = " + cod_venda;
            new NpgsqlDataAdapter(completos, Conectar()).Fill(conjCompleto);

            double valor = 0;
            for (int i = 0; i < conjCompleto.Rows.Count; i++)
            {
                string vlr = "select valorUnitarioCompleto from completo where cod_completo = " + Convert.ToInt32(conjCompleto.Rows[i].ItemArray.GetValue(0));
                DataTable vl = new DataTable();
                new NpgsqlDataAdapter(vlr, Conectar()).Fill(vl);
                double info = Convert.ToDouble(vl.Rows[0].ItemArray.GetValue(0));
                double quantidade = new BancoInformacao().quantidadeCompletaByCodigo(Convert.ToInt32(conjCompleto.Rows[i].ItemArray.GetValue(0)));
                valor+= ( info * quantidade);

                string completo = "update Completo set cancelado = true where cod_completo  = "
                    + Convert.ToInt32(conjCompleto.Rows[i].ItemArray.GetValue(0));

                DataTable dt = new DataTable();
                new NpgsqlDataAdapter(completo, Conectar()).Fill(dt);
            }
            double valorSomado;

            double comissao= new Banco().getValorComissao();
            if (new Banco().comissaoIsPct())
            {
                valorSomado = ((comissao / 100) *valor) + valor;
                valorSomado = ((comissao / 100) * valor);
            }
            else
                valorSomado = valor + comissao;

            string vendas = "update venda set subValor = " + new Tratamento().retornaValorEscrito(valor).Replace(',', '.')
                + ", cancelado = true, aberta = false, horario = current_time , valorComissao = "
                + new Tratamento().retornaValorEscrito(comissao).Replace(',', '.')
                + ", valorReal = " + new Tratamento().retornaValorEscrito(valorSomado).Replace(',', '.') + " where cod_venda = " + cod_venda;
            new NpgsqlDataAdapter(vendas, Conectar()).Fill(compl);
        }
        public void carregarGridItem()
        {
            try
            {
                DataTable t = new Banco().informacoes(listVenda.FocusedItem.Text);
                lvInfo.Items.Clear();
                for (int i = 0; i < t.Rows.Count; i++)
                {
                    lvInfo.Items.Add(new Banco().informacoes2(Convert.ToInt32(t.Rows[i].ItemArray.GetValue(0))));
                    lvInfo.Items[i].SubItems.Add(t.Rows[i].ItemArray.GetValue(1).ToString());
                    lvInfo.Items[i].SubItems.Add("R$ " + new Tratamento().retornaValorEscrito(Convert.ToDouble(t.Rows[i].ItemArray.GetValue(2))));
                    lvInfo.Items[i].SubItems.Add("" + new BancoInformacao().quantidadeCompletaByCodigo(Convert.ToInt32(t.Rows[i].ItemArray.GetValue(0))).ToString("0.000"));

                    lvInfo.Items[i].SubItems.Add("" +(Convert.ToDouble(t.Rows[i].ItemArray.GetValue(2))* new BancoInformacao().quantidadeCompletaByCodigo(Convert.ToInt32(t.Rows[i].ItemArray.GetValue(0)))).ToString("0.00"));
                }
                VendaFull vf =  new BancoVenda().carregaVenda(new Banco().codVendaSelecionada2(listVenda.FocusedItem.Text));
                lValor.Text = "SUB TOTAL R$ " + new Tratamento().retornaValorEscrito(vf.subValor);

                lValor2.Text ="COUVERT R$ " + new Tratamento().retornaValorEscrito(vf.valorComissao);
                lValor3.Text ="TOTAL PARCIAL R$ "+ new Tratamento().retornaValorEscrito(vf.valorSomado);
                lValor.Visible = true;
                if (vf.valorComissao > 0)
                {

                    lValor.Margin = new Padding(3, 9, 4, 0);
                    lValor2.Visible = true;
                    lValor3.Visible = true;
                }
                else
                {
                    lValor.Margin = new Padding(150, 9, 4, 0);
                    lValor2.Visible = false;
                    lValor3.Visible = false;
                }
            }
            catch { return; }
        }
        // FIM ----
        private void ImprimirBematech(string StrArquivo, int cod_impressora)
        {
            DataTable impressora = new Banco().impressora(cod_impressora);
            MP2032.ConfiguraModeloImpressora(Convert.ToInt16(impressora.Rows[0].ItemArray.GetValue(2)));
            MP2032.IniciaPorta(impressora.Rows[0].ItemArray.GetValue(3).ToString());//se for internet a porta é o IP

            MP2032.AjustaLarguraPapel(48);

            try
            {
                using (StreamReader sr = new StreamReader(StrArquivo))
                {
                    String linha;
                    //Ler e exibe as linhas até alcançar o fim do arquivo.
                    while ((linha = sr.ReadLine()) != null)
                    {
                        MP2032.FormataTX(linha + "\r\n"
                            , Convert.ToInt16(impressora.Rows[0].ItemArray.GetValue(4))
                            , Convert.ToInt16(impressora.Rows[0].ItemArray.GetValue(5))
                            , Convert.ToInt16(impressora.Rows[0].ItemArray.GetValue(6))
                            , Convert.ToInt16(impressora.Rows[0].ItemArray.GetValue(7))
                            , Convert.ToInt16(impressora.Rows[0].ItemArray.GetValue(8)));

                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("Não é possivel ler o arquivo");
                MessageBox.Show(e.Message);
            }

            MP2032.AcionaGuilhotina(1);
            MP2032.FechaPorta();
        }
        public void novoMetodo(Completa[] produto, string[] mesa)
        {
            try
            {
                Reporter mr = new Reporter();
                EpsonCodes mer = new EpsonCodes();

                if (File.Exists(endereco))
                    File.Delete(endereco);

                mr.Output = endereco;
                mr.StartJob();
                Comanda cc = new Comanda(venda.cod_venda, true);
                string pont = "|---------------------------|";
                int line = 1;
                int limite = 29;
                mr.PrintText(line++, 01, "|----------COZINHA----------|");

                mr.PrintText(line, 01, "|Data:" + DateTime.Now.ToShortDateString()); mr.PrintText(line++, limite, "|");
                mr.PrintText(line, 01, "|Hora:" + DateTime.Now.ToShortTimeString()); mr.PrintText(line++, limite, "|");
                mr.PrintText(line++, 01, pont);
                mr.PrintText(line, 01, "|"); mr.PrintText(line++, limite, "|");
                //produto
                int ii = produto.Length;

                while (ii-- > 0)
                {
                    mr.PrintText(line, 1, "| - " + produto[ii].segmentoImprimir); mr.PrintText(line++, limite, "|");
                    string tam = new BancoInformacao().tamanhoDescricaoByCodigo(produto[ii].produto[0].cod_tamanho);
                    if (tam.Length > 18) tam = tam.Substring(0, 18);
                    mr.PrintText(line, 1, "|Tamanho- " + tam); mr.PrintText(line++, limite, "|");
                    for (int j = 0; j < produto[ii].produto.Length; j++)
                    {
                        string prod = new Banco().preencherNomeProdctAll(produto[ii].produto[j].cod_produto);
                        if (prod.Length > 27) prod = prod.Substring(0, 27);
                        mr.PrintText(line, 01, "|" + prod); mr.PrintText(line++, limite, "|");
                        mr.PrintText(line, 01, "|"); mr.PrintText(line, 6, "--" + (produto[ii].produto[j].porcentagem * 100) + " %"); mr.PrintText(line++, limite, "|");
                    }

                    mr.PrintText(line, 1, "|Quantidade - " + produto[ii].quantidade); mr.PrintText(line++, limite, "|");
                    string noticia = "";
                    int u = 0;
                    string nota = produto[ii].getNoticia(); string obs = "obs. "; int limit = limite -7;
                    while (u < nota.Length)
                    {
                        if (noticia.Length % limit == 0 && u >= limit)
                        {
                            mr.PrintText(line, 01, obs + noticia); mr.PrintText(line++, limite, "|"); noticia = ""; obs = ""; limit = limite-1;
                        }
                        noticia += produto[ii].getNoticia().Substring(u++, 1);
                    }
                    mr.PrintText(line, 01, "|" + noticia); mr.PrintText(line++, limite, "|"); noticia = "";
                    mr.PrintText(line++, 01, "| -- - -- - --  |");
                }
                //produto
                mr.PrintText(line++, 01, pont);
                if (produto[0].garconImprimir.Length > 15) produto[0].garconImprimir = produto[0].garconImprimir.Substring(0, 15);
                string garc = "|GARCON -" + produto[0].garconImprimir;
                mr.PrintText(line, 01, garc); mr.PrintText(line++, limite, "|");

                mr.PrintText(line, 01, "| " + mesa[mesa.Length - 1]); mr.PrintText(line++, limite, "|");
                mr.PrintText(line++, 01, pont);

                mr.PrintJob();
                mr.EndJob();

                ImprimirBematech(endereco, new Banco().getCodImpressoraByTipo(new BancoConsulta().cod_tipoPeloNome(new Banco().segmentoDoProduto(produto[0].produto[0].cod_produto))));

            }
            catch { }
        }
        public void imprimirComanda(int cod_impressora, VendaFull vend )
        {
            try
            {

                impressora = new Banco().impressora(cod_impressora);

                   Comanda cc = new Comanda(vend.cod_venda);

                //
                string pont = "|----------------------------------------------|";
                string linha = "| ID da VENDA : " + vend.cod_venda; linha = linha.PadRight(47, ' '); linha += "|";
                string[] VETOR1 = new string[vend.Completos.Length];
                string[] VETOR2 = new string[vend.Completos.Length];

                   int ii = 0; int i = vend.Completos.Length;
                   while (ii < i)
                   {
                       string ID = (ii + 1).ToString("000");

                       string CODPRODUTO = "" + vend.Completos[ii].produto[0].cod_produto.ToString("000"); // 3
                       string PRODUTO  = new Banco().preencherNomeProdctAll(vend.Completos[ii].produto[0].cod_produto); // 3
                       if (vend.Completos[ii].produto.Length > 1) PRODUTO = "mista " + PRODUTO; //18

                       if(PRODUTO.Length > 18 )    PRODUTO = PRODUTO.Substring(0, 18);
                       else                        PRODUTO = PRODUTO.PadRight(18,' ');

                       string TAMANHO = new BancoInformacao().tamanhoDescricaoByCodigo(vend.Completos[ii].produto[0].cod_tamanho); // 9
                       if(TAMANHO.Length > 9 )    TAMANHO = TAMANHO.Substring(0, 9);
                       else                        TAMANHO = TAMANHO.PadRight(9,' ');
                       linha = "| "+ID+ " - "+ CODPRODUTO + "   , "+ PRODUTO + " | " + TAMANHO + " |"; //48
                       VETOR1[ii] = linha;

                       string QUANTIDADE =  vend.Completos[ii].quantidade.ToString("0.000").PadRight(6, ' ');//6

                       string UNITARIO = (vend.Completos[ii].valorUnitario).ToString("0.00").PadRight(8, ' ');//8
                       string VALORSOMADO = ( vend.Completos[ii].quantidade * vend.Completos[ii].valorUnitario).ToString("0.00");

                       linha = ("|    "+ QUANTIDADE + "   X   "+ UNITARIO+ "        = "+ VALORSOMADO+"").PadRight(47,' ')+ "|";//48
                       VETOR2[ii] = linha;
                       ii++;
                   }
                   string COMISSAO = "";
                   if (vend.valorComissao > 0)
                   {
                       COMISSAO = "COUVERT : " + String.Format("{0:C}", vend.valorComissao) + " |";
                       COMISSAO = "|" + COMISSAO.PadLeft(47, ' ');

                   }
                   string VALORCOMANDA;
                   VALORCOMANDA = "VALOR TOTAL : " + String.Format("{0:C}", vend.valorSomado) + " |";
                   VALORCOMANDA = "|" + VALORCOMANDA.PadLeft(47, ' ');

                   //rotina GARCON
                   List<String> garcons = new List<string>();
                   for (int k = 0; k < vend.Completos.Length; k++)
                       for (int l = 0; l < vend.Completos[k].garcons.Length; l++)
                       {
                           bool can = true;
                           for (int m = 0; m < garcons.Count; m++)
                               if (garcons[m] == vend.Completos[k].garcons[l].nome)
                                   can = false;
                           if (can) garcons.Add(vend.Completos[k].garcons[l].nome);
                       }

                   int n = 0; string GARCON = "| GARCOM - ";
                   while (n < garcons.Count)
                       GARCON += garcons[n++] + " - ";
                   if (GARCON.Length > 47) GARCON = GARCON.Substring(0, 47);
                   GARCON = GARCON.PadRight(47, ' ') + "|";
                   string MESA = "";
                   for (int l = 0; l < vend.mesa.Length && l < 7; l++)
                       MESA += "| " + vend.mesa[l] + " ";
                   MESA = MESA.PadRight(47, ' ') + "|";
                   string CAIXA = "| CAIXA : " + new BancoVenda().nomeVendedor(vend.cod_caixa);
                   CAIXA = CAIXA.PadRight(47, ' ') + "|";
                   string HORARIOVENDA = "| Abertura : " + vend.horario + "  - Final : " + DateTime.Now.ToShortTimeString();
                   string LIMPO = "|";
                   LIMPO = LIMPO.PadRight(47, ' ') + "|";
                   HORARIOVENDA = HORARIOVENDA.PadRight(47, ' ') + "|";
                   string SUBLINADA = "|";
                   SUBLINADA = SUBLINADA.PadRight(47, '_') + "|";

                   //IMRESSAO
                   MP2032.ConfiguraModeloImpressora(Convert.ToInt16(impressora.Rows[0].ItemArray.GetValue(2)));
                   MP2032.IniciaPorta(impressora.Rows[0].ItemArray.GetValue(3).ToString());//se for internet a porta é o IP

                  MP2032.AjustaLarguraPapel(48);
                   MP2032.ImprimeBmpEspecial(Application.StartupPath + "logo.bmp", -1, -1, 0);
                   inserirLinhaImpressao(pont, 0);
                   inserirLinhaImpressao(cc.empresa, 0);
                   inserirLinhaImpressao(cc.telefone, 0);
                   inserirLinhaImpressao(pont, 0);
                   inserirLinhaImpressao(cc.titulo, 0);
                   inserirLinhaImpressao(pont, 0);
                   inserirLinhaImpressao("| ID | CODIGO |      DESCRICAO     | CATEGORIA |", 0);
                   inserirLinhaImpressao("|    QTD Unid  X  VALOR Unit       = SUB-TOTAL |", 0);
                   inserirLinhaImpressao(pont, 0);
                   for (int h = 0; h < VETOR1.Length; h++)
                   {
                       inserirLinhaImpressao(VETOR1[h], 0);
                       inserirLinhaImpressao(VETOR2[h], 0);
                   }
                   inserirLinhaImpressao(pont, 0);
                   if(vend.valorComissao >0)
                       inserirLinhaImpressao(COMISSAO, 0);
                   //IMPRESSAO DESDE VALOR ATE O FIM
                   inserirLinhaImpressao(VALORCOMANDA, 1);
                   inserirLinhaImpressao(pont, 0);
                   inserirLinhaImpressao(GARCON, 0);
                   inserirLinhaImpressao(MESA, 0);
                   inserirLinhaImpressao(pont, 0);
                   inserirLinhaImpressao(CAIXA, 0);
                   inserirLinhaImpressao(pont, 0);
                   inserirLinhaImpressao(HORARIOVENDA, 0);
                   inserirLinhaImpressao(pont, 0);
                   inserirLinhaImpressao(LIMPO, 0);
                   inserirLinhaImpressao(cc.mensagem, 0);
                   inserirLinhaImpressao(LIMPO, 0);
                   inserirLinhaImpressao(cc.cidade, 0);
                   inserirLinhaImpressao(cc.progNome, 0);
                   inserirLinhaImpressao(cc.progTelefone, 0);
                   inserirLinhaImpressao(SUBLINADA, 0);
                MP2032.AcionaGuilhotina(1);
                MP2032.FechaPorta();

            }
               catch { }
        }
        public void gerarComandaNaoFiscal(string formaPagamento,double dinheiro, double troco)
        {
            int qtdLinha = 30 + (venda.Completos.Length * 2);
            qtdLinha *= 10;
            qtdLinha += 70;
            this.printDocument1.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("comanda", 304, qtdLinha);
                        printDocument1.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(this.printDocument1_PrintPage);
            try
            {
                Reporter mr = new Reporter();
                //quem vai colocar em italico e talz
                EpsonCodes mer = new EpsonCodes();
                if (File.Exists(endereco))
                    File.Delete(endereco);
                mr.Output = endereco;
                mr.StartJob();
                //--------------------------------------------------------------------------------
                Comanda cc = new Comanda(venda.cod_venda);
                string pont = "|-----------------------------------|";
                int line = 1; int i = 0; int ii = 0;
                mr.PrintText(line++, 02, cc.empresa);
                //o \n serve como paper feed na impressora...
                mr.PrintText(line++, 01, cc.telefone);
                mr.PrintText(line++, 01, pont);
                mr.PrintText(line++, 01, cc.fixCenter("Cupom Nao Fiscal", 1));
                mr.PrintText(line++, 01, pont);
                mr.PrintText(line++, 01, pont);
                mr.PrintText(line, 01, "ID da VENDA : " + venda.cod_venda); mr.PrintText(line++, 37, "|");
                mr.PrintText(line++, 01, pont);
                //data e hora
                mr.PrintText(line++, 01,  cc.fixCenter("Data : "+DateTime.Now.ToShortDateString()+" Hora : "+DateTime.Now.ToShortTimeString(),1));
                mr.PrintText(line++, 01, pont);

                mr.PrintText(line++, 01, "| ID |COD |     DESCRICAO    |CATEG |");//id casa 1  - cod casa 7 -  desc - casa 12 - categ casa 32
                mr.PrintText(line++, 01, "|    QTD Un X VL Un   =  SUB-TOTAL  |");// qtd - casa 6  - X na casa 7 - val Uni - casa 8 - sub total casa 18
                mr.PrintText(line++, 01, pont);

                i = venda.Completos.Length;
                while (ii < i)
                {
                    mr.PrintText(line, 01, "|"); mr.PrintText(line, 02, "" + new Tratamento().makeId(ii + 1)); mr.PrintText(line, 06, "-");
                    mr.PrintText(line, 07, "" + venda.Completos[ii].produto[0].cod_produto); mr.PrintText(line, 11, "-");
                    string prod = new Banco().preencherNomeProdctAll(venda.Completos[ii].produto[0].cod_produto);
                    if (venda.Completos[ii].produto.Length > 1) prod = "mist " + prod;
                    if (prod.Length > 16) prod = prod.Substring(0, 16);
                    mr.PrintText(line, 12, prod);
                    mr.PrintText(line, 28, "-");
                    string tam = new BancoInformacao().tamanhoDescricaoByCodigo(venda.Completos[ii].produto[0].cod_tamanho);
                    if (tam.Length > 7) tam = tam.Substring(0, 7); mr.PrintText(line, 29, tam);
                    mr.PrintText(line++, 37, "|");

                    mr.PrintText(line, 01, "|"); mr.PrintText(line, 08, "" + venda.Completos[ii].quantidade); mr.PrintText(line, 11, "X");

                    mr.PrintText(line, 15, new Tratamento().retornaValorEscritoCo(venda.Completos[ii].valorUnitario));
                    mr.PrintText(line, 23, "=");

                    if ((venda.Completos[ii].valorUnitario * venda.Completos[ii].quantidade) >= 100)
                        mr.PrintText(line, 26, new Tratamento().retornaValorEscritoCo((venda.Completos[ii].valorUnitario * venda.Completos[ii++].quantidade)));
                    else
                        mr.PrintText(line, 25, new Tratamento().retornaValorEscritoCo((venda.Completos[ii].valorUnitario * venda.Completos[ii++].quantidade)));
                    mr.PrintText(line++, 37, "|");
                }
                mr.PrintText(line++, 01, pont);
                if (venda.valorComissao > 0)
                {
                    mr.PrintText(line++, 01, cc.fixRightPont("COUVERT : " + new Tratamento().retornaValorEscrito(venda.valorComissao), 1));

                }

                mr.PrintText(line++, 01, pont);
                                mr.PrintText(line++, 01,cc.fixCenter( "FORMA DE PAGAMENTO : "+formaPagamento, 1));

                mr.PrintText(line, 01, "|"); mr.PrintText(line, 18, ("TOTAL RS : " + new Tratamento().retornaValorEscrito(venda.valorSomado)));
                mr.PrintText(line++, 37, "|");
                mr.PrintText(line, 01, "|"); mr.PrintText(line, 18, ("DINHEIRO : " + new Tratamento().retornaValorEscrito(dinheiro)));
                mr.PrintText(line++, 37, "|");
                mr.PrintText(line, 01, "|"); mr.PrintText(line, 18, ("TROCO    : " + new Tratamento().retornaValorEscrito(troco)));
                mr.PrintText(line++, 37, "|");
                mr.PrintText(line++, 01, pont);
                //--------------------------------

                mr.PrintText(line, 01, "|"); mr.PrintText(line++, 37, "|");
                mr.PrintText(line++, 01, cc.mensagem);
                mr.PrintText(line, 01, "|"); mr.PrintText(line++, 37, "|");
                mr.PrintText(line++, 01, pont);
                mr.PrintText(line++, 01, cc.cidade);
                mr.PrintText(line++, 01, pont);
                mr.PrintText(line++, 01, cc.progNome);
                mr.PrintText(line++, 01, cc.progTelefone);
                mr.PrintText(line++, 01, "|___________________________________|");

                mr.PrintJob();
                mr.EndJob();
                lerArquivo(1);

            }
            catch { }
        }
        public void atualiza()
        {
            if (retira)
            {
                listVenda.Clear();
                listVenda.LargeImageList = imageList1;

                string[] mesa = new BancoVenda().mesasDaVenda(cod_venda);
                for (int i = 0; i < mesa.Length; i++)
                {
                    conjItem.Add(new ListViewItem(mesa[i], 0));
                    listVenda.Items.Add(conjItem.Last());
                }
                // Allow the user to rearrange columns.
                listVenda.AllowColumnReorder = true;

                // Select the item and subitems when selection is made.
                listVenda.FullRowSelect = true;
                // Display grid lines.
                listVenda.GridLines = true;
                // Sort the items in the list in ascending order.
                //  listMesas.Sorting = SortOrder.Ascending;
                listVenda.CheckBoxes = true;
                this.btConfirmar.BackgroundImage = global::Pizzaria.Properties.Resources.BTnewAvancar;
                //       btConfirmar.BackgroundImage = this.BackgroundImage.
            }
            else
            {
                listVenda.Clear();
                listVenda.LargeImageList = imageList1;

                string[] mesa = new Banco().mesasDisponiveis();
                for (int i = 0; i < mesa.Length; i++)
                {
                    conjItem.Add(new ListViewItem(mesa[i], 4));
                    listVenda.Items.Add(conjItem.Last());
                }
                listVenda.AllowColumnReorder = true;
                listVenda.FullRowSelect = true;
                listVenda.GridLines = true;
                listVenda.CheckBoxes = true;

            }
        }
        public void preencherLabelDescritivo(int cod_tamanho, int cod_divisor)
        {
            string[] lbs = new Banco().subDivisorByTamanhoDivisor(cod_tamanho, cod_divisor);
            switch (lbs.Length)
            {
                case 1:
                    {
                        lbPct1.Text = lbs[0];
                        lbPct1.Visible = true;
                        lbPct2.Visible = false;
                        lbPct3.Visible = false;
                        lbPct4.Visible = false;
                        double t = new Banco().valorProduto(Convert.ToInt16(mtCodigo.Text), cod_tamanho);
                        mtCodigo1.Visible = false;
                        mtCodigo2.Visible = false;
                        mtCodigo3.Visible = false;
                        btConsulta2.Visible = false;
                        btConsulta3.Visible = false;
                        btConsulta4.Visible = false;
                        lbNomePizza1.Visible = true;
                        lbNomePizza2.Visible = false;
                        lbNomePizza3.Visible = false;
                        lbNomePizza4.Visible = false;
                        lbNomePizza2.Text = "";
                        lbNomePizza3.Text = "";
                        lbNomePizza4.Text = "";

                        mtCodigo1.Clear();
                        mtCodigo2.Clear();
                        mtCodigo3.Clear();
                        mascaraValor(t);

                        break;
                    }
                case 2:
                    {
                        lbPct1.Text = lbs[0];
                        lbPct2.Text = lbs[1];
                        lbPct1.Visible = true;
                        lbPct2.Visible = true;
                        lbPct3.Visible = false;
                        lbPct4.Visible = false;
                        mtCodigo1.Visible = true;
                        mtCodigo2.Visible = false;
                        mtCodigo3.Visible = false;
                        btConsulta2.Visible = true;
                        btConsulta3.Visible = false;
                        btConsulta4.Visible = false;
                        lbNomePizza1.Visible = true;
                        lbNomePizza2.Visible = true;
                        lbNomePizza3.Visible = false;
                        lbNomePizza4.Visible = false;
                        double valor1 = new Banco().valorProduto(Convert.ToInt16(mtCodigo.Text), cod_tamanho) *
                            new Banco().numeroPercentualSubDivisor(lbs[0]);
                        double valor2 = new Banco().valorProduto(Convert.ToInt16(mtCodigo1.Text), cod_tamanho) *
                             new Banco().numeroPercentualSubDivisor(lbs[1]);
                        mtCodigo2.Clear();
                        mtCodigo3.Clear();
                        if (!new Banco().formaDePrecoConjunto())
                            mascaraValor(valor1 + valor2);
                        else
                        {
                            if (valor1 >= valor2)
                                mascaraValor(new Banco().valorProduto(Convert.ToInt16(mtCodigo.Text), cod_tamanho));
                            else mascaraValor(new Banco().valorProduto(Convert.ToInt16(mtCodigo1.Text), cod_tamanho));
                        }
                        lbNomePizza3.Text = "";
                        lbNomePizza4.Text = "";
                        break;
                    }
                case 3:
                    {
                        lbPct1.Text = lbs[0];
                        lbPct2.Text = lbs[1];
                        lbPct3.Text = lbs[2];
                        lbPct1.Visible = true;
                        lbPct2.Visible = true;
                        lbPct3.Visible = true;
                        lbPct4.Visible = false;
                        mtCodigo1.Visible = true;
                        mtCodigo2.Visible = true;
                        mtCodigo3.Visible = false;
                        btConsulta2.Visible = true;
                        btConsulta3.Visible = true;
                        btConsulta4.Visible = false;
                        lbNomePizza1.Visible = true;
                        lbNomePizza2.Visible = true;
                        lbNomePizza3.Visible = true;
                        lbNomePizza4.Visible = false;
                        double valor1 = new Banco().valorProduto(Convert.ToInt16(mtCodigo.Text), cod_tamanho) *
                            new Banco().numeroPercentualSubDivisor(lbs[0]);
                        double valor2 = new Banco().valorProduto(Convert.ToInt16(mtCodigo1.Text), cod_tamanho) *
                            new Banco().numeroPercentualSubDivisor(lbs[1]);
                        double valor3 = new Banco().valorProduto(Convert.ToInt16(mtCodigo2.Text), cod_tamanho) *
                            new Banco().numeroPercentualSubDivisor(lbs[2]);

                        lbNomePizza4.Text = "";
                        mtCodigo3.Clear();
                   if (!new Banco().formaDePrecoConjunto())
                            mascaraValor(valor1 + valor2 + valor3);
                        else
                        {
                         if(new Banco().valorProduto(Convert.ToInt16(mtCodigo.Text), cod_tamanho) >=
                             new Banco().valorProduto(Convert.ToInt16(mtCodigo1.Text), cod_tamanho))
                         {
                            if(new Banco().valorProduto(Convert.ToInt16(mtCodigo.Text), cod_tamanho)>=
                                new Banco().valorProduto(Convert.ToInt16(mtCodigo2.Text), cod_tamanho))
                                 mascaraValor(new Banco().valorProduto(Convert.ToInt16(mtCodigo.Text), cod_tamanho));
                            else
                                mascaraValor( new Banco().valorProduto(Convert.ToInt16(mtCodigo2.Text), cod_tamanho));
                         }
                         else
                         {
                            if(new Banco().valorProduto(Convert.ToInt16(mtCodigo1.Text), cod_tamanho)>=
                                new Banco().valorProduto(Convert.ToInt16(mtCodigo2.Text), cod_tamanho))
                                mascaraValor( new Banco().valorProduto(Convert.ToInt16(mtCodigo1.Text), cod_tamanho));
                            else
                                mascaraValor( new Banco().valorProduto(Convert.ToInt16(mtCodigo2.Text), cod_tamanho));
                         }
                        }
                        break;
                    }
                case 4:
                    {
                        lbPct1.Text = lbs[0];
                        lbPct2.Text = lbs[1];
                        lbPct3.Text = lbs[2];
                        lbPct4.Text = lbs[3];
                        lbPct1.Visible = true;
                        lbPct2.Visible = true;
                        lbPct3.Visible = true;
                        lbPct4.Visible = true;
                        mtCodigo1.Visible = true;
                        mtCodigo2.Visible = true;
                        mtCodigo3.Visible = true;
                        btConsulta2.Visible = true;
                        btConsulta3.Visible = true;
                        btConsulta4.Visible = true;
                        lbNomePizza1.Visible = true;
                        lbNomePizza2.Visible = true;
                        lbNomePizza3.Visible = true;
                        lbNomePizza4.Visible = true;
                        double teste1 = new Banco().valorProduto(Convert.ToInt16(mtCodigo.Text), cod_tamanho);
                        double teste2 = new Banco().numeroPercentualSubDivisor(lbs[0]);
                        double valor1 = new Banco().valorProduto(Convert.ToInt16(mtCodigo.Text), cod_tamanho) *
                                new Banco().numeroPercentualSubDivisor(lbs[0]);
                        double valor2 = new Banco().valorProduto(Convert.ToInt16(mtCodigo1.Text), cod_tamanho) *
                            new Banco().numeroPercentualSubDivisor(lbs[1]);
                        double valor3 = new Banco().valorProduto(Convert.ToInt16(mtCodigo2.Text), cod_tamanho) *
                            new Banco().numeroPercentualSubDivisor(lbs[2]);
                        double valor4 = new Banco().valorProduto(Convert.ToInt16(mtCodigo3.Text), cod_tamanho) *
                            new Banco().numeroPercentualSubDivisor(lbs[3]);
                        if (!new Banco().formaDePrecoConjunto())
                        mascaraValor(valor1 + valor2 + valor3 + valor4);
                        else{
                            if(valor1 >= valor2)
                            {
                                if(valor1 >= valor3)
                                {
                                    if(valor1 >= valor4)
                                         mascaraValor(new Banco().valorProduto(Convert.ToInt16(mtCodigo.Text), cod_tamanho));
                                    else
                                         mascaraValor(new Banco().valorProduto(Convert.ToInt16(mtCodigo3.Text), cod_tamanho));
                                }
                                else
                                {
                                    if(valor3 >= valor4)
                                         mascaraValor(new Banco().valorProduto(Convert.ToInt16(mtCodigo2.Text), cod_tamanho));
                                    else
                                         mascaraValor(new Banco().valorProduto(Convert.ToInt16(mtCodigo3.Text), cod_tamanho));
                                }
                            }
                            else
                            {
                                if(valor2 >= valor3)
                                {
                                    if(valor2 >= valor4)
                                         mascaraValor(new Banco().valorProduto(Convert.ToInt16(mtCodigo1.Text), cod_tamanho));
                                    else
                                         mascaraValor(new Banco().valorProduto(Convert.ToInt16(mtCodigo3.Text), cod_tamanho));
                                }
                                else
                                {
                                    if(valor3 >= valor4)
                                         mascaraValor(new Banco().valorProduto(Convert.ToInt16(mtCodigo2.Text), cod_tamanho));
                                    else
                                         mascaraValor(new Banco().valorProduto(Convert.ToInt16(mtCodigo3.Text), cod_tamanho));
                                }
                            }

                        }
                        break;
                    }
            }
        }
        // olhar os 3 metodos depois de criar as aberturas das telas usadas pelos metodos !!!!!!!!!!!!!!!!!!!!!!!!!!
        private void MSImprimir_Click(object sender, EventArgs e)
        {
            try
            {
                if (MessageBox.Show("Confirma Impressão?", "Confirme sua Opcao", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    int cod_venda = new Banco().codigoDaVendaPelaMesa(listVenda.FocusedItem.Text);
                    VendaFull vd = new BancoVenda().carregaVenda(cod_venda);
                    Impressao p = new Impressao();
                    new BancoVenda().imprimiu(cod_venda);
                    p.imprimirComanda(1, vd);
                    new BancoVenda().imprimiu(cod_venda);
                    carregarMesa(true);

                }
            }
            catch { }
        }
        public void unirVendas(string [] mesasDaVenda, string mesaDestino)
        {
            int[] vendas = new int[mesasDaVenda.Length];
              for (int i = 0; i < mesasDaVenda.Length; i++)
              {
              vendas[i] = new Banco().codigoDaVendaPelaMesa(mesasDaVenda[i]);
              string query = "update vendaCompleta set cod_venda = " + new Banco().codigoDaVendaPelaMesa(mesaDestino) + " where cod_venda = " + vendas[i];;
              string query2 = "update vendaMesa set  cod_venda = " + new Banco().codigoDaVendaPelaMesa(mesaDestino) + " where cod_venda = " + vendas[i];
              string query3 = "update supervenda set cod_venda = " + new Banco().codigoDaVendaPelaMesa(mesaDestino) + " where cod_venda = " + vendas[i]; ;

              string query4 = "delete from venda where cod_venda = " + vendas[i];

              new NpgsqlDataAdapter(query, Conectar()).Fill(new DataTable());
              new NpgsqlDataAdapter(query2, Conectar()).Fill(new DataTable());
              new NpgsqlDataAdapter(query3, Conectar()).Fill(new DataTable());
              if(mesasDaVenda[i]!=mesaDestino)
              new NpgsqlDataAdapter(query4, Conectar()).Fill(new DataTable());
              }
        }
 public void garconDaVenda()
 {
     Banco bg = new Banco();
     if (bg.temGarconIn(cod_venda))
     {
         lbGarcon.Visible = true;
         cbGarVen.Visible = true;
         pGarLivre.Visible = false;
         cbGarVen.DataSource = bg.GarconDaVenda(cod_venda);
         cbGarVen.DisplayMember = "nome";
         cbGarVen.SelectedIndex = 0;
         btGarc.Visible = true;
     }
     else
     {
         btGarc.Visible = false;
         garconNaoDaVenda();
     }
 }
        public void encerrarVenda(double subValor, double comissao, double valorTotal, int cod_venda, string[] mesas, bool isBalcao)
        {
            new NpgsqlDataAdapter("UPDATE venda   SET aberta = false, valorreal = '"
                + new Tratamento().retornaValorEscrito(valorTotal).Replace(',', '.')
                + "',subValor = " + new Tratamento().retornaValorEscrito(subValor).Replace(',', '.')
                + ", valorComissao = " + new Tratamento().retornaValorEscrito(comissao).Replace(',', '.') + " WHERE cod_venda = " + cod_venda, Conectar()).Fill(new DataTable());

            int[] i = new Banco().cod_mesa(mesas);
            if(!isBalcao)
            for (int j = 0; j < i.Length; j++)
                new Banco().disponibilizarMesa(i[j]);
        }
        private void cbTamanho_SelectedIndexChanged(object sender, EventArgs e)
        {
            int codTamanho = new Banco().codTamanho(cbTamanho.Text);

            cbMista.DataSource = new Banco().divisorByTamanho(codTamanho);
            cbMista.DisplayMember = "descricao";
            cbMista.SelectedIndex = 0;

            if (cbTamanho.Items.Count >= 2) { cbTamanho.Visible = true; lTamanho.Visible = true; }
            else { cbTamanho.Visible = false; lTamanho.Visible = false; tbQuantidade.Focus();}
            preencherLabelDescritivo(codTamanho, new Banco().codDivisorByDescricao(cbMista.Text));

            if (cbMista.Items.Count >=2) { cbMista.Visible = true; lbMista.Visible = true; }
            else { cbMista.Visible = false; lbMista.Visible = false;  }

            //lbMista.Visible = true;
            //cbMista.Visible = true;
            panelValor.Visible = true;
        }
 private void cbMista_SelectedIndexChanged(object sender, EventArgs e)
 {
     int codTamanho = new Banco().codTamanho(cbTamanho.Text);
     try
     {
         preencherLabelDescritivo(codTamanho, new Banco().codDivisorByDescricao(cbMista.Text));
     }
     catch { return; }
 }
        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 { };
        }
        public void gerarComandaCozinha(Completa[] produto, string[] mesa, bool reimpresso)
        {
            try
            {
                this.printDocument1.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("comanda", 304, 2000);
                printDocument1.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(this.printDocument1_PrintPage);
                Reporter mr = new Reporter();
                if (File.Exists(endereco))
                    File.Delete(endereco);

                mr.Output = endereco;
                mr.StartJob();
                //tamanho Interno 23

                Comanda cc = new Comanda(venda.cod_venda, true);
                string pont = "|---------------------|";
                int line = 1;
                //

                string cozinha = new Banco().carregaComandaCozinha();
                mr.PrintText(line++, 01, "|----" + cozinha + "----|");//13

                mr.PrintText(line, 01, "| Data : " + DateTime.Now.ToShortDateString()); mr.PrintText(line++, 23, "|");
                mr.PrintText(line, 01, "| Hora : " + DateTime.Now.ToShortTimeString()); mr.PrintText(line++, 23, "|");
                mr.PrintText(line++, 01, pont);
                mr.PrintText(line, 01, "|"); mr.PrintText(line++, 23, "|");
                //produto
                int ii = produto.Length;

                while (ii-- > 0)
                {
                    if (reimpresso)
                    {
                        mr.PrintText(line, 1, "| - REIMPRESSAO "); mr.PrintText(line++, 23, "|");
                    }
                    mr.PrintText(line, 1, "| - " + produto[ii].segmentoImprimir); mr.PrintText(line++, 23, "|");

                    string tam = new BancoInformacao().tamanhoDescricaoByCodigo(produto[ii].produto[0].cod_tamanho);
                    if (tam.Length > 14) tam = tam.Substring(0, 14);
                    mr.PrintText(line, 1, "| Especif. - " + tam); mr.PrintText(line++, 23, "|");
                    for (int j = 0; j < produto[ii].produto.Length; j++)
                    {
                        string prod = "Item - " + new Banco().preencherNomeProdctAll(produto[ii].produto[j].cod_produto);
                        if (prod.Length > 16) prod = prod.Substring(0, 16);
                        mr.PrintText(line, 01, "| " + prod); mr.PrintText(line++, 23, "|");
                        mr.PrintText(line, 1, "| PRECO UNITARIO - " + produto[ii].valorUnitario); mr.PrintText(line++, 23, "|");
                        if (produto[ii].produto[j].porcentagem != 1)
                        {
                            mr.PrintText(line, 01, "|");
                            mr.PrintText(line, 6, " -- " + (produto[ii].produto[j].porcentagem * 100) + " %");
                            mr.PrintText(line++, 23, "|");
                        }
                    }
                    mr.PrintText(line, 1, "|Quantidade - " + produto[ii].quantidade.ToString("0.000")); mr.PrintText(line++, 23, "|");
                    mr.PrintText(line, 1, "|Valor Item - " + (produto[ii].valorUnitario * produto[ii].quantidade).ToString("0.00")); mr.PrintText(line++, 23, "|");
                    //   mr.PrintText(line, 01, "|"); mr.PrintText(line++, 17, "|");
                    string noticia = "";
                    int u = 0;
                    string nota = produto[ii].getNoticia(); string obs = "obs. "; int limite = 16;
                    while (u < nota.Length)
                    {
                        if (noticia.Length % limite == 0 && u >= limite)
                        {
                            mr.PrintText(line, 01, obs + noticia); mr.PrintText(line++, 23, "|"); noticia = ""; obs = ""; limite = 22;
                        }
                        noticia += produto[ii].getNoticia().Substring(u++, 1);
                    }
                    mr.PrintText(line, 01, "|" + noticia); mr.PrintText(line++, 23, "|"); noticia = "";
                    mr.PrintText(line++, 01, "| --  -   --   -  --  |");
                }
                //produto
                mr.PrintText(line++, 01, pont);
                if (produto[0].garconImprimir.Length > 12) produto[0].garconImprimir = produto[0].garconImprimir.Substring(0, 12);
                string garc = "| GARCOM -" + produto[0].garconImprimir;
                mr.PrintText(line, 01, garc); mr.PrintText(line++, 23, "|");

                mr.PrintText(line, 01, "| " + mesa[mesa.Length - 1]); mr.PrintText(line++, 23, "|");
                mr.PrintText(line++, 01, pont);

                mr.PrintJob();
                mr.EndJob();
                lerArquivo(new Banco().getCodImpressoraByTipo(new BancoConsulta().cod_tipoPeloNome(new Banco().segmentoDoProduto(produto[0].produto[0].cod_produto))));
            }
            catch (Exception ee)
            {
                MessageBox.Show(ee.Message+ "info add:  "+ ee.Data);
            }
        }
 private void btConfirmar_Click(object sender, EventArgs e)
 {
     if (agrupar) {
         if (listVenda.CheckedItems.Count < 2) MessageBox.Show("Selecione duas ou mais vendas para Uni-las", "MENSAGEM");
         else
         {string [] mesas =  new string [listVenda.CheckedItems.Count];
             for (int i = 0; i < listVenda.CheckedItems.Count; i++)
                 mesas [i]= (listVenda.CheckedItems[i].Text);
             new BancoVenda().unirVendas(mesas, (cbMista.Text));
          cod_venda =    new Banco().codigoDaVendaPelaMesa(cbMista.Text);
          new BancoInformacao().unirProdutosIguais(new BancoVenda().carregaVenda(cod_venda));
         }
     }
     else
     if (!troca)
         for (int i = 0; i < listVenda.CheckedItems.Count; i++)
         {
             if (retira) new BancoVenda().removerMesaIntoVenda(cod_venda, new BancoVenda().codMesaPelaDescricao(listVenda.CheckedItems[i].Text));
             else new BancoVenda().inserirMesaIntoVenda(cod_venda, new BancoVenda().codMesaPelaDescricao(listVenda.CheckedItems[i].Text));
         }
     else
     {
         if (listVenda.CheckedItems.Count > 0)
         {
             string[] mesa = new BancoVenda().mesasDaVenda(cod_venda);
             for (int i = 0; i < listVenda.CheckedItems.Count; i++)
                 new BancoVenda().inserirMesaIntoVenda(cod_venda, new BancoVenda().codMesaPelaDescricao(listVenda.CheckedItems[i].Text));
             for (int i = 0; i < mesa.Length; i++)
                 new BancoVenda().removerMesaIntoVenda(cod_venda, new BancoVenda().codMesaPelaDescricao(mesa[i]));
         }
     }
     this.Close();
 }
        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 { }
        }
Ejemplo n.º 26
0
 public void setCodigo(string nome)
 {
     this.nome2 = nome;
     cod_tamanho2 = new Banco().codTamanho(nome);
 }
 private void MSProduto_Click(object sender, EventArgs e)
 {
     int cod_venda = new Banco().codigoDaVendaPelaMesa(listVenda.FocusedItem.Text);
     VendaFull f = (new BancoVenda().carregaVenda(cod_venda));
        new AddProduto(f.cod_venda).ShowDialog();
     new BancoVenda().naoImprimiu(cod_venda);
     carregarMesa(true);
 }
 public void garconNaoDaVenda()
 {
     Banco bg = new Banco();
     cbGarLivre.DataSource = bg.GarconNaoUsadoPelaVenda(cod_venda);
     cbGarLivre.DisplayMember = "nome";
     cbGarLivre.SelectedIndex = 0;
     {
         lbGarcon.Visible = false;
         cbGarVen.Visible = false;
         pGarLivre.Visible = true;
     }
 }
        public void carregarMesa(bool indisponivel)
        {
            if (indisponivel)
            {
                listVenda.Clear();
                ImageList il = new ImageList();

                //imageList1.ImageSize =
                listVenda.LargeImageList = imageList1;

                string[] mesa = new Banco().mesasIndisponiveis();
                for (int i = 0; i < mesa.Length; i++)
                {
                    listVenda.LargeImageList = imageList1;
                    if (new BancoConsulta().mesaImpressa(mesa[i]))
                    {
                        conjItem.Add(new ListViewItem(mesa[i], 1));
                    }
                    else conjItem.Add(new ListViewItem(mesa[i], 2));
                    listVenda.Items.Add(conjItem.Last());
                }
                // Allow the user to rearrange columns.
                listVenda.AllowColumnReorder = true;

                // Select the item and subitems when selection is made.
                listVenda.FullRowSelect = true;
                // Display grid lines.
                listVenda.GridLines = true;
                // Sort the items in the list in ascending order.
                //  listMesas.Sorting = SortOrder.Ascending;
                listVenda.CheckBoxes = false;
                //   lbVenda.Text = "MESAS OCUPADAS";
                vendendo = true;
            }
            else
            {
                listVenda.Clear();
                listVenda.LargeImageList = imageList2;

                string[] mesa = new Banco().mesasDisponiveis();
                for (int i = 0; i < mesa.Length; i++)
                {
                    conjItem.Add(new ListViewItem(mesa[i], 0));
                    listVenda.Items.Add(conjItem.Last());
                }
                // Allow the user to rearrange columns.
                listVenda.AllowColumnReorder = true;

                // Select the item and subitems when selection is made.
                listVenda.FullRowSelect = true;
                // Display grid lines.
                listVenda.GridLines = true;
                // Sort the items in the list in ascending order.
                //  listMesas.Sorting = SortOrder.Ascending;
                listVenda.CheckBoxes = true;
                //   lbVenda.Text = "MESAS LIVRES";
                vendendo = false;
            }
        }
        public void removerMesaIntoVenda(int cod_venda, int cod_mesa)
        {
            int[] mesa = new Banco().cod_mesa(mesasDaVenda(cod_venda));

            if (mesa.Length == 1) return;
            for (int i = 0; i < mesa.Length; i++)

                if (mesa[i] == cod_mesa)
                {
                    retirarMesa(cod_mesa, cod_venda);
                    return;
                }
        }