Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package application;
- import javafx.scene.Scene;
- import javafx.stage.Stage;
- import javafx.scene.text.Font;
- import javafx.scene.text.Text;
- import javafx.scene.control.Alert;
- import javafx.scene.control.Button;
- import javafx.scene.control.ButtonType;
- import javafx.scene.control.ChoiceBox;
- import javafx.scene.control.TextField;
- import javafx.scene.image.Image;
- import javafx.scene.image.ImageView;
- import javafx.scene.control.Alert.AlertType;
- import javafx.scene.Group;
- import javafx.scene.Node;
- import javafx.scene.layout.GridPane;
- import java.io.FileInputStream;
- import java.io.FileNotFoundException;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import java.time.LocalDate;
- import java.time.LocalDateTime;
- import java.time.format.DateTimeFormatter;
- import javafx.event.ActionEvent;
- import javafx.event.EventHandler;
- import javafx.geometry.Insets;
- import javafx.geometry.Pos;
- public class HomePage extends Stage{
- public HomePage() {
- Stage current = this;
- Connection con;
- Button addPatient = new Button("Add Patient");
- addPatient.setMinSize(100, 50);
- Button search = new Button("Search");
- search.setMinSize(100, 50);
- Button missing = new Button("Missing Reports");
- missing.setMinSize(100, 50);
- Button upComing = new Button("Up Coming Sessions");
- upComing.setMinSize(100, 50);
- Button provider = new Button("Provider");
- provider.setMinSize(100, 50);
- //Styling nodes
- addPatient.setStyle("-fx-background-color: pink; -fx-text-fill: black;");
- search.setStyle("-fx-background-color: pink; -fx-text-fill: black;");
- missing.setStyle("-fx-background-color: pink; -fx-text-fill: black;");
- upComing.setStyle("-fx-background-color: pink; -fx-text-fill: black;");
- provider.setStyle("-fx-background-color: pink; -fx-text-fill: black;");
- //Creating a Grid Pane
- GridPane gridPane = new GridPane();
- //Setting size for the pane
- gridPane.setMinSize(800, 600);
- //Setting the padding
- gridPane.setPadding(new Insets(10, 10, 10, 10));
- //Setting the vertical and horizontal gaps between the columns
- gridPane.setVgap(30);
- gridPane.setHgap(30);
- //Setting the Grid alignment
- // gridPane.setAlignment(Pos.CENTER);
- //Arranging all the nodes in the grid
- gridPane.add(search,1,1);
- gridPane.add(upComing, 2, 1);
- gridPane.add(addPatient, 3,1 );
- gridPane.add(missing,5 ,1 );
- gridPane.add(provider,4 ,1 );
- gridPane.setStyle("-fx-background-image: url(\"33682672_1485248468245623_4434124833390854144_n.jpg\"); -fx-background-color:white;");
- upComing.setOnAction(new EventHandler<ActionEvent>() {
- @Override
- public void handle(ActionEvent event) {
- LocalDate date = LocalDate.now();
- Sessions sessions = new Sessions(current, date);
- sessions.show();
- current.close();
- }
- });
- addPatient.setOnAction(new EventHandler<ActionEvent>() {
- @Override
- public void handle(ActionEvent event) {
- Connection conn = null;
- try {
- conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/company?useSSL=false","root", "ahmed666");
- String select="select * from help";
- PreparedStatement selectStmt = conn.prepareStatement(select);
- ResultSet res=selectStmt.executeQuery();
- String ID = null;
- while(res.next()) {
- ID=res.getString("ID");
- }
- if(ID!=null) {
- String delete="delete from help where ID = ?";
- PreparedStatement deleteStmt = conn.prepareStatement(delete);
- deleteStmt.setString(1, ID);
- deleteStmt.executeUpdate();
- }
- } catch (SQLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- Add add = new Add(current);
- add.show();
- current.close();
- }
- });
- search.setOnAction(new EventHandler<ActionEvent>() {
- @Override
- public void handle(ActionEvent event) {
- Search searchPage = new Search(current,null,null);
- searchPage.show();
- current.close();
- }
- });
- missing.setOnAction(new EventHandler<ActionEvent>() {
- @Override
- public void handle(ActionEvent event) {
- MissingReports missingPage = new MissingReports(current);
- missingPage.show();
- current.close();
- }
- });
- provider.setOnAction(new EventHandler<ActionEvent>() {
- @Override
- public void handle(ActionEvent event) {
- Provider provider = new Provider(current);
- provider.show();
- current.close();
- }
- });
- Scene scene = new Scene(gridPane);
- //scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
- setScene(scene);
- setTitle(" رؤية");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement