zapis i już
This commit is contained in:
parent
b8c4e12d6f
commit
3f474500ab
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -42,12 +42,10 @@
|
||||
<Group type="103" groupAlignment="1" max="-2" attributes="0">
|
||||
<Component id="lcategory" max="32767" attributes="0"/>
|
||||
<Component id="lyear" pref="92" max="32767" attributes="0"/>
|
||||
<Component id="authorsurname" alignment="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace min="-2" pref="17" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="year" alignment="0" min="-2" pref="76" max="-2" attributes="0"/>
|
||||
<Component id="script" min="-2" pref="220" 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>
|
||||
@ -73,11 +71,6 @@
|
||||
<Component id="director" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="authorsurname" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="script" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="lyear" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="year" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
@ -125,24 +118,6 @@
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="script">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Tahoma" size="14" style="0"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="scriptActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="authorsurname">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Tahoma" size="14" style="0"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="Scenariusz:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="lyear">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
|
@ -25,7 +25,7 @@ public class Album extends Item {
|
||||
};
|
||||
@Override
|
||||
public void delFromDB(){
|
||||
String query = "DELETE FROM albums WHERE id=" + this.getId() + ";";
|
||||
|
||||
};
|
||||
@Override
|
||||
public void editInDB(){
|
||||
|
@ -11,6 +11,9 @@ package library;
|
||||
*/
|
||||
public class Book extends Item {
|
||||
|
||||
private String authorName, authorSurname, publishing, ISBN;
|
||||
private Database d = new Database();
|
||||
|
||||
Book() {
|
||||
//nothing to do
|
||||
}
|
||||
@ -31,24 +34,17 @@ public class Book extends Item {
|
||||
d.insertBookQ(this);
|
||||
}
|
||||
|
||||
;
|
||||
@Override
|
||||
@Override
|
||||
public void delFromDB() {
|
||||
String query = "DELETE FROM books WHERE id=" + this.getId() + ";";
|
||||
|
||||
}
|
||||
|
||||
;
|
||||
@Override
|
||||
@Override
|
||||
public void editInDB() {
|
||||
|
||||
}
|
||||
|
||||
;
|
||||
/*public void insertQuery(){
|
||||
System.out.println("INSERT INTO books VALUES('NULL', '" +name + "', '" + authorName + "', '" + authorSurname + "', '"+ publishing + "', '"+ year + "', '"+ ISBN + "', '"+ category + "');");
|
||||
}*/
|
||||
|
||||
public void setPublishing(String s) {
|
||||
public void setPublishing(String s) {
|
||||
this.publishing = s;
|
||||
}
|
||||
|
||||
@ -79,7 +75,5 @@ public void setPublishing(String s) {
|
||||
public String getISBN() {
|
||||
return this.ISBN;
|
||||
}
|
||||
private String authorName, authorSurname, publishing, ISBN;
|
||||
private Database d = new Database();
|
||||
|
||||
}
|
||||
|
@ -85,9 +85,8 @@ public class Database {
|
||||
prepStmt.setInt(5, b.getYear());
|
||||
prepStmt.setString(6, b.getISBN());
|
||||
prepStmt.setString(7, b.getCategory());
|
||||
|
||||
prepStmt.execute();
|
||||
|
||||
JOptionPane.showMessageDialog(null, "Dodano poprawnie.", "Informacja:", JOptionPane.INFORMATION_MESSAGE);
|
||||
/* String sel = "SELECT * FROM books WHERE name LIKE ? AND author_name LIKE ? AND author_surname LIKE ? AND publishing LIKE ? AND year = ? AND isbn LIKE ? AND category LIKE ? ;";
|
||||
PreparedStatement prepStmt2 = conn.prepareStatement(sel);
|
||||
prepStmt.setString(1, b.getName());
|
||||
@ -115,14 +114,14 @@ public class Database {
|
||||
prepStmt.setString(2, a.getMusican());
|
||||
prepStmt.setInt(3, a.getYear());
|
||||
prepStmt.setString(4, a.getCategory());
|
||||
|
||||
prepStmt.execute();
|
||||
JOptionPane.showMessageDialog(null, "Dodano poprawnie.", "Informacja:", JOptionPane.INFORMATION_MESSAGE);
|
||||
} catch (SQLException e) {
|
||||
JOptionPane.showMessageDialog(null, "Błąd przy dodawaniu do bazy", "Error:", JOptionPane.INFORMATION_MESSAGE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void insertMovieQ(Movie m) {
|
||||
try {
|
||||
PreparedStatement prepStmt = conn.prepareStatement(
|
||||
@ -132,6 +131,7 @@ public class Database {
|
||||
prepStmt.setInt(3, m.getYear());
|
||||
prepStmt.setString(4, m.getCategory());
|
||||
prepStmt.execute();
|
||||
JOptionPane.showMessageDialog(null, "Dodano poprawnie.", "Informacja:", JOptionPane.INFORMATION_MESSAGE);
|
||||
} catch (SQLException e) {
|
||||
JOptionPane.showMessageDialog(null, "Błąd przy dodawaniu do bazy", "Error:", JOptionPane.INFORMATION_MESSAGE);
|
||||
}
|
||||
|
@ -15,43 +15,44 @@ import javax.swing.JOptionPane;
|
||||
*
|
||||
* @author Agnieszka
|
||||
*/
|
||||
public class Movie extends Item{
|
||||
public class Movie extends Item {
|
||||
|
||||
public Connection conn;
|
||||
public Statement stat;
|
||||
private String director;
|
||||
private Database d = new Database();
|
||||
|
||||
Movie(){
|
||||
|
||||
Movie() {
|
||||
//nothing to do there
|
||||
}
|
||||
|
||||
Movie(int id, String n, String d, int y, String c){
|
||||
|
||||
Movie(int id, String n, String d, int y, String c) {
|
||||
this.setId(id);
|
||||
this.setName(n);
|
||||
this.director = d;
|
||||
this.setYear(y);
|
||||
this.setCategory(c);
|
||||
|
||||
}
|
||||
@Override
|
||||
public void insertToDB(){
|
||||
d.insertMovieQ(this);
|
||||
};
|
||||
|
||||
public String getDirector(){
|
||||
return this.director;
|
||||
}
|
||||
@Override
|
||||
public void delFromDB(){
|
||||
@Override
|
||||
public void insertToDB() {
|
||||
d.insertMovieQ(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delFromDB() {
|
||||
String query = "DELETE FROM books WHERE id=" + this.getId() + ";";
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void editInDB(){
|
||||
|
||||
};
|
||||
@Override
|
||||
public void editInDB() {
|
||||
|
||||
}
|
||||
|
||||
public String getDirector() {
|
||||
return this.director;
|
||||
}
|
||||
}
|
||||
/*public void insertQuery(){
|
||||
/*public void insertQuery(){
|
||||
System.out.println("INSERT INTO books VALUES('NULL', '" +name + "', '" + authorName + "', '" + authorSurname + "', '"+ publishing + "', '"+ year + "', '"+ ISBN + "', '"+ category + "');");
|
||||
}*/
|
||||
|
@ -42,12 +42,10 @@
|
||||
<Group type="103" groupAlignment="1" max="-2" attributes="0">
|
||||
<Component id="lcategory" max="32767" attributes="0"/>
|
||||
<Component id="lyear" pref="92" max="32767" attributes="0"/>
|
||||
<Component id="authorsurname" alignment="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace min="-2" pref="17" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="year" alignment="0" min="-2" pref="76" max="-2" attributes="0"/>
|
||||
<Component id="script" min="-2" pref="220" 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>
|
||||
@ -73,11 +71,6 @@
|
||||
<Component id="director" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="authorsurname" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="script" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="lyear" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="year" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
@ -125,24 +118,6 @@
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="script">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Tahoma" size="14" style="0"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="scriptActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="authorsurname">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Tahoma" size="14" style="0"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="Scenariusz:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="lyear">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
|
@ -42,8 +42,6 @@ public class MovieFieldPattern extends javax.swing.JFrame {
|
||||
movieTitle = new javax.swing.JTextField();
|
||||
directorrname = new javax.swing.JLabel();
|
||||
director = new javax.swing.JTextField();
|
||||
script = new javax.swing.JTextField();
|
||||
authorsurname = new javax.swing.JLabel();
|
||||
lyear = new javax.swing.JLabel();
|
||||
year = new javax.swing.JTextField();
|
||||
lcategory = new javax.swing.JLabel();
|
||||
@ -63,16 +61,6 @@ public class MovieFieldPattern extends javax.swing.JFrame {
|
||||
|
||||
director.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
|
||||
|
||||
script.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
|
||||
script.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
scriptActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
authorsurname.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
|
||||
authorsurname.setText("Scenariusz:");
|
||||
|
||||
lyear.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
|
||||
lyear.setText("Rok:");
|
||||
|
||||
@ -124,12 +112,10 @@ public class MovieFieldPattern extends javax.swing.JFrame {
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
|
||||
.addComponent(lcategory, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(lyear, javax.swing.GroupLayout.DEFAULT_SIZE, 92, Short.MAX_VALUE)
|
||||
.addComponent(authorsurname, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addComponent(lyear, javax.swing.GroupLayout.DEFAULT_SIZE, 92, Short.MAX_VALUE))
|
||||
.addGap(17, 17, 17)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(year, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(script, javax.swing.GroupLayout.PREFERRED_SIZE, 220, 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))))
|
||||
.addContainerGap(21, Short.MAX_VALUE))
|
||||
@ -148,10 +134,6 @@ public class MovieFieldPattern extends javax.swing.JFrame {
|
||||
.addComponent(directorrname)
|
||||
.addComponent(director, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(authorsurname)
|
||||
.addComponent(script, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(lyear)
|
||||
.addComponent(year, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
@ -177,7 +159,8 @@ public class MovieFieldPattern extends javax.swing.JFrame {
|
||||
|
||||
private void SaveChangesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SaveChangesActionPerformed
|
||||
if (this.add) {
|
||||
JOptionPane.showMessageDialog(null, "DODAJ");
|
||||
Movie m = new Movie(0, movieTitle.getText(), director.getText(), Integer.parseInt(year.getText()), Category.getSelectedItem().toString() );
|
||||
m.insertToDB();
|
||||
} else if (this.edit) {
|
||||
JOptionPane.showMessageDialog(null, "EDYTUJ");
|
||||
} else if (this.delete) {
|
||||
@ -186,10 +169,6 @@ public class MovieFieldPattern extends javax.swing.JFrame {
|
||||
dispose();
|
||||
}//GEN-LAST:event_SaveChangesActionPerformed
|
||||
|
||||
private void scriptActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_scriptActionPerformed
|
||||
// TODO add your handling code here:
|
||||
}//GEN-LAST:event_scriptActionPerformed
|
||||
|
||||
private void yearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_yearActionPerformed
|
||||
// TODO add your handling code here:
|
||||
}//GEN-LAST:event_yearActionPerformed
|
||||
@ -235,14 +214,12 @@ 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.JLabel authorsurname;
|
||||
private javax.swing.JTextField director;
|
||||
private javax.swing.JLabel directorrname;
|
||||
private javax.swing.JLabel lcategory;
|
||||
private javax.swing.JLabel lyear;
|
||||
private javax.swing.JLabel mainlabel;
|
||||
private javax.swing.JTextField movieTitle;
|
||||
private javax.swing.JTextField script;
|
||||
private javax.swing.JTextField year;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user