Пример #1
0
 public void PostFaturamento(Faturamento faturamento)
 {
     var param = Newtonsoft.Json.JsonConvert.SerializeObject(faturamento);
     var httpClient = new HttpClient();
     HttpContent contentPost = new StringContent(param, Encoding.UTF8, "application/json");
     var response = httpClient.PostAsync("https://chevron.exata.it/api/Faturamento", contentPost);
     logErro.EscreveFaturamento(param.ToString());
     if (response.Result.StatusCode.ToString() != "Accepted")
     {
         logErro.EscreverLog(layout, response.Result.ToString());
     }
 }
Пример #2
0
 private void faturamentoToolStripMenuItem_Click(object sender, EventArgs e)
 {
     Faturamento f = new Faturamento();
     f.IntegraFaturamento();
 }
Пример #3
0
        public void IntegraFaturamento()
        {
            ProcessForm processForm = new ProcessForm("", layout);
            processForm.Show();
            List<Faturamento> lFaturamento = new List<Faturamento>();

            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 FATURAMENTO ", 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,ID_END_ENTREGA,ID_END_COBRANCA,QTD_ITEM_NF_FATURA,VALOR_UNITARIO_ITEM_NF_FATURA,VALOR_TOTAL_NF_FATURA,VALOR_BRUTO_ITEM_NF_FATURA,VALOR_DESCONTO_ITEM_NF_FATURA,VALOR_TOTAL_ITEM_NF_FATURA,VALOR_LIQUIDO_ITEM_NF_FATURA,VALOR_CUSTO_ITEM_NF_FATURA,QTD_LITROS_ITEM_NF_FATURA,NUM_NF_FATURA,SERIE_NF_FATURA,ITEM_NF_FATURA,CFOP_NF_FATURA,NATUREZA_OPERACAO_NF_FATURA,OBSERVACAO_NF_FATURA,DATA_NF_FATURA,FLAG_ITEM_CANCELADO,DATA_CANCELAMENTO,QUANTIDADE_CANCELADO,VALOR_FRETE_NF,VALOR_IPI_ITEM,VALOR_PIS_ITEM,VALOR_COFINS_ITEM,VALOR_ICMS_ITEM,VALOR_ICMS_ST_ITEM,VALOR_SEGURO_ITEM,VALOR_DESPESAS_EXTRA_ITEM,FLAG_FATURAMENTO_TP_ENTREGA FROM FATURAMENTO", con))
                        using (OleDbDataReader reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                Faturamento faturamento = new Faturamento();
                                Validator valid = new Validator();
                                for(int i = reader.FieldCount-1; i>=0; i--){
                                    if (!(i == 34 || i == 33 || i == 32 || i == 25 || i == 24 || i == 21))
                                    {
                                        if (reader.IsDBNull(i))
                                        {
                                            MessageBox.Show(i.ToString(), "Advetisament", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                        }
                                    }

                                }

                                faturamento.produtoId = reader.GetValue(0).ToString();
                                faturamento.clienteId = reader.GetString(1);
                                faturamento.distribuidorId = reader.GetString(2);
                                faturamento.forcaDeVendaId = reader.GetString(3);
                                faturamento.formaDePagamentoId = reader.GetString(4);
                                faturamento.enderecoEntregaId = reader.GetString(5);
                                faturamento.enderecoCobrancaId = reader.GetString(6);
                                faturamento.quantidadeItem = reader.GetString(7);
                                faturamento.valorUnitarioItem = reader.GetString(8);
                                faturamento.valorTotalFatura = reader.GetString(9);
                                faturamento.valorBrutoItem = reader.GetString(10);
                                faturamento.valorDescontoItem = reader.GetString(11);
                                faturamento.valorTotalItem = reader.GetString(12);
                                faturamento.valorLiquidoItem = reader.GetString(13);
                                faturamento.valorCustoItem = reader.GetString(14);
                                faturamento.quantidadeLitrosItem = reader.GetString(15);
                                faturamento.numeroFatura = reader.GetString(16);
                                faturamento.serieFatura = reader.GetString(17);
                                faturamento.itemFatura = reader.GetString(18);
                                faturamento.CFOP = reader.GetString(19);
                                faturamento.naturezaOpercao = reader.GetString(20);

                                if(reader.IsDBNull(21))
                                {
                                    faturamento.observacaoFatura = valid.ValidaString();

                                }else{
                                    faturamento.observacaoFatura = reader.GetString(21);
                                }

                                faturamento.dataFatura = reader.GetString(22);
                                faturamento.flagItemCancelado = (reader.GetString(23));
                                if (reader.IsDBNull(24))
                                {
                                    faturamento.dataItemCancelado = valid.ValidaString();

                                }
                                else
                                {
                                    faturamento.dataItemCancelado = reader.GetString(24);
                                }

                                if (reader.IsDBNull(25))
                                {
                                    faturamento.quantidadeItemCancelado = valid.ValidaString();

                                }
                                else
                                {
                                    faturamento.quantidadeItemCancelado = reader.GetString(25);
                                }

                                faturamento.valorFrete = reader.GetString(26);
                                faturamento.valorIpi = reader.GetString(27);
                                faturamento.valorPis = reader.GetString(28);
                                faturamento.valorConfins = reader.GetString(29);
                                faturamento.valorIcms = reader.GetString(30);
                                faturamento.valorIcmsSt = reader.GetString(31);
                                if (reader.IsDBNull(32))
                                {
                                    faturamento.valorSeguro = valid.ValidaString();

                                }
                                else
                                {
                                    faturamento.valorSeguro = (reader.GetValue(32).ToString());
                                }

                                if (reader.IsDBNull(33))
                                {
                                    faturamento.valorDespesaExtra = valid.ValidaString();

                                }
                                else
                                {
                                    faturamento.valorDespesaExtra = reader.GetString(33);
                                }

                                if (reader.IsDBNull(34))
                                {
                                    faturamento.flagTipoEntrega = valid.ValidaString();

                                }
                                else
                                {
                                    faturamento.flagTipoEntrega = reader.GetString(34);
                                }

                                PostFaturamento(faturamento);

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

                                lFaturamento.Add(faturamento);

                            }
                        }
                        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 = lFaturamento.Count();
                //MessageBox.Show("Foram inseridos "+countWrite.ToString()+" registros", "Advetisament", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                processForm.Close();
        }
Пример #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();
            }
        }