public static List<Renta> GetAllRentas()
        {
            conn.Open();

            string sql = "SELECT * FROM Rentas";
            SqlCommand command = new SqlCommand(sql, conn);
            var reader = command.ExecuteReader();

            var rentas = new List<Renta>();
            while (reader.Read())
            {
                Renta renta = new Renta();
                renta.id = (int)reader["id"];
                renta.idCliente = (int) reader["id_cliente"];
                renta.idTitulo = (int)reader["id_titulo"];
                renta.idRecargo = (int)reader["id_recargo"];
                renta.fechaDevolucion = (DateTime) reader["fecha_devolucion"];

                rentas.Add(renta);
            }

            conn.Close();

            return rentas;
        }
        public static bool InsertRenta(Renta renta)
        {
            conn.Open();

            string sql = "INSERT INTO Rentas (id_cliente, id_titulo, id_recargo, fecha_devolucion) VALUES (@idCliente, @idTitulo, @idRecargo, @fecha_devolucion)";
            SqlCommand command = new SqlCommand(sql, conn);
            command.Parameters.Add(new SqlParameter("@idCliente", renta.idCliente));
            command.Parameters.Add(new SqlParameter("@idTitulo", renta.idTitulo));
            command.Parameters.Add(new SqlParameter("@idRecargo", renta.idRecargo));
            command.Parameters.Add(new SqlParameter("@fecha_devolucion", renta.fechaDevolucion));

            int res = command.ExecuteNonQuery();
            conn.Close();

            return (res == 1);
        }
        public static Renta GetRenta(int id)
        {
            conn.Open ();

            string sql = String.Format ("SELECT * FROM Rentas WHERE Id = {0}", id);
            SqlCommand command = new SqlCommand(sql, conn);
            var reader = command.ExecuteReader();

            Renta renta = new Renta ();

            while (reader.Read ())
            {
                renta.id                = (int) reader ["id"];
                renta.idCliente         = (int) reader ["id_cliente"];
                renta.idTitulo          = (int) reader ["id_titulo"];
                renta.idRecargo         = (int) reader ["id_recargo"];
                renta.fechaDevolucion   = (DateTime) reader ["fecha_devolucion"];
            }

            conn.Close();

            return renta;
        }
        public static bool UpdateRenta(int id, Renta renta)
        {
            conn.Open();

            string sql = "UPDATE Rentas SET id_cliente = @idCliente, id_titulo = @idTitulo, id_recargo = @id_recargo, fecha_devolucion = @fechaDevolucion WHERE Id = @id";
            SqlCommand command = new SqlCommand(sql, conn);
            command.Parameters.Add(new SqlParameter("@idCliente", renta.idCliente));
            command.Parameters.Add(new SqlParameter("@idTitulo", renta.idTitulo));
            command.Parameters.Add(new SqlParameter("@idRecargo", renta.idRecargo));
            command.Parameters.Add(new SqlParameter("@fechaDevolucion", renta.fechaDevolucion));
            command.Parameters.Add(new SqlParameter("@id", id));

            int res = command.ExecuteNonQuery();

            conn.Close();

            return res == 1;
        }