projekt gotowy :)

This commit is contained in:
Agnieszka Janicka 2016-06-11 18:08:59 +02:00
parent 0d3d99d8ce
commit 94ac1d5e0e
8 changed files with 273 additions and 187 deletions

Binary file not shown.

View File

@ -234,6 +234,7 @@ public class AlbumFieldPattern extends javax.swing.JFrame {
e.printStackTrace(); e.printStackTrace();
} }
} }
d.closeConnection();
dispose(); dispose();
}//GEN-LAST:event_SaveChangesActionPerformed }//GEN-LAST:event_SaveChangesActionPerformed

View File

@ -138,9 +138,6 @@
<Font name="Tahoma" size="14" style="0"/> <Font name="Tahoma" size="14" style="0"/>
</Property> </Property>
</Properties> </Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="bookTitleActionPerformed"/>
</Events>
<AuxValues> <AuxValues>
<AuxValue name="JavaCodeGenerator_SerializeTo" type="java.lang.String" value="BookFieldPattern_bookTitle"/> <AuxValue name="JavaCodeGenerator_SerializeTo" type="java.lang.String" value="BookFieldPattern_bookTitle"/>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/> <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
@ -167,9 +164,6 @@
<Font name="Tahoma" size="14" style="0"/> <Font name="Tahoma" size="14" style="0"/>
</Property> </Property>
</Properties> </Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="authorSurnameActionPerformed"/>
</Events>
</Component> </Component>
<Component class="javax.swing.JLabel" name="authorsurname"> <Component class="javax.swing.JLabel" name="authorsurname">
<Properties> <Properties>
@ -229,7 +223,6 @@
<Events> <Events>
<EventHandler event="focusGained" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="ISBNFocusGained"/> <EventHandler event="focusGained" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="ISBNFocusGained"/>
<EventHandler event="focusLost" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="ISBNFocusLost"/> <EventHandler event="focusLost" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="ISBNFocusLost"/>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="ISBNActionPerformed"/>
</Events> </Events>
</Component> </Component>
<Component class="javax.swing.JLabel" name="lcategory"> <Component class="javax.swing.JLabel" name="lcategory">

View File

@ -128,11 +128,6 @@ public class BookFieldPattern extends javax.swing.JFrame {
Title.setText("Tytuł:"); Title.setText("Tytuł:");
bookTitle.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N bookTitle.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
bookTitle.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
bookTitleActionPerformed(evt);
}
});
authorname.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N authorname.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
authorname.setText("Imię autora:"); authorname.setText("Imię autora:");
@ -140,11 +135,6 @@ public class BookFieldPattern extends javax.swing.JFrame {
authorName.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N authorName.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
authorSurname.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N authorSurname.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
authorSurname.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
authorSurnameActionPerformed(evt);
}
});
authorsurname.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N authorsurname.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
authorsurname.setText("Nazwisko autora:"); authorsurname.setText("Nazwisko autora:");
@ -174,11 +164,6 @@ public class BookFieldPattern extends javax.swing.JFrame {
ISBNFocusLost(evt); ISBNFocusLost(evt);
} }
}); });
ISBN.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
ISBNActionPerformed(evt);
}
});
lcategory.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N lcategory.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
lcategory.setText("Kategoria:"); lcategory.setText("Kategoria:");
@ -324,29 +309,18 @@ public class BookFieldPattern extends javax.swing.JFrame {
Book b = new Book(0, bookTitle.getText(), authorName.getText(), authorSurname.getText(), year.getText(), ISBN.getText(), publishing.getText(), Category.getSelectedItem().toString()); Book b = new Book(0, bookTitle.getText(), authorName.getText(), authorSurname.getText(), year.getText(), ISBN.getText(), publishing.getText(), Category.getSelectedItem().toString());
this.search(b); this.search(b);
} else if (this.update) { } else if (this.update) {
Book b = new Book(Integer.parseInt(idValue.getText()), bookTitle.getText(), authorName.getText(), authorSurname.getText(), year.getText(), ISBN.getText(), publishing.getText(), Category.getSelectedItem().toString());
try { try {
Book b = new Book(Integer.parseInt(idValue.getText()), bookTitle.getText(), authorName.getText(), authorSurname.getText(), year.getText(), ISBN.getText(), publishing.getText(), Category.getSelectedItem().toString());
d.updateQ(b); d.updateQ(b);
} catch (SQLException e) { } catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
d.closeConnection();
dispose(); dispose();
}//GEN-LAST:event_SaveChangesActionPerformed }//GEN-LAST:event_SaveChangesActionPerformed
private void authorSurnameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_authorSurnameActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_authorSurnameActionPerformed
private void bookTitleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bookTitleActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_bookTitleActionPerformed
private void ISBNActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ISBNActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_ISBNActionPerformed
private void ISBNFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_ISBNFocusGained private void ISBNFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_ISBNFocusGained
jLabel1.setVisible(true); jLabel1.setVisible(true);
}//GEN-LAST:event_ISBNFocusGained }//GEN-LAST:event_ISBNFocusGained

