Ejemplo n.º 1
0
        public static T_GUQ_PRESUPUESTO Obtener(int id)
        {
            RicardoPalmaEntities db = new RicardoPalmaEntities();
            var presupuesto         = db.T_GUQ_PRESUPUESTO.Find(id);

            return(presupuesto);
        }
Ejemplo n.º 2
0
        public static List <T_GG_EMPLEADO> ListarMedicos(int tipoOperacion, DateTime fecha, int hora)
        {
            List <T_GG_EMPLEADO> lista      = new List <T_GG_EMPLEADO>();
            DateTime             nuevaFecha = Convert.ToDateTime(fecha);

            if (nuevaFecha.CompareTo(new DateTime(1900, 1, 1)) == 0)
            {
                return(lista);
            }
            try
            {
                RicardoPalmaEntities db = new RicardoPalmaEntities();
                var      tipo           = db.T_GUQ_TIPO_OPERACIÓN.Find(tipoOperacion);
                DateTime fechaInicio;
                DateTime fechaFin;
                fechaInicio = fecha.AddHours(hora);
                fechaInicio = fechaInicio.AddHours((Convert.ToInt32(tipo.duracion) - 1) * -1);
                fechaFin    = nuevaFecha.AddHours(hora);
                fechaFin    = fechaFin.AddHours(Convert.ToInt32(tipo.duracion) - 1);

                var listaEspecialidad = db.T_GDA_ESPECIALIDAD__MEDICA.Where(x => x.idOperacion == tipoOperacion).ToList();
                var listaEmpleados    = db.T_GG_EMPLEADO.ToList();
                listaEmpleados = listaEmpleados.Where(x => listaEspecialidad.Any(y => y.idEspecialidad == x.idEspecialidad)).ToList();

                var reservas = db.T_GUQ_RESERVA_SALA_OPERACIÓN.Where(x => x.fechaInicio >= fechaInicio && x.fechaInicio <= fechaFin).ToList();

                lista = listaEmpleados.Where(x => !reservas.Any(y => y.idEmpleado == x.idEmpleado)).ToList();
            }
            catch (Exception ex)
            {
                log.Error("Error al consultar los médicos", ex);
            }

            return(lista);
        }
Ejemplo n.º 3
0
        public static bool Editar(T_GDA_INGRESOUCI IngresoUCI)
        {
            bool exito = false;
            RicardoPalmaEntities db = new RicardoPalmaEntities();

            try
            {
                db.Database.ExecuteSqlCommand(
                    "UPDATE T_GDA_INGRESOUCI SET estPaciente = @p1 , gravedad =  @p2 , motDesaprobacion = @p3 , obsDesaprobacion = @p4 WHERE idIngreso = @p5",
                    new SqlParameter[]
                {
                    new SqlParameter("p1", IngresoUCI.estPaciente),
                    new SqlParameter("p2", IngresoUCI.gravedad),
                    new SqlParameter("p3", IngresoUCI.motDesaprobacion),
                    new SqlParameter("p4", IngresoUCI.obsDesaprobacion),
                    new SqlParameter("p5", IngresoUCI.idIngreso),
                }
                    );
                db.SaveChanges();
                exito = true;
            }
            catch (Exception ex)
            {
                exito = false;
                Bitacora.CrearLog("Error al editar el presupuesto", TipoLog.Error, ex);
            }

            return(exito);
        }
