Exemplo n.º 1
0
  public static int editBook(Book book) throws Exception {
    int intStat = 0;

    String sql =
        "UPDATE Books SET ISBN10 = ?, ISBN13 = ?, "
            + "Title = ?, Author = ?, Edition = ?, Publisher = ?, "
            + "Description = ?, YearPublish = ?, Copies = ? "
            + "WHERE ID = ?";

    PreparedStatement ps = Connector.getConnection().prepareStatement(sql);

    ps.setString(1, book.getIsbn10());
    ps.setString(2, book.getIsbn13());
    ps.setString(3, book.getTitle());
    ps.setString(4, book.getAuthor());
    ps.setString(5, book.getEdition());
    ps.setString(6, book.getPublisher());
    ps.setString(7, book.getDescription());
    ps.setInt(8, book.getYearPublish());
    ps.setInt(9, book.getCopies());
    ps.setInt(10, book.getBookId());

    intStat = ps.executeUpdate();

    Connector.close();

    return intStat;
  }
Exemplo n.º 2
0
  public static int addBook(Book book) throws Exception {
    int intStat = 0;

    if (null != book.getIsbn10()) {
      book.setIsbn13(IsbnUtil.convert(book.getIsbn10()));
    } else {
      book.setIsbn10(IsbnUtil.convert(book.getIsbn13()));
    }

    String sql =
        "INSERT INTO Books (ISBN10, ISBN13, Title, Author, "
            + "Edition, Publisher, Description, YearPublish, "
            + "Copies) VALUES (?,?,?,?,?,?,?,?,?)";

    PreparedStatement ps = Connector.getConnection().prepareStatement(sql);
    ps.setString(1, book.getIsbn10());
    ps.setString(2, book.getIsbn13());
    ps.setString(3, book.getTitle());
    ps.setString(4, book.getAuthor());
    ps.setString(5, book.getEdition());
    ps.setString(6, book.getPublisher());
    ps.setString(7, book.getDescription());
    ps.setInt(8, book.getYearPublish());
    ps.setInt(9, book.getCopies());

    intStat = ps.executeUpdate();

    Connector.close();

    return intStat;
  }
Exemplo n.º 3
0
 public OwnedBook(Book book) {
   super(
       book.getId(),
       book.getGoodreadsId(),
       book.getAuthorName(),
       book.getGoodreadsAuthorId(),
       book.getName(),
       book.getIsbn(),
       book.getIsbn13(),
       book.getPublishedYear(),
       book.getDescription(),
       book.getPublisher(),
       book.getNumberOfPages(),
       book.getImageUrl());
   setBookType(book.getBookType());
 }
Exemplo n.º 4
0
  private void majListBook() {
    ListView bookList = (ListView) findViewById(R.id.bookList);
    List<Map<String, String>> l_books = new ArrayList<Map<String, String>>();

    for (Book book : BookCollection.getBooks()) {
      Map<String, String> bookMap = new HashMap<String, String>();
      bookMap.put("img", String.valueOf(book.getId_img())); // use available img
      bookMap.put("author", book.getAuthor());
      bookMap.put("title", book.getTitle());
      bookMap.put("gender", book.getGender());
      bookMap.put("isbn", book.getIsbn());
      bookMap.put("year", book.getYear());
      bookMap.put("description", book.getDescription());
      l_books.add(bookMap);
    }

    SimpleAdapter listAdapter =
        new SimpleAdapter(
            this.getBaseContext(),
            l_books,
            R.layout.book_detail,
            /*ajout gender*/
            new String[] {"img", "author", "title", "gender", "isbn", "year", "description"},
            new int[] {
              R.id.img_cover,
              R.id.author,
              R.id.title,
              R.id.gender,
              R.id.isbn,
              R.id.year,
              R.id.description
            });

    bookList.setAdapter(listAdapter);
    bookList.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            ActionBar actionBar = getSupportActionBar();
            HashMap<String, String> map =
                (HashMap<String, String>) parent.getItemAtPosition(position);
            actionBar.setTitle(map.get("title"));
            lastItemClicked = position;
            System.out.println(position + "   " + id);
          }
        });
  }