Exemplo n.º 1
0
        void infornota_Retorno(DadosNota nota)
        {
            MsgBox.Show.EspereFechar();

            Boolean semlote = false;

            for (int a = 0; a < nota.produto.Count; a++)
            {
                if (nota.produto[a].lote.Count > 0)
                {
                    semlote = true;
                }
            }

            if (!semlote)
            {
                MsgBox.Show.Error("A nota fiscal " + nota.nota + " que você quer adicionar não existe lotes segregados para ela." + Environment.NewLine + "" + Environment.NewLine + "Cfop:" + nota.cfop + "");
            }
            else
            {
                if (MsgBox.Show.Pergunta("Voce quer mesmo adicionar." + Environment.NewLine + "Nota Fiscal:" + nota.nota + "" + Environment.NewLine + "" + Environment.NewLine + "Cliente :" + nota.cliente + "" + Environment.NewLine + "" + Environment.NewLine + "Cfop:" + nota.cfop + "" + Environment.NewLine + "" + Environment.NewLine + "Cfaz:" + nota.cfaz + ""))
                {
                    Injetar(nota);
                }
            }
        }
Exemplo n.º 2
0
        private void Injetar(DadosNota nota)
        {
            DateTime emissao = DateTime.Parse(nota.data);

            data_emissao.SelectedDate = emissao;
            txt_cliente.Text          = nota.cliente;
            cbo_estado.Text           = nota.estado;
            txt_cidade.Text           = nota.cidade;
            txt_nota.Text             = nota.nota;



            for (int a = 0; a < nota.produto.Count; a++)
            {
                double liquido = 0;
                double bruto   = 0;

                for (int c = 0; c < produtos.Rows.Count; c++)
                {
                    if (produtos.Rows[c]["idsap"].ToString() == nota.produto[a].produto.ToString())
                    {
                        try
                        {
                            liquido = double.Parse(produtos.Rows[c]["peso"].ToString() + "");
                        }
                        catch { }

                        string bbb = produtos.Rows[c]["conversao"] + "";
                        try
                        {
                            bruto = double.Parse(bbb);
                        }
                        catch { }
                    }
                }

                InjectarPorIdSap(nota.produto[a].produto);
                for (int b = 0; b < nota.produto[a].lote.Count; b++)
                {
                    double qtd_pallet = double.Parse(nota.produto[a].volume[b] + "") / liquido;

                    double brutal = qtd_pallet * bruto;

                    txt_lote.Text    = nota.produto[a].lote[b];
                    txt_liquido.Text = nota.produto[a].volume[b] + "";
                    txt_bruto.Text   = brutal + "";
                    btn_add_Click(null, null);
                }
            }
        }
