Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
techgirldiaries authored Sep 5, 2024
1 parent e3c744a commit b3e3b78
Show file tree
Hide file tree
Showing 61 changed files with 2,874 additions and 0 deletions.
19 changes: 19 additions & 0 deletions nb-configuration.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<project-shared-configuration>
<!--
This file contains additional configuration written by modules in the NetBeans IDE.
The configuration is intended to be shared among all the users of project and
therefore it is assumed to be part of version control checkout.
Without this configuration present, some functionality in the IDE may be limited or fail altogether.
-->
<properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
<!--
Properties that influence various parts of the IDE, especially code formatting and the like.
You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
That way multiple projects can share the same settings (useful for formatting rules for example).
Any value defined here will override the pom.xml file value but is only applicable to the current project.
-->
<netbeans.compile.on.save>none</netbeans.compile.on.save>
<netbeans.hint.jdkPlatform>FXJDK_22</netbeans.hint.jdkPlatform>
</properties>
</project-shared-configuration>
40 changes: 40 additions & 0 deletions nbactions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<actions>
<action>
<actionName>run</actionName>
<packagings>
<packaging>jar</packaging>
</packagings>
<goals>
<goal>clean</goal>
<goal>javafx:run</goal>
</goals>
</action>
<action>
<actionName>debug</actionName>
<goals>
<goal>clean</goal>
<goal>javafx:run@ide-debug</goal>
</goals>
<properties>
<jpda.listen>true</jpda.listen>
</properties>
</action>
<action>
<actionName>profile</actionName>
<goals>
<goal>clean</goal>
<goal>javafx:run@ide-profile</goal>
</goals>
</action>
<action>
<actionName>CUSTOM-jlink</actionName>
<displayName>jlink</displayName>
<goals>
<goal>clean</goal>
<!-- compile not needed with javafx-maven-plugin v0.0.5 -->
<goal>compile</goal>
<goal>javafx:jlink</goal>
</goals>
</action>
</actions>
108 changes: 108 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany</groupId>
<artifactId>App4</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.36.0.1</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>22</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>22</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<archive>
<manifest>
<mainClass>com.mycompany.app4.Main</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>11</release>
</configuration>
</plugin>
<plugin>
<groupId>com.gluonhq</groupId>
<artifactId>gluonfx-maven-plugin</artifactId>
<version>1.0.22</version>
<configuration>
<mainClass>com.mycompany.app4.Main</mainClass>
</configuration>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.1</version>
<configuration>
<mainClass>com.mycompany.app4.Main</mainClass>
</configuration>
<executions>
<execution>
<!-- Default configuration for running -->
<!-- Usage: mvn clean javafx:run -->
<id>default-cli</id>
</execution>
<execution>
<!-- Configuration for manual attach debugging -->
<!-- Usage: mvn clean javafx:run@debug -->
<id>debug</id>
<configuration>
<options>
<option>-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=localhost:8000</option>
</options>
</configuration>
</execution>
<execution>
<!-- Configuration for automatic IDE debugging -->
<id>ide-debug</id>
<configuration>
<options>
<option>-agentlib:jdwp=transport=dt_socket,server=n,address=${jpda.address}</option>
</options>
</configuration>
</execution>
<execution>
<!-- Configuration for automatic IDE profiling -->
<id>ide-profile</id>
<configuration>
<options>
<option>${profiler.jvmargs.arg1}</option>
<option>${profiler.jvmargs.arg2}</option>
<option>${profiler.jvmargs.arg3}</option>
<option>${profiler.jvmargs.arg4}</option>
<option>${profiler.jvmargs.arg5}</option>
</options>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
121 changes: 121 additions & 0 deletions src/main/java/com/mycompany/app4/AddServiceController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/javafx/FXMLController.java to edit this template
*/
package com.mycompany.app4;

import java.net.URL;
import java.sql.SQLException;
import java.util.ResourceBundle;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Alert;
import javafx.scene.control.Button;
import javafx.scene.control.TextField;
import javafx.stage.Stage;

/**
* FXML Controller class
*
* @author HP
*/
public class AddServiceController implements Initializable {

@FXML
private Button cancelButton;

@FXML
private TextField serviceNameField;

@FXML
private TextField serviceDescriptionField;

@FXML
private TextField estimatedDurationField;

@FXML
private TextField costField;

private ServiceDAO serviceDAO; // Inject ServiceDAO dependency




// Setter method for ServiceDAO
public AddServiceController () throws SQLException {
// Initialize customerDAO object and authentication object.
try{
this.serviceDAO = new ServiceDAO();
} catch (SQLException e) {
// If an exception occurs during initialization (e.g., database connectivity failure)
// Display an error message to the user
displayErrorMessage("Database Connection Error", "Failed to connect to the database. Please check your database configuration.");
e.printStackTrace();
}
}

// Method to display an error message
private void displayErrorMessage(String title, String message) {
Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle(title);
alert.setHeaderText(null);
alert.setContentText(message);
alert.showAndWait();
}


@FXML
private void cancelButtonDo() {
// Close the current window
Stage stage = (Stage) cancelButton.getScene().getWindow();
stage.close();
}


/**
* Initializes the controller class.
* @param url
* @param rb
*/
@Override
public void initialize(URL url, ResourceBundle rb) {
// TODO
}

@FXML
private void addService() {
try {
int estimated_duration = Integer.parseInt(estimatedDurationField.getText());
double cost = Double.parseDouble(costField.getText());

Service newService = new Service(serviceNameField.getText(), serviceDescriptionField.getText(), estimated_duration, cost);

int insertedServiceId = serviceDAO.insertService(newService);

if (insertedServiceId != -1) {
Alert alert = new Alert(Alert.AlertType.INFORMATION);
alert.setTitle("Service Added");
alert.setHeaderText(null);
alert.setContentText("The service has been added successfully!");
alert.showAndWait();

serviceNameField.clear();
serviceDescriptionField.clear();
estimatedDurationField.clear();
costField.clear();
} else {
System.err.println("Error: serviceDAO is not initialized.");
}
} catch (NumberFormatException e) {
// Handle the case when the estimated duration or cost is not a valid number
Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setContentText("Cost and duration must be numeric values.");
alert.showAndWait();
}

}


}


38 changes: 38 additions & 0 deletions src/main/java/com/mycompany/app4/App.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.mycompany.app4;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

import java.io.IOException;

/**
* JavaFX App
*/
public class App extends Application {

private static Scene scene;

@Override
public void start(Stage stage) throws IOException {
scene = new Scene(loadFXML("primary"), 640, 480);
stage.setScene(scene);
stage.show();
}

static void setRoot(String fxml) throws IOException {
scene.setRoot(loadFXML(fxml));
}

private static Parent loadFXML(String fxml) throws IOException {
FXMLLoader fxmlLoader = new FXMLLoader(App.class.getResource(fxml + ".fxml"));
return fxmlLoader.load();
}

public static void main(String[] args) {
launch();
}

}
Loading

0 comments on commit b3e3b78

Please sign in to comment.