próby z oknem wyników

This commit is contained in:
Agnieszka Janicka 2016-06-06 11:25:42 +02:00
parent c8484bb75b
commit 98fa27dd1b
18 changed files with 98 additions and 11 deletions

View File

@ -1,4 +1,4 @@
#Mon, 30 May 2016 12:41:20 +0200
#Mon, 06 Jun 2016 11:21:26 +0200
D\:\\PROJEKT\\Library=

Binary file not shown.

Binary file not shown.

View File

@ -43,7 +43,10 @@
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="26" max="-2" attributes="0"/>
<Component id="searchButtonsPanel" min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="allBooksShow" min="-2" max="-2" attributes="0"/>
<Component id="searchButtonsPanel" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="21" max="32767" attributes="0"/>
</Group>
</Group>
@ -57,7 +60,9 @@
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="searchButtonsPanel" min="-2" pref="87" max="-2" attributes="0"/>
<EmptySpace min="0" pref="282" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="allBooksShow" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="250" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -214,5 +219,13 @@
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.JButton" name="allBooksShow">
<Properties>
<Property name="text" type="java.lang.String" value="Wszyskie ksi&#x105;&#x17c;ki"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="allBooksShowActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Form>

BIN
dist/Library.jar vendored

Binary file not shown.

View File

@ -4,9 +4,16 @@
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
<group>
<file>file:/D:/PROJEKT/Library/src/library/MovieFieldPattern.java</file>
<file>file:/D:/PROJEKT/Library/src/library/MainMenu.java</file>
<file>file:/D:/PROJEKT/Library/src/library/BookFieldPattern.java</file>
<file>file:/D:/PROJEKT/Library/src/library/WelcomeLogon.java</file>
<file>file:/D:/PROJEKT/Library/src/library/MainMenu.java</file>
<file>file:/D:/PROJEKT/Library/src/library/Item.java</file>
<file>file:/D:/PROJEKT/Library/src/library/Validation.java</file>
<file>file:/D:/PROJEKT/Library/src/library/Album.java</file>
<file>file:/D:/PROJEKT/Library/src/library/AlbumFieldPattern.java</file>
<file>file:/D:/PROJEKT/Library/src/library/Book.java</file>
<file>file:/D:/PROJEKT/Library/src/library/Movie.java</file>
<file>file:/D:/PROJEKT/Library/src/library/Database.java</file>
<file>file:/D:/PROJEKT/Library/src/library/ListResult.java</file>
</group>
</open-files>
</project-private>

View File

@ -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();
}

View File

@ -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<Book> selectBooks() {
List<Book> books = new LinkedList<Book>();

View File

@ -43,7 +43,10 @@
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="26" max="-2" attributes="0"/>
<Component id="searchButtonsPanel" min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="allBooksShow" min="-2" max="-2" attributes="0"/>
<Component id="searchButtonsPanel" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="21" max="32767" attributes="0"/>
</Group>
</Group>
@ -57,7 +60,9 @@
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="searchButtonsPanel" min="-2" pref="87" max="-2" attributes="0"/>
<EmptySpace min="0" pref="282" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="allBooksShow" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="250" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -214,5 +219,13 @@
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.JButton" name="allBooksShow">
<Properties>
<Property name="text" type="java.lang.String" value="Wszyskie ksi&#x105;&#x17c;ki"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="allBooksShowActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Form>

View File

@ -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;