Skip to content

Commit

Permalink
feat: Crafting Master Form Features & Docker Compose Configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
belajarqywok committed May 20, 2024
1 parent 33662dc commit 27e7663
Show file tree
Hide file tree
Showing 51 changed files with 2,470 additions and 452 deletions.
35 changes: 35 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
version: '3.8'

services:
mariadb:
image: mariadb:10.5
container_name: viz_prog_assignment_db
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: iron_sales_db
MYSQL_USER: root
MYSQL_PASSWORD: root
volumes:
- mariadb_volume:/var/lib/mysql
ports:
- "3306:3306"
networks:
- mariadb_network

migration:
image: mariadb:10.5
container_name: migration
depends_on:
- mariadb
volumes:
- ./migrations/migration.sh:/docker-entrypoint-initdb.d/migration.sh
entrypoint: /docker-entrypoint-initdb.d/migration.sh
networks:
- mariadb_network

volumes:
mariadb_volume:

networks:
mariadb_network:
driver: bridge
28 changes: 15 additions & 13 deletions migrations/mysql.schemas.sql
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ USE iron_sales_db;


/*
Create Admin Auth Table
Table: Admin Auth Table
design ref: Login
default => user: admin; pass: user246
*/
Expand Down Expand Up @@ -49,7 +49,7 @@ DESCRIBE admin_auth; SELECT " ";


