package edu.spbstu.hoteldb.panels;
import java.sql.SQLException;
import java.util.List;
import javafx.geometry.Insets;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.VBox;
import edu.spbstu.hoteldb.handlers.BookEventHandler;
import edu.spbstu.hoteldb.handlers.NumFilter;
import edu.spbstu.hoteldb.interfaces.Panel;
public class ReceptionPanel extends VBox implements Panel {
private final RoomSearchPanel rsearch = new RoomSearchPanel();
@Override
public void create(List<Object> args) {
this.setSpacing(10);
this.setPadding(new Insets(10, 10, 10, 10));
TextArea results = (TextArea)args.get(0);
rsearch.create(args);
GridPane rbook = new GridPane();
rbook.setHgap(10);
rbook.setVgap(10);
rbook.setPadding(new Insets(50, 0, 0, 0));
Label lbook = new Label("Booking");
Label lclid = new Label("Client id: ");
TextField tfid = new TextField();
tfid.addEventHandler(KeyEvent.KEY_TYPED, new NumFilter());
Label lroomnum = new Label("Room number: ");
TextField tfroomnum = new TextField();
tfroomnum.addEventHandler(KeyEvent.KEY_TYPED, new NumFilter());
Button btnbook = new Button("Book!");
btnbook.setDisable(true);
btnbook.setOnAction(new BookEventHandler(results, tfid, tfroomnum));
rbook.add(lbook, 0, 0);
rbook.add(lclid, 0, 1);
rbook.add(tfid, 1, 1);
rbook.add(lroomnum, 0, 2);
rbook.add(tfroomnum, 1, 2);
rbook.add(btnbook, 0, 3);
this.getChildren().addAll(rsearch, rbook);
}
@Override
public void connect() throws ClassNotFoundException, SQLException {
rsearch.connect();
}
@Override
public void close() throws SQLException {
rsearch.close();
}
}