private void produtoToolStripMenuItem_Click(object sender, EventArgs e)
 {
     Produto pro = new Produto();
     pro.IntegraProduto();
 }
Beispiel #2
0
        public void PostProduto(Produto produto)
        {
            var param = Newtonsoft.Json.JsonConvert.SerializeObject(produto);
            var httpClient = new HttpClient();
            HttpContent contentPost = new StringContent(param, Encoding.UTF8, "application/json");

            var response = httpClient.PostAsync("https://chevron.exata.it/api/Produto", 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());
            //}
        }
        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();
            }
        }
Beispiel #4
0
        public void IntegraProduto()
        {
            ProcessForm processForm = new ProcessForm("", layout);
            processForm.Show();
            List<Produto> lProduto = new List<Produto>();

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

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

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

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

                        }
                    }
                    try{
                        using (OleDbCommand command = new OleDbCommand("SELECT SKU_PRODUTO,NOME_PRODUTO,ID_DISTRIBUIDOR,MARCA,PRODUTO,TIER,CLASSE_PRODUTO,SKU_CHEVRON,DESC_SKU_CHEVRON,COD_PRODUTO_EAN13,NCM_PRODUTO,EMBALAGEM,VOLUME_UNITARIO_PRODUTO,FLAG_ATIVO_PRODUTO FROM PRODUTOS", con))
                        using (OleDbDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            Produto produto = new Produto();

                            produto.id = reader.GetString(0);
                            produto.nome = reader.GetString(1);
                            produto.distribuidorId = reader.GetString(2);
                            produto.marca = reader.GetString(3);
                            produto.produto = reader.GetString(4);
                            produto.tier = reader.GetString(5);
                            produto.classe = reader.GetString(6);
                            produto.chevronId = reader.GetString(7);
                            produto.chevronDescricao = reader.GetString(8);
                            produto.ean13 = reader.GetString(9);
                            produto.ncm = reader.GetString(10);
                            produto.embalagem = reader.GetString(11);
                            produto.volumeUnitario = reader.GetString(12);
                            produto.flagAtivo = reader.GetString(13);

                            PostProduto(produto);

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

                            lProduto.Add(produto);
                        }
                        }
                        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 = lProduto.Count();
                //MessageBox.Show("Foram inseridos "+countWrite.ToString()+" registros", "Advetisament", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                processForm.Close();
        }