示例#1
0
        public async void GetAllVendas()
        {
            pdvapi = new PDVTEF.PagAPI();
            string URI = "http://pagapi.azurewebsites.net/API/getStatusVendas";

            GetAtualizaPDV(pdvapi.GetMacAddress());
            using (var client = new HttpClient())
            {
                using (var response = await client.GetAsync(URI))
                {
                    if (response.IsSuccessStatusCode)
                    {
                        try
                        {
                            var VendasJsonString = await response.Content.ReadAsStringAsync();

                            var lstvendas = JsonConvert.DeserializeObject <PDVTEF.Entity.Vendas[]>(VendasJsonString).ToList();
                            foreach (var itens in lstvendas)
                            {
                                int    ID          = itens.ID;
                                string valor       = Convert.ToString(itens.VALOR); //"100,00";
                                string cupomFiscal = "1234";                        // Convert.ToString(itens.VALOR); //"12345";
                                string dataFiscal  = "20171119";
                                string horario     = "002400";
                                string operador    = pdvapi.GetMacAddress(); // txtOperador.Text; //"OPERADOR";
                                string restricoes  = "";
                                string Status      = itens.STATUS;

                                //Caue - 22/11/2017
                                string qtdeParcelas         = "0";
                                string valorPrimeiraParcela = "0";
                                string valorDemaisParcelas  = "0";
                                int    funcao          = 0;
                                string codigoSeguranca = "";

                                if (Status == "Aguardando Pagto PDV")
                                {
                                    timer1.Enabled = false;
                                    //FuncVenda(valor, cupomFiscal, dataFiscal, horario, restricoes);
                                    FuncVenda(valor, cupomFiscal, dataFiscal, horario, restricoes, qtdeParcelas, valorPrimeiraParcela, valorDemaisParcelas, funcao, codigoSeguranca);
                                    GetAtualizaVendas(ID);
                                }
                            }
                        }
                        catch
                        {
                            insereLog("ERRO - GetAllVendas");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Não foi possível obter o vendas : " + response.StatusCode);
                    }
                }
            }
        }
示例#2
0
        //private void FuncVenda(string valor, string cupomFiscal, string dataFiscal, string horario, string restricoes)
        //{

        //    if (!clisitef.Configurado)
        //    {
        //        btnConfigura_Click(null, null);
        //    }

        //    pdvapi = new PDVTEF.PagAPI();
        //    string operador = pdvapi.GetMacAddress(); // txtOperador.Text; //"OPERADOR";
        //    //int retorno = clisitef.Venda(0, valor, cupomFiscal, dataFiscal, horario, operador, restricoes);
        //    int retorno = clisitef.Venda(funcao, valor, cupomFiscal, dataFiscal, horario, operador, restricoes, qtdeParcelas, valorPrimeiraParcela, valorDemaisParcelas);
        //}

        private void FuncVenda(string valor, string cupomFiscal, string dataFiscal, string horario, string restricoes, string qtdeParcelas, string valorPrimeiraParcela, string valorDemaisParcelas, int funcao, string codigoSeguranca)
        {
            if (!clisitef.Configurado)
            {
                btnConfigura_Click(null, null);
            }

            pdvapi = new PDVTEF.PagAPI();
            string operador = pdvapi.GetMacAddress(); // txtOperador.Text; //"OPERADOR";
            int    retorno  = clisitef.Venda(funcao, valor, cupomFiscal, dataFiscal, horario, operador, restricoes, qtdeParcelas, valorPrimeiraParcela, valorDemaisParcelas, codigoSeguranca);
        }
示例#3
0
        private void btnVenda_Click(object sender, System.EventArgs e)
        {
            if (!clisitef.Configurado)
            {
                btnConfigura_Click(null, null);
            }



            string valor       = txtValor.Text;       //"100,00";
            string cupomFiscal = txtCupomFiscal.Text; //"12345";
            string dataFiscal  = "20171203";
            string horario     = "165400";
            string operador    = "operador";//pdvapi.GetMacAddress(); // txtOperador.Text; //"OPERADOR";
            string restricoes  = "";

            //caue = 22/11/2017
            int    funcao               = 0;
            string qtdeParcelas         = "0";
            string valorPrimeiraParcela = "0";
            string valorDemaisParcelas  = "0";

            string codigoSeguranca = txtCodigoSeguranca.Text;

            pdvapi = new PDVTEF.PagAPI();
            //System.Windows.Forms.MessageBox.Show("MACADRRES: " + operador);
            insereLog("MACADRRES: " + operador);

            //Caue - 22/11/2017
            // Verifica o tipo de venda a ser realizado
            if (cmbTipoVenda.SelectedItem.ToString() == "Debito")
            {
                funcao = 2; //Debito
            }
            else
            {
                funcao               = 3;      //Credito
                qtdeParcelas         = trkQtdParcelas.Value.ToString();
                valorPrimeiraParcela = "5.00"; //txtValorPrimeiraParcela.Text;
                valorDemaisParcelas  = "5,00"; //txtValorDemaisParcelas.Text;
            }

            //int retorno = clisitef.Venda(0, valor, cupomFiscal, dataFiscal, horario, operador, restricoes);
            int retorno = clisitef.Venda(funcao, valor, cupomFiscal, dataFiscal, horario, operador, restricoes, qtdeParcelas, valorPrimeiraParcela, valorDemaisParcelas, codigoSeguranca);

            //System.Windows.Forms.MessageBox.Show("retorno: [" + retorno.ToString() + "]", "Venda CliSiTef");

            insereLog("retorno: [" + retorno.ToString() + "]");

            if (retorno == 0)
            {
                //Imprime cupom
                string meuCupom = "           RAZAO SOCIAL DA EMPESA                " + Environment.NewLine;
                meuCupom += "                  ENDERECO                      " + Environment.NewLine;
                meuCupom += "              CIDADE - ESTADO                   " + Environment.NewLine;
                meuCupom += "          CNPJ: 00.000.000/0000-00              " + Environment.NewLine;
                meuCupom += "            IE: 000.0000000.0000                " + Environment.NewLine;
                meuCupom += "------------------------------------------------" + Environment.NewLine;
                meuCupom += "      DATA " + DateTime.Now.ToShortDateString() + "  HORA " + DateTime.Now.ToShortTimeString() + "  004-001      " + Environment.NewLine;
                meuCupom += "------------------------------------------------" + Environment.NewLine;

                if (funcao == 2)
                {
                    meuCupom += "               DEBITO A VISTA                   " + Environment.NewLine;
                }
                else
                {
                    meuCupom += "               CREDITO A VISTA                  " + Environment.NewLine;
                }

                int novoValor = int.Parse(txtValor.Text) / 100;

                meuCupom += "VALOR                                " + novoValor.ToString("C2") + Environment.NewLine;

                txtCuponsFiscal.Text = txtCupomFiscal.Text + Environment.NewLine + meuCupom;
//RAZAO SOCIAL DA EMPESA
//ENDERECO
//CIDADE - B.H MINAS GERAIS
//CNPJ: 00.000.000/0000-00
//IE: 000.0000000.0000
//------------------------------------------------
//11/10/2014  13:35:49  CNF:350714      COD:503297
//------------------------------------------------
//                 CUPOM não FISCAL

//ITEM CODIGO        DESCRIÇÃO
//   QTD.   UN.    VL.UNIT(R$)    ST   VL ITEM(R$)
//------------------------------------------------
//01   7898939332407 CASTANHA DE CAJU
//      2     UN           8,98      A       17,96
//02   7891700019880 MAIONESE
//     250Kg  UN           3,29      A        3,29
//03   2000000023455 MACA NAC. VERMELHA
//     1.430  KG  x        2,98      A        4,26
//02   7891700019880 MAIONESE
//     250Kg  UN           3,29      A        3,29
//03   2000000023455 MACA NAC. VERMELHA
//     1.430  KG  x        2,98      A        4,26
//02   7891700019880 MAIONESE
//     250Kg  UN           3,29      A        3,29
//03   2000000023455 MACA NAC. VERMELHA
//     1.430  KG  x        2,98      A        4,26
//------------------------------------------------
//TOTAL R$                                   25,51
//DINHEIRO                                   30,00
//TROCO R$                                    4,49
//------------------------------------------------
//OP: 25414  MARIA DA SILVA
//PARA TROCA/DEVOLUCAO DE MERCADORIAS E
//OBRIGATORIO APRESENTACAO DESTE CUPOM.
//-------------------------------------------------
//DADOS DE ENTREGA: HORARIO: DE 17:00 AS 21:00
//NOME: MARIA  SILVA
//RUA TESTE, 150 - MARIAS
//FONE:(31)0000-0000 - BELO HORIZONTE - MG
//-------------------------------------------------
            }



            Output.WriteLine(clisitef.sCupomFiscal);
            Output.WriteLine("%VENDA% - Retorno: " + retorno.ToString());
        }