Ejemplo n.º 4
0
        public static List <T_GDA_PACIENTE> ListarPacientes(int tipoOperacion, DateTime fecha, int hora)
        {
            List <T_GDA_PACIENTE> lista = new List <T_GDA_PACIENTE>();
            DateTime nuevaFecha         = Convert.ToDateTime(fecha);

            if (nuevaFecha.CompareTo(new DateTime(1900, 1, 1)) == 0)
            {
                return(lista);
            }
            try
            {
                RicardoPalmaEntities db = new RicardoPalmaEntities();
                var      tipo           = db.T_GUQ_TIPO_OPERACIÓN.Find(tipoOperacion);
                DateTime fechaInicio;
                DateTime fechaFin;
                fechaInicio = fecha.AddHours(hora);
                fechaInicio = fechaInicio.AddHours((Convert.ToInt32(tipo.duracion) - 1) * -1);
                fechaFin    = nuevaFecha.AddHours(hora);
                fechaFin    = fechaFin.AddHours(Convert.ToInt32(tipo.duracion) - 1);

                var listaEmpleados = db.T_GDA_PACIENTE.ToList();
                var reservas       = db.T_GUQ_RESERVA_SALA_OPERACIÓN.Where(x => x.fechaInicio >= fechaInicio && x.fechaInicio <= fechaFin).ToList();

                lista = listaEmpleados.Where(x => !reservas.Any(y => y.idPaciente == x.idPaciente)).ToList();
            }
            catch (Exception ex)
            {
                log.Error("Error al consultar los pacientes", ex);
            }

            return(lista);
        }
Ejemplo n.º 5
0
        public static T_GDA_INGRESOUCI Obtener(int id)
        {
            RicardoPalmaEntities db = new RicardoPalmaEntities();
            var ingreso             = db.T_GDA_INGRESOUCI.Find(id);

            return(ingreso);
        }
Ejemplo n.º 6
0
        public static bool Editar(T_GUQ_PRESUPUESTO presupuesto, List <T_GUQ_PARTIDA> listaPartidas, List <double> listaMontos)
        {
            bool exito = false;

            try
            {
                RicardoPalmaEntities      db = new RicardoPalmaEntities();
                T_GUQ_PRESUPUESTO_PARTIDA PresupuestoPartida;


                db.Database.ExecuteSqlCommand(
                    "DELETE FROM  T_GUQ_PRESUPUESTO_PARTIDA  WHERE idPresupuesto = @idPer",
                    new SqlParameter[]
                {
                    new SqlParameter("idPer", presupuesto.idPresupuesto)
                }
                    );

                presupuesto.estado = "Generado";
                presupuesto.monto  = 0;
                for (int i = 0; i < listaPartidas.Count(); i++)
                {
                    PresupuestoPartida               = new T_GUQ_PRESUPUESTO_PARTIDA();
                    PresupuestoPartida.idPartida     = listaPartidas[i].idPartida;
                    PresupuestoPartida.idPresupuesto = presupuesto.idPresupuesto;
                    PresupuestoPartida.montoPartida  = listaMontos[i];
                    presupuesto.idPresupuesto        = presupuesto.idPresupuesto;
                    presupuesto.monto = presupuesto.monto + listaMontos[i];

                    db.Database.ExecuteSqlCommand(
                        "InSERT INTO  T_GUQ_PRESUPUESTO_PARTIDA VALUES(@P1,@P2,@P3)",
                        new SqlParameter[]
                    {
                        new SqlParameter("P1", PresupuestoPartida.idPresupuesto),
                        new SqlParameter("P2", PresupuestoPartida.idPartida),
                        new SqlParameter("P3", PresupuestoPartida.montoPartida)
                    }
                        );
                }

                db.Database.ExecuteSqlCommand(
                    "UPDATE   T_GUQ_PRESUPUESTO SET monto = @p1  WHERE idPresupuesto = @p2",
                    new SqlParameter[]
                {
                    new SqlParameter("P1", presupuesto.monto),
                    new SqlParameter("P2", presupuesto.idPresupuesto)
                }
                    );

                db.SaveChanges();

                exito = true;
            }
            catch (Exception ex)
            {
                exito = false;
                Bitacora.CrearLog("Error al editar el presupuesto", TipoLog.Error, ex);
            }
            return(exito);
        }
Ejemplo n.º 7
0
        public static T_GUQ_PARTIDA Obtener(int id)
        {
            RicardoPalmaEntities db = new RicardoPalmaEntities();
            var partida             = db.T_GUQ_PARTIDA.Find(id);

            return(partida);
        }
