public static List <Prestamos> ObtenerPrestamos() { //return listaProveedores; Prestamos prestamo; listaPrestamos.Clear(); using (SqlConnection con = new SqlConnection(SqlServer.CADENA_CONEXION)) { con.Open(); string textoCmd = "Select * from Prestamos"; SqlCommand cmd = new SqlCommand(textoCmd, con); SqlDataReader elLectorDeDatos = cmd.ExecuteReader(); while (elLectorDeDatos.Read()) { prestamo = new Prestamos(); prestamo.Id = elLectorDeDatos.GetInt32(0); prestamo.fechaInicio = elLectorDeDatos.GetDateTime(1); prestamo.fechaFin = elLectorDeDatos.GetDateTime(2); prestamo.socio = Socios.ObtenerSocio(elLectorDeDatos.GetInt32(3)); prestamo.usuario = Usuarios.ObtenerUsuario(elLectorDeDatos.GetInt32(4)); prestamo.libro = Libros.ObtenerLibro(elLectorDeDatos.GetInt32(5)); listaPrestamos.Add(prestamo); } } return(listaPrestamos); }
public static List <Libros> ObtenerLibros() { //return listaProveedores; Libros libro; listalibros.Clear(); using (SqlConnection con = new SqlConnection(SqlServer.CADENA_CONEXION)) { con.Open(); string textoCmd = "Select l.*, a.Id from Libro l inner join AutorLibro al on l.Id = al.IdLibro inner join Autor a on a.Id= al.IdAutor"; SqlCommand cmd = new SqlCommand(textoCmd, con); SqlDataReader elLectorDeDatos = cmd.ExecuteReader(); while (elLectorDeDatos.Read()) { libro = new Libros(); libro.Id = elLectorDeDatos.GetInt32(0); libro.titulo = elLectorDeDatos.GetString(1); libro.ISBN = elLectorDeDatos.GetInt32(2); libro.año = elLectorDeDatos.GetInt32(3); libro.idioma = (Idioma)elLectorDeDatos.GetInt32(4); libro.genero = (Genero)elLectorDeDatos.GetInt32(5); libro.editorial = Editorial.ObtenerEditorial(elLectorDeDatos.GetInt32(6)); libro.autor = Autor.ObtenerAutores(elLectorDeDatos.GetInt32(7)); listalibros.Add(libro); } } return(listalibros); }
public string MostrarPrestamo(Socios cliente, Usuarios encargado, Libros objeto) { this.socio = cliente; this.usuario = encargado; this.libro = objeto; return(String.Format("{0} prestado a {1} {2} en fecha {3}", this.libro.titulo, this.socio.Nombre, this.socio.Apellido, this.fechaInicio)); }
public static Libros ObtenerLibro(int id) { Libros libro = null; if (listalibros.Count == 0) { Libros.ObtenerLibros(); } foreach (Libros l in listalibros) { if (l.Id == id) { libro = l; break; } } return(libro); }
public static void AgregarLibros(Libros l) { listalibros.Add(l); }