示例#1
0
        public static string Excluir(TRegistro_Quitarfatura val, BancoDados.TObjetoBanco banco)
        {
            bool             st_transacao = false;
            TCD_QuitarFatura qtb_quitar   = new TCD_QuitarFatura();

            try
            {
                if (banco == null)
                {
                    st_transacao = qtb_quitar.CriarBanco_Dados(true);
                }
                else
                {
                    qtb_quitar.Banco_Dados = banco;
                }
                qtb_quitar.Excluir(val);
                if (st_transacao)
                {
                    qtb_quitar.Banco_Dados.Commit_Tran();
                }
                return("OK");
            }
            catch (Exception ex)
            {
                if (st_transacao)
                {
                    qtb_quitar.Banco_Dados.RollBack_Tran();
                }
                throw new Exception("Erro excluir quitação: " + ex.Message.Trim());
            }
            finally
            {
                if (st_transacao)
                {
                    qtb_quitar.deletarBanco_Dados();
                }
            }
        }
示例#2
0
        public static void EstornarQuitacaoFatura(TRegistro_Quitarfatura val, BancoDados.TObjetoBanco banco)
        {
            bool             st_transacao = false;
            TCD_FaturaCartao qtb_fatura   = new TCD_FaturaCartao();

            try
            {
                if (banco == null)
                {
                    st_transacao = qtb_fatura.CriarBanco_Dados(true);
                }
                else
                {
                    qtb_fatura.Banco_Dados = banco;
                }
                //Buscar caixa da quitacao
                string aux  = string.Empty;
                string virg = string.Empty;
                if (!string.IsNullOrEmpty(val.Cd_lanctocaixaquitstr))
                {
                    aux  = val.Cd_lanctocaixaquitstr;
                    virg = ",";
                }
                if (!string.IsNullOrEmpty(val.Cd_lanctocaixajurostr))
                {
                    aux += virg + val.Cd_lanctocaixajurostr;
                    virg = ",";
                }
                if (!string.IsNullOrEmpty(val.Cd_lanctocaixatxstr))
                {
                    aux += virg + val.Cd_lanctocaixatxstr;
                }
                TList_LanCaixa lCaixa =
                    new TCD_LanCaixa(qtb_fatura.Banco_Dados).Select(
                        new Utils.TpBusca[]
                {
                    new Utils.TpBusca()
                    {
                        vNM_Campo = "isnull(a.st_estorno, 'N')",
                        vOperador = "<>",
                        vVL_Busca = "'S'"
                    },
                    new Utils.TpBusca()
                    {
                        vNM_Campo = string.Empty,
                        vOperador = string.Empty,
                        vVL_Busca = "((a.cd_contager = '" + val.Cd_contager.Trim() + "' " +
                                    "and a.cd_lanctocaixa = " + val.Cd_lanctocaixastr + ") or " +
                                    "(a.cd_contager = '" + val.Cd_contagerquit.Trim() + "' " +
                                    "and a.cd_lanctocaixa in(" + aux + ")))"
                    }
                }, 0, string.Empty);
                //Excluir registro quitacao
                TCN_QuitarFatura.Excluir(val, qtb_fatura.Banco_Dados);
                lCaixa.ForEach(p => CamadaNegocio.Financeiro.Caixa.TCN_LanCaixa.EstornarCaixa(p, null, qtb_fatura.Banco_Dados));
                if (st_transacao)
                {
                    qtb_fatura.Banco_Dados.Commit_Tran();
                }
            }
            catch (Exception ex)
            {
                if (st_transacao)
                {
                    qtb_fatura.Banco_Dados.RollBack_Tran();
                }
                throw new Exception("Erro estornar quitação fatura: " + ex.Message.Trim());
            }
            finally
            {
                if (st_transacao)
                {
                    qtb_fatura.deletarBanco_Dados();
                }
            }
        }