예제 #1
0
        public Resultado AlterarStatus(byte codigo, int status)
        {
            Resultado retorno = new Resultado();

            using (ConexaoOracle db = new ConexaoOracle())
            {
                db.AdicionarParametro("P_ID_SISTEMA", codigo);
                db.AdicionarParametro("P_STATUS", status == 0?1:0);

                try
                {
                    db.ExecutarDML("FUN_PKG_SISTEMA.ALTERARSTATUS");

                    retorno.Sucesso("Sistema excluído com sucesso!");
                }
                catch (OracleException erroOracle)
                {
                    retorno.Erro("Erro de Banco de Dados: " + erroOracle.Message);
                }
                catch (Exception erro)
                {
                    retorno.Erro("Erro ao excluir Sistema: " + erro.Message);
                }
            }

            return(retorno);
        }
예제 #2
0
        public Resultado AlterarStatus(int codigo, int status)
        {
            Resultado retorno = new Resultado();

            using (ConexaoOracle db = new ConexaoOracle())
            {
                db.AdicionarParametro("P_ID_MENU", codigo);
                db.AdicionarParametro("P_status", status == 0?1:0);

                try
                {
                    db.ExecutarDML("FUN_PKG_MENU.ALTERARSTATUS");
                    retorno.Sucesso("status alterado com sucesso!");
                }
                catch (OracleException erroOracle)
                {
                    retorno.Erro("Erro de Banco de Dados: " + erroOracle.Message);
                }
                catch (Exception erro)
                {
                    retorno.Erro("Erro ao alterar Menu: " + erro.Message);
                }
            }

            return(retorno);
        }
예제 #3
0
        public Resultado SaveData(AAT_TBL_EMPRESTIMO_DESCONTO updLancamentoDesc)
        {
            Resultado res = new Resultado();

            try
            {
                var atualiza = m_DbContext.AAT_TBL_EMPRESTIMO_DESCONTO.Find(updLancamentoDesc.COD_EMPRESTIMO_DESCONTO);

                if (atualiza != null)
                {
                    m_DbContext.Entry(atualiza).CurrentValues.SetValues(updLancamentoDesc);
                    m_DbContext.SaveChanges();
                    res.Sucesso("Lançamento salvo com sucesso!");
                }
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException ex)
            {
                res.Erro(Util.GetEntityValidationErrors(ex));
            }
            catch (System.Data.Entity.Infrastructure.DbUpdateException ex)
            {
                res.Erro(Util.GetInnerException(ex));
            }
            return(res);
        }
예제 #4
0
        public Resultado Alterar(Menu objMenu)
        {
            Resultado retorno = new Resultado();

            if (objMenu.Codigo == byte.MinValue)
            {
                retorno.Erro("Código não informado");
                return(retorno);
            }

            if (String.IsNullOrEmpty(objMenu.Nome))
            {
                retorno.Erro("Nome não informada");
                return(retorno);
            }

            if (objMenu.Link.Trim() == string.Empty && objMenu.Nivel == 4)
            {
                retorno.Erro("Link não informado");
                return(retorno);
            }

            if (objMenu.MenuPai.Codigo == int.MinValue && objMenu.Nivel > 1)
            {
                retorno.Erro("Menu pai não informado");
                return(retorno);
            }

            retorno = new MenuDAL().Alterar(objMenu);

            return(retorno);
        }
예제 #5
0
        public Resultado GravarMedicao(MEDCTR med)
        {
            Resultado res = new Resultado();

            try
            {
                m_DbContext.MEDCTR.Add(med);

                int linha = m_DbContext.SaveChanges();

                if (linha > 0)
                {
                    res.Sucesso("Registro inserido com sucesso.");
                }
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException ex)
            {
                res.Erro(Util.GetEntityValidationErrors(ex));
            }
            catch (System.Data.Entity.Infrastructure.DbUpdateException ex)
            {
                res.Erro(Util.GetInnerException(ex));
            }

            return(res);
        }
