Beispiel #1
0
        public static bool guardarCooperante(Cooperante cooperante)
        {
            bool ret = false;

            try
            {
                using (DbConnection db = new OracleContext().getConnection())
                {
                    long existe = db.ExecuteScalar <long>("SELECT COUNT(*) FROM COOPERANTE WHERE codigo=:codigo", new { codigo = cooperante.codigo });

                    if (existe > 0)
                    {
                        int result = db.Execute("UPDATE cooperante SET siglas=:siglas, nombre=:nombre, descripcion=:descripcion, usuario_creo=:usuarioCreo, " +
                                                "usuario_actualizo=:usuarioActualizo, fecha_creacion=:fechaCreacion, fecha_actualizacion=:fechaActualizacion, estado=:estado " +
                                                "WHERE codigo=:codigo AND ejercicio=:ejercicio", cooperante);
                        ret = result > 0 ? true : false;
                    }
                    else
                    {
                        int result = db.Execute("INSERT INTO cooperante VALUES (:codigo, :siglas, :nombre, :descripcion, :usuarioCreo, :usuarioActualizo, :fechaCreacion, " +
                                                ":fechaActualizacion, :estado, :ejercicio)", cooperante);
                        ret = result > 0 ? true : false;
                    }
                }
            }
            catch (Exception e)
            {
                CLogger.write("3", "CooperanteDAO.class", e);
            }
            return(ret);
        }
Beispiel #2
0
        public IActionResult Datos(string codigoPresupuestario)
        {
            try
            {
                DtmAvanceFisfinanDti inf = DataSigadeDAO.getavanceFisFinanDMS1(codigoPresupuestario);

                stprestamo temp = new stprestamo();
                if (inf != null)
                {
                    temp.codigoPresupuestario = inf.codigoPresupuestario;
                    temp.numeroPrestamo       = inf.noPrestamo;
                    temp.proyectoPrograma     = inf.nombrePrograma;
                    Cooperante cooperante = CooperanteDAO.getCooperantePorCodigo(inf.codigoOrganismoFinan ?? default(int));
                    if (cooperante != null)
                    {
                        temp.cooperantecodigo    = cooperante.codigo;
                        temp.cooperantenombre    = cooperante.nombre;
                        temp.cooperanteejercicio = cooperante.ejercicio;
                    }

                    temp.fechaDecreto = inf.fechaDecreto != null?inf.fechaDecreto.Value.ToString("dd/MM/yyyy H:mm:ss") : null;

                    temp.fechaSuscripcion = inf.fechaSuscripcion != null?inf.fechaSuscripcion.Value.ToString("dd/MM/yyyy H:mm:ss") : null;

                    temp.fechaVigencia = inf.fechaVigencia != null?inf.fechaVigencia.Value.ToString("dd/MM/yyyy H:mm:ss") : null;

                    TipoMoneda moneda = TipoMonedaDAO.getTipoMonedaPorSimbolo(inf.monedaPrestamo);
                    temp.tipoMonedaNombre       = String.Join("", moneda.nombre, " (" + moneda.simbolo + ")");
                    temp.tipoMonedaid           = moneda.id;
                    temp.montoContratado        = inf.montoContratado ?? default(decimal);
                    temp.montoContratadoUsd     = inf.montoContratadoUsd ?? default(decimal);
                    temp.montoContratadoQtz     = inf.montoContratadoGtq ?? default(decimal);
                    temp.desembolsoAFechaUsd    = inf.desembolsosUsd ?? default(decimal);
                    temp.montoPorDesembolsarUsd = inf.porDesembolsarUsd ?? default(decimal);
                    temp.objetivo   = inf.objetivo;
                    temp.fechaCorte = Utils.getFechaHoraNull(inf.fechaCorte);

                    return(Ok(new { success = true, prestamo = temp }));
                }
                else
                {
                    return(Ok(new { success = false }));
                }
            }
            catch (Exception e)
            {
                CLogger.write("1", "DataSigadeController.class", e);
                return(BadRequest(500));
            }
        }
        public IActionResult Cooperante([FromBody] dynamic value)
        {
            try
            {
                CooperanteValidator validator = new CooperanteValidator();
                ValidationResult    results   = validator.Validate(value);

                if (results.IsValid)
                {
                    Cooperante cooperante = new Cooperante();
                    cooperante.codigo        = value.codigo;
                    cooperante.descripcion   = value.descripcion;
                    cooperante.ejercicio     = value.ejercicio;
                    cooperante.estado        = value.estado;
                    cooperante.fechaCreacion = DateTime.Now;
                    cooperante.nombre        = value.nombre;
                    cooperante.siglas        = value.siglas;
                    cooperante.usuarioCreo   = User.Identity.Name;

                    bool result = CooperanteDAO.guardarCooperante(cooperante);

                    if (result)
                    {
                        return(Ok(new
                        {
                            success = true,
                            id = cooperante.codigo,
                            usuarioCreo = cooperante.usuarioCreo,
                            fechaCreacion = cooperante.fechaCreacion.ToString("dd/MM/yyyy H:mm:ss"),
                            usuarioactualizo = cooperante.usuarioActualizo != null ? cooperante.usuarioActualizo : "",
                            fechaactualizacion = cooperante.fechaActualizacion != null ? cooperante.fechaActualizacion.Value.ToString("dd/MM/yyyy H:mm:ss") : ""
                        }));
                    }
                    else
                    {
                        return(Ok(new { success = false }));
                    }
                }
                else
                {
                    return(Ok(new { success = false }));
                }
            }
            catch (Exception e)
            {
                CLogger.write("2", "CooperanteController.class", e);
                return(BadRequest(500));
            }
        }
