Package edu.spbstu.hoteldb.admin.handler

Source Code of edu.spbstu.hoteldb.admin.handler.PersonnelSearchEventHandler

package edu.spbstu.hoteldb.admin.handler;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.LinkedList;
import java.util.List;

import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Node;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import edu.spbstu.hoteldb.interfaces.SQLQuery;
import edu.spbstu.hoteldb.sql.PersonnelSearchQuery;

public class PersonnelSearchEventHandler implements EventHandler<ActionEvent> {

  private final TextArea results;
  private final Connection connect;
  private final List<Node> args;
 
  public PersonnelSearchEventHandler(TextArea ta, Connection c, List<Node> arg) {
    results = ta;
    connect = c;
    args = arg;
  }
 
  @Override
  public void handle(ActionEvent arg0) {
    List<Object> arg = new LinkedList<Object>();
    arg.add(((TextField) args.get(0)).getText());
    arg.add(((TextField) args.get(1)).getText());
    try {
      SQLQuery query = new PersonnelSearchQuery(results, connect);
      query.prepareQuery(arg);
      query.doQuery();
      query.close();
    } catch (SQLException e) {
      results.appendText("invalid query\n");
      e.printStackTrace();
    }
  }

}
TOP

Related Classes of edu.spbstu.hoteldb.admin.handler.PersonnelSearchEventHandler

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.