예제 #6
0
        public Resultado Incluir(Menu objMenu)
        {
            Resultado retorno = new Resultado();

            //VALIDAÇÕES/REGRAS DE NEGÓCIO
            if (objMenu.Codigo == byte.MinValue)
            {
                retorno.Erro("Código não informado");
                return(retorno);
            }

            if (objMenu.Nome.Trim() == string.Empty)
            {
                retorno.Erro("Nome não informada");
                return(retorno);
            }

            if (objMenu.Link.Trim() == string.Empty && objMenu.Nivel == 4)
            {
                retorno.Erro("Link não informado");
                return(retorno);
            }

            if (objMenu.MenuPai.Codigo == int.MinValue && objMenu.Nivel > 1)
            {
                retorno.Erro("Menu pai não informado");
                return(retorno);
            }

            //TÉRMINO DAS VALIDAÇÕES

            retorno = new MenuDAL().Incluir(objMenu);

            return(retorno);
        }
예제 #7
0
        public Resultado ConsolidaListaDebitoConta(String NomeArquivo)
        {
            Resultado res = new Resultado();
            List <AAT_TBL_RET_DEB_CONTA> lsDebConta = new List <AAT_TBL_RET_DEB_CONTA>();
            //DebitoContaRetornoDAL DebContaRetDAL = new DebitoContaRetornoDAL();
            DebitoContaDAL DebContaDAL = new DebitoContaDAL();

            //lsDebConta = GetWhere(NomeArquivo, null, "B", null).Where(d => d.AAT_TBL_RET_DEB_CONTA_CRITICAS.Count == 0).ToList();
            //lsDebConta = GetWhere(NomeArquivo, null, "B", null,0,"",false).Where(d => d.AAT_TBL_RET_DEB_CONTA_CRITICAS.Count == 0).ToList();
            lsDebConta = GetWhere(null, null, null, NomeArquivo, null, "B", false).Where(d => d.AAT_TBL_RET_DEB_CONTA_CRITICAS.Count == 0).ToList();
            string   userName        = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
            DateTime currentDateTime = DateTime.Now;

            res.Sucesso(lsDebConta.Count + " registro(s) importado(s) com sucesso.");

            foreach (AAT_TBL_RET_DEB_CONTA retDebConta in lsDebConta)
            {
                AAT_TBL_DEB_CONTA debConta = new AAT_TBL_DEB_CONTA();
                debConta.COD_EMPRS       = Util.String2Short(retDebConta.COD_EMPRESA);
                debConta.NUM_RGTRO_EMPRG = Util.String2Int32(retDebConta.NUM_REGISTRO);
                //debConta.NUM_IDNTF_RPTANT = Util.String2Int32(retDebConta.NUM_REPRESENTANTE); // linha comentada e adicionado a linha de baixo.
                debConta.NUM_IDNTF_RPTANT = Convert.ToInt32(retDebConta.NUM_REPRESENTANTE);
                debConta.COD_PRODUTO      = short.Parse(retDebConta.ID_DEB_BANC.Substring(0, 3));
                debConta.NUM_CPF          = Int64.Parse(retDebConta.ID_DEB_BANC.Substring(3));
                debConta.ID_DEB_BANC      = retDebConta.ID_DEB_BANC;
                //debConta.IND_ATIVO = short.Parse((retDebConta.COD_MOVIMENTO == "0") ? "1" : "0"); // TIPO F: 0=Débito   / 1=Cancelamento
                debConta.IND_ATIVO     = short.Parse((retDebConta.COD_MOVIMENTO == "2") ? "1" : "0"); // TIPO B: 1=Inclusão / 2=Exclusão
                debConta.LOG_INCLUSAO  = userName;
                debConta.DTH_INCLUSAO  = currentDateTime;
                debConta.DCR_NOM_ARQ   = retDebConta.DCR_NOM_ARQ;
                debConta.NUM_SEQ_LINHA = retDebConta.NUM_SEQ_LINHA;

                debConta.COD_BANCO   = "033";
                debConta.COD_AGENCIA = retDebConta.AGENC_DEB_CONTA;
                debConta.TIP_CONTA   = retDebConta.ID_CLIENTE_BANCO.Substring(0, 2);
                debConta.NUM_CONTA   = retDebConta.ID_CLIENTE_BANCO.Substring(2).Trim();

                Resultado resSave = DebContaDAL.SaveData(debConta);
                if (!resSave.Ok)
                {
                    retDebConta.AAT_TBL_RET_DEB_CONTA_CRITICAS.Add(
                        new AAT_TBL_RET_DEB_CONTA_CRITICAS
                    {
                        COD_CRITICA = "999",
                        DCR_CRITICA = "Erro ao inserir o registro na tabela: " + resSave.Mensagem
                    });
                    m_DbContext.SaveChanges(); // Grava a critica de erro do banco
                    res.Erro("Occoreram erros na importação.");
                }
            }

            if (lsDebConta.Count == 0)
            {
                res.Erro("Nenhum registro do tipo 'B' foi importado.");
            }
            return(res);
        }