/*
Create Category Table
Table: Category Table
design ref: Kategori
*/
CREATE TABLE categories (
Expand All @@ -66,13 +66,16 @@ CREATE INDEX idx_category_brand
CREATE INDEX idx_category_type
ON categories (category_type);

CREATE INDEX idx_category_desc
ON categories (category_desc);

DESCRIBE categories; SELECT " ";




/*
Create Supplier Table
Table: Supplier Table
design ref: Supplier
*/
CREATE TABLE suppliers (
Expand All @@ -98,7 +101,7 @@ DESCRIBE suppliers; SELECT " ";


/*
Create Customer Table
Table: Customer Table
design ref: Pelanggan
*/
CREATE TABLE customers (
Expand All @@ -124,7 +127,7 @@ DESCRIBE customers; SELECT " ";


/*
Create Purchasing Table
Table: Purchasing Table
design ref: Pembelian
*/
CREATE TABLE purchasings (
Expand Down Expand Up @@ -161,7 +164,7 @@ DESCRIBE purchasings; SELECT " ";


/*
Create Reception Table
Table: Reception Table
design ref: Penerimaan
*/
CREATE TABLE receptions (
Expand Down Expand Up @@ -189,20 +192,19 @@ DESCRIBE receptions; SELECT " ";


/*
Create Stock Table
Table: Stock Table
design ref: Stok
*/
CREATE TABLE stocks (
stock_id VARCHAR(16) NOT NULL PRIMARY KEY,
category_id VARCHAR(16) NOT NULL,

stock_sell_price BIGINT NOT NULL,
stock_purchace_price BIGINT NOT NULL,
stock_purchase_price BIGINT NOT NULL,

stock_size VARCHAR(16) NOT NULL,
stock_size VARCHAR(16) NOT NULL,
stock_amount INT NOT NULL,
stock_unit VARCHAR(16) NOT NULL,
stock_image VARCHAR(64) NOT NULL,

FOREIGN KEY (category_id)
REFERENCES categories(category_id)
Expand All @@ -216,8 +218,8 @@ CREATE INDEX idx_stock_size
CREATE INDEX idx_stock_sell_price
ON stocks (stock_sell_price);

CREATE INDEX idx_stock_purchace_price
ON stocks (stock_purchace_price);
CREATE INDEX idx_stock_purchase_price
ON stocks (stock_purchase_price);

CREATE INDEX idx_stock_amount
ON stocks (stock_amount);
Expand All @@ -230,7 +232,7 @@ DESCRIBE stocks; SELECT " ";


/*
Create Sales Table
Table: Sales Table
design ref: Penjualan
*/
CREATE TABLE sales (
Expand Down
15 changes: 7 additions & 8 deletions migrations/mysql.seeders.sql
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,17 @@ INSERT INTO stocks (
category_id,

stock_sell_price,
stock_purchace_price,
stock_purchase_price,

stock_size,
stock_amount,
stock_unit,
stock_image
stock_unit
) VALUES
("STK-1", "CT-1", 150000, 120000, "10 mm", 50, "batang", "image1.jpg"),
("STK-2", "CT-1", 160000, 130000, "10 mm", 40, "batang", "image2.jpg"),
("STK-3", "CT-1", 170000, 140000, "10 mm", 30, "batang", "image3.jpg"),
("STK-4", "CT-1", 180000, 150000, "10 mm", 20, "batang", "image4.jpg"),
("STK-5", "CT-1", 190000, 160000, "10 mm", 15, "batang", "image5.jpg");
("STK-1", "CT-1", 150000, 120000, "10 mm", 50, "batang"),
("STK-2", "CT-1", 160000, 130000, "10 mm", 40, "batang"),
("STK-3", "CT-1", 170000, 140000, "10 mm", 30, "batang"),
("STK-4", "CT-1", 180000, 150000, "10 mm", 20, "batang"),
("STK-5", "CT-1", 190000, 160000, "10 mm", 15, "batang");

-- Insert Sales Datas
INSERT INTO sales (
Expand Down
1 change: 0 additions & 1 deletion pom.bat

This file was deleted.

Empty file removed poms/alfariqy/pom.xml
Empty file.
Empty file removed poms/rionggo/pom.xml
Empty file.
212 changes: 212 additions & 0 deletions src/main/java/com/lestarieragemilang/Category.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
package com.lestarieragemilang;

import java.util.List;

import javafx.collections.FXCollections;
import javafx.collections.ObservableList;

import javafx.fxml.FXML;
import javafx.scene.control.Label;

import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.BorderPane;

import javafx.scene.control.Alert;
import javafx.scene.control.ButtonType;
import javafx.scene.control.TextField;
import javafx.scene.control.Button;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;

import javafx.event.EventHandler;
import javafx.scene.input.MouseEvent;

import com.lestarieragemilang.Utilities.Redirect;
import com.lestarieragemilang.Utilities.CacheService;

import com.lestarieragemilang.Entities.CategoryEntity;
import com.lestarieragemilang.Repositories.CategoryRepositories;


/**
* Category Handler
*/
public class Category extends CategoryRepositories {

@FXML
private TableView<CategoryEntity> categoriesTable;

@FXML
private TableColumn<CategoryEntity, String> categoryId;

@FXML
private TableColumn<CategoryEntity, String> categoryBrand;

@FXML
private TableColumn<CategoryEntity, String> categoryType;

@FXML
private TableColumn<CategoryEntity, String> categoryDescription;


@FXML
private AnchorPane anchorPane;

@FXML
private Label featureLabel;

@FXML
private TextField searchTextField;

@FXML
private Button editCategory;

@FXML
private Button addCategory;

@FXML
private Button deleteCategory;


@FXML
private BorderPane bp;

private ObservableList<CategoryEntity> data;


@FXML
void searchCategoryAction(MouseEvent event) {
addCategory.setVisible(true);
editCategory.setVisible(false);
deleteCategory.setVisible(false);

CacheService.clear();

data = FXCollections.observableArrayList();

List<Object[]> searchCategories = this
.searchCategoriesRepository(searchTextField.getText());

for (Object[] rowData : searchCategories) {
CategoryEntity entity = new CategoryEntity();

entity.setCategoryId((String) rowData[0]);
entity.setCategoryBrand((String) rowData[1]);
entity.setCategoryType((String) rowData[2]);
entity.setCategoryDescription((String) rowData[3]);

data.add(entity);
categoriesTable.setItems(data);
}
}


@FXML
void addCategoryAction (MouseEvent event) {
Redirect.page("categoryForm", anchorPane, getClass());
}


@FXML
void editCategoryAction (MouseEvent event) {
Redirect.page("categoryForm", anchorPane, getClass());
}


@FXML
void deleteCategoryAction (MouseEvent event) {
Alert confirmationDialog = new Alert(Alert.AlertType.CONFIRMATION);
confirmationDialog.getDialogPane().setPrefSize(450, 250);

confirmationDialog.setTitle("Konfirmasi");
confirmationDialog.setHeaderText("hapus kategori");
confirmationDialog.setContentText("Apakah anda yakin ?.");

confirmationDialog.getButtonTypes().setAll(ButtonType.YES, ButtonType.NO);

confirmationDialog.showAndWait().ifPresent(buttonType -> {
if (buttonType == ButtonType.YES) {
deleteCategoryRepository((String) CacheService.get("categoryId"));
Redirect.page("category", anchorPane, getClass());
}
});
}


private void connectAndReadFromDatabase() {
data = FXCollections.observableArrayList();

List<Object[]> getCategories = this
.getCategoriesRepository();

for (Object[] rowData : getCategories) {
CategoryEntity entity = new CategoryEntity();

entity.setCategoryId((String) rowData[0]);
entity.setCategoryBrand((String) rowData[1]);
entity.setCategoryType((String) rowData[2]);
entity.setCategoryDescription((String) rowData[3]);

data.add(entity);
}
}


private void clickHandler () {
EventHandler<MouseEvent> handler = new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
addCategory.setVisible(true);
editCategory.setVisible(false);
deleteCategory.setVisible(false);

CacheService.clear();
}
};

anchorPane.setOnMouseClicked(handler);
featureLabel.setOnMouseClicked(handler);
searchTextField.setOnMouseClicked(handler);
}


@FXML
public void initialize() {
categoryId.setCellValueFactory(
new PropertyValueFactory<CategoryEntity, String>("categoryId"));
categoryBrand.setCellValueFactory(
new PropertyValueFactory<CategoryEntity, String>("categoryBrand"));
categoryType.setCellValueFactory(
new PropertyValueFactory<CategoryEntity, String>("categoryType"));
categoryDescription.setCellValueFactory(
new PropertyValueFactory<CategoryEntity, String>("categoryDescription"));

CacheService.clear();
connectAndReadFromDatabase();
clickHandler();

categoriesTable.setOnMouseClicked(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
if (event.getClickCount() == 1) {
CategoryEntity selectedCategory = categoriesTable
.getSelectionModel().getSelectedItem();

if (selectedCategory != null) {
CacheService.put("categoryId", selectedCategory.getCategoryId());
CacheService.put("categoryBrand", selectedCategory.getCategoryBrand());
CacheService.put("categoryType", selectedCategory.getCategoryType());
CacheService.put("categoryDescription", selectedCategory.getCategoryDescription());

addCategory.setVisible(false);
editCategory.setVisible(true);
deleteCategory.setVisible(true);
}
}
}
});

categoriesTable.setItems(data);
}
}
Loading

0 comments on commit 27e7663

Please sign in to comment.