Exemplo n.º 1
0
        public static List<Pabellonero> VistaPabellonero()
        {
            using (OracleConnection conn = Conexion.conectar())
            {
                conn.Open();
                List<Pabellonero> nuevaLista = new List<Pabellonero>();
                OracleCommand consulta = new OracleCommand("prMostrarPabellonero", conn);
                consulta.CommandType = CommandType.StoredProcedure;
                consulta.Parameters.Add("p_cursor", OracleDbType.RefCursor).Direction = ParameterDirection.Output;
                consulta.ExecuteNonQuery();
                OracleDataReader dr = ((OracleRefCursor)consulta.Parameters["p_cursor"].Value).GetDataReader();
                while (dr.Read())
                {
                    Pabellonero nuevo = new Pabellonero();
                    nuevo.Rutpabellonero = dr[0].ToString();
                    nuevo.Nombre = dr[1].ToString();
                    nuevo.Apellido = dr[2].ToString();
                    nuevo.Fono = int.Parse(dr[3].ToString());
                    nuevo.Email = dr[4].ToString();
                    nuevaLista.Add(nuevo);
                }

                conn.Close();

                return nuevaLista;
            }
        }
Exemplo n.º 2
0
        public static List<Agenda> VistaAgenda()
        {
            using (OracleConnection conn = Conexion.conectar())
            {
                conn.Open();
                List<Agenda> nuevaLista = new List<Agenda>();
                OracleCommand consulta = new OracleCommand("prMostrarAgenda", conn);
                consulta.CommandType = CommandType.StoredProcedure;
                consulta.Parameters.Add("p_cursor", OracleDbType.RefCursor).Direction = ParameterDirection.Output;
                consulta.ExecuteNonQuery();
                OracleDataReader dr = ((OracleRefCursor)consulta.Parameters["p_cursor"].Value).GetDataReader();
                while (dr.Read())
                {
                    Agenda nuevo = new Agenda();
                    nuevo.Idagenda = int.Parse(dr[0].ToString());
                    nuevo.Horainicio = dr[1].ToString();
                    nuevo.Horatermino = dr[2].ToString();
                    int duracion;
                    bool parse = int.TryParse(dr[3].ToString(), out duracion);
                    nuevo.Duracion = duracion;
                    DateTime tiempo;
                    bool validar = DateTime.TryParse(dr[4].ToString(), out tiempo);
                    nuevo.Fecha = tiempo;
                    nuevo.Aseo = dr[5].ToString();
                    List<Usuario> listausuario = VistaUsuario().Where(a => a.Rutusuario == dr[6].ToString()).ToList();
                    nuevo.Fk_Usuario = listausuario.First();

                    List<Paciente> listapaciente = VistaPacientes().Where(a => a.Rut == dr[7].ToString()).ToList();

                    if (listapaciente.Count() != 0)
                    {
                        nuevo.Fk_Paciente = listapaciente[0];
                    }

                    List<Pabellon> listapabellon = VistaPabellon().Where(a => a.Idpabellon.ToString() == dr[8].ToString()).ToList();
                    if (listapabellon.Count() != 0)
                    {
                        nuevo.Fk_Pabellon = listapabellon[0];
                    }

                    List<Enfermero> listaenfermero = VistanEnfermero().Where(a => a.Rutenfermero == dr[9].ToString()).ToList();
                    if (listaenfermero.Count() != 0)
                    {
                        nuevo.Fk_Enfermero = listaenfermero[0];
                    }
                    else
                    {
                        Enfermero en = new Enfermero();
                        en.Nombre = "[No Especificado]";
                        en.Apellido = "";
                        nuevo.Fk_Enfermero = en;
                    }

                    List<Cirujano> listacirujano = VistaCirujano().Where(a => a.RutCirujano == dr[10].ToString()).ToList();
                    if (listacirujano.Count() != 0)
                    {
                        nuevo.Fk_Cirujano = listacirujano[0];
                    }

                    List<Pabellonero> listapabellonero = VistaPabellonero().Where(a => a.Rutpabellonero == dr[11].ToString()).ToList();
                    if (listapabellonero.Count() != 0)
                    {
                        nuevo.Fk_Pabellonero = listapabellonero[0];
                    }
                    else
                    {
                        Pabellonero pa = new Pabellonero();
                        pa.Nombre = "[No Especificado]";
                        pa.Apellido = "";
                        nuevo.Fk_Pabellonero = pa;
                    }

                    List<Anestesista> listaanestesista = VistanAnestesista().Where(a => a.Rutanestesista == dr[12].ToString()).ToList();
                    if (listaanestesista.Count == 0)
                    {
                        Anestesista an = new Anestesista();
                        an.Nombre = "[No Especificado]";
                        an.Apellido = "";
                        nuevo.Fk_Anestesista = an;
                    }
                    else
                    {
                        if (listaanestesista[0] != null)
                        {
                            nuevo.Fk_Anestesista = listaanestesista[0];
                        }
                    }

                    List<Tanestesista> listatanestesista = VistanTanestesista().Where(a => a.Ruttanestesista == dr[13].ToString()).ToList();
                    if (listatanestesista.Count() != 0)
                    {
                        nuevo.Fk_Tanestesia = listatanestesista[0];
                    }
                    else
                    {
                        Tanestesista ta = new Tanestesista();
                        ta.Nombre = "[No Especificado]";
                        ta.Apellido = "";
                        nuevo.Fk_Tanestesia = ta;
                    }

                    List<Arsenalero> listaarsenalero = VistanArsenalero().Where(a => a.Rutarsenalero == dr[14].ToString()).ToList();
                    if (listaarsenalero.Count() != 0)
                    {
                        nuevo.Fk_Arsenalero = listaarsenalero[0];
                    }
                    else
                    {
                        Arsenalero ar = new Arsenalero();
                        ar.Nombre = "[No Especificado]";
                        ar.Apellido = "";
                        nuevo.Fk_Arsenalero = ar;
                    }

                    nuevo.Fk_Especialidad = VistaEspecialidada().Where(a => a.Idespecialidad.ToString() == dr[15].ToString()).First();

                    nuevo.Fk_Estado = VistaEstado().Where(a => a.Idestado.ToString() == dr[16].ToString()).First();

                    nuevaLista.Add(nuevo);
                }

                conn.Close();

                return nuevaLista;
            }
        }