예제 #8
0
        public Resultado InsertData(FUN_TBL_RELATORIO_PARAM uptParametro)
        {
            Resultado res = new Resultado();

            try
            {
                var ja_existe = m_DbContext.FUN_TBL_RELATORIO_PARAM.FirstOrDefault(p => p.ID_RELATORIO_PARAMETRO == uptParametro.ID_RELATORIO_PARAMETRO);
                if (ja_existe == null)
                {
                    decimal max_key = m_DbContext.FUN_TBL_RELATORIO_PARAM.Max(r => r.ID_RELATORIO_PARAMETRO);
                    uptParametro.ID_RELATORIO_PARAMETRO = max_key + 1;
                    m_DbContext.FUN_TBL_RELATORIO_PARAM.Add(uptParametro);
                    int rows_inserted = m_DbContext.SaveChanges();
                    if (rows_inserted > 0)
                    {
                        res.Sucesso(String.Format("{0} registro(s) inserido(s).", rows_inserted));
                    }
                }
            }
            catch (Exception ex)
            {
                res.Erro("Problemas contate o administrador do sistema: \\n" + ex.Message);
            }

            return(res);
        }
예제 #9
0
        public static Resultado XmlValidator(string sXML, string sXSD)
        {
            Resultado res = new Resultado();

            XmlSchemaSet Xss = new XmlSchemaSet();

            Xss.Add("", XmlReader.Create(new StringReader(sXSD)));

            XDocument doc1   = XDocument.Parse(sXML);
            string    err    = "";
            bool      errors = false;

            doc1.Validate(Xss, (o, e) =>
            {
                err   += e.Message;
                errors = true;
            });

            if (errors)
            {
                res.Erro(err);
            }
            else
            {
                res.Sucesso(string.Empty);
            }

            return(res);
        }
예제 #10
0
        public Resultado Incluir(Menu objMenu)
        {
            Resultado retorno = new Resultado();

            using (ConexaoOracle db = new ConexaoOracle())
            {
                db.AdicionarParametroOut("P_ID_MENU");
                db.AdicionarParametro("P_NM_MENU", objMenu.Nome);
                db.AdicionarParametro("P_DS_LINK", objMenu.Link == string.Empty ? DBNull.Value : (object)objMenu.Link);
                db.AdicionarParametro("P_ID_SISTEMA", objMenu.Sistema.Codigo);
                db.AdicionarParametro("P_CD_NIVEL", objMenu.Nivel);
                db.AdicionarParametro("P_ID_MENU_PAI", objMenu.MenuPai.Codigo == int.MinValue ? DBNull.Value : (object)objMenu.MenuPai.Codigo);

                try
                {
                    //se FOR NECESSÁRIO capturar o código de saída
                    int codigoGerado = db.ExecutarDMLOutput("FUN_PKG_MENU.INSERIR", "P_ID_MENU");

                    retorno.Sucesso("Menu incluido com sucesso!", codigoGerado);
                }
                catch (Exception erro)
                {
                    retorno.Erro("Erro ao incluir Menu: " + erro.Message);
                }
            }

            return(retorno);
        }
예제 #11
0
        public Resultado AtualizaCcComplementar()
        {
            ConexaoOracle objConexao = new ConexaoOracle();
            Resultado     res        = new Resultado();

            try
            {
                bool result = objConexao.ExecutarNonQuery("OWN_FUNCESP.FUN_PKG_ATUALIZA_CC_LOTE.PRC_ATUALIZA_CC_COMPLEMEN");

                if (result == true)
                {
                    res.Sucesso("Processamento Feito com Sucesso");
                }
            }
            catch (Exception ex)
            {
                res.Erro(Util.GetInnerException(ex));
            }
            finally
            {
                objConexao.Dispose();
            }

            return(res);
        }
