Example #1
0
        public void Carrega(string seqNF)
        {
            try
            {
                DataTable dt = BuscaFrete(seqNF);

                if (dt.Rows.Count > 0)
                {
                    DataRow drTranspor = dt.Rows[0];
                    if (drTranspor["modFrete"].ToString() == "0")
                    {
                        this.Modfrete = "0";
                    }
                    else if (drTranspor["modFrete"].ToString() == "1") // destinatario
                    {
                        this.Modfrete = "1";
                    }
                    else if (drTranspor["modFrete"].ToString() == "2")
                    {
                        this.Modfrete = "2";
                    }
                    else
                    {
                        this.Modfrete = "9";
                    }
                    belTransportadora thisortadora = new belTransportadora();

                    if (drTranspor["st_pessoaj"].ToString() == "S")
                    {
                        if (drTranspor["CNPJ"].ToString() != "")
                        {
                            thisortadora.Cnpj = Util.TiraSimbolo(drTranspor["CNPJ"].ToString().PadLeft(14, '0'), "");
                        }
                    }
                    else
                    {
                        if (drTranspor["CD_CPF"].ToString() != "")
                        {
                            thisortadora.Cpf = Util.TiraSimbolo(drTranspor["CD_CPF"].ToString().PadLeft(11, '0'), "");
                        }
                    }

                    if (drTranspor["xnome"] != null)
                    {
                        int iTamanho = drTranspor["xnome"].ToString().Length - 1;
                        if (iTamanho > 59)
                        {
                            iTamanho           = 59;
                            thisortadora.Xnome = Util.TiraSimbolo(drTranspor["xnome"].ToString().Substring(0, iTamanho), "");
                        }
                        else
                        {
                            thisortadora.Xnome = Util.TiraSimbolo(drTranspor["xnome"].ToString().Substring(0, drTranspor["xnome"].ToString().Length), "");
                        }
                    }

                    if (drTranspor["IE"].ToString() != "")
                    {
                        thisortadora.Ie = Util.TiraSimbolo(drTranspor["IE"].ToString(), "");
                    }

                    if (drTranspor["xEnder"].ToString() != "")
                    {
                        thisortadora.Xender = Util.TiraSimbolo(drTranspor["xEnder"].ToString(), "");
                    }
                    if (drTranspor["xMun"].ToString() != "")
                    {
                        thisortadora.Xmun = Util.TiraSimbolo(drTranspor["xMun"].ToString(), "");
                    }
                    if (drTranspor["UF"].ToString() != "")
                    {
                        thisortadora.Uf = drTranspor["UF"].ToString();
                    }
                    this.belTransportadora = thisortadora;
                    if ((drTranspor["placa"].ToString() != "") && (drTranspor["placa"].ToString() != null))
                    {
                        this.belVeicTransp.Placa = Util.TiraSimbolo(drTranspor["placa"].ToString().Replace(" ", "").Trim(), "");
                        if (drTranspor["UF"].ToString() != "")
                        {
                            this.belVeicTransp.Uf = drTranspor["UF"].ToString().Trim();
                        }

                        if (drTranspor["RNTC"].ToString() != "")
                        {
                            this.belVeicTransp.Rntc = drTranspor["RNTC"].ToString().Trim();
                        }
                        else
                        {
                            this.belVeicTransp.Rntc = "00";
                        }
                    }


                    try
                    {
                        decimal dqVol = Convert.ToDecimal(drTranspor["qVol"].ToString());
                        if ((drTranspor["qVol"].ToString() == "") || (drTranspor["qVol"].ToString() == "0"))
                        {
                            if (Acesso.NM_EMPRESA != "ZINCOBRIL")
                            {
                                dqVol = 1;
                            }
                            else
                            {
                                dqVol = 0;
                            }
                        }
                        this.belVol.Qvol = dqVol;
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(string.Format("{0} - Campo de Quantidade de Volumes na tela de Montar NF",
                                                          ex.Message));
                    }

                    if (drTranspor["nVol"].ToString() != "")
                    {
                        this.belVol.Nvol = drTranspor["nVol"].ToString();
                    }

                    if (drTranspor["esp"].ToString() != "")
                    {
                        this.belVol.Esp = Util.TiraSimbolo(drTranspor["esp"].ToString(), "");
                    }

                    if (drTranspor["marca"].ToString() != "")
                    {
                        this.belVol.Marca = drTranspor["marca"].ToString();
                    }
                    if (drTranspor["pesoL"].ToString() != "")
                    {
                        try
                        {
                            decimal dpesoL = Math.Round(Convert.ToDecimal(drTranspor["pesoL"].ToString()), 3);
                            this.belVol.PesoL = dpesoL;
                        }
                        catch (Exception ex)
                        {
                            throw new Exception(string.Format("{0} - Campo Peso Liquido",
                                                              ex.Message));
                        }
                    }
                    if (drTranspor["pesoB"].ToString() != "")
                    {
                        try
                        {
                            decimal dpesoB = Math.Round(Convert.ToDecimal(drTranspor["pesoB"].ToString()), 3);
                            this.belVol.PesoB = dpesoB;
                        }
                        catch (Exception ex)
                        {
                            throw new Exception(string.Format("{0} - Campo Peso Bruto",
                                                              ex.Message));
                        }
                    }
                }
                else
                {
                    this.Modfrete = "9";
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #2
0
        public void Carrega(string seqNF)
        {
            try
            {
                DataTable dt = BuscaFrete(seqNF);

                if (dt.Rows.Count > 0)
                {
                    DataRow drTranspor = dt.Rows[0];
                    if (drTranspor["modFrete"].ToString() == "0")
                    {
                        this.Modfrete = "0";
                    }
                    else if (drTranspor["modFrete"].ToString() == "1") // destinatario
                    {
                        this.Modfrete = "1";
                    }
                    else if (drTranspor["modFrete"].ToString() == "2")
                    {
                        this.Modfrete = "2";
                    }
                    else
                    {
                        this.Modfrete = "9";
                    }
                    belTransportadora thisortadora = new belTransportadora();

                    if (drTranspor["st_pessoaj"].ToString() == "S")
                    {
                        if (drTranspor["CNPJ"].ToString() != "")
                        {
                            thisortadora.Cnpj = Util.TiraSimbolo(drTranspor["CNPJ"].ToString().PadLeft(14, '0'), "");
                        }
                    }
                    else
                    {
                        if (drTranspor["CD_CPF"].ToString() != "")
                        {
                            thisortadora.Cpf = Util.TiraSimbolo(drTranspor["CD_CPF"].ToString().PadLeft(11, '0'), "");
                        }

                    }

                    if (drTranspor["xnome"] != null)
                    {

                        int iTamanho = drTranspor["xnome"].ToString().Length - 1;
                        if (iTamanho > 59)
                        {
                            iTamanho = 59;
                            thisortadora.Xnome = Util.TiraSimbolo(drTranspor["xnome"].ToString().Substring(0, iTamanho), "");
                        }
                        else
                        {
                            thisortadora.Xnome = Util.TiraSimbolo(drTranspor["xnome"].ToString().Substring(0, drTranspor["xnome"].ToString().Length), "");
                        }
                    }

                    if (drTranspor["IE"].ToString() != "")
                    {
                        thisortadora.Ie = Util.TiraSimbolo(drTranspor["IE"].ToString(), "");
                    }

                    if (drTranspor["xEnder"].ToString() != "")
                    {
                        thisortadora.Xender = Util.TiraSimbolo(drTranspor["xEnder"].ToString(), "");
                    }
                    if (drTranspor["xMun"].ToString() != "")
                    {
                        thisortadora.Xmun = Util.TiraSimbolo(drTranspor["xMun"].ToString(), "");
                    }
                    if (drTranspor["UF"].ToString() != "")
                    {
                        thisortadora.Uf = drTranspor["UF"].ToString();
                    }
                    this.belTransportadora = thisortadora;
                    if ((drTranspor["placa"].ToString() != "") && (drTranspor["placa"].ToString() != null))
                    {
                        this.belVeicTransp.Placa = Util.TiraSimbolo(drTranspor["placa"].ToString().Replace(" ", "").Trim(), "");
                        if (drTranspor["UF"].ToString() != "")
                        {
                            this.belVeicTransp.Uf = drTranspor["UF"].ToString().Trim();
                        }

                        if (drTranspor["RNTC"].ToString() != "")
                        {
                            this.belVeicTransp.Rntc = drTranspor["RNTC"].ToString().Trim();
                        }
                        else
                        {
                            this.belVeicTransp.Rntc = "00";
                        }
                    }


                    try
                    {
                        decimal dqVol = Convert.ToDecimal(drTranspor["qVol"].ToString());
                        if ((drTranspor["qVol"].ToString() == "") || (drTranspor["qVol"].ToString() == "0"))
                        {
                            if (Acesso.NM_EMPRESA != "ZINCOBRIL")
                            {
                                dqVol = 1;
                            }
                            else
                            {
                                dqVol = 0;
                            }

                        }
                        this.belVol.Qvol = dqVol;
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(string.Format("{0} - Campo de Quantidade de Volumes na tela de Montar NF",
                                            ex.Message));
                    }

                    if (drTranspor["nVol"].ToString() != "")
                    {
                        this.belVol.Nvol = drTranspor["nVol"].ToString();
                    }

                    if (drTranspor["esp"].ToString() != "")
                    {
                        this.belVol.Esp = Util.TiraSimbolo(drTranspor["esp"].ToString(), "");
                    }

                    if (drTranspor["marca"].ToString() != "")
                    {
                        this.belVol.Marca = drTranspor["marca"].ToString();
                    }
                    if (drTranspor["pesoL"].ToString() != "")
                    {
                        try
                        {
                            decimal dpesoL = Math.Round(Convert.ToDecimal(drTranspor["pesoL"].ToString()), 3);
                            this.belVol.PesoL = dpesoL;
                        }
                        catch (Exception ex)
                        {
                            throw new Exception(string.Format("{0} - Campo Peso Liquido",
                                                              ex.Message));
                        }
                    }
                    if (drTranspor["pesoB"].ToString() != "")
                    {
                        try
                        {
                            decimal dpesoB = Math.Round(Convert.ToDecimal(drTranspor["pesoB"].ToString()), 3);
                            this.belVol.PesoB = dpesoB;
                        }
                        catch (Exception ex)
                        {
                            throw new Exception(string.Format("{0} - Campo Peso Bruto",
                                                             ex.Message));
                        }
                    }
                }
                else
                {
                    this.Modfrete = "9";
                }                
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #3
0
        public belTransp xmlBuscaTransp()
        {
            belTransp objTransp = new belTransp();
            XmlDocument xTransp = new XmlDocument();

            try
            {
                xTransp.LoadXml(xDoc.GetElementsByTagName("transp")[0].OuterXml);

                objTransp.Modfrete = xTransp.GetElementsByTagName("modFrete")[0].InnerText;

                XmlDocument xTransporta = new XmlDocument();

                if (xTransp.GetElementsByTagName("transporta")[0] != null)
                {
                    xTransporta.LoadXml(xTransp.GetElementsByTagName("transporta")[0].OuterXml);

                    belTransportadora objTransportadora = new belTransportadora();
                    if (xTransporta.GetElementsByTagName("CNPJ").Count > 0)
                    {
                        objTransportadora.Cnpj = xTransporta.GetElementsByTagName("CNPJ")[0].InnerText;
                    }
                    if (xTransporta.GetElementsByTagName("CPF").Count > 0)
                    {
                        objTransportadora.Cpf = xTransporta.GetElementsByTagName("CPF")[0].InnerText;
                    }
                    if (xTransporta.GetElementsByTagName("xNome").Count > 0)
                    {
                        objTransportadora.Xnome = xTransporta.GetElementsByTagName("xNome")[0].InnerText;
                    }
                    if (xTransporta.GetElementsByTagName("IE").Count > 0)
                    {
                        objTransportadora.Ie = xTransporta.GetElementsByTagName("IE")[0].InnerText;
                    }
                    if (xTransporta.GetElementsByTagName("xEnder").Count > 0)
                    {
                        objTransportadora.Xender = xTransporta.GetElementsByTagName("xEnder")[0].InnerText;
                    }
                    if (xTransporta.GetElementsByTagName("xMun").Count > 0)
                    {
                        objTransportadora.Xmun = xTransporta.GetElementsByTagName("xMun")[0].InnerText;
                    }
                    if (xTransporta.GetElementsByTagName("UF").Count > 0)
                    {
                        objTransportadora.Uf = xTransporta.GetElementsByTagName("UF")[0].InnerText;
                    }

                    objTransp.belTransportadora = objTransportadora;
                }



                if (xTransp.GetElementsByTagName("retTransp").Count > 0)
                {
                    XmlDocument xRetTransp = new XmlDocument();
                    xRetTransp.LoadXml(xTransp.GetElementsByTagName("retTransp")[0].OuterXml);

                    belRetTransp objRetTransp = new belRetTransp();
                    if (xRetTransp.GetElementsByTagName("vServ").Count > 0)
                    {
                        objRetTransp.Vserv = Convert.ToDecimal(xRetTransp.GetElementsByTagName("vServ")[0].InnerText.ToString().Replace(".", ","));
                    }
                    if (xRetTransp.GetElementsByTagName("vBCRet").Count > 0)
                    {
                        objRetTransp.Vbvret = Convert.ToDecimal(xRetTransp.GetElementsByTagName("vBCRet")[0].InnerText.ToString().Replace(".", ","));
                    }
                    if (xRetTransp.GetElementsByTagName("pICMSRet").Count > 0)
                    {
                        objRetTransp.Picmsret = Convert.ToDecimal(xRetTransp.GetElementsByTagName("pICMSRet")[0].InnerText.ToString().Replace(".", ","));
                    }
                    if (xRetTransp.GetElementsByTagName("vICMSRet").Count > 0)
                    {
                        objRetTransp.Vicmsret = Convert.ToDecimal(xRetTransp.GetElementsByTagName("vICMSRet")[0].InnerText.ToString().Replace(".", ","));
                    }
                    if (xRetTransp.GetElementsByTagName("CFOP").Count > 0)
                    {
                        objRetTransp.Cfop = xRetTransp.GetElementsByTagName("CFOP")[0].InnerText;
                    }
                    if (xRetTransp.GetElementsByTagName("cMunFG").Count > 0)
                    {
                        objRetTransp.Cmunfg = xRetTransp.GetElementsByTagName("cMunFG")[0].InnerText;
                    }
                    objTransp.belRetTransp = objRetTransp;

                }

                if (xTransp.GetElementsByTagName("veicTransp").Count > 0)
                {
                    XmlDocument xveicTransp = new XmlDocument();
                    xveicTransp.LoadXml(xTransp.GetElementsByTagName("veicTransp")[0].OuterXml);

                    belVeicTransp objVeictransp = new belVeicTransp();
                    if (xveicTransp.GetElementsByTagName("placa").Count > 0)
                    {
                        objVeictransp.Placa = xveicTransp.GetElementsByTagName("placa")[0].InnerText;
                    }

                    if (xveicTransp.GetElementsByTagName("UF").Count > 0)
                    {
                        objVeictransp.Uf = xveicTransp.GetElementsByTagName("UF")[0].InnerText;
                    }

                    if (xveicTransp.GetElementsByTagName("RNTC").Count > 0)
                    {
                        objVeictransp.Rntc = xveicTransp.GetElementsByTagName("RNTC")[0].InnerText;
                    }

                    objTransp.belVeicTransp = objVeictransp;
                }

                if (xTransp.GetElementsByTagName("reboque").Count > 0)
                {
                    XmlDocument xReboque = new XmlDocument();
                    xReboque.LoadXml(xTransp.GetElementsByTagName("reboque")[0].OuterXml);

                    belReboque objReboque = new belReboque();

                    if (xReboque.GetElementsByTagName("placa").Count > 0)
                    {
                        objReboque.Placa = xReboque.GetElementsByTagName("placa")[0].InnerText;
                    }
                    if (xReboque.GetElementsByTagName("UF").Count > 0)
                    {
                        objReboque.Uf = xReboque.GetElementsByTagName("UF")[0].InnerText;
                    }
                    if (xReboque.GetElementsByTagName("RNTC").Count > 0)
                    {
                        objReboque.Rntc = xReboque.GetElementsByTagName("RNTC")[0].InnerText;
                    }

                    objTransp.belReboque = objReboque;

                }

                if (xTransp.GetElementsByTagName("vol").Count > 0)
                {
                    XmlDocument xVol = new XmlDocument();
                    xVol.LoadXml(xTransp.GetElementsByTagName("vol")[0].OuterXml);

                    belVol objVol = new belVol();

                    if (xVol.GetElementsByTagName("qVol").Count > 0)
                    {
                        objVol.Qvol = Convert.ToDecimal(xVol.GetElementsByTagName("qVol")[0].InnerText.ToString().Replace(".", ","));
                    }

                    if (xVol.GetElementsByTagName("esp").Count > 0)
                    {
                        objVol.Esp = xVol.GetElementsByTagName("esp")[0].InnerText;
                    }

                    if (xVol.GetElementsByTagName("marca").Count > 0)
                    {
                        objVol.Marca = xVol.GetElementsByTagName("marca")[0].InnerText;
                    }

                    if (xVol.GetElementsByTagName("nVol").Count > 0)
                    {
                        objVol.Nvol = xVol.GetElementsByTagName("nVol")[0].InnerText;//Danner - o.s. 24432 - 04/05/2010
                    }

                    if (xVol.GetElementsByTagName("pesoL").Count > 0)
                    {
                        objVol.PesoL = Convert.ToDecimal(xVol.GetElementsByTagName("pesoL")[0].InnerText.ToString().Replace(".", ","));
                    }

                    if (xVol.GetElementsByTagName("pesoB").Count > 0)
                    {
                        objVol.PesoB = Convert.ToDecimal(xVol.GetElementsByTagName("pesoB")[0].InnerText.ToString().Replace(".", ","));
                    }

                    objTransp.belVol = objVol;

                }

                if (xTransp.GetElementsByTagName("lacres").Count > 0)
                {
                    XmlDocument xLacres = new XmlDocument();
                    xLacres.LoadXml(xTransp.GetElementsByTagName("lacres")[0].OuterXml);

                    belLacres objLacres = new belLacres();

                    if (xLacres.GetElementsByTagName("nLacre").Count > 0)
                    {
                        objLacres.Nlacre = xLacres.GetElementsByTagName("nLacre")[0].InnerText;
                    }

                    objTransp.belLacres = objLacres;

                }


            }
            catch (Exception ex)
            {

                throw new Exception(string.Format("Problemas lendo a Tag Transp, Erro.: {0}",
                                                  ex.Message));
            }

            return objTransp;

        }