Skip to content

Commit

Permalink
Backend Update 34
Browse files Browse the repository at this point in the history
  • Loading branch information
gayanukabulegoda committed Nov 27, 2023
1 parent 8accfe7 commit 563a654
Show file tree
Hide file tree
Showing 31 changed files with 400 additions and 87 deletions.
17 changes: 17 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,28 @@
<artifactId>activation</artifactId>
<version>1.1.1</version>
</dependency>
<!-- Dependency for Mail(Zxing) -->
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<version>1.6.2</version>
</dependency>
<!-- Dependencies for QR(Zxing) -->
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>core</artifactId>
<version>3.4.1</version>
</dependency>
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>javase</artifactId>
<version>3.4.1</version>
</dependency>
<dependency>
<groupId>com.github.sarxos</groupId>
<artifactId>webcam-capture</artifactId>
<version>0.3.12</version>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ void txtSearchOnAction(ActionEvent event) throws IOException, SQLException {

for (int i = 0; i < allCustomerId.size(); i++) {
if (txtSearch.getText().equals(customerModel.getCustomerContactNo(allCustomerId.get(i)))) {
CustomerViewPopUpFormController.customerId = customerModel.getAllCustomerId().get(i);
CustomerViewPopUpFormController.customerId = allCustomerId.get(i);
Navigation.imgPopUpBackground("customerViewPopUpForm.fxml");
txtSearch.clear();
return;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@ void btnCustomerOrdersOnAction(ActionEvent event) {

}

@FXML
void btnRefreshTableOnAction(ActionEvent event) {
try {
allCustomerOrderId();
} catch (SQLException e) {
throw new RuntimeException(e);
}
}

@FXML
void btnSupplierOrdersOnAction(ActionEvent event) throws IOException {
Navigation.switchPaging(GlobalFormController.getInstance().pagingPane, "supplierOrderManageForm.fxml");
Expand All @@ -69,28 +78,55 @@ void btnSupplierOrdersOnAction(ActionEvent event) throws IOException {
@FXML
void txtSearchOnAction(ActionEvent event) throws IOException, SQLException {

if (!validateId()) {
new Alert(Alert.AlertType.ERROR, "Invalid Id! Id Should be in the format 'CO-01' !!").show();
if (!(validateId() | validateContactNo())) {
new Alert(Alert.AlertType.ERROR, "Invalid Contact No Or Order ID!!").show();
return;
}

CustomerOrderModel customerOrderModel = new CustomerOrderModel();
CustomerModel customerModel = new CustomerModel();
ArrayList<String> allCustomerOrderId = customerOrderModel.getAllCustomerOrderId();

for (int i = 0; i < allCustomerOrderId.size(); i++) {
if (txtSearch.getText().equals(allCustomerOrderId.get(i))) {
CustomerOrderViewPopUpFormController.customerOrderId = txtSearch.getText();
Navigation.imgPopUpBackground("customerOrderViewPopUpForm.fxml");
txtSearch.clear();
return;
}

ArrayList<String> customerIds = customerOrderModel.getCustomerId(allCustomerOrderId.get(i));

for (int j = 0; j < customerIds.size(); j++) {
if (txtSearch.getText().equals(customerModel.getCustomerContactNo(customerIds.get(j)))) {
allSelectedCustomerOrderId(customerIds.get(j));
txtSearch.clear();
return;
}
}
}
new Alert(Alert.AlertType.ERROR, "Invalid Id! Id Should be in the format 'CO-01' !!").show();
new Alert(Alert.AlertType.ERROR, "Invalid Contact No Or Order ID!!").show();
}

private boolean validateId() {
return Pattern.matches("(CO-0)\\d+", txtSearch.getText());
}

private boolean validateContactNo() {
return Pattern.matches("[0-9]{10}", txtSearch.getText());
}

public void allSelectedCustomerOrderId(String id) throws SQLException {

vBoxCustomerOrders.getChildren().clear();
CustomerOrderModel customerOrderModel = new CustomerOrderModel();
ArrayList<String> list = customerOrderModel.getSelectedAllCustomerOrderId(id);

for (int i = 0; i < list.size(); i++) {
loadDataTable(list.get(i));
}
}

public void allCustomerOrderId() throws SQLException {

vBoxCustomerOrders.getChildren().clear();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package lk.grb.ceylonPottersPalette.controller;

import com.google.zxing.WriterException;
import com.jfoenix.controls.JFXButton;
import com.jfoenix.controls.JFXComboBox;
import javafx.event.ActionEvent;
Expand All @@ -12,6 +13,7 @@
import javafx.scene.layout.Pane;
import lk.grb.ceylonPottersPalette.dto.EmployeeDto;
import lk.grb.ceylonPottersPalette.model.EmployeeModel;
import lk.grb.ceylonPottersPalette.qr.QrGenerator;
import lk.grb.ceylonPottersPalette.util.DateTimeUtil;
import lk.grb.ceylonPottersPalette.util.Navigation;
import lk.grb.ceylonPottersPalette.util.NewId;
Expand Down Expand Up @@ -134,9 +136,9 @@ public void setDataInComboBox() {
}

@FXML
void btnAddOnAction(ActionEvent event) throws SQLException {
void btnAddOnAction(ActionEvent event) throws SQLException, IOException, WriterException {

if(validateEmployee()) {
if(true) {
EmployeeDto employeeDto = new EmployeeDto();

ArrayList<String> list = employeeModel.getAllEmployeeId();
Expand All @@ -158,6 +160,7 @@ void btnAddOnAction(ActionEvent event) throws SQLException {
boolean save = employeeModel.save(employeeDto);

if (save) {
QrGenerator.generateQr(employeeDto.getEmployee_Id());
Navigation.closePane();
EmployeeManageFormController.getInstance().allEmployeeId();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
import javafx.scene.control.TextField;
import javafx.scene.layout.Pane;
import javafx.scene.layout.VBox;
import lk.grb.ceylonPottersPalette.model.CustomerOrderModel;
import lk.grb.ceylonPottersPalette.model.EmployeeAttendanceModel;
import lk.grb.ceylonPottersPalette.model.EmployeeModel;
import lk.grb.ceylonPottersPalette.model.SupplierModel;
import lk.grb.ceylonPottersPalette.model.EmployeeSalaryModel;
import lk.grb.ceylonPottersPalette.qr.QrReader;
import lk.grb.ceylonPottersPalette.util.Navigation;

import java.io.IOException;
Expand Down Expand Up @@ -64,29 +64,38 @@ void btnEmployeeAttendanceOnAction(ActionEvent event) {

}

@FXML
void btnRefreshTableOnAction(ActionEvent event) {
try {
allAttendanceId();
} catch (SQLException e) {
throw new RuntimeException(e);
}
}

@FXML
void txtSearchOnAction(ActionEvent event) throws IOException, SQLException {

if (!validateId()) {
new Alert(Alert.AlertType.ERROR, "Invalid Id! Id Should be in the format 'E-001' !!").show();
new Alert(Alert.AlertType.ERROR, "Invalid Contact No!!").show();
return;
}

EmployeeModel employeeModel = new EmployeeModel();
ArrayList<String> allEmployeeId = employeeModel.getAllEmployeeId();

for (int i = 0; i < allEmployeeId.size(); i++) {
if (txtSearch.getText().equals(allEmployeeId.get(i))) {
EmployeeViewPopUpFormController.employeeId = txtSearch.getText();
Navigation.imgPopUpBackground("employeeViewPopUpForm.fxml");
if (txtSearch.getText().equals(employeeModel.getEmployeeContactNo(allEmployeeId.get(i)))) {
allSelectedEmployeeSalaryId(allEmployeeId.get(i));
txtSearch.clear();
return;
}
}
new Alert(Alert.AlertType.ERROR, "Invalid Id! Id Should be in the format 'E-001' !!").show();
new Alert(Alert.AlertType.ERROR, "Invalid Contact No!!").show();
}

private boolean validateId() {
return Pattern.matches("(E-00)\\d{1,}", txtSearch.getText());
return Pattern.matches("[0-9]{10}", txtSearch.getText());
}

@FXML
Expand All @@ -104,6 +113,23 @@ void btnEnterIdOnAction(ActionEvent event) throws IOException {
Navigation.imgPopUpBackground("employeeAttendanceMarkPopUp.fxml");
}

@FXML
void btnQrOnAction(ActionEvent event) throws SQLException {
String id = QrReader.readQr();
EmployeeAttendanceMarkPopUpController.markAttendanceOViaQr(id);
}

public void allSelectedEmployeeSalaryId(String id) throws SQLException {

vBoxEmployeeAttendance.getChildren().clear();
EmployeeAttendanceModel employeeAttendanceModel = new EmployeeAttendanceModel();
ArrayList<String> list = employeeAttendanceModel.getSelectedAllAttendanceId(id);

for (int i = 0; i < list.size(); i++) {
loadDataTable(list.get(i));
}
}

public void allAttendanceId() throws SQLException {

vBoxEmployeeAttendance.getChildren().clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.ResourceBundle;
import java.util.regex.Pattern;

public class EmployeeAttendanceMarkPopUpController implements Initializable {

Expand Down Expand Up @@ -53,7 +52,7 @@ public class EmployeeAttendanceMarkPopUpController implements Initializable {
private Pane markAttendaceBtnPane;

EmployeeModel employeeModel = new EmployeeModel();
EmployeeAttendanceModel employeeAttendanceModel = new EmployeeAttendanceModel();
public static EmployeeAttendanceModel employeeAttendanceModel = new EmployeeAttendanceModel();

@FXML
void btnCloseIconOnAction(ActionEvent event) {
Expand Down Expand Up @@ -82,6 +81,25 @@ void btnMarkAttendanceOnAction(ActionEvent event) throws SQLException {
}
}

public static void markAttendanceOViaQr(String id) throws SQLException {

EmployeeAttendanceDto employeeAttendanceDto = new EmployeeAttendanceDto();

ArrayList<String> list = employeeAttendanceModel.getAllAttendanceId();

employeeAttendanceDto.setAttendance_Id(NewId.newId(list, NewId.GetType.ATTENDANCE_ID));
employeeAttendanceDto.setEmployee_Id(id);
employeeAttendanceDto.setDate(DateTimeUtil.dateNow());
employeeAttendanceDto.setTime(DateTimeUtil.timeNow());

boolean save = employeeAttendanceModel.save(employeeAttendanceDto);

if (save) {
//Navigation.closePane();
EmployeeAttendanceFormController.getInstance().allAttendanceId();
}
}

private boolean validateEmployeeAttendance() {

if ((cmbEmployeeId.getSelectionModel().getSelectedItem()) == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,25 +82,26 @@ void btnEmployeeSalaryOnAction(ActionEvent event) throws IOException {
void txtSearchOnAction(ActionEvent event) throws IOException, SQLException {

if (!validateId()) {
new Alert(Alert.AlertType.ERROR, "Invalid Id! Id Should be in the format 'E-001' !!").show();
new Alert(Alert.AlertType.ERROR, "Invalid Contact No!!").show();
return;
}

EmployeeModel employeeModel = new EmployeeModel();
ArrayList<String> allEmployeeId = employeeModel.getAllEmployeeId();

for (int i = 0; i < allEmployeeId.size(); i++) {
if (txtSearch.getText().equals(allEmployeeId.get(i))) {
EmployeeViewPopUpFormController.employeeId = txtSearch.getText();
if (txtSearch.getText().equals(employeeModel.getEmployeeContactNo(allEmployeeId.get(i)))) {
EmployeeViewPopUpFormController.employeeId = allEmployeeId.get(i);
Navigation.imgPopUpBackground("employeeViewPopUpForm.fxml");
txtSearch.clear();
return;
}
}
new Alert(Alert.AlertType.ERROR, "Invalid Id! Id Should be in the format 'E-001' !!").show();
new Alert(Alert.AlertType.ERROR, "Invalid Contact No!!").show();
}

private boolean validateId() {
return Pattern.matches("(E-00)\\d{1,}", txtSearch.getText());
return Pattern.matches("[0-9]{10}", txtSearch.getText());
}

public void allEmployeeId() throws SQLException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,30 +78,39 @@ void btnEmployeeSalaryOnAction(ActionEvent event) {

}

@FXML
void btnRefreshTableOnAction(ActionEvent event) {
try {
allSalaryId();
} catch (SQLException e) {
throw new RuntimeException(e);
}
}

@FXML
void txtSearchOnAction(ActionEvent event) throws IOException, SQLException {

if (!validateId()) {
new Alert(Alert.AlertType.ERROR, "Invalid Id! Id Should be in the format 'E-001' !!").show();
new Alert(Alert.AlertType.ERROR, "Invalid Contact No!!").show();
return;
}

EmployeeSalaryModel employeeSalaryModel = new EmployeeSalaryModel();
EmployeeModel employeeModel = new EmployeeModel();
ArrayList<String> allEmployeeId = employeeSalaryModel.getAllEmployeeId();

for (int i = 0; i < allEmployeeId.size(); i++) {
if (txtSearch.getText().equals(allEmployeeId.get(i))) {
String salaryId = employeeSalaryModel.getSalaryId(txtSearch.getText());
EmployeeSalaryViewPopUpFormController.salaryId = salaryId;
Navigation.imgPopUpBackground("employeeSalaryViewPopUpForm.fxml");
if (txtSearch.getText().equals(employeeModel.getEmployeeContactNo(allEmployeeId.get(i)))) {
allSelectedEmployeeSalaryId(allEmployeeId.get(i));
txtSearch.clear();
return;
}
}
new Alert(Alert.AlertType.ERROR, "Invalid Id! Id Should be in the format 'E-001' !!").show();
new Alert(Alert.AlertType.ERROR, "Invalid Contact No!!").show();
}

private boolean validateId() {
return Pattern.matches("(E-00)\\d+", txtSearch.getText());
return Pattern.matches("[0-9]{10}", txtSearch.getText());
}

public void allSalaryId() throws SQLException {
Expand All @@ -115,6 +124,17 @@ public void allSalaryId() throws SQLException {
}
}

public void allSelectedEmployeeSalaryId(String id) throws SQLException {

vBoxEmployeeSalary.getChildren().clear();
EmployeeSalaryModel employeeSalaryModel = new EmployeeSalaryModel();
ArrayList<String> list = employeeSalaryModel.getSelectedAllSalaryId(id);

for (int i = 0; i < list.size(); i++) {
loadDataTable(list.get(i));
}
}

private void loadDataTable(String id) {
try {
FXMLLoader loader = new FXMLLoader(EmployeeSalaryFormController.class.getResource("/view/employeeSalaryBarForm.fxml"));
Expand Down
Loading

0 comments on commit 563a654

Please sign in to comment.