예제 #1
0
        public string VerificaCampoProtocoloEnvioByChave(string sNumCte, bool bCancelado)
        {
            try
            {
                daoBuscaDadosGerais objGerais = new daoBuscaDadosGerais();
                string        sChaveCteRet    = objGerais.BuscaChaveRetornoCte(sNumCte);
                string        sPasta          = sChaveCteRet.Substring(4, 2) + "-" + sChaveCteRet.Substring(2, 2);
                DirectoryInfo dPasta          = null;
                if (bCancelado == false)
                {
                    dPasta = new DirectoryInfo(Pastas.ENVIADOS + @"\\" + sPasta);
                }
                else
                {
                    dPasta = new DirectoryInfo(Pastas.CANCELADOS + @"\\" + sPasta);
                }

                string      sPath = dPasta.ToString() + "\\Cte_" + sChaveCteRet + ".xml";
                XmlDocument doc   = new XmlDocument();
                doc.Load(sPath);
                XmlNodeList infProt = doc.GetElementsByTagName("infProt");
                string      nProt   = "";
                for (int a = 0; a < infProt.Count; a++)
                {
                    for (int j = 0; j < infProt[a].ChildNodes.Count; j++)
                    {
                        switch (infProt[a].ChildNodes[j].LocalName)
                        {
                        case "nProt": nProt = infProt[a].ChildNodes[j].InnerText;
                            break;
                        }
                    }
                }

                StringBuilder sSql = new StringBuilder();
                sSql.Append("update conhecim set cd_nprotcte = '");
                sSql.Append(nProt);
                sSql.Append("'");
                sSql.Append(" Where conhecim.cd_empresa = '");
                sSql.Append(Acesso.CD_EMPRESA);
                sSql.Append("' and ");
                sSql.Append("conhecim.cd_conheci = '");
                sSql.Append(sNumCte);
                sSql.Append("'");
                try
                {
                    HlpDbFuncoes.qrySeekUpdate(sSql.ToString());
                }
                catch (Exception)
                {
                    throw;
                }
                return(nProt);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #2
0
        private void CancelaCte()
        {
            try
            {
                daoBuscaDadosGerais objdaoDadosGerais = new daoBuscaDadosGerais();
                daoGravaDadosRetorno objDadosRetorno = new daoGravaDadosRetorno();
                belCancelaCte objCancelaCte = new belCancelaCte();


                string sJustificativa = txtJust.Text;
                belCancelaCte objCte = objCancelaCte.PopulaDadosCancelamento(sCodConhecimento, sJustificativa);

                belCriaXml objXml = new belCriaXml();
                HLP.GeraXml.bel.CTe.Evento.TRetEvento ret = objXml.GerarXmlCancelamento(objCte);


                if (ret.infEvento.cStat == "135")
                {
                    objDadosRetorno.GravarReciboCancelamento(sCodConhecimento, ret.infEvento.nProt, sJustificativa);
                    objXml.SalvaArquivoPastaCancelado(objdaoDadosGerais.BuscaChaveRetornoCteSeq(objCte.chCTe));
                }

                string sMessageRetorno = string.Format("Codigo do Retorno: {0}{1}Motivo: {2}{1}Chave: {3}{1}Protocolo: {4}{1}",
                    ret.infEvento.cStat,
                    Environment.NewLine,
                    ret.infEvento.xMotivo,
                    ret.infEvento.chCTe,
                    ret.infEvento.nProt);

                KryptonMessageBox.Show(sMessageRetorno, Mensagens.CHeader, MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #3
0
        private void btnPendencias_Click(object sender, EventArgs e)
        {
            try
            {
                daoBuscaDadosGerais objdaoGerais = new daoBuscaDadosGerais();

                StringBuilder strCampos = new StringBuilder();
                strCampos.Append("c.nr_lanc, ");
                strCampos.Append("coalesce(c.cd_conheci, '') cd_conheci , ");
                strCampos.Append("cast(case when coalesce(c.st_contingencia, 'N') = 'S' then 1 else 0 end as smallint) st_contingencia , ");
                strCampos.Append("c.dt_emi, ");
                strCampos.Append("r.nm_social, ");
                strCampos.Append("c.vl_total, ");
                strCampos.Append("cast(case when coalesce(c.st_cte, 'N') = 'S' then 1 else 0 end as smallint ) st_cte, ");
                strCampos.Append("cast(case when coalesce(c.ds_cancelamento, 'N') = 'N' then 0 else 1 end as smallint) ds_cancelamento ");

                dgvArquivos.DataSource = objdaoGerais.PesquisaGridViewContingencia(strCampos.ToString());
                lblTotalRegistros.Text = dgvArquivos.Rows.Count + " Registro(s) encontrado(s)";

                for (int i = 0; i < dgvArquivos.RowCount; i++)
                {
                    if (Convert.ToBoolean(dgvArquivos["ds_cancelamento", i].Value) == true)
                    {
                        dgvArquivos.Rows[i].DefaultCellStyle.BackColor = Color.Khaki;
                    }
                    else if (Convert.ToBoolean(dgvArquivos["st_cte", i].Value) == true)
                    {
                        dgvArquivos.Rows[i].DefaultCellStyle.BackColor = Color.LightGreen;
                    }
                    else if (Convert.ToBoolean(dgvArquivos["st_cte", i].Value) == false && Convert.ToBoolean(dgvArquivos["st_contingencia", i].Value) == true)
                    {
                        dgvArquivos.Rows[i].DefaultCellStyle.BackColor = Color.Red;
                    }

                }
                VerificaPendenciasContingencia();
            }
            catch (Exception ex)
            {
                new HLPexception(ex);
            }
        }
예제 #4
0
        public string VerificaCampoProtocoloEnvioByChave(string sNumCte, bool bCancelado)
        {
            try
            {
                daoBuscaDadosGerais objGerais = new daoBuscaDadosGerais();
                string sChaveCteRet = objGerais.BuscaChaveRetornoCte(sNumCte);
                string sPasta = sChaveCteRet.Substring(4, 2) + "-" + sChaveCteRet.Substring(2, 2);
                DirectoryInfo dPasta = null;
                if (bCancelado == false)
                {
                    dPasta = new DirectoryInfo(Pastas.ENVIADOS + @"\\" + sPasta);
                }
                else
                {
                    dPasta = new DirectoryInfo(Pastas.CANCELADOS + @"\\" + sPasta);
                }

                string sPath = dPasta.ToString() + "\\Cte_" + sChaveCteRet + ".xml";
                XmlDocument doc = new XmlDocument();
                doc.Load(sPath);
                XmlNodeList infProt = doc.GetElementsByTagName("infProt");
                string nProt = "";
                for (int a = 0; a < infProt.Count; a++)
                {
                    for (int j = 0; j < infProt[a].ChildNodes.Count; j++)
                    {
                        switch (infProt[a].ChildNodes[j].LocalName)
                        {
                            case "nProt": nProt = infProt[a].ChildNodes[j].InnerText;
                                break;
                        }
                    }
                }

                StringBuilder sSql = new StringBuilder();
                sSql.Append("update conhecim set cd_nprotcte = '");
                sSql.Append(nProt);
                sSql.Append("'");
                sSql.Append(" Where conhecim.cd_empresa = '");
                sSql.Append(Acesso.CD_EMPRESA);
                sSql.Append("' and ");
                sSql.Append("conhecim.cd_conheci = '");
                sSql.Append(sNumCte);
                sSql.Append("'");
                try
                {
                    HlpDbFuncoes.qrySeekUpdate(sSql.ToString());
                }
                catch (Exception)
                {
                    throw;
                }
                return nProt;

            }
            catch (Exception ex)
            {
                throw ex;
            }

        }