예제 #1
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            uninfeDummy.ClearControls(this, true, true);

            foreach (var estado in Propriedade.Estados)
            {
                this.edtUF.Items.Add(estado.UF);
            }
            this.edtUF.SelectedIndex = 0;

            var      _PadroesDataSource = new List <PadroesDataSource>();
            XElement axml = XElement.Load(Propriedade.NomeArqXMLWebService_NFSe);
            var      xs   = (from p in axml.Descendants(NFe.Components.NFeStrConstants.Estado)
                             where p.Attribute(NFe.Components.TpcnResources.UF.ToString()).Value == "XX" &&
                             p.Attribute(NFe.Components.TpcnResources.ID.ToString()).Value == p.Attribute(NFe.Components.NFeStrConstants.Padrao).Value
                             orderby p.Attribute(NFe.Components.NFeStrConstants.Padrao).Value
                             select p);

            foreach (var item in xs)
            {
                PadroesNFSe type = WebServiceNFSe.GetPadraoFromString(item.Attribute(NFe.Components.NFeStrConstants.Padrao).Value);
                _PadroesDataSource.Add(new PadroesDataSource {
                    fromType = type.ToString(), fromDescription = EnumHelper.GetEnumItemDescription(type)
                });
            }

            this.edtPadrao.Sorted        = false;
            this.edtPadrao.DataSource    = _PadroesDataSource;// WebServiceNFSe.PadroesNFSeListDataSource.Where(p => p.fromType != PadroesNFSe.NaoIdentificado.ToString()).ToList();
            this.edtPadrao.ValueMember   = "fromType";
            this.edtPadrao.DisplayMember = "fromDescription";

            this.edtPadrao.SelectedIndex = 0;
        }
예제 #2
0
 public Municipio(int _cod, string _uf, string _nome, PadroesNFSe _padrao)
 {
     this.Nome = _nome;
     if (!_nome.Trim().EndsWith(" - " + _uf))
         this.Nome = _nome.Trim() + " - " + _uf;
     this.CodigoMunicipio = _cod;
     this.Padrao = _padrao;
     this.PadraoStr = _padrao.ToString();
     this.UF = _uf;
 }
예제 #3
0
 public Municipio(int _cod, string _uf, string _nome, PadroesNFSe _padrao)
 {
     this.Nome = _nome;
     if (!_nome.Trim().EndsWith(" - " + _uf))
     {
         this.Nome = _nome.Trim() + " - " + _uf;
     }
     this.CodigoMunicipio = _cod;
     this.Padrao          = _padrao;
     this.PadraoStr       = _padrao.ToString();
     this.UF = _uf;
 }