예제 #12
0
        public async Task <Resultado> Cadastrar(FamiliaDto familiaDto)
        {
            var status = await _familiaRepository.ObterStatus(familiaDto.StatusId);

            var familia = _familiaFactory.Criar(status);

            foreach (var pessoa in familiaDto.Pessoas)
            {
                familia.CriarPessoa(
                    Nome.CriarNovo(pessoa.Nome),
                    Idade.CriarNovo(pessoa.DataDeNascimento),
                    pessoa.Tipo,
                    pessoa.Renda.HasValue ? Renda.CriarNovo(pessoa.Renda.Value) : null);
            }
            if (!familia.Validar())
            {
                return(Resultado.Erro("Familia deve possuir apenas um pretendente e apenas um cônjuge."));
            }

            await _familiaRepository.Adicionar(familia);

            if (familia.Status.CadastroValido)
            {
                await _calculoDePontosDosCriteriosAtendidos.Executar(familia);
            }

            return(Resultado.OK());
        }
예제 #13
0
        public Resultado <AplicacaoFinanceira> ResgatarAplicacao(int id)
        {
            var aplicacao = GetById(id);

            if (aplicacao == null)
            {
                return(Resultado <AplicacaoFinanceira> .Erro("Aplicação não encontrada."));
            }
            if (aplicacao.DataResgate.HasValue)
            {
                return(Resultado <AplicacaoFinanceira> .Erro("Aplicação já resgatada."));
            }

            aplicacao.DataResgate = DateTime.Now;

            var mensagemErro = ValidarResgate(aplicacao.DataAplicacao, aplicacao.DataResgate.Value);

            if (!string.IsNullOrEmpty(mensagemErro))
            {
                return(Resultado <AplicacaoFinanceira> .Erro(mensagemErro));
            }

            aplicacao = CalcularRendimento(aplicacao);
            base.Update(aplicacao);

            return(Resultado <AplicacaoFinanceira> .OK(aplicacao));
        }
예제 #14
0
        public Resultado InsereAberturaFinanceiraCPFL(int mes, int ano)
        {
            ConexaoOracle objConexao = new ConexaoOracle();
            Resultado     res        = new Resultado();

            try
            {
                objConexao.AdicionarParametro("mes", mes);
                objConexao.AdicionarParametro("ano", ano);
                bool result = objConexao.ExecutarNonQuery("own_funcesp.FUN_PKG_ABERTURA_FINANCEIRA.prc_insere_abert_fin_cpfl");

                if (result == true)
                {
                    res.Sucesso("Processamento Feito com Sucesso");
                }
            }
            catch (Exception ex)
            {
                res.Erro(Util.GetInnerException(ex));
            }
            finally
            {
                objConexao.Dispose();
            }

            return(res);
        }
예제 #15
0
        public Resultado AprovacaoAberturaFinanceira(int idReg, string usuario)
        {
            Resultado res = new Resultado();

            try
            {
                var atualiza = m_DbContext.FIN_TBL_RES_ABERT_FINANCEIRA.FirstOrDefault(abert => abert.ID_REG == idReg);

                atualiza.APROVACAO     = "S";
                atualiza.USU_APROVACAO = usuario;
                atualiza.DAT_APROVACAO = DateTime.Now;

                int rows_update = m_DbContext.SaveChanges();

                if (rows_update > 0)
                {
                    res.Sucesso("Aprovado");
                }
            }
            catch (Exception ex)
            {
                res.Erro(Util.GetInnerException(ex));
            }

            return(res);
        }
