już nie. dodawanie w miarę ok.

This commit is contained in:
Agnieszka Janicka 2016-06-07 22:04:40 +02:00
parent 57172c7a72
commit 5f0fb40d46
42 changed files with 254 additions and 60 deletions

Binary file not shown.

View File

@ -47,7 +47,11 @@
<Component id="lcategory" min="-2" pref="92" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="SaveChanges" min="-2" pref="220" max="-2" attributes="0"/>
<Group type="102" attributes="0">
<Component id="SaveChanges" min="-2" pref="220" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="37" max="-2" attributes="0"/>
<Component id="cancel" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="Category" min="-2" pref="220" max="-2" attributes="0"/>
</Group>
</Group>
@ -82,7 +86,10 @@
<Component id="Category" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="SaveChanges" min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="SaveChanges" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="cancel" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
@ -186,5 +193,13 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="SaveChangesActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="cancel">
<Properties>
<Property name="text" type="java.lang.String" value="Anuluj"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cancelActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Form>

View File

@ -56,7 +56,10 @@
<Component id="SaveChanges" alignment="0" min="-2" pref="220" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<Component id="cancel" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
@ -110,8 +113,11 @@
<Component id="Category" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="SaveChanges" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="33" max="32767" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="SaveChanges" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="cancel" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="32" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -286,5 +292,13 @@
<AuxValue name="JavaCodeGenerator_AddingCodePost" type="java.lang.String" value="jLabel1.setVisible(false);"/>
</AuxValues>
</Component>
<Component class="javax.swing.JButton" name="cancel">
<Properties>
<Property name="text" type="java.lang.String" value="Anuluj"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cancelActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Form>

Binary file not shown.

View File

@ -74,7 +74,7 @@
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jToggleButton1" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="50" max="32767" attributes="0"/>
<EmptySpace pref="43" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -374,11 +374,16 @@
<Group type="102" attributes="0">
<Component id="jLabel4" min="-2" pref="125" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="numberOfAlbums1" min="-2" max="-2" attributes="0"/>
<Component id="numberOfMovies" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace min="0" pref="23" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="69" max="-2" attributes="0"/>
<Component id="refreshNumbersOfItems" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
@ -397,9 +402,10 @@
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="numberOfAlbums1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="numberOfMovies" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="25" max="32767" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="refreshNumbersOfItems" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -428,6 +434,7 @@
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_InitCodePre" type="java.lang.String" value="String n = new Integer(d.countAll(&quot;books&quot;)).toString();"/>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="1"/>
</AuxValues>
</Component>
<Component class="javax.swing.JLabel" name="numberOfAlbums">
@ -440,7 +447,7 @@
<AuxValue name="JavaCodeGenerator_InitCodePre" type="java.lang.String" value="n = new Integer(d.countAll(&quot;albums&quot;)).toString();"/>
</AuxValues>
</Component>
<Component class="javax.swing.JLabel" name="numberOfAlbums1">
<Component class="javax.swing.JLabel" name="numberOfMovies">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="n" type="code"/>
@ -450,6 +457,14 @@
<AuxValue name="JavaCodeGenerator_InitCodePre" type="java.lang.String" value="n = new Integer(d.countAll(&quot;movies&quot;)).toString();"/>
</AuxValues>
</Component>
<Component class="javax.swing.JButton" name="refreshNumbersOfItems">
<Properties>
<Property name="text" type="java.lang.String" value="Od&#x15b;wie&#x17c;"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="refreshNumbersOfItemsActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.JToggleButton" name="jToggleButton1">

Binary file not shown.

View File

@ -47,7 +47,11 @@
<Group type="103" groupAlignment="0" attributes="0">
<Component id="year" alignment="0" min="-2" pref="76" max="-2" attributes="0"/>
<Component id="Category" min="-2" pref="220" max="-2" attributes="0"/>
<Component id="SaveChanges" alignment="0" min="-2" pref="220" max="-2" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Component id="SaveChanges" min="-2" pref="220" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="cancel" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
</Group>
@ -81,8 +85,11 @@
<Component id="Category" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="33" max="-2" attributes="0"/>
<Component id="SaveChanges" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="26" max="32767" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="SaveChanges" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="cancel" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="25" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -186,5 +193,13 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="SaveChangesActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="cancel">
<Properties>
<Property name="text" type="java.lang.String" value="Anuluj"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cancelActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Form>

View File

@ -11,6 +11,8 @@ package library;
*/
public class Album extends Item {
private String musican;
Album() {
}
@ -20,7 +22,7 @@ public class Album extends Item {
this.setName(n);
this.setYear(y);
this.setCategory(c);
this.musican = m;
this.setMusican(m);
}
public static Object[][] insertRowToTable(Object[][] tab, int r, Album a) {
@ -38,28 +40,22 @@ public class Album extends Item {
d.insertAlbumQ(this);
}
;
@Override
@Override
public void delFromDB() {
}
;
@Override
@Override
public void editInDB() {
}
;
public void setMusican(String s) {
public void setMusican(String s) {
this.musican = s;
}
public String getMusican() {
return this.musican;
}
private String musican;
}

View File

@ -47,7 +47,11 @@
<Component id="lcategory" min="-2" pref="92" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="SaveChanges" min="-2" pref="220" max="-2" attributes="0"/>
<Group type="102" attributes="0">
<Component id="SaveChanges" min="-2" pref="220" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="37" max="-2" attributes="0"/>
<Component id="cancel" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="Category" min="-2" pref="220" max="-2" attributes="0"/>
</Group>
</Group>
@ -82,7 +86,10 @@
<Component id="Category" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="SaveChanges" min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="SaveChanges" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="cancel" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
@ -186,5 +193,13 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="SaveChangesActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="cancel">
<Properties>
<Property name="text" type="java.lang.String" value="Anuluj"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cancelActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Form>

View File

@ -49,6 +49,7 @@ public class AlbumFieldPattern extends javax.swing.JFrame {
Category = new javax.swing.JComboBox<>();
mainlabel = new javax.swing.JLabel();
SaveChanges = new javax.swing.JButton();
cancel = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
@ -94,6 +95,13 @@ public class AlbumFieldPattern extends javax.swing.JFrame {
}
});
cancel.setText("Anuluj");
cancel.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cancelActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
@ -118,7 +126,10 @@ public class AlbumFieldPattern extends javax.swing.JFrame {
.addComponent(lcategory, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(SaveChanges, javax.swing.GroupLayout.PREFERRED_SIZE, 220, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addComponent(SaveChanges, javax.swing.GroupLayout.PREFERRED_SIZE, 220, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(37, 37, 37)
.addComponent(cancel))
.addComponent(Category, javax.swing.GroupLayout.PREFERRED_SIZE, 220, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addContainerGap(26, Short.MAX_VALUE))
);
@ -144,7 +155,9 @@ public class AlbumFieldPattern extends javax.swing.JFrame {
.addComponent(lcategory)
.addComponent(Category, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addComponent(SaveChanges)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(SaveChanges)
.addComponent(cancel))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
@ -163,18 +176,23 @@ public class AlbumFieldPattern extends javax.swing.JFrame {
if (this.add) {
Album a = new Album(0, albumTitle.getText(), musican.getText(), Integer.parseInt(year.getText()), Category.getSelectedItem().toString());
a.insertToDB();
this.dispose();
} else if (this.edit) {
JOptionPane.showMessageDialog(null, "EDYTUJ");
} else if (this.delete) {
JOptionPane.showMessageDialog(null, "USUŃ");
}
dispose();
}//GEN-LAST:event_SaveChangesActionPerformed
private void yearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_yearActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_yearActionPerformed
private void cancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelActionPerformed
this.dispose();
}//GEN-LAST:event_cancelActionPerformed
/**
* @param args the command line arguments
*/
@ -219,6 +237,7 @@ public class AlbumFieldPattern extends javax.swing.JFrame {
private javax.swing.JButton SaveChanges;
private javax.swing.JLabel Title;
private javax.swing.JTextField albumTitle;
private javax.swing.JButton cancel;
private javax.swing.JLabel lcategory;
private javax.swing.JLabel lmusican;
private javax.swing.JLabel lyear;

View File

@ -56,7 +56,10 @@
<Component id="SaveChanges" alignment="0" min="-2" pref="220" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<Component id="cancel" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
@ -110,8 +113,11 @@
<Component id="Category" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="SaveChanges" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="33" max="32767" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="SaveChanges" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="cancel" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="32" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -286,5 +292,13 @@
<AuxValue name="JavaCodeGenerator_AddingCodePost" type="java.lang.String" value="jLabel1.setVisible(false);"/>
</AuxValues>
</Component>
<Component class="javax.swing.JButton" name="cancel">
<Properties>
<Property name="text" type="java.lang.String" value="Anuluj"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cancelActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Form>

View File

@ -60,6 +60,7 @@ public class BookFieldPattern extends javax.swing.JFrame {
mainlabel = new javax.swing.JLabel();
SaveChanges = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
cancel = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
@ -145,6 +146,13 @@ public class BookFieldPattern extends javax.swing.JFrame {
jLabel1.setDoubleBuffered(true);
jLabel1.setName(""); // NOI18N
cancel.setText("Anuluj");
cancel.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cancelActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
@ -177,7 +185,9 @@ public class BookFieldPattern extends javax.swing.JFrame {
.addComponent(Category, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(SaveChanges, javax.swing.GroupLayout.PREFERRED_SIZE, 220, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addComponent(jLabel1)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1)
.addComponent(cancel))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
@ -219,8 +229,10 @@ public class BookFieldPattern extends javax.swing.JFrame {
.addComponent(lcategory)
.addComponent(Category, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addComponent(SaveChanges)
.addContainerGap(33, Short.MAX_VALUE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(SaveChanges)
.addComponent(cancel))
.addContainerGap(32, Short.MAX_VALUE))
);
jLabel1.setVisible(false);
@ -271,6 +283,10 @@ public class BookFieldPattern extends javax.swing.JFrame {
jLabel1.setVisible(false);
}//GEN-LAST:event_ISBNFocusLost
private void cancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelActionPerformed
this.dispose();
}//GEN-LAST:event_cancelActionPerformed
/**
* @param args the command line arguments
*/
@ -318,6 +334,7 @@ public class BookFieldPattern extends javax.swing.JFrame {
private javax.swing.JLabel authorname;
private javax.swing.JLabel authorsurname;
private javax.swing.JTextField bookTitle;
private javax.swing.JButton cancel;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel lISBN;
private javax.swing.JLabel lcategory;

View File

@ -73,7 +73,7 @@ public class Database {
public boolean createTables() {
String createBooks = "CREATE TABLE IF NOT EXISTS books (id INTEGER PRIMARY KEY AUTOINCREMENT, name varchar(255), author_name varchar(50), author_surname varchar(50), publishing varchar(50), year int, isbn varchar(20), category varchar(100))";
String createAlbums = "CREATE TABLE IF NOT EXISTS albums (id INTEGER PRIMARY KEY AUTOINCREMENT, name varchar(255), musican varchar(50), author_surname varchar(50), year int, category varchar(100))";
String createAlbums = "CREATE TABLE IF NOT EXISTS albums (id INTEGER PRIMARY KEY AUTOINCREMENT, name varchar(255), musican varchar(50), year int, category varchar(100))";
String createMovies = "CREATE TABLE IF NOT EXISTS movies (id INTEGER PRIMARY KEY AUTOINCREMENT, name varchar(255), director varchar(50), year int, category varchar(100))";
try {
stat.execute(createBooks);
@ -89,7 +89,7 @@ public class Database {
public void insertBookQ(Book b) {
try {
PreparedStatement prepStmt = conn.prepareStatement(
"INSERT INTO books VALUES (NULL, '?', '?', '?', '?', ?, '?', '?');");
"INSERT INTO books VALUES (NULL, ?, ?, ?, ?, ?, ?, ?);");
prepStmt.setString(1, b.getName());
prepStmt.setString(2, b.getAuthorName());
prepStmt.setString(3, b.getAuthorSurname());
@ -111,13 +111,12 @@ public class Database {
public void insertAlbumQ(Album a) {
try {
PreparedStatement prepStmt = conn.prepareStatement(
"INSERT INTO albums VALUES (NULL, '?', '?', ?, '?');");
"INSERT INTO albums VALUES (NULL, ?, ?, ?, ?);");
prepStmt.setString(1, a.getName());
prepStmt.setString(2, a.getMusican());
prepStmt.setInt(3, a.getYear());
prepStmt.setString(4, a.getCategory());
prepStmt.execute();
System.out.println(prepStmt);
JOptionPane.showMessageDialog(null, "Dodano poprawnie.", "Informacja:", JOptionPane.INFORMATION_MESSAGE);
} catch (SQLException e) {
JOptionPane.showMessageDialog(null, "Błąd przy dodawaniu albumu do bazy", "Error:", JOptionPane.INFORMATION_MESSAGE);
@ -129,7 +128,7 @@ public class Database {
public void insertMovieQ(Movie m) {
try {
PreparedStatement prepStmt = conn.prepareStatement(
"INSER INTO movies VALUES (NULL, '?', '?', ?, '?');");
"INSER INTO movies VALUES (NULL, ?, ?, ?, ?);");
prepStmt.setString(1, m.getName());
prepStmt.setString(2, m.getDirector());
prepStmt.setInt(3, m.getYear());

View File

@ -74,7 +74,7 @@
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jToggleButton1" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="50" max="32767" attributes="0"/>
<EmptySpace pref="43" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -374,11 +374,16 @@
<Group type="102" attributes="0">
<Component id="jLabel4" min="-2" pref="125" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="numberOfAlbums1" min="-2" max="-2" attributes="0"/>
<Component id="numberOfMovies" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace min="0" pref="23" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="69" max="-2" attributes="0"/>
<Component id="refreshNumbersOfItems" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
@ -397,9 +402,10 @@
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="numberOfAlbums1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="numberOfMovies" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="25" max="32767" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="refreshNumbersOfItems" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -428,6 +434,7 @@
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_InitCodePre" type="java.lang.String" value="String n = new Integer(d.countAll(&quot;books&quot;)).toString();"/>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="1"/>
</AuxValues>
</Component>
<Component class="javax.swing.JLabel" name="numberOfAlbums">
@ -440,7 +447,7 @@
<AuxValue name="JavaCodeGenerator_InitCodePre" type="java.lang.String" value="n = new Integer(d.countAll(&quot;albums&quot;)).toString();"/>
</AuxValues>
</Component>
<Component class="javax.swing.JLabel" name="numberOfAlbums1">
<Component class="javax.swing.JLabel" name="numberOfMovies">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="n" type="code"/>
@ -450,6 +457,14 @@
<AuxValue name="JavaCodeGenerator_InitCodePre" type="java.lang.String" value="n = new Integer(d.countAll(&quot;movies&quot;)).toString();"/>
</AuxValues>
</Component>
<Component class="javax.swing.JButton" name="refreshNumbersOfItems">
<Properties>
<Property name="text" type="java.lang.String" value="Od&#x15b;wie&#x17c;"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="refreshNumbersOfItemsActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.JToggleButton" name="jToggleButton1">

View File

@ -59,7 +59,8 @@ public class MainMenu extends javax.swing.JFrame {
jLabel4 = new javax.swing.JLabel();
numberOfBooks = new javax.swing.JLabel();
numberOfAlbums = new javax.swing.JLabel();
numberOfAlbums1 = new javax.swing.JLabel();
numberOfMovies = new javax.swing.JLabel();
refreshNumbersOfItems = new javax.swing.JButton();
jToggleButton1 = new javax.swing.JToggleButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
@ -264,7 +265,14 @@ public class MainMenu extends javax.swing.JFrame {
numberOfAlbums.setText(n);
n = new Integer(d.countAll("movies")).toString();
numberOfAlbums1.setText(n);
numberOfMovies.setText(n);
refreshNumbersOfItems.setText("Odśwież");
refreshNumbersOfItems.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
refreshNumbersOfItemsActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
@ -283,8 +291,12 @@ public class MainMenu extends javax.swing.JFrame {
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(numberOfAlbums1)))
.addComponent(numberOfMovies)))
.addGap(0, 23, Short.MAX_VALUE))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(69, 69, 69)
.addComponent(refreshNumbersOfItems)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@ -300,8 +312,9 @@ public class MainMenu extends javax.swing.JFrame {
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4)
.addComponent(numberOfAlbums1))
.addContainerGap(25, Short.MAX_VALUE))
.addComponent(numberOfMovies))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(refreshNumbersOfItems))
);
jToggleButton1.setText("Własne zapytanie SELECT");
@ -347,7 +360,7 @@ public class MainMenu extends javax.swing.JFrame {
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jToggleButton1)
.addContainerGap(50, Short.MAX_VALUE))
.addContainerGap(43, Short.MAX_VALUE))
);
pack();
@ -384,7 +397,7 @@ public class MainMenu extends javax.swing.JFrame {
b.edit = true;
}
if (radioBSearch.getModel().isSelected()) {
MovieFieldPattern b = new MovieFieldPattern();
AlbumFieldPattern b = new AlbumFieldPattern();
b.setVisible(true);
b.delete = true;
}
@ -491,6 +504,17 @@ public class MainMenu extends javax.swing.JFrame {
}//GEN-LAST:event_allAlbumsShowActionPerformed
private void refreshNumbersOfItemsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_refreshNumbersOfItemsActionPerformed
String n = Integer.toString(d.countAll("books"));
numberOfBooks.setText(n);
n = "";
n = Integer.toString(d.countAll("albums"));
numberOfAlbums.setText(n);
n = "";
n = Integer.toString(d.countAll("movies"));
numberOfMovies.setText(n);
}//GEN-LAST:event_refreshNumbersOfItemsActionPerformed
/**
* @param args the command line arguments
*/
@ -547,13 +571,14 @@ public class MainMenu extends javax.swing.JFrame {
private javax.swing.JButton newestMovie;
private javax.swing.JButton newestMovie1;
private javax.swing.JLabel numberOfAlbums;
private javax.swing.JLabel numberOfAlbums1;
private javax.swing.JLabel numberOfBooks;
public javax.swing.JLabel numberOfBooks;
private javax.swing.JLabel numberOfMovies;
private javax.swing.JLabel programTitle;
private javax.swing.JRadioButton radioBAdd;
private javax.swing.JRadioButton radioBDelete1;
private javax.swing.JRadioButton radioBEdit;
private javax.swing.JRadioButton radioBSearch;
private javax.swing.JButton refreshNumbersOfItems;
private javax.swing.JPanel searchButtonsPanel;
// End of variables declaration//GEN-END:variables
}

View File

@ -33,6 +33,7 @@ public class Movie extends Item {
this.setYear(y);
this.setCategory(c);
}
public static Object[][] insertRowToTable(Object[][] tab, int r, Movie m) {
tab[r][0] = m.getId();
tab[r][1] = m.getName();
@ -42,6 +43,7 @@ public class Movie extends Item {
return tab;
}
@Override
public void insertToDB() {
d.insertMovieQ(this);

View File

@ -47,7 +47,11 @@
<Group type="103" groupAlignment="0" attributes="0">
<Component id="year" alignment="0" min="-2" pref="76" max="-2" attributes="0"/>
<Component id="Category" min="-2" pref="220" max="-2" attributes="0"/>
<Component id="SaveChanges" alignment="0" min="-2" pref="220" max="-2" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Component id="SaveChanges" min="-2" pref="220" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="cancel" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
</Group>
@ -81,8 +85,11 @@
<Component id="Category" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="33" max="-2" attributes="0"/>
<Component id="SaveChanges" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="26" max="32767" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="SaveChanges" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="cancel" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="25" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -186,5 +193,13 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="SaveChangesActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="cancel">
<Properties>
<Property name="text" type="java.lang.String" value="Anuluj"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cancelActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Form>

View File

@ -48,6 +48,7 @@ public class MovieFieldPattern extends javax.swing.JFrame {
Category = new javax.swing.JComboBox<>();
mainlabel = new javax.swing.JLabel();
SaveChanges = new javax.swing.JButton();
cancel = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
@ -93,6 +94,13 @@ public class MovieFieldPattern extends javax.swing.JFrame {
}
});
cancel.setText("Anuluj");
cancel.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cancelActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
@ -117,7 +125,10 @@ public class MovieFieldPattern extends javax.swing.JFrame {
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(year, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(Category, javax.swing.GroupLayout.PREFERRED_SIZE, 220, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(SaveChanges, javax.swing.GroupLayout.PREFERRED_SIZE, 220, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addGroup(layout.createSequentialGroup()
.addComponent(SaveChanges, javax.swing.GroupLayout.PREFERRED_SIZE, 220, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(cancel)))))
.addContainerGap(21, Short.MAX_VALUE))
);
layout.setVerticalGroup(
@ -142,8 +153,10 @@ public class MovieFieldPattern extends javax.swing.JFrame {
.addComponent(lcategory)
.addComponent(Category, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(33, 33, 33)
.addComponent(SaveChanges)
.addContainerGap(26, Short.MAX_VALUE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(SaveChanges)
.addComponent(cancel))
.addContainerGap(25, Short.MAX_VALUE))
);
pack();
@ -166,13 +179,17 @@ public class MovieFieldPattern extends javax.swing.JFrame {
} else if (this.delete) {
JOptionPane.showMessageDialog(null, "USUŃ");
}
dispose();
this.dispose();
}//GEN-LAST:event_SaveChangesActionPerformed
private void yearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_yearActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_yearActionPerformed
private void cancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelActionPerformed
this.dispose();
}//GEN-LAST:event_cancelActionPerformed
/**
* @param args the command line arguments
*/
@ -214,6 +231,7 @@ public class MovieFieldPattern extends javax.swing.JFrame {
private javax.swing.JComboBox<String> Category;
private javax.swing.JButton SaveChanges;
private javax.swing.JLabel Title;
private javax.swing.JButton cancel;
private javax.swing.JTextField director;
private javax.swing.JLabel directorrname;
private javax.swing.JLabel lcategory;