Package edu.spbstu.hoteldb.panels

Source Code of edu.spbstu.hoteldb.panels.RoomSearchPanel

package edu.spbstu.hoteldb.panels;

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

import javafx.collections.FXCollections;
import javafx.geometry.Insets;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ChoiceBox;
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 edu.spbstu.hoteldb.handlers.NumFilter;
import edu.spbstu.hoteldb.handlers.SearchRoomEventHandler;
import edu.spbstu.hoteldb.interfaces.Panel;

public class RoomSearchPanel extends GridPane implements Panel {
  private Connection connect;

  @Override
  public void create(List<Object> args) {
    TextArea results = (TextArea) args.get(0);
   
    this.setHgap(10);
    this.setVgap(10);
    this.setPadding(new Insets(50, 0, 0, 0));
    Label lrooms = new Label("Room search");
    Label lpcount = new Label("People count: ");
    TextField tfpcount = new TextField();
    tfpcount.addEventHandler(KeyEvent.KEY_TYPED, new NumFilter());
    Label lcost = new Label("Cost: ");
    TextField tfcost = new TextField();
    tfcost.addEventHandler(KeyEvent.KEY_TYPED, new NumFilter());
    Label ldesc = new Label("Description");
    Label lbar = new Label("Bar");
    CheckBox chckbxdesc = new CheckBox();
    ChoiceBox<String> cbbar = new ChoiceBox<String>(
        FXCollections.observableArrayList("---", "yes", "no"));
    cbbar.setValue("---");
    Button sbtn = new Button("Search");
    sbtn.setOnAction(new SearchRoomEventHandler(connect, results, tfpcount,
        tfcost, chckbxdesc, cbbar));
    this.add(lrooms, 0, 1);
    this.add(lpcount, 0, 2);
    this.add(tfpcount, 1, 2);
    this.add(lcost, 0, 3);
    this.add(tfcost, 1, 3);
    this.add(ldesc, 0, 4);
    this.add(chckbxdesc, 1, 4);
    this.add(lbar, 0, 5);
    this.add(cbbar, 1, 5);
    this.add(sbtn, 0, 6);
  }
 
  @Override
  public void connect() throws ClassNotFoundException, SQLException {
    Class.forName("com.mysql.jdbc.Driver");
    connect = DriverManager
        .getConnection("jdbc:mysql://localhost/hotel_db?"
            + "user=hoteldb_client&password=");   
  }

  @Override
  public void close() throws SQLException {
    connect.close();
  }


}
TOP

Related Classes of edu.spbstu.hoteldb.panels.RoomSearchPanel

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.