package edu.spbstu.hoteldb.handlers;
import java.sql.SQLException;
import java.util.LinkedList;
import java.util.List;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import edu.spbstu.hoteldb.interfaces.SQLQuery;
import edu.spbstu.hoteldb.sql.BookUpdate;
public class BookEventHandler implements EventHandler<ActionEvent> {
TextField textField;
TextArea textArea;
public BookEventHandler(TextArea ta, TextField tf, TextField rn) {
textField = tf;
}
@Override
public void handle(ActionEvent event) {
try {
Integer id = Integer.parseInt(textField.getText());
Integer roomnum = Integer.parseInt(textField.getText());
SQLQuery bu = new BookUpdate(null, textArea);
List<Object> args = new LinkedList<Object>();
args.add(id); args.add(roomnum);
bu.prepareQuery(args);
bu.doQuery();
} catch (NumberFormatException e) {
textArea.appendText("invalid room number");
} catch (SQLException e) {
e.printStackTrace();
}
}
}