Ejemplo n.º 1
0
        public void PostPedido(Pedido pedido)
        {
            var param = Newtonsoft.Json.JsonConvert.SerializeObject(pedido);
            var httpClient = new HttpClient();
            HttpContent contentPost = new StringContent(param, Encoding.UTF8, "application/json");

            var response = httpClient.PostAsync("https://chevron.exata.it/api/Pedido", contentPost);
            //MessageBox.Show(param.ToString() + "response: " + response.Result.ToString(), "Advetisament", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            if (response.Result.StatusCode.ToString() != "Accepted")
            {
                logErro.EscreverLog(layout, response.Result.ToString());
            }
        }
Ejemplo n.º 2
0
 private void pedidoToolStripMenuItem_Click(object sender, EventArgs e)
 {
     Pedido p = new Pedido();
     p.IntegraPedido();
 }
Ejemplo n.º 3
0
        public void IntegraPedido()
        {
            ProcessForm processForm = new ProcessForm("", layout);
            processForm.Show();
            List<Pedido> lPedido = new List<Pedido>();

            IEnumerable<String> streamRead = File.ReadLines(System.Environment.CurrentDirectory.ToString() + "\\config.txt");
            var connection = streamRead.First();
            //int index = 0;

            using (OleDbConnection con = new OleDbConnection(connection))
            {
                try
                {
                    con.Open();

                    using (OleDbCommand commandCount = new OleDbCommand("SELECT COUNT(*) FROM PEDIDOS ", con))
                    using (OleDbDataReader readerCount = commandCount.ExecuteReader())
                    {
                        while (readerCount.Read())
                        {

                            countRegister = readerCount.GetValue(0).ToString();

                        }
                    }
                    try
                    {
                        using (OleDbCommand command = new OleDbCommand("SELECT SKU_PRODUTO,ID_CLIENTE,ID_DISTRIBUIDOR,ID_FV,ID_FORMA_PAGAMENTO,NUMERO_PEDIDO,DATA_PEDIDO,QUANTIDADE_ITEM_PEDIDO,VALOR_UNITARIO_PEDIDO,VALOR_TOTAL_ITEM_PEDIDO,CFOP_PEDIDO,NATUREZA_OPERACAO_NF,FLAG_PEDIDO_ITEM_CANCELADO,DATA_PEDIDO_ITEM_CANCELADO FROM PEDIDOS", con))
                        using (OleDbDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            Pedido pedido = new Pedido();

                            pedido.produtoId = reader.GetString(0);
                            pedido.clienteId= reader.GetString(1);
                            pedido.distribuidorId = reader.GetString(2);
                            pedido.forcaDeVendaId=reader.GetString(3);
                            pedido.formaDePagamentoId = reader.GetString(4);
                            pedido.numeroPedido = reader.GetString(5);
                            pedido.data = reader.GetString(6);
                            pedido.quantidadeItens = reader.GetString(7);
                            pedido.valorUnitario = reader.GetString(8);
                            pedido.valorTotalItens = reader.GetString(9);
                            pedido.cfop = reader.GetString(10);
                            pedido.naturezaOperacaoNF = reader.GetString(11);
                            pedido.flagItemCancelado = reader.GetString(12);
                            pedido.dataItemCancelado = reader.GetString(13);

                            PostPedido(pedido);

                            string msg = "Foram inseridos: " + lPedido.Count().ToString() +" de "+countRegister+ " registros";
                            processForm.writeMessage(msg);
                            processForm.Enabled = false;
                            processForm.Enabled = true;

                            lPedido.Add(pedido);
                            //index++;
                        }
                        }
                        con.Dispose();
                    }

                    catch (Exception ex)
                    {
                        logErro.EscreverLog(layout, ex.Message.ToString());
                        //MessageBox.Show(ex.Message.ToString(), "Advetisament", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }

                }
                catch (Exception ex)
                {
                    logErro.EscreverLog(layout, ex.Message.ToString());
                    //MessageBox.Show(ex.Message.ToString(), "Advetisament", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }

                int countWrite = lPedido.Count();
                //MessageBox.Show("Foram inseridos "+countWrite.ToString()+" registros", "Advetisament", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                processForm.Close();
                //return index;
        }
Ejemplo n.º 4
0
        private void Timer_Tick(object sender, EventArgs e)
        {
            //MessageBox.Show("Começou!!!");
            interval--;
            label1.Text = interval.ToString();
            if(interval==0){

                Timer.Stop();

                CarteiraCliente carteiraCliente = new CarteiraCliente();
                Cliente cliente = new Cliente();
                EnderecoCliente enderecoCliente = new EnderecoCliente();
                Estoque estoque = new Estoque();
                Faturamento faturamento = new Faturamento();
                ForcaDeVenda forcaDeVenda = new ForcaDeVenda();
                FormaDePagamento formaDePagamento = new FormaDePagamento();
                Pedido pedido = new Pedido();
                Produto produto = new Produto();
                TabelaPreco tabelaPreco = new TabelaPreco();

                carteiraCliente.IntegraCarteiraCliente();
                cliente.IntegraCliente();
                enderecoCliente.IntegraEnderecoCliente();
                estoque.IntegraEstoque();
                faturamento.IntegraFaturamento();
                forcaDeVenda.IntegraForcaDeVenda();
                formaDePagamento.IntegraFormaDePagamento();
                pedido.IntegraPedido();
                produto.IntegraProduto();
                tabelaPreco.IntegraTabelaPreço();

                Timer.Enabled = true;
                //interval = 10;
                interval = int.Parse(System.Configuration.ConfigurationManager.AppSettings["Interval"]);
                //interval = ChevronClienteApplication.
                Timer.Start();
            }
        }