public void GravarProtocoloEnvio(belStatusCte cte)
        {
            try
            {
                if (cte.Protocolo != null)
                {
                    StringBuilder sQuery = new StringBuilder();
                    sQuery.Append("Update conhecim ");
                    sQuery.Append("set conhecim.cd_nprotcte='" + cte.Protocolo + "' ");
                    sQuery.Append("where conhecim.nr_lanc='" + cte.NumeroSeq.PadLeft(6, '0') + "' ");
                    sQuery.Append("and conhecim.cd_empresa ='" + belStatic.CodEmpresaCte + "'");

                    FbCommand fbConn = new FbCommand(sQuery.ToString(), cx.get_Conexao());
                    cx.Open_Conexao();
                    fbConn.ExecuteNonQuery();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                cx.Close_Conexao();
            }

        }
        public void AlterarStatusCte(belStatusCte status)
        {
            try
            {
                StringBuilder sQuery = new StringBuilder();
                sQuery.Append("Update conhecim ");
                sQuery.Append("set  conhecim.st_cte ='S' ");
                sQuery.Append("where conhecim.nr_lanc ='" + status.NumeroSeq + "' ");
                sQuery.Append("and conhecim.cd_empresa ='" + belStatic.CodEmpresaCte + "'");

                FbCommand fbConn = new FbCommand(sQuery.ToString(), cx.get_Conexao());
                cx.Open_Conexao();
                fbConn.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                cx.Close_Conexao();
            }
        }
Esempio n. 3
0
        private List<belStatusCte> TrataDadosRetorno(string sRetorno)
        {
            try
            {

                List<belStatusCte> ListaStatus = new List<belStatusCte>();

                XmlDocument docRetorno = new XmlDocument();
                docRetorno.LoadXml(sRetorno);

                XmlNodeList xNodeList = null;

                if (docRetorno.GetElementsByTagName("infProt").Count > 0)
                {
                    xNodeList = docRetorno.GetElementsByTagName("infProt");
                }
                else if (docRetorno.GetElementsByTagName("infCanc").Count > 0)
                {
                    xNodeList = docRetorno.GetElementsByTagName("infCanc");
                }
                else if (docRetorno.GetElementsByTagName("infInut").Count > 0)
                {
                    xNodeList = docRetorno.GetElementsByTagName("infInut");
                }
                else if (docRetorno.GetElementsByTagName("retConsStatServCte").Count > 0)
                {
                    xNodeList = docRetorno.GetElementsByTagName("retConsStatServCte");
                }
                else if (docRetorno.GetElementsByTagName("retConsReciCTe").Count > 0)
                {
                    xNodeList = docRetorno.GetElementsByTagName("retConsReciCTe");
                }
                else if (docRetorno.GetElementsByTagName("retConsSitCTe").Count > 0)
                {
                    xNodeList = docRetorno.GetElementsByTagName("retConsSitCTe");
                }


                foreach (XmlNode node in xNodeList)
                {
                    belStatusCte cte = new belStatusCte();
                    if (node["chCTe"] != null)
                    {
                        cte.NumeroSeq = node["chCTe"].InnerText.Substring(36, 7);
                        cte.Chave = node["chCTe"].InnerText;
                    }
                    if (node["cStat"] != null)
                    {
                        cte.CodRetorno = node["cStat"].InnerText;
                        if (cte.CodRetorno == "100" || cte.CodRetorno == "204")
                        {
                            cte.Enviado = true;
                        }
                    }
                    if (node["xMotivo"] != null)
                    {
                        cte.Motivo = node["xMotivo"].InnerText;
                    }
                    //Protocolo de Retorno
                    if (node["nProt"] != null)
                    {
                        cte.Protocolo = node["nProt"].InnerText;
                    }
                    if (node["dhRecbto"] != null)
                    {
                        DateTime data = Convert.ToDateTime(node["dhRecbto"].InnerText);
                        cte.DataRecebimento = data.ToLongDateString() + " às " + data.ToShortTimeString();
                    }
                    ListaStatus.Add(cte);
                }

                return ListaStatus;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }