Package edu.spbstu.hoteldb.handlers

Source Code of edu.spbstu.hoteldb.handlers.BookEventHandler

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();
    }
  }
}
TOP

Related Classes of edu.spbstu.hoteldb.handlers.BookEventHandler

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.