Exemplo n.º 3
0
        public DadosNota RetornarInformacao(string arquivo)
        {
            StreamReader leitor = new StreamReader(arquivo);
            string       x      = leitor.ReadToEnd();

            leitor.Close();
            if (x.IndexOf("infEvento") != -1)
            {
                return(null);
            }
            int    p1    = x.IndexOf("Id=") + 4;
            string nfe   = x.Substring(p1, 47);
            string nota  = sub(x, "<nNF>", "</nNF>");
            string cfaz  = sub(x, "<xMotivo>", "</xMotivo>");
            double valor = 0;

            try
            {
                valor = double.Parse(sub(x, "</vST><vProd>", "</vProd><vFrete>"));
            }
            catch { }
            string data = sub(x, "Emi>", "</d");
            string dia  = "";

            dia = data.Substring(8, 2);
            string mes = "";

            mes = data.Substring(5, 2);
            string ano = "";

            ano  = data.Substring(0, 4);
            data = "" + dia + "/" + mes + "/" + ano + "";
            string xcliente           = sub(x, "<dest>", "</dest>");
            string cliente            = sub(xcliente, "<xNome>", "</xNome>");
            string UF                 = sub(xcliente, "<UF>", "</UF>");
            string cidade             = sub(xcliente, "<xMun>", "</xMun>");
            string bairro             = sub(xcliente, "<xBairro>", "</xBairro>");
            string rua                = sub(xcliente, "<xLgr>", "</xLgr>");
            string numero             = sub(xcliente, "<nro>", "</nro>");
            string pais               = sub(xcliente, "<xPais>", "</xPais>");
            string cep                = sub(xcliente, "<CEP>", "</CEP>");
            string fone               = sub(xcliente, "<fone>", "</fone>");
            string email              = sub(xcliente, "<email>", "</email>");
            string cnpj_cliente       = sub(xcliente, "<CNPJ>", "</CNPJ>");
            string cfop               = sub(x, "<natOp>", "</natOp>");
            string xtraps             = sub(x, "<transp>", "</transp>");
            string cnpj_trasportadora = sub(xtraps, "<CNPJ>", "</CNPJ>");
            string transportadora     = sub(xtraps, "<xNome>", "</xNome>");
            string embalegem          = sub(xtraps, "<esp>", "</esp>");
            string qtd_embalagem      = sub(xtraps, "<qVol>", "</qVol>");
            double peso_liquido       = 0;
            double peso_bruto         = 0;

            try
            {
                peso_liquido = double.Parse(sub(xtraps, "<pesoL>", "</pesoL>")) / 1000;
            }
            catch { }
            try
            {
                peso_bruto = double.Parse(sub(xtraps, "<pesoB>", "</pesoB>")) / 1000;
            }
            catch { }



            List <Produto> n = new List <Produto>();

            string y = sub(x, "<det ", "<total>");

            for (int p = 0; p <= 1000; p++)
            {
                if (y.IndexOf("<cProd>") == -1)
                {
                    break;
                }

                Produto       po     = new Produto();
                List <string> lotes  = new List <string>();
                List <double> volume = new List <double>();

                po.produto = sub(y, "<cProd>", "</cProd>");
                po.valor   = 0;
                try
                {
                    po.valor = double.Parse(sub(y, "<vProd>", "</vProd>")) / 100;
                }
                catch { }



                p1 = y.IndexOf("<infAdProd>") + 11;
                int p2 = y.IndexOf("</infAdProd>");
                if (p2 < 0)
                {
                    p2 = 0;
                }
                int p3 = p2 - p1;
                int pf = p2 + 12;

                if (p3 > 0)
                {
                    string w = y.Substring(p1, p3);



                    for (int b1 = 0; b1 < 1000; b1++)
                    {
                        if (w.IndexOf("Lote") == -1)
                        {
                            break;
                        }

                        p1 = w.IndexOf("Lote");
                        p2 = w.Length;
                        if (p2 < 0)
                        {
                            p2 = 0;
                        }
                        p3 = p2 - p1;

                        w = w.Substring(p1, p3);

                        p1 = w.IndexOf("Lote:") + 5;
                        p2 = w.IndexOf(",");
                        if (p2 < 0)
                        {
                            p2 = 0;
                        }
                        p3 = p2 - p1;

                        string p1l = w.Substring(p1, p3);


                        p1 = 0;
                        p2 = p1l.IndexOf("Qtde:");
                        if (p2 < 0)
                        {
                            p2 = 0;
                        }
                        p3 = p2 - p1;

                        string lot = p1l.Substring(p1, p3).Trim();

                        p1 = p1l.IndexOf("Qtde:") + 5;
                        p2 = p1l.Length;
                        if (p2 < 0)
                        {
                            p2 = 0;
                        }
                        p3 = p2 - p1;

                        string vol = p1l.Substring(p1, p3).Trim();

                        lotes.Add(lot);
                        volume.Add(double.Parse(vol));


                        p1 = w.IndexOf(",");
                        p2 = w.Length;
                        if (p2 < 0)
                        {
                            p2 = 0;
                        }
                        p3 = p2 - p1;

                        w = w.Substring(p1, p3);
                    }
                }
                po.lote   = lotes;
                po.volume = volume;
                n.Add(po);


                p1 = pf;
                p2 = y.Length;
                p3 = p2 - p1;

                y = y.Substring(p1, p3);
            }

            DadosNota novo = new DadosNota();

            novo.cfop                = cfop;
            novo.cidade              = cidade;
            novo.cliente             = cliente;
            novo.data                = data;
            novo.estado              = UF;
            novo.nota                = nota;
            novo.Valor               = valor / 100;
            novo.produto             = n;
            novo.cfaz                = cfaz;
            novo.bairro              = bairro;
            novo.rua                 = rua;
            novo.numero              = numero;
            novo.cep                 = cep;
            novo.pais                = pais;
            novo.fone                = fone;
            novo.email               = email;
            novo.cnpj_cliente        = cnpj_cliente;
            novo.cnpj_transportadora = cnpj_trasportadora;
            novo.transportadora      = transportadora;
            novo.embalegem           = embalegem;
            novo.qtd_embalagem       = qtd_embalagem;
            novo.peso_liquido        = peso_liquido;
            novo.peso_bruto          = peso_bruto;


            double con = 0;

            for (int a = 0; a < n.Count; a++)
            {
                con += n[a].valor;
            }

            novo.dif_valor = novo.Valor - con;

            try
            {
                File.Delete(Config.local + "" + Nota + ".retorno");
            }
            catch { }
            return(novo);
        }
Exemplo n.º 4
0
        void infornota_Retorno(DadosNota x)
        {
            try
            {
                ogrid.ItemsSource = null;
            }
            catch { }
            MsgBox.Show.EspereFechar();



            nota.Content           = x.nota;
            data.Content           = x.data;
            cliente.Content        = x.cliente;
            estado.Content         = x.estado;
            cidade.Content         = x.cidade;
            bairro.Content         = x.bairro;
            rua.Content            = x.rua;
            cep.Content            = x.cep;
            pais.Content           = x.pais;
            telefone.Content       = x.fone;
            email.Content          = x.email;
            cnpj.Content           = x.cnpj_cliente;
            cfop.Content           = x.cfop;
            cfaz.Content           = x.cfaz;
            valor.Content          = x.Valor;
            dif_valor.Content      = x.dif_valor;
            transportadora.Content = x.transportadora;
            cnpj_transp.Content    = x.cnpj_transportadora;
            embalagem.Content      = x.embalegem;
            qtd_embalagem.Content  = x.qtd_embalagem;
            peso_bruto.Content     = x.peso_bruto;
            peso_liquido.Content   = x.peso_liquido;

            DataTable tabela = new DataTable();

            tabela.Columns.Add("Produto", typeof(string));
            tabela.Columns.Add("Valor", typeof(double));
            tabela.Columns.Add("Lote", typeof(string));
            tabela.Columns.Add("Volume", typeof(double));

            for (int a = 0; a < x.produto.Count; a++)
            {
                string p  = "";
                double v  = 0;
                string l  = "";
                double vo = 0;

                p = x.produto[a].produto + "";
                v = x.produto[a].valor;

                for (int b = 0; b < x.produto[a].lote.Count; b++)
                {
                    l  = x.produto[a].lote[b] + "";
                    vo = x.produto[a].volume[b];

                    tabela.Rows.Add(p, v, l, vo);
                }

                if (tabela.Rows.Count <= 0)
                {
                    tabela.Rows.Add(p, v, l, v);
                }
            }

            ogrid.ItemsSource = tabela.DefaultView;
        }