예제 #16
0
        public Resultado UpdateData(FUN_TBL_RELATORIO uptRelatorio)
        {
            Resultado res = new Resultado();

            try
            {
                var atualiza = m_DbContext.FUN_TBL_RELATORIO.FirstOrDefault(p => p.ID_RELATORIO == uptRelatorio.ID_RELATORIO);
                if (atualiza != null)
                {
                    atualiza.RELATORIO          = uptRelatorio.RELATORIO;
                    atualiza.TITULO             = uptRelatorio.TITULO;
                    atualiza.ARQUIVO            = uptRelatorio.ARQUIVO;
                    atualiza.ID_TIPO_RELATORIO  = uptRelatorio.ID_TIPO_RELATORIO;
                    atualiza.RELATORIO_EXTENSAO = uptRelatorio.RELATORIO_EXTENSAO;
                    int rows_updated = m_DbContext.SaveChanges();
                    if (rows_updated > 0)
                    {
                        res.Sucesso(String.Format("{0} registro(s) atualizado(s).", rows_updated));
                    }
                }
            }
            catch (Exception ex)
            {
                res.Erro("Problemas contate o administrador do sistema: \\n" + ex.Message);
            }
            return(res);
        }
예제 #17
0
        public Resultado UpdateData(FUN_TBL_RELATORIO_PARAM uptParametro)
        {
            Resultado res = new Resultado();

            try
            {
                var atualiza = m_DbContext.FUN_TBL_RELATORIO_PARAM.FirstOrDefault(p => p.ID_RELATORIO_PARAMETRO == uptParametro.ID_RELATORIO_PARAMETRO);
                if (atualiza != null)
                {
                    atualiza.ID_RELATORIO         = int.Parse(uptParametro.ID_RELATORIO.ToString());
                    atualiza.PARAMETRO            = uptParametro.PARAMETRO;
                    atualiza.DESCRICAO            = uptParametro.DESCRICAO;
                    atualiza.TIPO                 = uptParametro.TIPO;
                    atualiza.COMPONENTE_WEB       = uptParametro.COMPONENTE_WEB;
                    atualiza.DROPDOWLIST_CONSULTA = uptParametro.DROPDOWLIST_CONSULTA;
                    atualiza.VALOR_INICIAL        = uptParametro.VALOR_INICIAL;
                    atualiza.HABILITADO           = uptParametro.HABILITADO;
                    atualiza.VISIVEL              = uptParametro.VISIVEL;
                    atualiza.PERMITE_NULL         = uptParametro.PERMITE_NULL;
                    atualiza.ORDEM                = uptParametro.ORDEM;

                    int rows_updated = m_DbContext.SaveChanges();
                    if (rows_updated > 0)
                    {
                        res.Sucesso(String.Format("{0} registro(s) atualizado(s).", rows_updated));
                    }
                }
            }
            catch (Exception ex)
            {
                res.Erro("Problemas contate o administrador do sistema: \\n" + ex.Message);
            }
            return(res);
        }
예제 #18
0
        public Resultado Alterar(Menu objMenu)
        {
            Resultado retorno = new Resultado();

            using (ConexaoOracle db = new ConexaoOracle())
            {
                db.AdicionarParametro("P_ID_MENU", objMenu.Codigo);
                db.AdicionarParametro("P_NM_MENU", objMenu.Nome);
                db.AdicionarParametro("P_ID_SISTEMA", objMenu.Sistema.Codigo);
                db.AdicionarParametro("P_CD_NIVEL", objMenu.Nivel);
                db.AdicionarParametro("P_ID_MENU_PAI", objMenu.MenuPai.Codigo == int.MinValue ? DBNull.Value : (object)objMenu.MenuPai.Codigo);
                db.AdicionarParametro("P_DS_LINK", objMenu.Link == string.Empty ? DBNull.Value : (object)objMenu.Link);

                try
                {
                    db.ExecutarDML("FUN_PKG_MENU.ALTERAR");

                    retorno.Sucesso("Menu alterado com sucesso!");
                }
                catch (Exception erro)
                {
                    retorno.Erro("Erro ao alterar Menu: " + erro.Message);
                }
            }

            return(retorno);
        }
