Example #1
0
        public static void ReabrirNfeProcessar(TRegistro_LanLoteNFE_X_NotaFiscal val, BancoDados.TObjetoBanco banco)
        {
            bool st_transacao = false;
            TCD_LanLoteNFE_X_NotaFiscal qtb_nfe = new TCD_LanLoteNFE_X_NotaFiscal();

            try
            {
                if (banco == null)
                {
                    st_transacao = qtb_nfe.CriarBanco_Dados(true);
                }
                else
                {
                    qtb_nfe.Banco_Dados = banco;
                }
                System.Collections.Hashtable hs = new System.Collections.Hashtable();
                hs.Add("@P_EMPRESA", val.Cd_empresa);
                hs.Add("@P_LANCTO", val.Nr_lanctofiscal);
                qtb_nfe.executarSql("update tb_fat_notafiscal set chave_acesso_nfe = null, xml_nfe = null, dt_alt = getdate() " +
                                    "where cd_empresa = @P_EMPRESA and nr_lanctofiscal = @P_LANCTO", hs);
                qtb_nfe.Excluir(val);
                //Verificar se existe mais alguma nota amarrada ao lote
                object obj = qtb_nfe.BuscarEscalar(
                    new Utils.TpBusca[]
                {
                    new Utils.TpBusca()
                    {
                        vNM_Campo = "a.id_lote",
                        vOperador = "=",
                        vVL_Busca = val.Id_lote.ToString()
                    }
                }, "1");
                if (obj == null)
                {
                    TCN_LanLoteNFE.Excluir(new TRegistro_LanLoteNFE()
                    {
                        Id_lote = val.Id_lote
                    }, qtb_nfe.Banco_Dados);
                }
                if (st_transacao)
                {
                    qtb_nfe.Banco_Dados.Commit_Tran();
                }
            }
            catch (Exception ex)
            {
                if (st_transacao)
                {
                    qtb_nfe.Banco_Dados.RollBack_Tran();
                }
                throw new Exception("Erro reabrir NF-e processar: " + ex.Message.Trim());
            }
            finally
            {
                if (st_transacao)
                {
                    qtb_nfe.deletarBanco_Dados();
                }
            }
        }
Example #2
0
        public static string Excluir(TRegistro_LanLoteNFE_X_NotaFiscal val, BancoDados.TObjetoBanco banco)
        {
            bool st_transacao = false;
            TCD_LanLoteNFE_X_NotaFiscal qtb_lote = new TCD_LanLoteNFE_X_NotaFiscal();

            try
            {
                if (st_transacao)
                {
                    st_transacao = qtb_lote.CriarBanco_Dados(true);
                }
                else
                {
                    qtb_lote.Banco_Dados = banco;
                }
                qtb_lote.Excluir(val);
                if (st_transacao)
                {
                    qtb_lote.Banco_Dados.Commit_Tran();
                }
                return("OK");
            }
            catch (Exception ex)
            {
                if (st_transacao)
                {
                    qtb_lote.Banco_Dados.RollBack_Tran();
                }
                throw new Exception("Erro excluir registro: " + ex.Message.Trim());
            }
            finally
            {
                if (st_transacao)
                {
                    qtb_lote.deletarBanco_Dados();
                }
            }
        }