Example #1
0
        // ESTORNAR A PAGAR AND DELETE SAIDA
        //------------------------------------------------------------------------------------------------------------
        public bool EstornarAPagar(
            objAPagar apagar,
            objMovimentacao saida,
            Action <int, decimal> ContaSldLocalUpdate,
            Action <int, decimal> SetorSldLocalUpdate)
        {
            AcessoDados dbTran = null;

            try
            {
                dbTran = new AcessoDados();
                dbTran.BeginTransaction();

                // Verifica CONTA BLOQUEIO
                ContaBLL cBLL = new ContaBLL();

                if (!cBLL.ContaDateBlockPermit((int)saida.IDConta, saida.MovData, dbTran))
                {
                    throw new AppException("A Data da Conta está BLOQUEADA nesta Data proposta...", 2);
                }

                // CHECK SOURCE DESPESA IS DESPESA COMUM AND CHANGE SITUACAO
                if (apagar.DespesaOrigem == 1)
                {
                    var dBLL = new DespesaComumBLL();
                    dBLL.ChangeSituacaoDespesa(apagar.IDDespesa, 1, dbTran);
                }

                // DELETE REMOVE SAIDA
                new MovimentacaoBLL().DeleteMovimentacao((long)saida.IDMovimentacao, ContaSldLocalUpdate, SetorSldLocalUpdate, dbTran);

                // Change APAGAR
                decimal DoValor = saida.MovValor - (saida.AcrescimoValor ?? 0);

                apagar.ValorAcrescimo -= saida.AcrescimoValor ?? 0;
                apagar.ValorPago      += DoValor;
                apagar.PagamentoData   = null;
                apagar.IDSituacao      = 1;
                apagar.Situacao        = "Em Aberto";

                // Update APAGAR
                UpdateAPagar(apagar, dbTran);

                dbTran.CommitTransaction();

                return(true);
            }
            catch (Exception ex)
            {
                dbTran.RollBackTransaction();
                throw ex;
            }
        }