예제 #19
0
        public Resultado SaveData(AAT_TBL_BOLETO newBoleto)
        {
            Resultado res = new Resultado();

            try
            {
                //var atualiza = m_DbContext.AAT_TBL_BOLETO.FirstOrDefault(p => p.COD_EMPRS == newBoleto.COD_EMPRS
                //                                                              && p.NUM_RGTRO_EMPRG == newBoleto.NUM_RGTRO_EMPRG
                //                                                              && p.NUM_IDNTF_RPTANT == newBoleto.NUM_IDNTF_RPTANT
                //                                                              && p.COD_PRODUTO == newBoleto.COD_PRODUTO
                //                                                              && p.DTH_EXCLUSAO == null);

                var atualiza = m_DbContext.AAT_TBL_BOLETO.Find(newBoleto.COD_BOLETO);

                bool iguais = (atualiza != null) ? atualiza.Comparar(newBoleto) : false;
                //bool iguais = atualiza.Comparar(newBoleto);

                if (iguais)
                {
                    res.Sucesso("Registro não inserido. Já existe um 'igual'.");
                }
                else
                {
                    if (atualiza != null)
                    {
                        atualiza.DTH_EXCLUSAO = newBoleto.DTH_INCLUSAO; // Desativa o registro atual
                    }
                    m_DbContext.AAT_TBL_BOLETO.Add(newBoleto);          // Insere um registro novo ativo (DTH_EXCLUSAO=null)
                    int rows_updated = m_DbContext.SaveChanges();
                    if (rows_updated > 0)
                    {
                        res.Sucesso("Registro atualizado com sucesso.", newBoleto.COD_BOLETO);
                    }
                }
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException ex)
            {
                res.Erro(Util.GetEntityValidationErrors(ex));
            }
            catch (System.Data.Entity.Infrastructure.DbUpdateException ex)
            {
                res.Erro(Util.GetInnerException(ex));
            }
            return(res);
        }
예제 #20
0
        public Resultado Salvar(Socio socio)
        {
            Resultado retorno = new Resultado();

            Socio socioConsulta = repoSocio.ObterPorFiltros(c => c.idSocio == socio.idSocio).FirstOrDefault();

            if (socioConsulta != null)
            {
                retorno.AddMensagem("Cadastro", "Sócio já cadastrado.");
            }

            if (!retorno.Sucesso)
            {
                if (socio.idSocio == null || socio.idSocio == Guid.Empty)
                {
                    retorno.Erro("Erros encontrados ao cadastrar o sócio");
                }
                else
                {
                    retorno.Erro("Erros encontrados ao alterar acesso.");
                }
                return(retorno);
            }

            try
            {
                if (socio.idSocio == null || socio.idSocio == Guid.Empty)
                {
                    socio.idSocio = Guid.NewGuid();
                    repoSocio.Adicionar(socio);
                }
                else
                {
                    repoSocio.Alterar(socio);
                }
                contexto.SaveChanges();
                retorno.Ok("Cadastro de sócio realizado com sucesso.");
            }
            catch (Exception erro)
            {
                retorno.Erro(erro.Message);
            }
            return(retorno);
        }
예제 #21
0
        public Resultado Salvar(Dependente dependente)
        {
            Resultado retorno = new Resultado();

            Dependente dependenteConsulta = repoDependente.ObterPorFiltros(c => c.idDependente != dependente.idDependente).FirstOrDefault();

            if (dependenteConsulta != null)
            {
                retorno.AddMensagem("Cadastro", "Dependente já cadastrado.");
            }

            if (!retorno.Sucesso)
            {
                if (dependente.idDependente == null)
                {
                    retorno.Erro("Erros encontrados ao cadastrar o dependente");
                }
                else
                {
                    retorno.Erro("Erros encontrados ao alterar dependente.");
                }
                return(retorno);
            }

            try
            {
                if (dependente.idDependente == null)
                {
                    repoDependente.Adicionar(dependente);
                }
                else
                {
                    repoDependente.Alterar(dependente);
                }
                contexto.SaveChanges();
                retorno.Ok("Cadastro de dependente realizado com sucesso.");
            }
            catch (Exception erro)
            {
                retorno.Erro(erro.Message);
            }
            return(retorno);
        }
