Exemplo n.º 1
0
        public static string Excluir(TRegistro_CadContaGer val, BancoDados.TObjetoBanco banco)
        {
            bool            st_transacao = false;
            TCD_CadContaGer cd           = new TCD_CadContaGer();

            try
            {
                if (banco == null)
                {
                    st_transacao = cd.CriarBanco_Dados(true);
                }
                else
                {
                    cd.Banco_Dados = banco;
                }
                cd.Excluir(val);
                if (st_transacao)
                {
                    cd.Banco_Dados.Commit_Tran();
                }
                return("OK");
            }
            catch (Exception ex)
            {
                if (st_transacao)
                {
                    cd.Banco_Dados.RollBack_Tran();
                }
                throw new Exception("Erro excluir conta: " + ex.Message.Trim());
            }
            finally
            {
                if (st_transacao)
                {
                    cd.deletarBanco_Dados();
                }
            }
        }
Exemplo n.º 2
0
        private void afterBusca()
        {
            if (cbContaGer.SelectedItem != null)
            {
                string cheque  = string.Empty;
                string estorno = string.Empty;
                if (ST_Cheques.Checked)
                {
                    cheque = string.Empty;
                }
                else
                {
                    cheque = ST_Cheques.Vl_False;
                }

                if (ST_Estorno.Checked)
                {
                    estorno = string.Empty;
                }
                else
                {
                    estorno = ST_Estorno.Vl_False;
                }

                bindingSourceCaixa.DataSource = TCN_LanCaixa.Busca(cbContaGer.SelectedValue.ToString(),
                                                                   string.Empty,
                                                                   string.Empty,
                                                                   nr_docto.Text,
                                                                   cd_historico.Text,
                                                                   string.Empty,
                                                                   DT_Inicial.Text,
                                                                   DT_Final.Text,
                                                                   vl_ini.Value,
                                                                   vl_fin.Value,
                                                                   rgValor.NM_Valor,
                                                                   cheque,
                                                                   estorno,
                                                                   false,
                                                                   string.Empty,
                                                                   0,
                                                                   cbAvulsos.Checked,
                                                                   null);
                //Buscar Totais
                object obj = new CamadaDados.Financeiro.Titulo.TCD_LanTitulo().BuscarEscalar(
                    new TpBusca[]
                {
                    new TpBusca()
                    {
                        vNM_Campo = "isnull(a.status_compensado, 'N')",
                        vOperador = "=",
                        vVL_Busca = "'N'"
                    },
                    new TpBusca()
                    {
                        vNM_Campo = "a.tp_titulo",
                        vOperador = "=",
                        vVL_Busca = "'R'"
                    },
                    new TpBusca()
                    {
                        vNM_Campo = string.Empty,
                        vOperador = "exists",
                        vVL_Busca = "(select 1 from tb_fin_titulo_x_caixa x " +
                                    "inner join tb_fin_caixa y " +
                                    "on x.cd_contager = y.cd_contager " +
                                    "and x.cd_lanctocaixa = y.cd_lanctocaixa " +
                                    "where x.cd_empresa = a.cd_empresa " +
                                    "and x.cd_banco = a.cd_banco " +
                                    "and x.nr_lanctocheque = a.nr_lanctocheque " +
                                    "and y.cd_contager = '" + cbContaGer.SelectedValue.ToString() + "' " +
                                    "and isnull(y.st_estorno, 'N') <> 'S')"
                    }
                }, "isnull(sum(a.vl_titulo), 0)");
                Tot_Ch_REC.Value = obj != null?decimal.Parse(obj.ToString()) : decimal.Zero;

                obj = new CamadaDados.Financeiro.Titulo.TCD_LanTitulo().BuscarEscalar(
                    new TpBusca[]
                {
                    new TpBusca()
                    {
                        vNM_Campo = "isnull(a.status_compensado, 'N')",
                        vOperador = "=",
                        vVL_Busca = "'N'"
                    },
                    new TpBusca()
                    {
                        vNM_Campo = "a.tp_titulo",
                        vOperador = "=",
                        vVL_Busca = "'P'"
                    },
                    new TpBusca()
                    {
                        vNM_Campo = string.Empty,
                        vOperador = "exists",
                        vVL_Busca = "(select 1 from tb_fin_titulo_x_caixa x " +
                                    "inner join tb_fin_caixa y " +
                                    "on x.cd_contager = y.cd_contager " +
                                    "and x.cd_lanctocaixa = y.cd_lanctocaixa " +
                                    "inner join tb_fin_contager z " +
                                    "on y.cd_contager = z.cd_contager_compensacao " +
                                    "where x.cd_empresa = a.cd_empresa " +
                                    "and x.cd_banco = a.cd_banco " +
                                    "and x.nr_lanctocheque = a.nr_lanctocheque " +
                                    "and z.cd_contager = '" + cbContaGer.SelectedValue.ToString() + "' " +
                                    "and isnull(y.st_estorno, 'N') <> 'S')"
                    }
                }, "isnull(sum(a.vl_titulo), 0)");
                Tot_Ch_PAG.Value = obj != null?decimal.Parse(obj.ToString()) : decimal.Zero;

                VL_DifCX.Value = TCN_LanCaixa.BuscarSaldoCaixa(cbContaGer.SelectedValue.ToString(), null);
                //Verificar se a conta e de compensacao
                object obj_conta = new TCD_CadContaGer().BuscarEscalar(
                    new TpBusca[]
                {
                    new TpBusca()
                    {
                        vNM_Campo = "a.cd_contager",
                        vOperador = "=",
                        vVL_Busca = "'" + cbContaGer.SelectedValue.ToString().Trim() + "'"
                    },
                    new TpBusca()
                    {
                        vNM_Campo = "isnull(a.st_contacompensacao, 'N')",
                        vOperador = "=",
                        vVL_Busca = "'S'"
                    }
                }, "1");
                VL_SaldoLiquido.Value = VL_DifCX.Value - (obj_conta == null ? Tot_Ch_PAG.Value : Tot_Ch_PAG.Value * -1);
                //Buscar Aplicações
                bsSaldoAplic.DataSource = new TCD_SaldoContaGer().Select(string.Empty, cbContaGer.SelectedValue.ToString());
                if (bsSaldoAplic.Count > 0)
                {
                    tlpTotais.ColumnStyles[1].Width = 405;
                }
                else
                {
                    tlpTotais.ColumnStyles[1].Width = 0;
                }
                bindingSourceCaixa_PositionChanged(this, new EventArgs());
            }
            else
            {
                MessageBox.Show("Obrigatório informar conta gerencial.", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }