Input Verifier wszystko okej
This commit is contained in:
parent
264b557d48
commit
fa5c2eec24
BIN
biblioteka.db
BIN
biblioteka.db
Binary file not shown.
@ -47,11 +47,7 @@
|
||||
<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">
|
||||
<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="SaveChanges" min="-2" pref="220" max="-2" attributes="0"/>
|
||||
<Component id="Category" min="-2" pref="220" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
@ -86,11 +82,8 @@
|
||||
<Component id="Category" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace type="separate" 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"/>
|
||||
<Component id="SaveChanges" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="14" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
@ -193,13 +186,5 @@
|
||||
<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>
|
||||
|
@ -19,13 +19,22 @@ public class AlbumFieldPattern extends javax.swing.JFrame {
|
||||
* Creates new form bookFieldPattern
|
||||
*/
|
||||
public AlbumFieldPattern() {
|
||||
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
initComponents();
|
||||
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
}
|
||||
|
||||
public AlbumFieldPattern(boolean required) {
|
||||
initComponents();
|
||||
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
Validation verify;
|
||||
if (required) {
|
||||
verify = new Validation(true);
|
||||
} else {
|
||||
verify = new Validation();
|
||||
}
|
||||
albumTitle.setInputVerifier(verify);
|
||||
musican.setInputVerifier(verify);
|
||||
year.setInputVerifier(verify);
|
||||
}
|
||||
public boolean add = false, delete = false, edit = false, search = false;
|
||||
|
||||
@ -48,7 +57,6 @@ 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,13 +102,6 @@ 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(
|
||||
@ -125,10 +126,7 @@ 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)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(SaveChanges, javax.swing.GroupLayout.PREFERRED_SIZE, 220, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(37, 37, 37)
|
||||
.addComponent(cancel))
|
||||
.addComponent(SaveChanges, javax.swing.GroupLayout.PREFERRED_SIZE, 220, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(Category, javax.swing.GroupLayout.PREFERRED_SIZE, 220, javax.swing.GroupLayout.PREFERRED_SIZE))))
|
||||
.addContainerGap(26, Short.MAX_VALUE))
|
||||
);
|
||||
@ -154,10 +152,8 @@ 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)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(SaveChanges)
|
||||
.addComponent(cancel))
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addComponent(SaveChanges)
|
||||
.addContainerGap(14, Short.MAX_VALUE))
|
||||
);
|
||||
|
||||
pack();
|
||||
@ -192,10 +188,6 @@ public class AlbumFieldPattern extends javax.swing.JFrame {
|
||||
// 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
|
||||
*/
|
||||
@ -240,7 +232,6 @@ 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;
|
||||
|
@ -22,12 +22,18 @@ public class Book extends Item {
|
||||
//nothing to do
|
||||
}
|
||||
|
||||
Book(int id, String n, String an, String asn, int y, String isbn, String p, String c) {
|
||||
Book(int id, String n, String an, String asn, String y, String isbn, String p, String c) {
|
||||
this.setId(id);
|
||||
this.setName(n);
|
||||
this.authorName = an;
|
||||
this.authorSurname = asn;
|
||||
this.setYear(y);
|
||||
try{
|
||||
this.setYear(Integer.parseInt(y));
|
||||
}
|
||||
catch(NumberFormatException e){
|
||||
this.setYear(0);
|
||||
}
|
||||
|
||||
this.setCategory(c);
|
||||
this.ISBN = isbn;
|
||||
this.publishing = p;
|
||||
|
@ -56,10 +56,7 @@
|
||||
<Component id="SaveChanges" alignment="0" min="-2" pref="220" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace type="separate" 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>
|
||||
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
@ -113,11 +110,8 @@
|
||||
<Component id="Category" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace type="separate" 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 pref="32" max="32767" attributes="0"/>
|
||||
<Component id="SaveChanges" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="33" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
@ -242,15 +236,16 @@
|
||||
<Component class="javax.swing.JComboBox" name="Category">
|
||||
<Properties>
|
||||
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
|
||||
<StringArray count="8">
|
||||
<StringItem index="0" value="Przygodowe"/>
|
||||
<StringItem index="1" value="Naukowe"/>
|
||||
<StringItem index="2" value="Powieść"/>
|
||||
<StringItem index="3" value="Poezja"/>
|
||||
<StringItem index="4" value="Kryminał"/>
|
||||
<StringItem index="5" value="Dla dzieci"/>
|
||||
<StringItem index="6" value="Psychologiczne"/>
|
||||
<StringItem index="7" value="Podręczniki"/>
|
||||
<StringArray count="9">
|
||||
<StringItem index="0" value=" "/>
|
||||
<StringItem index="1" value="Przygodowe"/>
|
||||
<StringItem index="2" value="Naukowe"/>
|
||||
<StringItem index="3" value="Powieść"/>
|
||||
<StringItem index="4" value="Poezja"/>
|
||||
<StringItem index="5" value="Kryminał"/>
|
||||
<StringItem index="6" value="Dla dzieci"/>
|
||||
<StringItem index="7" value="Psychologiczne"/>
|
||||
<StringItem index="8" value="Podręczniki"/>
|
||||
</StringArray>
|
||||
</Property>
|
||||
</Properties>
|
||||
@ -295,13 +290,5 @@
|
||||
<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>
|
||||
|
@ -7,6 +7,8 @@ package library;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.swing.JFrame;
|
||||
@ -18,20 +20,27 @@ import javax.swing.JOptionPane;
|
||||
*/
|
||||
public class BookFieldPattern extends javax.swing.JFrame {
|
||||
|
||||
/**
|
||||
* Creates new form bookFieldPattern
|
||||
*/
|
||||
public boolean add = false, delete = false, edit = false, search = false;
|
||||
private Database d = new Database();
|
||||
|
||||
public BookFieldPattern() {
|
||||
initComponents();
|
||||
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
Validation verify = new Validation();
|
||||
year.setInputVerifier(verify);
|
||||
ISBN.setInputVerifier(verify);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public BookFieldPattern(boolean required) {
|
||||
initComponents();
|
||||
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
Validation verify;
|
||||
if (required) {
|
||||
verify = new Validation(true);
|
||||
} else {
|
||||
verify = new Validation();
|
||||
}
|
||||
bookTitle.setInputVerifier(verify);
|
||||
authorName.setInputVerifier(verify);
|
||||
authorSurname.setInputVerifier(verify);
|
||||
@ -40,9 +49,6 @@ public class BookFieldPattern extends javax.swing.JFrame {
|
||||
publishing.setInputVerifier(verify);
|
||||
}
|
||||
|
||||
public boolean add = false, delete = false, edit = false, search = false;
|
||||
private Validation verify = new Validation();
|
||||
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is always
|
||||
@ -69,7 +75,6 @@ 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);
|
||||
|
||||
@ -132,7 +137,7 @@ public class BookFieldPattern extends javax.swing.JFrame {
|
||||
lcategory.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
|
||||
lcategory.setText("Kategoria:");
|
||||
|
||||
Category.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Przygodowe", "Naukowe", "Powieść", "Poezja", "Kryminał", "Dla dzieci", "Psychologiczne", "Podręczniki" }));
|
||||
Category.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { " ", "Przygodowe", "Naukowe", "Powieść", "Poezja", "Kryminał", "Dla dzieci", "Psychologiczne", "Podręczniki" }));
|
||||
Category.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
CategoryActionPerformed(evt);
|
||||
@ -157,13 +162,6 @@ 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(
|
||||
@ -196,9 +194,7 @@ 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)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jLabel1)
|
||||
.addComponent(cancel))
|
||||
.addComponent(jLabel1)
|
||||
.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)
|
||||
@ -240,10 +236,8 @@ 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)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(SaveChanges)
|
||||
.addComponent(cancel))
|
||||
.addContainerGap(32, Short.MAX_VALUE))
|
||||
.addComponent(SaveChanges)
|
||||
.addContainerGap(33, Short.MAX_VALUE))
|
||||
);
|
||||
|
||||
jLabel1.setVisible(false);
|
||||
@ -263,18 +257,38 @@ public class BookFieldPattern extends javax.swing.JFrame {
|
||||
private void SaveChangesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SaveChangesActionPerformed
|
||||
if (this.add) {
|
||||
try {
|
||||
Book b = new Book(0, bookTitle.getText(), authorName.getText(), authorSurname.getText(), Integer.parseInt(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());
|
||||
b.insertToDB();
|
||||
} catch (SQLException e) {
|
||||
e.getMessage();
|
||||
}
|
||||
|
||||
} else if (this.edit) {
|
||||
JOptionPane.showMessageDialog(null, "EDYTUJ");
|
||||
try {
|
||||
Book b = new Book(0, bookTitle.getText(), authorName.getText(), authorSurname.getText(), year.getText(), ISBN.getText(), publishing.getText(), Category.getSelectedItem().toString());
|
||||
List<Book> books = new LinkedList<>();
|
||||
//books = d.selectBooks(b);
|
||||
d.selectBooks(b);
|
||||
/*Object[][] data = d.convertToTable(books);
|
||||
String[] columnNames = {"ID",
|
||||
"Tytuł",
|
||||
"Imię Autora",
|
||||
"Nazwisko Autora",
|
||||
"Rok",
|
||||
"ISBN",
|
||||
"Wydawnictwo",
|
||||
"Kategoria"};
|
||||
ListResult table = new ListResult(data, columnNames);
|
||||
table.setVisible(true);*/
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
//nothing to do here
|
||||
}
|
||||
// ListResult l = new ListResult();
|
||||
|
||||
} else if (this.delete) {
|
||||
JOptionPane.showMessageDialog(null, "USUŃ");
|
||||
} else if (this.search) {
|
||||
|
||||
|
||||
}
|
||||
dispose();
|
||||
}//GEN-LAST:event_SaveChangesActionPerformed
|
||||
@ -299,10 +313,6 @@ 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
|
||||
*/
|
||||
@ -350,7 +360,6 @@ public class BookFieldPattern extends javax.swing.JFrame {
|
||||
private javax.swing.JLabel authorname;
|
||||
private javax.swing.JLabel authorsurname;
|
||||
javax.swing.JTextField bookTitle;
|
||||
private javax.swing.JButton cancel;
|
||||
private javax.swing.JLabel jLabel1;
|
||||
private javax.swing.JLabel lISBN;
|
||||
private javax.swing.JLabel lcategory;
|
||||
|
@ -135,11 +135,11 @@ public class Database {
|
||||
List<Book> books = new ArrayList<Book>();
|
||||
try {
|
||||
ResultSet result = stat.executeQuery("SELECT * FROM books");
|
||||
int id, year;
|
||||
String name, authorName, authorSurname, isbn, category, publishing;
|
||||
int id;
|
||||
String name, authorName, authorSurname, isbn, category, publishing, year;
|
||||
while (result.next()) {
|
||||
id = result.getInt("id");
|
||||
year = result.getInt("year");
|
||||
year = result.getString("year");
|
||||
name = result.getString("name");
|
||||
authorName = result.getString("author_name");
|
||||
authorSurname = result.getString("author_surname");
|
||||
@ -154,48 +154,51 @@ public class Database {
|
||||
return books;
|
||||
}
|
||||
|
||||
public List<Book> selectBooks(Book searchData) {
|
||||
//public List<Book> selectBooks(Book searchData) {
|
||||
public void selectBooks(Book searchData) {
|
||||
List<Book> books = new ArrayList<>();
|
||||
try {
|
||||
List<String> wheres = new ArrayList<>();
|
||||
if (searchData.getName().length() > 0) {
|
||||
wheres.add("WHERE name LIKE " + searchData.getName());
|
||||
System.out.println("WHERE name LIKE " + searchData.getName());
|
||||
}
|
||||
if (searchData.getAuthorName().length() > 0) {
|
||||
wheres.add("WHERE author_name LIKE " + searchData.getAuthorName());
|
||||
System.out.println("WHERE author_name LIKE " + searchData.getAuthorName());
|
||||
}
|
||||
if (searchData.getPublishing().length() > 0) {
|
||||
wheres.add("WHERE publishing LIKE " + searchData.getPublishing());
|
||||
System.out.println("WHERE publishing LIKE " + searchData.getPublishing());
|
||||
}
|
||||
if (searchData.getYear() > 0) {
|
||||
wheres.add("WHERE year = " + searchData.getYear());
|
||||
System.out.println("WHERE year = " + searchData.getYear());
|
||||
}
|
||||
if (searchData.getName().length() > 0) {
|
||||
wheres.add("WHERE name LIKE " + searchData.getName());
|
||||
System.out.println("WHERE name LIKE " + searchData.getName());
|
||||
}
|
||||
if (searchData.getName().length() > 0) {
|
||||
wheres.add("WHERE name LIKE " + searchData.getName());
|
||||
System.out.println("WHERE name LIKE " + searchData.getName());
|
||||
}
|
||||
if (searchData.getISBN().length() > 0) {
|
||||
wheres.add("WHERE isbn LIKE " + searchData.getISBN());
|
||||
System.out.println("WHERE isbn LIKE " + searchData.getISBN());
|
||||
}
|
||||
if (searchData.getCategory().length() > 0) {
|
||||
wheres.add("WHERE category LIKE " + searchData.getCategory());
|
||||
System.out.println("WHERE category LIKE " + searchData.getCategory());
|
||||
}
|
||||
boolean EmptyAll = true;
|
||||
//try {
|
||||
List<String> wheres = new ArrayList<>();
|
||||
if (searchData.getName().length() > 0) {
|
||||
wheres.add("WHERE name LIKE '" + searchData.getName() + "'");
|
||||
System.out.println("WHERE name LIKE '" + searchData.getName() + "'");
|
||||
EmptyAll = false;
|
||||
}
|
||||
if (searchData.getAuthorName().length() > 0) {
|
||||
wheres.add("WHERE author_name LIKE '" + searchData.getAuthorName() + "'");
|
||||
System.out.println("WHERE author_name LIKE '" + searchData.getAuthorName() + "'");
|
||||
EmptyAll = false;
|
||||
}
|
||||
if (searchData.getPublishing().length() > 0) {
|
||||
wheres.add("WHERE publishing LIKE '" + searchData.getPublishing() + "'");
|
||||
System.out.println("WHERE publishing LIKE '" + searchData.getPublishing() + "'");
|
||||
EmptyAll = false;
|
||||
}
|
||||
if (searchData.getYear() > 0) {
|
||||
wheres.add("WHERE year = " + searchData.getYear());
|
||||
System.out.println("WHERE year = " + searchData.getYear());
|
||||
EmptyAll = false;
|
||||
}
|
||||
if (searchData.getISBN().length() > 0) {
|
||||
wheres.add("WHERE isbn LIKE " + searchData.getISBN());
|
||||
System.out.println("WHERE isbn LIKE '" + searchData.getISBN() + "'");
|
||||
EmptyAll = false;
|
||||
}
|
||||
if (searchData.getCategory().length() > 1) {
|
||||
wheres.add("WHERE category LIKE '" + searchData.getCategory() + "'");
|
||||
System.out.println("WHERE category LIKE '" + searchData.getCategory() + "'");
|
||||
EmptyAll = false;
|
||||
}
|
||||
if (EmptyAll) {
|
||||
System.out.println("PUSTO");
|
||||
}
|
||||
|
||||
String query = "SELECT * FROM books";
|
||||
if (query.length() == 19) {
|
||||
String query = "SELECT * FROM books";
|
||||
if (query.length() == 19) {
|
||||
|
||||
}
|
||||
ResultSet result = stat.executeQuery("SELECT * FROM books");
|
||||
}
|
||||
/*ResultSet result = stat.executeQuery("SELECT * FROM books");
|
||||
int id, year;
|
||||
String name, authorName, authorSurname, isbn, category, publishing;
|
||||
while (result.next()) {
|
||||
@ -212,7 +215,7 @@ public class Database {
|
||||
} catch (SQLException e) {
|
||||
JOptionPane.showMessageDialog(null, "Błąd przy odczycie z bazy.", "Error:", JOptionPane.INFORMATION_MESSAGE);
|
||||
}
|
||||
return books;
|
||||
return books;*/
|
||||
}
|
||||
|
||||
public List<Album> selectAlbums() {
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
|
||||
<Form version="1.6" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
|
||||
<Properties>
|
||||
<Property name="defaultCloseOperation" type="int" value="3"/>
|
||||
</Properties>
|
||||
@ -72,10 +72,15 @@
|
||||
<Property name="autoCreateColumnsFromModel" type="boolean" editor="org.netbeans.modules.form.RADConnectionPropertyEditor" postCode="table.setModel(new javax.swing.table.DefaultTableModel(
 rows,
 columnsNames
));">
|
||||
<Connection code="false" type="code"/>
|
||||
</Property>
|
||||
<Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor" postCode="table.setRowSelectionInterval(0, 0);">
|
||||
<Connection code="new javax.swing.table.DefaultTableModel(
 rows,
 columnsNames
)" type="code"/>
|
||||
</Property>
|
||||
<Property name="rowHeight" type="int" value="25"/>
|
||||
<Property name="rowHeight" type="int" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="25" type="code"/>
|
||||
</Property>
|
||||
<Property name="selectionModel" type="javax.swing.ListSelectionModel" editor="org.netbeans.modules.form.editors2.JTableSelectionModelEditor">
|
||||
<JTableSelectionModel selectionMode="0"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new javax.swing.JTable(rows, columnsNames)"/>
|
||||
|
@ -57,7 +57,9 @@ public class ListResult extends javax.swing.JFrame {
|
||||
rows,
|
||||
columnsNames
|
||||
));
|
||||
table.setRowSelectionInterval(0, 0);
|
||||
table.setRowHeight(25);
|
||||
table.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
|
||||
jScrollPane1.setViewportView(table);
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
|
@ -387,7 +387,7 @@ public class MainMenu extends javax.swing.JFrame {
|
||||
private void bAlbumActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bAlbumActionPerformed
|
||||
|
||||
if (radioBAdd.getModel().isSelected()) {
|
||||
AlbumFieldPattern b = new AlbumFieldPattern();
|
||||
AlbumFieldPattern b = new AlbumFieldPattern(true);
|
||||
b.setVisible(true);
|
||||
b.add = true;
|
||||
}
|
||||
@ -440,7 +440,6 @@ public class MainMenu extends javax.swing.JFrame {
|
||||
|
||||
private void allBooksShowActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_allBooksShowActionPerformed
|
||||
try {
|
||||
|
||||
List<Book> books = new LinkedList<>();
|
||||
books = d.selectBooks();
|
||||
Object[][] data = d.convertToTable(books);
|
||||
@ -504,7 +503,7 @@ public class MainMenu extends javax.swing.JFrame {
|
||||
n = "";
|
||||
n = Integer.toString(d.countAll("albums"));
|
||||
numberOfAlbums.setText(n);
|
||||
n = "";
|
||||
n = "";
|
||||
n = Integer.toString(d.countAll("movies"));
|
||||
numberOfMovies.setText(n);
|
||||
}//GEN-LAST:event_refreshNumbersOfItemsActionPerformed
|
||||
|
@ -19,13 +19,22 @@ public class MovieFieldPattern extends javax.swing.JFrame {
|
||||
* Creates new form bookFieldPattern
|
||||
*/
|
||||
public MovieFieldPattern() {
|
||||
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
initComponents();
|
||||
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
}
|
||||
|
||||
public MovieFieldPattern(boolean required) {
|
||||
initComponents();
|
||||
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
Validation verify;
|
||||
if (required) {
|
||||
verify = new Validation(true);
|
||||
} else {
|
||||
verify = new Validation();
|
||||
}
|
||||
movieTitle.setInputVerifier(verify);
|
||||
director.setInputVerifier(verify);
|
||||
year.setInputVerifier(verify);
|
||||
}
|
||||
public boolean add = false, delete = false, edit = false, search = false;
|
||||
|
||||
|
@ -18,6 +18,7 @@ import javax.swing.JTextField;
|
||||
*/
|
||||
public class Validation extends InputVerifier {
|
||||
|
||||
public final int nowadays = 2016;
|
||||
String expression;
|
||||
boolean required = false;
|
||||
int year;
|
||||
@ -37,7 +38,7 @@ public class Validation extends InputVerifier {
|
||||
public boolean checkField(JComponent input) {
|
||||
JTextField tf = (JTextField) input;
|
||||
if (required) {
|
||||
if ((tf.getText().equals(""))) {
|
||||
if ("".equals(tf.getText())) {
|
||||
JOptionPane.showMessageDialog(null, "Pole wymagane!", "Błąd wprowadzanych danych", JOptionPane.INFORMATION_MESSAGE);
|
||||
return false;
|
||||
}
|
||||
@ -47,7 +48,7 @@ public class Validation extends InputVerifier {
|
||||
if (!"".equals(tf.getText())) {
|
||||
try {
|
||||
year = Integer.parseInt(tf.getText());
|
||||
if (year > 2016 || year < 1900) {
|
||||
if (year > nowadays || year < 1900) {
|
||||
JOptionPane.showMessageDialog(null, "Data spoza zakresu.", "Błąd wprowadzanych danych", JOptionPane.INFORMATION_MESSAGE);
|
||||
return false;
|
||||
}
|
||||
@ -64,7 +65,7 @@ public class Validation extends InputVerifier {
|
||||
if (m.matches()) {
|
||||
return true;
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(null, "Niepoprawne dane!", "Sprawdzenie pola:", JOptionPane.INFORMATION_MESSAGE);
|
||||
JOptionPane.showMessageDialog(null, "Wpisz ISBN we właściwym formacie", "Sprawdzenie pola:", JOptionPane.INFORMATION_MESSAGE);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user