예제 #22
0
        public Resultado Salvar(Agregado agregado)
        {
            Resultado retorno = new Resultado();

            Agregado agregadoConsulta = repoAgregado.ObterPorFiltros(c => c.idAgregado != agregado.idAgregado).FirstOrDefault();

            if (agregadoConsulta != null)
            {
                retorno.AddMensagem("Cadastro", "Agregado já cadastrado.");
            }

            if (!retorno.Sucesso)
            {
                if (agregado.idAgregado == null)
                {
                    retorno.Erro("Erros encontrados ao cadastrar o agregado");
                }
                else
                {
                    retorno.Erro("Erros encontrados ao alterar agregado.");
                }
                return(retorno);
            }

            try
            {
                if (agregado.idAgregado == null)
                {
                    repoAgregado.Adicionar(agregado);
                }
                else
                {
                    repoAgregado.Alterar(agregado);
                }
                contexto.SaveChanges();
                retorno.Ok("Cadastro de agregado realizado com sucesso.");
            }
            catch (Exception erro)
            {
                retorno.Erro(erro.Message);
            }
            return(retorno);
        }
예제 #23
0
        public Resultado DePara(DataTable dt, String NomeArquivo)
        {
            Resultado res = new Resultado();
            List <AAT_TBL_RET_DEB_CONTA> lsDebConta = new List <AAT_TBL_RET_DEB_CONTA>();
            int line_count = 1;

            base.DeleteData(NomeArquivo);

            foreach (DataRow row in dt.Rows)
            {
                String _data = row["DATA"].ToString();
                AAT_TBL_RET_DEB_CONTA newRetDebConta = new AAT_TBL_RET_DEB_CONTA();
                newRetDebConta.DCR_NOM_ARQ       = NomeArquivo;
                newRetDebConta.ID_TP_REGISTRO    = _data.Substring(0, 1);
                newRetDebConta.COD_EMPRESA       = _data.Substring(79, 3);
                newRetDebConta.NUM_REGISTRO      = _data.Substring(82, 9);
                newRetDebConta.NUM_REPRESENTANTE = _data.Substring(91, 8);
                newRetDebConta.ID_DEB_BANC       = _data.Substring(1, 25);
                newRetDebConta.NUM_NOSSO_NUMERO  = _data.Substring(69, 10);
                newRetDebConta.DTA_VENCIMENTO    = _data.Substring(44, 8);
                newRetDebConta.VLR_DEBITO        = _data.Substring(52, 15);
                newRetDebConta.AGENC_DEB_CONTA   = _data.Substring(26, 4);
                newRetDebConta.ID_CLIENTE_BANCO  = _data.Substring(30, 14);
                switch (newRetDebConta.ID_TP_REGISTRO)
                {
                case "A":
                    newRetDebConta.DTA_VENCIMENTO = _data.Substring(65, 8);
                    break;

                case "F":
                    newRetDebConta.COD_MOTIVO_RET = _data.Substring(67, 2);
                    break;
                }
                //newRetDebConta.COD_MOTIVO_RET=(newRetDebConta.ID_TP_REGISTRO=="F") ? _data.Substring(67, 2) : null;
                newRetDebConta.COD_MOVIMENTO = _data.Substring(149, 1);
                newRetDebConta.AAT_TBL_RET_DEB_CONTA_MOTIVO = GetMotivo(newRetDebConta.COD_MOTIVO_RET);
                newRetDebConta.NUM_SEQ_LINHA = line_count;
                line_count++;
                lsDebConta.Add(newRetDebConta);
            }

            Criticar(lsDebConta);

            if (lsDebConta.Count > 0)
            {
                base.Persistir(lsDebConta);
                res.Sucesso(lsDebConta.Count + " registro(s) importado(s) com sucesso.");
            }
            else
            {
                res.Erro("Nenhum registro localizado.");
            }

            return(res);
        }