Ejemplo n.º 8
0
        public static List <T_GG_EMPLEADO> ListarDisponibles(int tipoOperacion)
        {
            RicardoPalmaEntities db = new RicardoPalmaEntities();
            var listaEspecialidad   = db.T_GDA_ESPECIALIDAD__MEDICA.Where(x => x.idOperacion == tipoOperacion).ToList();
            var listaEmpleados      = db.T_GG_EMPLEADO.ToList();

            listaEmpleados = listaEmpleados.Where(x => listaEspecialidad.Any(y => y.idEspecialidad == x.idEspecialidad)).ToList();
            return(listaEmpleados);
        }
Ejemplo n.º 9
0
        public static List <string> ListarHorarios(string fecha, int inmueble, int tipo)
        {
            List <String> horario = new List <string>();
            TimeSpan      result;
            string        timeString;
            DateTime      nuevaFecha = Convert.ToDateTime(fecha);

            if (nuevaFecha.CompareTo(new DateTime(1900, 1, 1)) == 0)
            {
                return(horario);
            }

            try
            {
                RicardoPalmaEntities db = new RicardoPalmaEntities();
                var tipoOperacion       = db.T_GUQ_TIPO_OPERACIÓN.Find(tipo);
                if (tipoOperacion == null)
                {
                    return(horario);
                }
                List <T_GUQ_RESERVA_SALA_OPERACIÓN> reservas = new List <T_GUQ_RESERVA_SALA_OPERACIÓN>();;
                DateTime fechaInicio;
                DateTime fechaFin;
                for (int i = 0; i < 24; i++)
                {
                    fechaInicio = nuevaFecha.AddHours(i);
                    fechaInicio = fechaInicio.AddHours((Convert.ToInt32(tipoOperacion.duracion) - 1) * -1);
                    fechaFin    = nuevaFecha.AddHours(i);
                    fechaFin    = fechaFin.AddHours(Convert.ToInt32(tipoOperacion.duracion) - 1);
                    reservas    = db.T_GUQ_RESERVA_SALA_OPERACIÓN.Where(x => x.idInmueble == inmueble && x.fechaInicio >= fechaInicio && x.fechaInicio <= fechaFin).ToList();

                    if (reservas == null || reservas.Count == 0)
                    {
                        result     = TimeSpan.FromHours(i);
                        timeString = result.ToString("hh':'mm");
                        horario.Add(timeString);
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error("Error al consultar los horarios", ex);
            }

            return(horario);
        }
Ejemplo n.º 10
0
        public static bool Crear(T_GUQ_RESERVA_SALA_OPERACIÓN reserva)
        {
            bool exito = false;

            try
            {
                RicardoPalmaEntities db = new RicardoPalmaEntities();
                db.T_GUQ_RESERVA_SALA_OPERACIÓN.Add(reserva);
                db.SaveChanges();
                exito = true;
            }
            catch (Exception ex)
            {
                exito = false;
                Bitacora.CrearLog("Error al crear la reserva", TipoLog.Error, ex);
            }
            return(exito);
        }
Ejemplo n.º 11
0
        public static bool Crear(T_GUQ_PRESUPUESTO_PARTIDA presupuestoPartida)
        {
            bool exito = false;

            try
            {
                RicardoPalmaEntities db = new RicardoPalmaEntities();

                db.T_GUQ_PRESUPUESTO_PARTIDA.Add(presupuestoPartida);
                db.SaveChanges();
                exito = true;
            }
            catch (Exception ex)
            {
                exito = false;
                Bitacora.CrearLog("Error al crear el presupuesto", TipoLog.Error, ex);
            }
            return(exito);
        }
Ejemplo n.º 12
0
        public static bool Crear(T_GUQ_PRESUPUESTO presupuesto, List <T_GUQ_PARTIDA> listaPartidas, List <double> listaMontos)
        {
            bool exito = false;

            try
            {
                RicardoPalmaEntities      db = new RicardoPalmaEntities();
                T_GUQ_PRESUPUESTO_PARTIDA PresupuestoPartida;


                presupuesto.estado = "Generado";
                for (int i = 0; i < listaPartidas.Count(); i++)
                {
                    PresupuestoPartida              = new T_GUQ_PRESUPUESTO_PARTIDA();
                    PresupuestoPartida.idPartida    = listaPartidas[i].idPartida;
                    PresupuestoPartida.montoPartida = listaMontos[i];
                    presupuesto.monto = presupuesto.monto + listaMontos[i];
                    presupuesto.T_GUQ_PRESUPUESTO_PARTIDA.Add(PresupuestoPartida);
                }

                db.Entry(presupuesto).State = EntityState.Added;
                //  db.T_GUQ_PRESUPUESTO.Add(presupuesto);

                for (int i = 0; i < listaPartidas.Count(); i++)
                {
                    db.Entry(listaPartidas[i]).State = EntityState.Unchanged;
                }

                db.SaveChanges();
                exito = true;
            }

            catch (Exception ex)
            {
                exito = false;
                Bitacora.CrearLog("Error al crear el presupuesto", TipoLog.Error, ex);
            }
            return(exito);
        }
Ejemplo n.º 13
0
        public static double ObtenerPromedio(int anio, int partida, int area)
        {
            RicardoPalmaEntities db = new RicardoPalmaEntities();
            double monto            = 0.00;
            double promedio         = 0.00;

            var listaMontos = db.T_GUQ_ESTADÍSTICA_RECURSOS.Where(c => c.idPartida == partida)
                              .Where(c => c.anio < anio)
                              .Where(c => c.anio >= anio - 3)
                              .Where(c => c.idArea == area).Select(c => c.montoHistórico).ToList();

            if (listaMontos.Count != 0)
            {
                for (int i = 0; i < listaMontos.Count; i++)
                {
                    monto = monto + listaMontos[i];
                }
                promedio = monto / 3;
            }



            return(Math.Round(promedio, 2));
        }
Ejemplo n.º 14
0
        public static List <T_GUQ_PARTIDA> ListarTodos()
        {
            RicardoPalmaEntities db = new RicardoPalmaEntities();

            return(db.T_GUQ_PARTIDA.ToList());
        }
Ejemplo n.º 15
0
        public static List <T_GG_EMPLEADO> GetAll()
        {
            RicardoPalmaEntities db = new RicardoPalmaEntities();

            return(db.T_GG_EMPLEADO.ToList());
        }
Ejemplo n.º 16
0
        public static List <T_GG_INMUEBLE> ListarTodos(int area)
        {
            RicardoPalmaEntities db = new RicardoPalmaEntities();

            return(db.T_GG_INMUEBLE.Where(x => x.idArea == area).ToList());
        }
Ejemplo n.º 17
0
        public static List <T_GG_INMUEBLE> ListarDisponibles(int tipoOperacion)
        {
            RicardoPalmaEntities db = new RicardoPalmaEntities();

            return(db.T_GG_INMUEBLE.Where(x => x.T_GUQ_TIPO_OPERACIÓN.Where(y => y.idOperación == tipoOperacion).Any()).ToList());
        }
Ejemplo n.º 18
0
        public static List <T_GUQ_RESERVA_SALA_OPERACIÓN> ListarTodos()
        {
            RicardoPalmaEntities db = new RicardoPalmaEntities();

            return(db.T_GUQ_RESERVA_SALA_OPERACIÓN.ToList());
        }
Ejemplo n.º 19
0
        public static List <T_GDA_INGRESOUCI> ListarTodos()
        {
            RicardoPalmaEntities db = new RicardoPalmaEntities();

            return(db.T_GDA_INGRESOUCI.Where(c => c.estPaciente == "En espera").ToList());
        }
Ejemplo n.º 20
0
        public static T_GUQ_TIPO_OPERACIÓN Obtener(int idOperacion)
        {
            RicardoPalmaEntities db = new RicardoPalmaEntities();

            return(db.T_GUQ_TIPO_OPERACIÓN.Find(idOperacion));
        }
Ejemplo n.º 21
0
        public static List <T_GDA_PACIENTE> ListarTodos()
        {
            RicardoPalmaEntities db = new RicardoPalmaEntities();

            return(db.T_GDA_PACIENTE.ToList());
        }
Ejemplo n.º 22
0
        public static List <T_GUQ_PRESUPUESTO> ListarTodos()
        {
            RicardoPalmaEntities db = new RicardoPalmaEntities();

            return(db.T_GUQ_PRESUPUESTO.ToList());
        }