Beispiel #4
0
        public static bool eliminarCooperante(Cooperante cooperante)
        {
            bool ret = false;

            try
            {
                cooperante.estado             = 0;
                cooperante.fechaActualizacion = DateTime.Now;
                ret = guardarCooperante(cooperante);
            }
            catch (Exception e)
            {
                CLogger.write("4", "CooperanteDAO.class", e);
            }
            return(ret);
        }
Beispiel #5
0
        public static Cooperante getCooperantePorCodigo(int codigo)
        {
            Cooperante ret = null;

            try
            {
                using (DbConnection db = new OracleContext().getConnection())
                {
                    ret = db.QueryFirstOrDefault <Cooperante>("SELECT c.* FROM Cooperante c WHERE c.estado = 1 and c.codigo=:codigo", new { codigo = codigo });
                }
            }
            catch (Exception e)
            {
                CLogger.write("7", "CooperanteDAO.class", e);
            }
            return(ret);
        }
Beispiel #6
0
        public static bool eliminarTotalCooperante(Cooperante cooperante)
        {
            bool ret = false;

            try
            {
                using (DbConnection db = new OracleContext().getConnection())
                {
                    var result = db.Execute("DELETE FROM cooperante WHERE codigo=:codigo AND ejercicio=:ejercicio", new { codigo = cooperante.codigo, ejercicio = cooperante.ejercicio });
                    ret = result > 1 ? true : false;
                }
            }
            catch (Exception e)
            {
                CLogger.write("5", "CooperanteDAO.class", e);
            }
            return(ret);
        }
        public IActionResult Cooperantes(int codigo)
        {
            try
            {
                if (codigo > 0)
                {
                    Cooperante cooperante = CooperanteDAO.getCooperantePorCodigo(codigo);
                    cooperante.usuarioActualizo = User.Identity.Name;

                    bool eliminado = CooperanteDAO.eliminarCooperante(cooperante);

                    return(Ok(new { success = (eliminado ? true : false) }));
                }
                else
                {
                    return(Ok(new { success = false }));
                }
            }
            catch (Exception e)
            {
                CLogger.write("4", "CooperanteController.class", e);
                return(BadRequest(500));
            }
        }