예제 #24
0
        public Resultado InsertData(string new_TITULO, string new_AREA, int?new_ID_USUARIO, string new_STATUS, DateTime?new_DT_INCLUSAO, DateTime?new_DT_TERMINO, string new_OBS, decimal new_CHAMADO)
        {
            Resultado res = new Resultado();

            try
            {
                var inseri = m_DbContext.TB_PRIORIZACHAMADO.FirstOrDefault(p => p.CHAMADO == new_CHAMADO);
                if (inseri == null)
                {
                    var PC = new TB_PRIORIZACHAMADO
                    {
                        CHAMADO     = new_CHAMADO,
                        TITULO      = new_TITULO,
                        AREA        = new_AREA,
                        ID_USUARIO  = new_ID_USUARIO,
                        STATUS      = new_STATUS,
                        DT_INCLUSAO = new_DT_INCLUSAO,
                        DT_TERMINO  = new_DT_TERMINO,
                        DT_STATUS   = new_DT_INCLUSAO,
                        OBS         = new_OBS
                    };

                    m_DbContext.TB_PRIORIZACHAMADO.Add(PC);

                    int rows_inserted = m_DbContext.SaveChanges();
                    if (rows_inserted > 0)
                    {
                        res.Sucesso(String.Format("Registro inserido.", rows_inserted));
                    }
                }
                else
                {
                    res.Erro("Chamado já esta priorizado para outro analista.");
                }
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException ex)
            {
                res.Erro(Util.GetEntityValidationErrors(ex));
            }

            return(res);
        }
예제 #25
0
        public Resultado <List <AplicacaoFinanceira> > ObterTodos()
        {
            var lista = base.GetAll();

            if (!lista.Any())
            {
                return(Resultado <List <AplicacaoFinanceira> > .Erro("Nenhum registro encontrado."));
            }

            return(Resultado <List <AplicacaoFinanceira> > .OK(lista.ToList()));
        }
예제 #26
0
        public Resultado <AplicacaoFinanceira> ObterPorId(int id)
        {
            var aplicacao = base.GetById(id);

            if (aplicacao == null)
            {
                return(Resultado <AplicacaoFinanceira> .Erro("Aplicação não encontrada."));
            }

            return(Resultado <AplicacaoFinanceira> .OK(aplicacao));
        }
예제 #27
0
        public Resultado DeleteData(int iCOD_EMPRESTIMO_DESCONTO)
        {
            Resultado res = new Resultado();

            try
            {
                var delete = m_DbContext.AAT_TBL_EMPRESTIMO_DESCONTO.Find(iCOD_EMPRESTIMO_DESCONTO);
                m_DbContext.AAT_TBL_EMPRESTIMO_DESCONTO.Remove(delete);
                m_DbContext.SaveChanges();
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException ex)
            {
                res.Erro(Util.GetEntityValidationErrors(ex));
            }
            catch (System.Data.Entity.Infrastructure.DbUpdateException ex)
            {
                res.Erro(Util.GetInnerException(ex));
            }
            return(res);
        }
예제 #28
0
        public Resultado Alterar(Sistema objSistema)
        {
            Resultado retorno = new Resultado();

            if (objSistema.Codigo == byte.MinValue)
            {
                retorno.Erro("Código não informado");
                return(retorno);
            }

            if (String.IsNullOrEmpty(objSistema.Nome))
            {
                retorno.Erro("Nome não informada");
                return(retorno);
            }

            retorno = new SistemaDAL().Alterar(objSistema);

            return(retorno);
        }
예제 #29
0
        public Resultado Excluir(int id)
        {
            Resultado retorno = new Resultado();

            if (!retorno.Sucesso)
            {
                retorno.Erro("Encontrados erros ao excluir Agregado.");
                return(retorno);
            }
            try
            {
                repoAgregado.Remover(id);
                contexto.SaveChanges();
                retorno.Ok("Agregado removido com sucesso!");
            }
            catch (Exception erro)
            {
                retorno.Erro("Erros ao excluir o Agregado." + erro.Message);
            }
            return(retorno);
        }
예제 #30
0
        public Resultado DeleteData(short pAno_ref, short pMes_ref)
        {
            Resultado res = new Resultado();

            try
            {
                m_DbContext.AAT_TBL_EMPRESTIMO_DESCONTO
                .Where(e => e.ANO_REF == pAno_ref && e.MES_REF == pMes_ref)
                .ToList()
                .ForEach(e => m_DbContext.AAT_TBL_EMPRESTIMO_DESCONTO.Remove(e));
                m_DbContext.SaveChanges();
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException ex)
            {
                res.Erro(Util.GetEntityValidationErrors(ex));
            }
            catch (System.Data.Entity.Infrastructure.DbUpdateException ex)
            {
                res.Erro(Util.GetInnerException(ex));
            }
            return(res);
        }