View File

@ -131,10 +131,15 @@ public class Database {
} }
public List<Book> selectBooks() { public List<Book> selectBooks(String...ownQuery) {
List<Book> books = new ArrayList<Book>(); List<Book> books = new ArrayList<Book>();
try { try {
ResultSet result = stat.executeQuery("SELECT * FROM books"); ResultSet result;
if (ownQuery[0].length() > 0) {
result = stat.executeQuery(ownQuery[0]);
} else {
result = stat.executeQuery("SELECT * FROM books ORDER BY name");
}
int id; int id;
String name, authorName, authorSurname, isbn, category, publishing, year; String name, authorName, authorSurname, isbn, category, publishing, year;
while (result.next()) { while (result.next()) {
@ -216,10 +221,15 @@ public class Database {
return books; return books;
} }
public List<Album> selectAlbums() { public List<Album> selectAlbums(String... ownQuery) {
List<Album> albums = new ArrayList<Album>(); List<Album> albums = new ArrayList<Album>();
try { try {
ResultSet result = stat.executeQuery("SELECT * FROM albums"); ResultSet result;
if (ownQuery[0].length() > 0) {
result = stat.executeQuery(ownQuery[0]);
} else {
result = stat.executeQuery("SELECT * FROM albums ORDER BY name");
}
int id; int id;
String name, musican, category, year; String name, musican, category, year;
while (result.next()) { while (result.next()) {
@ -232,6 +242,7 @@ public class Database {
} }
} catch (SQLException e) { } catch (SQLException e) {
JOptionPane.showMessageDialog(null, "Błąd przy odczycie z bazy.", "Error:", JOptionPane.INFORMATION_MESSAGE); JOptionPane.showMessageDialog(null, "Błąd przy odczycie z bazy.", "Error:", JOptionPane.INFORMATION_MESSAGE);
e.printStackTrace();
} }
return albums; return albums;
} }
@ -286,10 +297,15 @@ public class Database {
return albums; return albums;
} }
public List<Movie> selectMovies() { public List<Movie> selectMovies(String... ownQuery) {
List<Movie> movies = new ArrayList<Movie>(); List<Movie> movies = new ArrayList<Movie>();
try { try {
ResultSet result = stat.executeQuery("SELECT * FROM movies"); ResultSet result;
if (ownQuery[0].length() > 0) {
result = stat.executeQuery(ownQuery[0]);
} else {
result = stat.executeQuery("SELECT * FROM movies ORDER BY name;");
}
int id; int id;
String name, category, director, year; String name, category, director, year;
while (result.next()) { while (result.next()) {

View File

@ -34,28 +34,28 @@
<Component id="programTitle" pref="817" max="32767" attributes="0"/> <Component id="programTitle" pref="817" max="32767" attributes="0"/>
</Group> </Group>
<Group type="102" attributes="0"> <Group type="102" attributes="0">
<EmptySpace min="-2" pref="359" max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="19" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Component id="jToggleButton1" alignment="0" min="-2" max="-2" attributes="0"/> <Group type="102" attributes="0">
<EmptySpace min="-2" pref="359" max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0">
<Component id="jPanel2" min="-2" max="-2" attributes="0"/> <EmptySpace min="-2" pref="19" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <Group type="103" groupAlignment="0" attributes="0">
<Component id="jPanel1" min="-2" max="-2" attributes="0"/> <Component id="searchButtonsPanel" alignment="1" min="-2" max="-2" attributes="0"/>
<Group type="102" attributes="0">
<Component id="jPanel2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</Group> </Group>
</Group> </Group>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group> </Group>
</Group> </Group>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
</Group> </Group>
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<Component id="searchButtonsPanel" max="32767" attributes="0"/>
<EmptySpace min="-2" pref="141" max="-2" attributes="0"/>
</Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
<DimensionLayout dim="1"> <DimensionLayout dim="1">
@ -63,17 +63,15 @@
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="24" max="-2" attributes="0"/> <EmptySpace min="-2" pref="24" max="-2" attributes="0"/>
<Component id="programTitle" min="-2" pref="38" max="-2" attributes="0"/> <Component id="programTitle" min="-2" pref="38" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/> <EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="searchButtonsPanel" min="-2" pref="87" max="-2" attributes="0"/> <Component id="searchButtonsPanel" min="-2" pref="87" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace min="-2" pref="1" max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="0"/> <Group type="103" groupAlignment="0" max="-2" attributes="0">
<EmptySpace max="-2" attributes="0"/> <Component id="jPanel2" max="32767" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0"> <Component id="jPanel1" max="32767" attributes="0"/>
<Component id="jPanel2" min="-2" max="-2" attributes="0"/>
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
</Group> </Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="jToggleButton1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/> <EmptySpace max="32767" attributes="0"/>
</Group> </Group>
</Group> </Group>
@ -83,7 +81,7 @@
<Component class="javax.swing.JLabel" name="programTitle"> <Component class="javax.swing.JLabel" name="programTitle">
<Properties> <Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Tahoma" size="24" style="3"/> <Font name="Tahoma" size="24" style="2"/>
</Property> </Property>
<Property name="horizontalAlignment" type="int" value="0"/> <Property name="horizontalAlignment" type="int" value="0"/>
<Property name="text" type="java.lang.String" value="Library Manager 2016"/> <Property name="text" type="java.lang.String" value="Library Manager 2016"/>
@ -103,28 +101,27 @@
<Layout> <Layout>
<DimensionLayout dim="0"> <DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0"> <Group type="102" alignment="1" attributes="0">
<EmptySpace max="-2" attributes="0"/> <EmptySpace pref="194" max="32767" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="1" attributes="0">
<Group type="102" alignment="0" attributes="0"> <Group type="102" attributes="0">
<Component id="bBook" min="-2" max="-2" attributes="0"/> <Component id="bBook" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="bMovie" min="-2" max="-2" attributes="0"/> <Component id="bMovie" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="bAlbum" min="-2" max="-2" attributes="0"/> <Component id="bAlbum" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group> </Group>
<Group type="102" alignment="0" attributes="0"> <Group type="102" attributes="0">
<Component id="radioBSearch" min="-2" max="-2" attributes="0"/> <Component id="radioBSearch" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="133" max="32767" attributes="0"/> <EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="radioBAdd" min="-2" max="-2" attributes="0"/> <Component id="radioBAdd" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/> <EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="radioBEdit" min="-2" max="-2" attributes="0"/> <Component id="radioBEdit" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="radioBDelete" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="78" max="-2" attributes="0"/>
</Group> </Group>
</Group> </Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="radioBDelete" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="182" max="-2" attributes="0"/>
</Group> </Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
@ -181,9 +178,6 @@
</Property> </Property>
<Property name="text" type="java.lang.String" value="Dodawanie"/> <Property name="text" type="java.lang.String" value="Dodawanie"/>
</Properties> </Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="radioBAddActionPerformed"/>
</Events>
</Component> </Component>
<Component class="javax.swing.JRadioButton" name="radioBEdit"> <Component class="javax.swing.JRadioButton" name="radioBEdit">
<Properties> <Properties>
@ -192,9 +186,6 @@
</Property> </Property>
<Property name="text" type="java.lang.String" value="Modyfikacja"/> <Property name="text" type="java.lang.String" value="Modyfikacja"/>
</Properties> </Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="radioBEditActionPerformed"/>
</Events>
</Component> </Component>
<Component class="javax.swing.JRadioButton" name="radioBDelete"> <Component class="javax.swing.JRadioButton" name="radioBDelete">
<Properties> <Properties>
@ -203,9 +194,6 @@
</Property> </Property>
<Property name="text" type="java.lang.String" value="Usuwanie"/> <Property name="text" type="java.lang.String" value="Usuwanie"/>
</Properties> </Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="radioBDeleteActionPerformed"/>
</Events>
</Component> </Component>
<Component class="javax.swing.JRadioButton" name="radioBSearch"> <Component class="javax.swing.JRadioButton" name="radioBSearch">
<Properties> <Properties>
@ -248,9 +236,9 @@
</Group> </Group>
<EmptySpace min="-2" pref="34" max="-2" attributes="0"/> <EmptySpace min="-2" pref="34" max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" max="-2" attributes="0"> <Group type="103" groupAlignment="1" max="-2" attributes="0">
<Component id="newestMovie1" alignment="0" max="32767" attributes="0"/> <Component id="oldestMovie" alignment="0" max="32767" attributes="0"/>
<Component id="newestBook1" alignment="0" max="32767" attributes="0"/> <Component id="oldestBook" alignment="0" max="32767" attributes="0"/>
<Component id="newestAlbum1" alignment="0" min="-2" pref="139" max="-2" attributes="0"/> <Component id="oldestAlbum" alignment="0" min="-2" pref="139" max="-2" attributes="0"/>
</Group> </Group>
<EmptySpace pref="67" max="32767" attributes="0"/> <EmptySpace pref="67" max="32767" attributes="0"/>
</Group> </Group>
@ -262,11 +250,11 @@
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0"> <Group type="102" attributes="0">
<Component id="newestBook1" min="-2" max="-2" attributes="0"/> <Component id="oldestBook" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="newestMovie1" min="-2" max="-2" attributes="0"/> <Component id="oldestMovie" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="newestAlbum1" min="-2" max="-2" attributes="0"/> <Component id="oldestAlbum" min="-2" max="-2" attributes="0"/>
</Group> </Group>
<Group type="103" groupAlignment="1" attributes="0"> <Group type="103" groupAlignment="1" attributes="0">
<Group type="102" attributes="0"> <Group type="102" attributes="0">
@ -319,31 +307,49 @@
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="Najnowsza ksi&#x105;&#x17c;ka"/> <Property name="text" type="java.lang.String" value="Najnowsza ksi&#x105;&#x17c;ka"/>
</Properties> </Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="newestBookActionPerformed"/>
</Events>
</Component> </Component>
<Component class="javax.swing.JButton" name="newestMovie"> <Component class="javax.swing.JButton" name="newestMovie">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="Najnowszy film"/> <Property name="text" type="java.lang.String" value="Najnowszy film"/>
</Properties> </Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="newestMovieActionPerformed"/>
</Events>
</Component> </Component>
<Component class="javax.swing.JButton" name="newestAlbum"> <Component class="javax.swing.JButton" name="newestAlbum">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="Najnowszy album"/> <Property name="text" type="java.lang.String" value="Najnowszy album"/>
</Properties> </Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="newestAlbumActionPerformed"/>
</Events>
</Component> </Component>
<Component class="javax.swing.JButton" name="newestBook1"> <Component class="javax.swing.JButton" name="oldestBook">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="Najnowsza ksi&#x105;&#x17c;ka"/> <Property name="text" type="java.lang.String" value="Najstarsza ksi&#x105;&#x17c;ka"/>
</Properties> </Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="oldestBookActionPerformed"/>
</Events>
</Component> </Component>
<Component class="javax.swing.JButton" name="newestMovie1"> <Component class="javax.swing.JButton" name="oldestMovie">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="Najnowszy film"/> <Property name="text" type="java.lang.String" value="Najstarszy film"/>
</Properties> </Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="oldestMovieActionPerformed"/>
</Events>
</Component> </Component>
<Component class="javax.swing.JButton" name="newestAlbum1"> <Component class="javax.swing.JButton" name="oldestAlbum">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="Najnowszy album"/> <Property name="text" type="java.lang.String" value="Najstarszy album"/>
</Properties> </Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="oldestAlbumActionPerformed"/>
</Events>
</Component> </Component>
</SubComponents> </SubComponents>
</Container> </Container>
@ -467,10 +473,5 @@
</Component> </Component>
</SubComponents> </SubComponents>
</Container> </Container>
<Component class="javax.swing.JToggleButton" name="jToggleButton1">
<Properties>
<Property name="text" type="java.lang.String" value="W&#x142;asne zapytanie SELECT"/>
</Properties>
</Component>
</SubComponents> </SubComponents>
</Form> </Form>

View File

@ -50,9 +50,9 @@ public class MainMenu extends javax.swing.JFrame {
newestBook = new javax.swing.JButton(); newestBook = new javax.swing.JButton();
newestMovie = new javax.swing.JButton(); newestMovie = new javax.swing.JButton();
newestAlbum = new javax.swing.JButton(); newestAlbum = new javax.swing.JButton();
newestBook1 = new javax.swing.JButton(); oldestBook = new javax.swing.JButton();
newestMovie1 = new javax.swing.JButton(); oldestMovie = new javax.swing.JButton();
newestAlbum1 = new javax.swing.JButton(); oldestAlbum = new javax.swing.JButton();
jPanel2 = new javax.swing.JPanel(); jPanel2 = new javax.swing.JPanel();
jLabel2 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel();
@ -61,11 +61,10 @@ public class MainMenu extends javax.swing.JFrame {
numberOfAlbums = new javax.swing.JLabel(); numberOfAlbums = new javax.swing.JLabel();
numberOfMovies = new javax.swing.JLabel(); numberOfMovies = new javax.swing.JLabel();
refreshNumbersOfItems = new javax.swing.JButton(); refreshNumbersOfItems = new javax.swing.JButton();
jToggleButton1 = new javax.swing.JToggleButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
programTitle.setFont(new java.awt.Font("Tahoma", 3, 24)); // NOI18N programTitle.setFont(new java.awt.Font("Tahoma", 2, 24)); // NOI18N
programTitle.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); programTitle.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
programTitle.setText("Library Manager 2016"); programTitle.setText("Library Manager 2016");
@ -94,27 +93,12 @@ public class MainMenu extends javax.swing.JFrame {
mode.add(radioBAdd); mode.add(radioBAdd);
radioBAdd.setText("Dodawanie"); radioBAdd.setText("Dodawanie");
radioBAdd.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
radioBAddActionPerformed(evt);
}
});
mode.add(radioBEdit); mode.add(radioBEdit);
radioBEdit.setText("Modyfikacja"); radioBEdit.setText("Modyfikacja");
radioBEdit.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
radioBEditActionPerformed(evt);
}
});
mode.add(radioBDelete); mode.add(radioBDelete);
radioBDelete.setText("Usuwanie"); radioBDelete.setText("Usuwanie");
radioBDelete.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
radioBDeleteActionPerformed(evt);
}
});
mode.add(radioBSearch); mode.add(radioBSearch);
radioBSearch.setSelected(true); radioBSearch.setSelected(true);
@ -129,25 +113,24 @@ public class MainMenu extends javax.swing.JFrame {
searchButtonsPanel.setLayout(searchButtonsPanelLayout); searchButtonsPanel.setLayout(searchButtonsPanelLayout);
searchButtonsPanelLayout.setHorizontalGroup( searchButtonsPanelLayout.setHorizontalGroup(
searchButtonsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) searchButtonsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(searchButtonsPanelLayout.createSequentialGroup() .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, searchButtonsPanelLayout.createSequentialGroup()
.addContainerGap() .addContainerGap(194, Short.MAX_VALUE)
.addGroup(searchButtonsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(searchButtonsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(searchButtonsPanelLayout.createSequentialGroup() .addGroup(searchButtonsPanelLayout.createSequentialGroup()
.addComponent(bBook) .addComponent(bBook)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(bMovie) .addComponent(bMovie)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(bAlbum) .addComponent(bAlbum))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(searchButtonsPanelLayout.createSequentialGroup() .addGroup(searchButtonsPanelLayout.createSequentialGroup()
.addComponent(radioBSearch) .addComponent(radioBSearch)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 133, Short.MAX_VALUE) .addGap(18, 18, 18)
.addComponent(radioBAdd) .addComponent(radioBAdd)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(radioBEdit) .addComponent(radioBEdit)))
.addGap(18, 18, 18) .addGap(18, 18, 18)
.addComponent(radioBDelete) .addComponent(radioBDelete)
.addGap(78, 78, 78)))) .addGap(182, 182, 182))
); );
searchButtonsPanelLayout.setVerticalGroup( searchButtonsPanelLayout.setVerticalGroup(
searchButtonsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) searchButtonsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@ -190,16 +173,46 @@ public class MainMenu extends javax.swing.JFrame {
}); });
newestBook.setText("Najnowsza książka"); newestBook.setText("Najnowsza książka");
newestBook.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
newestBookActionPerformed(evt);
}
});
newestMovie.setText("Najnowszy film"); newestMovie.setText("Najnowszy film");
newestMovie.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
newestMovieActionPerformed(evt);
}
});
newestAlbum.setText("Najnowszy album"); newestAlbum.setText("Najnowszy album");
newestAlbum.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
newestAlbumActionPerformed(evt);
}
});
newestBook1.setText("Najnowsza książka"); oldestBook.setText("Najstarsza książka");
oldestBook.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
oldestBookActionPerformed(evt);
}
});
newestMovie1.setText("Najnowszy film"); oldestMovie.setText("Najstarszy film");
oldestMovie.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
oldestMovieActionPerformed(evt);
}
});
newestAlbum1.setText("Najnowszy album"); oldestAlbum.setText("Najstarszy album");
oldestAlbum.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
oldestAlbumActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout); jPanel1.setLayout(jPanel1Layout);
@ -218,9 +231,9 @@ public class MainMenu extends javax.swing.JFrame {
.addComponent(newestAlbum, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(newestAlbum, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(34, 34, 34) .addGap(34, 34, 34)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(newestMovie1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(oldestMovie, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(newestBook1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(oldestBook, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(newestAlbum1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(oldestAlbum, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(67, Short.MAX_VALUE)) .addContainerGap(67, Short.MAX_VALUE))
); );
jPanel1Layout.setVerticalGroup( jPanel1Layout.setVerticalGroup(
@ -229,11 +242,11 @@ public class MainMenu extends javax.swing.JFrame {
.addContainerGap() .addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(newestBook1) .addComponent(oldestBook)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(newestMovie1) .addComponent(oldestMovie)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(newestAlbum1)) .addComponent(oldestAlbum))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(newestBook) .addComponent(newestBook)
@ -317,8 +330,6 @@ public class MainMenu extends javax.swing.JFrame {
.addComponent(refreshNumbersOfItems)) .addComponent(refreshNumbersOfItems))
); );
jToggleButton1.setText("Własne zapytanie SELECT");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout); getContentPane().setLayout(layout);
layout.setHorizontalGroup( layout.setHorizontalGroup(
@ -329,37 +340,34 @@ public class MainMenu extends javax.swing.JFrame {
.addContainerGap() .addContainerGap()
.addComponent(programTitle, javax.swing.GroupLayout.DEFAULT_SIZE, 817, Short.MAX_VALUE)) .addComponent(programTitle, javax.swing.GroupLayout.DEFAULT_SIZE, 817, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addGap(359, 359, 359)
.addComponent(jLabel1))
.addGroup(layout.createSequentialGroup()
.addGap(19, 19, 19)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jToggleButton1)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(359, 359, 359)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel1))
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))) .addGroup(layout.createSequentialGroup()
.addGap(19, 19, 19)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(searchButtonsPanel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))))
.addGap(0, 0, Short.MAX_VALUE)))
.addContainerGap()) .addContainerGap())
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(searchButtonsPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(141, 141, 141))
); );
layout.setVerticalGroup( layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addGap(24, 24, 24) .addGap(24, 24, 24)
.addComponent(programTitle, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(programTitle, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(searchButtonsPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(searchButtonsPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGap(1, 1, 1)
.addComponent(jLabel1) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addComponent(jToggleButton1)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
); );
@ -382,7 +390,7 @@ public class MainMenu extends javax.swing.JFrame {
b.setVisible(true); b.setVisible(true);
b.delete = true; b.delete = true;
} }
if (radioBDelete.getModel().isSelected()) { if (radioBDelete.getModel().isSelected()) {
MovieFieldPattern b = new MovieFieldPattern(); MovieFieldPattern b = new MovieFieldPattern();
b.setVisible(true); b.setVisible(true);
b.delete = true; b.delete = true;
@ -413,18 +421,10 @@ public class MainMenu extends javax.swing.JFrame {
} }
}//GEN-LAST:event_bAlbumActionPerformed }//GEN-LAST:event_bAlbumActionPerformed
private void radioBEditActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_radioBEditActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_radioBEditActionPerformed
private void radioBSearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_radioBSearchActionPerformed private void radioBSearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_radioBSearchActionPerformed
// TODO add your handling code here: // TODO add your handling code here:
}//GEN-LAST:event_radioBSearchActionPerformed }//GEN-LAST:event_radioBSearchActionPerformed
private void radioBAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_radioBAddActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_radioBAddActionPerformed
private void bBookActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bBookActionPerformed private void bBookActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bBookActionPerformed
if (radioBAdd.getModel().isSelected()) { if (radioBAdd.getModel().isSelected()) {
BookFieldPattern b = new BookFieldPattern(true); BookFieldPattern b = new BookFieldPattern(true);
@ -441,7 +441,7 @@ public class MainMenu extends javax.swing.JFrame {
b.setVisible(true); b.setVisible(true);
b.search = true; b.search = true;
} }
if (radioBDelete.getModel().isSelected()) { if (radioBDelete.getModel().isSelected()) {
BookFieldPattern b = new BookFieldPattern(); BookFieldPattern b = new BookFieldPattern();
b.setVisible(true); b.setVisible(true);
b.delete = true; b.delete = true;
@ -449,15 +449,10 @@ public class MainMenu extends javax.swing.JFrame {
}//GEN-LAST:event_bBookActionPerformed }//GEN-LAST:event_bBookActionPerformed
private void radioBDeleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_radioBDeleteActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_radioBDeleteActionPerformed
private void allBooksShowActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_allBooksShowActionPerformed private void allBooksShowActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_allBooksShowActionPerformed
try { try {
List<Book> books = new LinkedList<>(); List<Book> books = new LinkedList<>();
books = d.selectBooks(); Object[][] data = d.convertToTable(d.selectBooks(""));
Object[][] data = d.convertToTable(books);
String[] columnNames = {"ID", String[] columnNames = {"ID",
"Tytuł", "Tytuł",
"Imię Autora", "Imię Autora",
@ -476,8 +471,7 @@ public class MainMenu extends javax.swing.JFrame {
private void allMovieShowActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_allMovieShowActionPerformed private void allMovieShowActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_allMovieShowActionPerformed
try { try {
List<Movie> movies = new LinkedList<>(); List<Movie> movies = new LinkedList<>();
movies = d.selectMovies(); Object[][] data = d.convertToTable(d.selectMovies(""));
Object[][] data = d.convertToTable(movies);
String[] columnNames = { String[] columnNames = {
"ID", "ID",
"Tytuł", "Tytuł",
@ -492,11 +486,9 @@ public class MainMenu extends javax.swing.JFrame {
}//GEN-LAST:event_allMovieShowActionPerformed }//GEN-LAST:event_allMovieShowActionPerformed
private void allAlbumsShowActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_allAlbumsShowActionPerformed private void allAlbumsShowActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_allAlbumsShowActionPerformed
try { try {
List<Album> albums = new LinkedList<>(); List<Album> albums = new LinkedList<>();
albums = d.selectAlbums(); Object[][] data = d.convertToTable(d.selectAlbums(""));
Object[][] data = d.convertToTable(albums);
String[] columnNames = { String[] columnNames = {
"ID", "ID",
"Tytuł", "Tytuł",
@ -509,7 +501,6 @@ public class MainMenu extends javax.swing.JFrame {
} catch (IndexOutOfBoundsException e) { } catch (IndexOutOfBoundsException e) {
//nothing to do here //nothing to do here
} }
}//GEN-LAST:event_allAlbumsShowActionPerformed }//GEN-LAST:event_allAlbumsShowActionPerformed
private void refreshNumbersOfItemsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_refreshNumbersOfItemsActionPerformed private void refreshNumbersOfItemsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_refreshNumbersOfItemsActionPerformed
@ -523,6 +514,116 @@ public class MainMenu extends javax.swing.JFrame {
numberOfMovies.setText(n); numberOfMovies.setText(n);
}//GEN-LAST:event_refreshNumbersOfItemsActionPerformed }//GEN-LAST:event_refreshNumbersOfItemsActionPerformed
private void newestBookActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newestBookActionPerformed
try {
List<Book> books = new LinkedList<>();
Object[][] data = d.convertToTable(d.selectBooks("SELECT id, name, author_name, author_surname, MAX(year) AS year, isbn, publishing, category FROM books ORDER BY name;"));
String[] columnNames = {"ID",
"Tytuł",
"Imię Autora",
"Nazwisko Autora",
"Rok",
"ISBN",
"Wydawnictwo",
"Kategoria"};
ListResult table = new ListResult(data, columnNames, "book");
table.setVisible(true);
} catch (IndexOutOfBoundsException e) {
//nothing to do here
}
}//GEN-LAST:event_newestBookActionPerformed
private void newestMovieActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newestMovieActionPerformed
try {
List<Movie> movies = new LinkedList<>();
movies = d.selectMovies("SELECT id, name, director, MAX(year) AS year, category FROM movies;");
Object[][] data = d.convertToTable(movies);
String[] columnNames = {
"ID",
"Tytuł",
"Reżyser",
"Rok",
"Kategoria"};
ListResult table = new ListResult(data, columnNames, "movie");
table.setVisible(true);
} catch (IndexOutOfBoundsException e) {
//nothing to do here
}
}//GEN-LAST:event_newestMovieActionPerformed
private void oldestBookActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_oldestBookActionPerformed
try {
List<Book> books = new LinkedList<>();
Object[][] data = d.convertToTable(d.selectBooks("SELECT id, name, author_name, author_surname, MIN(year) AS year, isbn, publishing, category FROM books ORDER BY name;"));
String[] columnNames = {"ID",
"Tytuł",
"Imię Autora",
"Nazwisko Autora",
"Rok",
"ISBN",
"Wydawnictwo",
"Kategoria"};
ListResult table = new ListResult(data, columnNames, "book");
table.setVisible(true);
} catch (IndexOutOfBoundsException e) {
//nothing to do here
}
}//GEN-LAST:event_oldestBookActionPerformed
private void oldestMovieActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_oldestMovieActionPerformed
try {
List<Movie> movies = new LinkedList<>();
movies = d.selectMovies("SELECT id, name, director, MIN(year) AS year, category FROM movies;");
Object[][] data = d.convertToTable(movies);
String[] columnNames = {
"ID",
"Tytuł",
"Reżyser",
"Rok",
"Kategoria"};
ListResult table = new ListResult(data, columnNames, "movie");
table.setVisible(true);
} catch (IndexOutOfBoundsException e) {
//nothing to do here
} // TODO add your handling code here:
}//GEN-LAST:event_oldestMovieActionPerformed
private void newestAlbumActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newestAlbumActionPerformed
try {
List<Album> albums = new LinkedList<>();
Object[][] data = d.convertToTable(d.selectAlbums("SELECT id, name, musican, MAX(year) AS year, category FROM albums ORDER BY name;"));
String[] columnNames = {
"ID",
"Tytuł",
"Muzyk/Zespół",
"Rok",
"Kategoria"};
ListResult table = new ListResult(data, columnNames, "album");
table.setVisible(true);
} catch (IndexOutOfBoundsException e) {
//nothing to do here
}
}//GEN-LAST:event_newestAlbumActionPerformed
private void oldestAlbumActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_oldestAlbumActionPerformed
try {
List<Album> albums = new LinkedList<>();
Object[][] data = d.convertToTable(d.selectAlbums("SELECT id, name, musican, MIN(year) AS year, category FROM albums ORDER BY name;"));
String[] columnNames = {
"ID",
"Tytuł",
"Muzyk/Zespół",
"Rok",
"Kategoria"};
ListResult table = new ListResult(data, columnNames, "album");
table.setVisible(true);
} catch (IndexOutOfBoundsException e) {
//nothing to do here
} // TODO add your handling code here:
}//GEN-LAST:event_oldestAlbumActionPerformed
/** /**
* @param args the command line arguments * @param args the command line arguments
*/ */
@ -570,17 +671,16 @@ public class MainMenu extends javax.swing.JFrame {
private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel4;
private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2; private javax.swing.JPanel jPanel2;
private javax.swing.JToggleButton jToggleButton1;
private javax.swing.ButtonGroup mode; private javax.swing.ButtonGroup mode;
private javax.swing.JButton newestAlbum; private javax.swing.JButton newestAlbum;
private javax.swing.JButton newestAlbum1;
private javax.swing.JButton newestBook; private javax.swing.JButton newestBook;
private javax.swing.JButton newestBook1;
private javax.swing.JButton newestMovie; private javax.swing.JButton newestMovie;
private javax.swing.JButton newestMovie1;
private javax.swing.JLabel numberOfAlbums; private javax.swing.JLabel numberOfAlbums;
public javax.swing.JLabel numberOfBooks; public javax.swing.JLabel numberOfBooks;
private javax.swing.JLabel numberOfMovies; private javax.swing.JLabel numberOfMovies;
private javax.swing.JButton oldestAlbum;
private javax.swing.JButton oldestBook;
private javax.swing.JButton oldestMovie;
private javax.swing.JLabel programTitle; private javax.swing.JLabel programTitle;
private javax.swing.JRadioButton radioBAdd; private javax.swing.JRadioButton radioBAdd;
private javax.swing.JRadioButton radioBDelete; private javax.swing.JRadioButton radioBDelete;

View File

@ -229,6 +229,7 @@ public class MovieFieldPattern extends javax.swing.JFrame {
e.printStackTrace(); e.printStackTrace();
} }
} }
d.closeConnection();
dispose(); dispose();
}//GEN-LAST:event_SaveChangesActionPerformed }//GEN-LAST:event_SaveChangesActionPerformed