library/src/library/Movie.java

73 lines
1.8 KiB
Java

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package library;
import java.sql.SQLException;
import java.sql.Statement;
import javax.swing.JOptionPane;
/**
*
* @author Agnieszka
*/
public class Movie extends Item {
private String director;
private Database d = new Database();
Movie() {
//nothing to do there
}
Movie(int id, String n, String d, String y, String c) {
try {
this.setYear(Integer.parseInt(y));
} catch (NumberFormatException e) {
this.setYear(0);
}
this.setId(id);
this.setName(n);
this.director = d;
this.setCategory(c);
}
public static Object[][] insertRowToTable(Object[][] tab, int r, Movie m) {
tab[r][0] = m.getId();
tab[r][1] = m.getName();
tab[r][2] = m.getDirector();
tab[r][3] = m.getYear();
tab[r][4] = m.getCategory();
return tab;
}
@Override
public void insertToDB() throws SQLException {
try {
d.insertMovieQ(this);
} catch (SQLException ex) {
throw new SQLException("Error dodawania filmu");
}
}
@Override
public void delFromDB() throws SQLException {
d.deleteQ(this);
}
@Override
public void editInDB() throws SQLException {
d.updateQ(this);
}
public String getDirector() {
return this.director;
}
}
/*public void insertQuery(){
System.out.println("INSERT INTO books VALUES('NULL', '" +name + "', '" + authorName + "', '" + authorSurname + "', '"+ publishing + "', '"+ year + "', '"+ ISBN + "', '"+ category + "');");
}*/