예제 #1
0
        public void IntegraEstoque()
        {
            ProcessForm processForm = new ProcessForm("", layout);
            processForm.Show();
            List<Estoque> lEstoque = new List<Estoque>();
            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 ESTOQUE ", con))
                    using (OleDbDataReader readerCount = commandCount.ExecuteReader())
                    {
                        while (readerCount.Read())
                        {

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

                        }
                    }
                    try
                    {

                        using (OleDbCommand command = new OleDbCommand("SELECT SKU_PRODUTO,ID_DISTRIBUIDOR,QUANTIDADE_ATUAL_ESTOQUE,QUANTIDADE_ULTIMA_COMPRA,QUANTIDADE_ULTIMA_VENDA,DATA_PRIMEIRA_COMPRA,DATA_ULTIMA_COMPRA,DATA_ULTIMA_VENDA,VALOR_CUSTO_UNITARIO_ESTOQUE,VALOR_CUSTO_TOTAL_ESTOQUE FROM ESTOQUE", con))
                        using (OleDbDataReader reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                Estoque estoque = new Estoque();
                                Validator valid = new Validator();

                                estoque.produtoId = reader.GetString(0);
                                estoque.distribuidorId = reader.GetString(1);
                                estoque.quantidadeAtualEstoque = reader.GetString(2);
                                estoque.quantidadeUltimaCompra = reader.GetString(3);
                                estoque.quantidadeUltimaVenda = reader.GetString(4);

                                if (reader.IsDBNull(5))
                                {
                                    estoque.dataPrimeiraCompra = valid.ValidaString();
                                }
                                else
                                {
                                    estoque.dataPrimeiraCompra = (reader.GetString(5));
                                }

                                if (reader.IsDBNull(6))
                                {
                                    estoque.dataUltimaCompra = valid.ValidaString();
                                }
                                else
                                {
                                    estoque.dataUltimaCompra = (reader.GetString(6));
                                }

                                if (reader.IsDBNull(7))
                                {
                                    estoque.dataUltimaVenda = valid.ValidaString();
                                }
                                else
                                {
                                    estoque.dataUltimaVenda = (reader.GetString(7));
                                }

                                estoque.valorCustoUnitarioEstoque = reader.GetString(8);
                                estoque.valorCustoTotalEstoque = reader.GetString(9);

                                PostEstoque(estoque);

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

                                lEstoque.Add(estoque);
                            }
                        }

                        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 = lEstoque.Count();
                //MessageBox.Show("Foram inseridos "+countWrite.ToString()+" registros", "Advetisament", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                processForm.Close();
            }
        }
예제 #2
0
 private void estoqueToolStripMenuItem_Click(object sender, EventArgs e)
 {
     Estoque es = new Estoque();
     es.IntegraEstoque();
 }
예제 #3
0
        public void PostEstoque(Estoque estoque)
        {
            var param = Newtonsoft.Json.JsonConvert.SerializeObject(estoque);
            var httpClient = new HttpClient();
            HttpContent contentPost = new StringContent(param, Encoding.UTF8, "application/json");

            var response = httpClient.PostAsync("https://chevron.exata.it/api/Estoque", 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());
            }
        }
예제 #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();
            }
        }