diff --git a/build/built-jar.properties b/build/built-jar.properties index b8bf569..ce2e78c 100644 --- a/build/built-jar.properties +++ b/build/built-jar.properties @@ -1,4 +1,4 @@ -#Mon, 30 May 2016 12:41:20 +0200 +#Mon, 06 Jun 2016 11:21:26 +0200 D\:\\PROJEKT\\Library= diff --git a/build/classes/library/Book.class b/build/classes/library/Book.class index b3c5974..d1c9fd6 100644 Binary files a/build/classes/library/Book.class and b/build/classes/library/Book.class differ diff --git a/build/classes/library/MainMenu$1.class b/build/classes/library/MainMenu$1.class index 9f7720e..ab7e0c5 100644 Binary files a/build/classes/library/MainMenu$1.class and b/build/classes/library/MainMenu$1.class differ diff --git a/build/classes/library/MainMenu$2.class b/build/classes/library/MainMenu$2.class index beb34c5..841ba53 100644 Binary files a/build/classes/library/MainMenu$2.class and b/build/classes/library/MainMenu$2.class differ diff --git a/build/classes/library/MainMenu$3.class b/build/classes/library/MainMenu$3.class index cf6de05..b70fc3a 100644 Binary files a/build/classes/library/MainMenu$3.class and b/build/classes/library/MainMenu$3.class differ diff --git a/build/classes/library/MainMenu$4.class b/build/classes/library/MainMenu$4.class index dceab63..513ca90 100644 Binary files a/build/classes/library/MainMenu$4.class and b/build/classes/library/MainMenu$4.class differ diff --git a/build/classes/library/MainMenu$5.class b/build/classes/library/MainMenu$5.class index 124f851..6956f1b 100644 Binary files a/build/classes/library/MainMenu$5.class and b/build/classes/library/MainMenu$5.class differ diff --git a/build/classes/library/MainMenu$6.class b/build/classes/library/MainMenu$6.class index bdaa70c..5ada160 100644 Binary files a/build/classes/library/MainMenu$6.class and b/build/classes/library/MainMenu$6.class differ diff --git a/build/classes/library/MainMenu$7.class b/build/classes/library/MainMenu$7.class index b3ba5db..5136975 100644 Binary files a/build/classes/library/MainMenu$7.class and b/build/classes/library/MainMenu$7.class differ diff --git a/build/classes/library/MainMenu$8.class b/build/classes/library/MainMenu$8.class index d37db59..d7724d6 100644 Binary files a/build/classes/library/MainMenu$8.class and b/build/classes/library/MainMenu$8.class differ diff --git a/build/classes/library/MainMenu.class b/build/classes/library/MainMenu.class index 70e3da2..c795486 100644 Binary files a/build/classes/library/MainMenu.class and b/build/classes/library/MainMenu.class differ diff --git a/build/classes/library/MainMenu.form b/build/classes/library/MainMenu.form index ac40e85..41829cb 100644 --- a/build/classes/library/MainMenu.form +++ b/build/classes/library/MainMenu.form @@ -43,7 +43,10 @@ - + + + + @@ -57,7 +60,9 @@ - + + + @@ -214,5 +219,13 @@ + + + + + + + + diff --git a/dist/Library.jar b/dist/Library.jar index 78849cf..b04852e 100644 Binary files a/dist/Library.jar and b/dist/Library.jar differ diff --git a/nbproject/private/private.xml b/nbproject/private/private.xml index 152c09b..6aefde8 100644 --- a/nbproject/private/private.xml +++ b/nbproject/private/private.xml @@ -4,9 +4,16 @@ file:/D:/PROJEKT/Library/src/library/MovieFieldPattern.java - file:/D:/PROJEKT/Library/src/library/MainMenu.java file:/D:/PROJEKT/Library/src/library/BookFieldPattern.java - file:/D:/PROJEKT/Library/src/library/WelcomeLogon.java + file:/D:/PROJEKT/Library/src/library/MainMenu.java + file:/D:/PROJEKT/Library/src/library/Item.java + file:/D:/PROJEKT/Library/src/library/Validation.java + file:/D:/PROJEKT/Library/src/library/Album.java + file:/D:/PROJEKT/Library/src/library/AlbumFieldPattern.java + file:/D:/PROJEKT/Library/src/library/Book.java + file:/D:/PROJEKT/Library/src/library/Movie.java + file:/D:/PROJEKT/Library/src/library/Database.java + file:/D:/PROJEKT/Library/src/library/ListResult.java diff --git a/src/library/Book.java b/src/library/Book.java index 449818c..c5f8f86 100644 --- a/src/library/Book.java +++ b/src/library/Book.java @@ -26,7 +26,7 @@ public class Book extends Item{ @Override public void insertToDB(){ - String query = "INSERT INTO books VALUES(NULL, '" +this.getName() + "', '" + this.getAuthorName() + "', '" + this.getAuthorSurname() + "', '"+ this.getPublishing() + "', '"+ this.getYear() + "', '"+ this.getISBN() + "', '"+ this.getCategory() + "');"; + db.insertBookQ(this); }; @Override public void delFromDB(){ @@ -65,4 +65,6 @@ public String getISBN(){ return this.publishing; } private String authorName, authorSurname, publishing, ISBN; +private Database db = new Database(); + } diff --git a/src/library/Database.java b/src/library/Database.java index 1c71de1..eab9fdf 100644 --- a/src/library/Database.java +++ b/src/library/Database.java @@ -6,6 +6,7 @@ package library; import java.sql.Connection; import java.sql.DriverManager; +import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; @@ -15,6 +16,7 @@ import javax.swing.JOptionPane; /** * * @author Agnieszka + * insert, delete i update do przeniesienia tutaj (9metod) */ public class Database { @@ -57,7 +59,39 @@ public class Database { } return true; } - + + public void insertBookQ(Book b){ + try { + PreparedStatement prepStmt = conn.prepareStatement( + "INSERT INTO books VALUES (NULL, ?, ?, ?, ?, ?, ?, ?);"); + prepStmt.setString(1, b.getName()); + prepStmt.setString(2, b.getAuthorName()); + prepStmt.setString(3, b.getAuthorSurname()); + prepStmt.setString(4, b.getPublishing()); + prepStmt.setInt(5, b.getYear()); + prepStmt.setString(6, b.getISBN()); + prepStmt.setString(7, b.getCategory()); + + prepStmt.execute(); + + /* String sel = "SELECT * FROM books WHERE name LIKE ? AND author_name LIKE ? AND author_surname LIKE ? AND publishing LIKE ? AND year = ? AND isbn LIKE ? AND category LIKE ? ;"; + PreparedStatement prepStmt2 = conn.prepareStatement(sel); + prepStmt.setString(1, b.getName()); + prepStmt.setString(2, b.getAuthorName()); + prepStmt.setString(3, b.getAuthorSurname()); + prepStmt.setString(4, b.getPublishing()); + prepStmt.setInt(5, b.getYear()); + prepStmt.setString(6, b.getISBN()); + prepStmt.setString(7, b.getCategory()); + + ResultSet rs = stat.executeQuery(sel); + b = new Book(rs.getInt("id"), rs.getString("name"), rs.getString("author_name"), rs.getString("suthor_surname"), rs.getInt("year"), rs.getString("isbn"), rs.getString("publishing"), rs.getString("category")); + */ + } catch (SQLException e) { + JOptionPane.showMessageDialog(null, "Błąd przy dodawaniu do bazy", "Error:", JOptionPane.INFORMATION_MESSAGE); + } + + } public List selectBooks() { List books = new LinkedList(); diff --git a/src/library/MainMenu.form b/src/library/MainMenu.form index ac40e85..41829cb 100644 --- a/src/library/MainMenu.form +++ b/src/library/MainMenu.form @@ -43,7 +43,10 @@ - + + + + @@ -57,7 +60,9 @@ - + + + @@ -214,5 +219,13 @@ + + + + + + + + diff --git a/src/library/MainMenu.java b/src/library/MainMenu.java index 7f7bbfb..8c17c71 100644 --- a/src/library/MainMenu.java +++ b/src/library/MainMenu.java @@ -41,6 +41,7 @@ public class MainMenu extends javax.swing.JFrame { radioBSearch = new javax.swing.JRadioButton(); bUser = new javax.swing.JButton(); radioBDelete1 = new javax.swing.JRadioButton(); + allBooksShow = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); @@ -154,6 +155,13 @@ public class MainMenu extends javax.swing.JFrame { .addGap(83, 83, 83)) ); + allBooksShow.setText("Wszyskie książki"); + allBooksShow.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + allBooksShowActionPerformed(evt); + } + }); + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( @@ -170,7 +178,9 @@ public class MainMenu extends javax.swing.JFrame { .addContainerGap()) .addGroup(layout.createSequentialGroup() .addGap(26, 26, 26) - .addComponent(searchButtonsPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(allBooksShow) + .addComponent(searchButtonsPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(21, Short.MAX_VALUE)) ); layout.setVerticalGroup( @@ -182,7 +192,9 @@ public class MainMenu extends javax.swing.JFrame { .addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(searchButtonsPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(0, 282, Short.MAX_VALUE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(allBooksShow) + .addGap(0, 250, Short.MAX_VALUE)) ); pack(); @@ -264,6 +276,11 @@ public class MainMenu extends javax.swing.JFrame { // TODO add your handling code here: }//GEN-LAST:event_radioBDelete1ActionPerformed + private void allBooksShowActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_allBooksShowActionPerformed + ListResult l = new ListResult(); + l.setVisible(true); + }//GEN-LAST:event_allBooksShowActionPerformed + /** * @param args the command line arguments */ @@ -299,6 +316,7 @@ public class MainMenu extends javax.swing.JFrame { } // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton allBooksShow; private javax.swing.JButton bAlbum; private javax.swing.JButton bBook; private javax.swing.JButton bMovie;