예제 #4
0
        private static string getURLs(string local, ref PadroesNFSe padrao, int idMunicipio)
        {
            /*
             * tenta ler as URL's do 'WebService.xml'
             * não encontrando, assume o ID='padrao' e UF='XX' e padrao='padrao'
             */

            if (System.IO.File.Exists(Propriedade.NomeArqXMLWebService_NFSe))
            {
                XElement axml = null;

                try
                {
                    axml = XElement.Load(Propriedade.NomeArqXMLWebService_NFSe);
                }
                catch (Exception ex)
                {
                    Functions.WriteLog("Ocorreu um erro na tentativa de carregamento do arquivo " + Propriedade.NomeArqXMLWebService_NFSe + ".\r\n" +
                                       "Acesse novamente o sistema para que se recupere automaticamente do erro.\r\n\r\n" +
                                       "Erro:\r\n\r\n" + ex.Message, true, true, "");

                    if (System.IO.File.Exists(Propriedade.XMLVersaoWSDLXSD))
                    {
                        System.IO.File.Delete(Propriedade.XMLVersaoWSDLXSD);
                    }

                    Environment.Exit(0);
                }

                ///
                /// primeiro, pesquisa pelo ID
                ///
                var s = (from p in axml.Descendants(NFeStrConstants.Estado)
                         where  //(string)p.Attribute(NFe.Components.NFeStrConstants.Padrao) == padrao.ToString() &&
                         (string)p.Attribute(TpcnResources.ID.ToString()) == idMunicipio.ToString()
                         select p);
                foreach (var item in s)
                {
                    if (item.Element(local) != null)
                    {
                        ///
                        /// pega o padrao definido no WebService.xml descartando o que constar no UninMunic.xml
                        ///
                        padrao = WebServiceNFSe.GetPadraoFromString(item.Attribute(NFeStrConstants.Padrao).Value);

                        return(local.Equals(NFeStrConstants.LocalHomologacao) ?
                               item.FirstNode.ToString() : item.LastNode.ToString());
                    }
                }
                ///
                /// não encontrei, assume o ID='padrao' e UF='XX' e padrao='padrao'
                ///
                PadroesNFSe pdr = padrao;

                var xs = (from p in axml.Descendants(NFeStrConstants.Estado)
                          where (string)p.Attribute(NFeStrConstants.Padrao) == pdr.ToString() &&
                          (string)p.Attribute(TpcnResources.UF.ToString()) == "XX" &&
                          (string)p.Attribute(TpcnResources.ID.ToString()) == pdr.ToString()
                          select p);
                foreach (var item in xs)
                {
                    if (item.Element(local) != null)
                    {
                        return(local.Equals(NFeStrConstants.LocalHomologacao) ?
                               item.FirstNode.ToString() : item.LastNode.ToString());
                    }
                }
            }
            else
            {
                Functions.WriteLog("Ocorreu um erro na tentativa de carregamento do arquivo " + Propriedade.NomeArqXMLWebService_NFSe + ".\r\n" +
                                   "Acesse novamente o sistema para que se recupere automaticamente do erro.", true, true, "");

                if (System.IO.File.Exists(Propriedade.XMLVersaoWSDLXSD))
                {
                    System.IO.File.Delete(Propriedade.XMLVersaoWSDLXSD);
                }

                Environment.Exit(0);
            }

            return("");
        }
예제 #5
0
        private static string getURLs(string local, ref PadroesNFSe padrao, int idMunicipio)
        {
            /*
             * tenta ler as URL's do 'WebService.xml'
             * não encontrando, assume o ID='padrao' e UF='XX' e padrao='padrao'
             */

            if (System.IO.File.Exists(Propriedade.NomeArqXMLWebService_NFSe))
            {
                XElement axml = XElement.Load(Propriedade.NomeArqXMLWebService_NFSe);
                ///
                /// primeiro, pesquisa pelo ID
                ///
                var s = (from p in axml.Descendants(NFe.Components.NFeStrConstants.Estado)
                         where  //(string)p.Attribute(NFe.Components.NFeStrConstants.Padrao) == padrao.ToString() &&
                         (string)p.Attribute(NFe.Components.TpcnResources.ID.ToString()) == idMunicipio.ToString()
                         select p);
                foreach (var item in s)
                {
                    if (item.Element(local) != null)
                    {
                        ///
                        /// pega o padrao definido no WebService.xml descartando o que constar no UninMunic.xml
                        ///
                        padrao = WebServiceNFSe.GetPadraoFromString(item.Attribute(NFe.Components.NFeStrConstants.Padrao).Value);

                        return(local.Equals(NFe.Components.NFeStrConstants.LocalHomologacao) ?
                               item.FirstNode.ToString() : item.LastNode.ToString());
                    }
                }
                ///
                /// não encontrei, assume o ID='padrao' e UF='XX' e padrao='padrao'
                ///
                PadroesNFSe pdr = padrao;

                var xs = (from p in axml.Descendants(NFe.Components.NFeStrConstants.Estado)
                          where  (string)p.Attribute(NFe.Components.NFeStrConstants.Padrao) == pdr.ToString() &&
                          (string)p.Attribute(TpcnResources.UF.ToString()) == "XX" &&
                          (string)p.Attribute(NFe.Components.TpcnResources.ID.ToString()) == pdr.ToString()
                          select p);
                foreach (var item in xs)
                {
                    if (item.Element(local) != null)
                    {
                        return(local.Equals(NFe.Components.NFeStrConstants.LocalHomologacao) ?
                               item.FirstNode.ToString() : item.LastNode.ToString());
                    }
                }
            }

            return("");
        }