Exemplo n.º 1
0
        public static void ExcluirTaxasProvisionadas(List <TRegistro_TaxaDeposito> val, BancoDados.TObjetoBanco banco)
        {
            bool st_transacao            = false;
            TCD_LanTaxaDeposito qtb_taxa = new TCD_LanTaxaDeposito();

            try
            {
                if (banco == null)
                {
                    st_transacao = qtb_taxa.CriarBanco_Dados(true);
                }
                else
                {
                    qtb_taxa.Banco_Dados = banco;
                }
                val.ForEach(p =>
                {
                    //Verificar se a taxa esta faturada
                    TList_Taxa_X_PedidoItem lTxPed = TCN_Taxa_X_PedidoItem.Buscar(p.Id_LanTaxa.ToString(), string.Empty, qtb_taxa.Banco_Dados);
                    lTxPed.ForEach(v => TCN_Taxa_X_PedidoItem.Excluir(v, qtb_taxa.Banco_Dados));
                    Excluir(p, qtb_taxa.Banco_Dados);
                });
                if (st_transacao)
                {
                    qtb_taxa.Banco_Dados.Commit_Tran();
                }
            }
            catch (Exception ex)
            {
                if (st_transacao)
                {
                    qtb_taxa.Banco_Dados.RollBack_Tran();
                }
                throw new Exception("Erro excluir taxas provisionadas: " + ex.Message.Trim());
            }
            finally
            {
                if (st_transacao)
                {
                    qtb_taxa.deletarBanco_Dados();
                }
            }
        }