├── src └── main │ ├── resources │ ├── img │ │ └── bck.png │ └── view │ │ ├── DashboardForm.fxml │ │ ├── CustomerForm.fxml │ │ ├── PlaceOrderForm.fxml │ │ └── ItemForm.fxml │ └── java │ ├── Main.java │ ├── dto │ ├── ItemDto.java │ ├── OrderDetailsDto.java │ ├── OrderDto.java │ ├── tm │ │ ├── OrderTm.java │ │ ├── ItemTm.java │ │ └── CustomerTm.java │ └── CustomerDto.java │ ├── model │ ├── OrderDetailsModel.java │ ├── OrderModel.java │ ├── ItemModel.java │ ├── CustomerModel.java │ └── impl │ │ ├── OrderDetailsModelImpl.java │ │ ├── ItemModelImpl.java │ │ ├── OrderModelImpl.java │ │ └── CustomerModelImpl.java │ ├── AppInitializer.java │ ├── db │ └── DBConnection.java │ └── controller │ ├── DashboardFormController.java │ ├── CustomerFormController.java │ ├── ItemFormController.java │ └── PlaceOrderFormController.java ├── target ├── classes │ ├── AppInitializer.class │ ├── controller │ │ └── DashboardFormController.class │ └── view │ │ └── DashboardForm.fxml └── maven-status │ └── maven-compiler-plugin │ └── compile │ └── default-compile │ ├── createdFiles.lst │ └── inputFiles.lst ├── .idea ├── vcs.xml ├── .gitignore ├── dataSources.xml ├── misc.xml ├── compiler.xml ├── jarRepositories.xml └── uiDesigner.xml └── pom.xml /src/main/resources/img/bck.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HasinduEshan/mvc-maven-pos/HEAD/src/main/resources/img/bck.png -------------------------------------------------------------------------------- /target/classes/AppInitializer.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HasinduEshan/mvc-maven-pos/HEAD/target/classes/AppInitializer.class -------------------------------------------------------------------------------- /src/main/java/Main.java: -------------------------------------------------------------------------------- 1 | public class Main { 2 | public static void main(String[] args) { 3 | AppInitializer.main(args); 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /target/classes/controller/DashboardFormController.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HasinduEshan/mvc-maven-pos/HEAD/target/classes/controller/DashboardFormController.class -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Editor-based HTTP Client requests 5 | /httpRequests/ 6 | # Datasource local storage ignored files 7 | /dataSources/ 8 | /dataSources.local.xml 9 | -------------------------------------------------------------------------------- /src/main/java/dto/ItemDto.java: -------------------------------------------------------------------------------- 1 | package dto; 2 | 3 | import lombok.*; 4 | 5 | @AllArgsConstructor 6 | @NoArgsConstructor 7 | @ToString 8 | @Getter 9 | @Setter 10 | public class ItemDto { 11 | private String code; 12 | private String desc; 13 | private double unitPrice; 14 | private int qty; 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/model/OrderDetailsModel.java: -------------------------------------------------------------------------------- 1 | package model; 2 | 3 | import dto.OrderDetailsDto; 4 | 5 | import java.sql.SQLException; 6 | import java.util.List; 7 | 8 | public interface OrderDetailsModel { 9 | boolean saveOrderDetails(List list) throws SQLException, ClassNotFoundException; 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/model/OrderModel.java: -------------------------------------------------------------------------------- 1 | package model; 2 | 3 | import dto.OrderDto; 4 | 5 | import java.sql.SQLException; 6 | 7 | public interface OrderModel { 8 | boolean saveOrder(OrderDto dto) throws SQLException, ClassNotFoundException; 9 | OrderDto lastOrder() throws SQLException, ClassNotFoundException; 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/dto/OrderDetailsDto.java: -------------------------------------------------------------------------------- 1 | package dto; 2 | 3 | import lombok.*; 4 | 5 | @AllArgsConstructor 6 | @NoArgsConstructor 7 | @Setter 8 | @Getter 9 | @ToString 10 | public class OrderDetailsDto { 11 | private String orderId; 12 | private String itemCode; 13 | private int qty; 14 | private double unitPrice; 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/dto/OrderDto.java: -------------------------------------------------------------------------------- 1 | package dto; 2 | 3 | import lombok.*; 4 | 5 | import java.util.List; 6 | 7 | @AllArgsConstructor 8 | @NoArgsConstructor 9 | @Setter 10 | @Getter 11 | @ToString 12 | public class OrderDto { 13 | private String orderId; 14 | private String date; 15 | private String custId; 16 | private List list; 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/model/ItemModel.java: -------------------------------------------------------------------------------- 1 | package model; 2 | 3 | import dto.ItemDto; 4 | 5 | import java.sql.SQLException; 6 | import java.util.List; 7 | 8 | public interface ItemModel { 9 | boolean saveItem(ItemDto dto); 10 | boolean updateItem(ItemDto dto); 11 | boolean deleteItem(String code); 12 | ItemDto getItem(String code) throws SQLException, ClassNotFoundException; 13 | List allItems() throws SQLException, ClassNotFoundException; 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/dto/tm/OrderTm.java: -------------------------------------------------------------------------------- 1 | package dto.tm; 2 | 3 | import com.jfoenix.controls.JFXButton; 4 | import com.jfoenix.controls.datamodels.treetable.RecursiveTreeObject; 5 | import lombok.*; 6 | 7 | 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | @Setter 11 | @Getter 12 | @ToString 13 | public class OrderTm extends RecursiveTreeObject { 14 | private String code; 15 | private String desc; 16 | private int qty; 17 | private double amount; 18 | private JFXButton btn; 19 | } 20 | -------------------------------------------------------------------------------- /.idea/dataSources.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | mysql.8 6 | true 7 | com.mysql.cj.jdbc.Driver 8 | jdbc:mysql://localhost:3306 9 | $ProjectFileDir$ 10 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/java/model/CustomerModel.java: -------------------------------------------------------------------------------- 1 | package model; 2 | 3 | import dto.CustomerDto; 4 | 5 | import java.sql.SQLException; 6 | import java.util.List; 7 | 8 | public interface CustomerModel { 9 | boolean saveCustomer(CustomerDto dto) throws SQLException, ClassNotFoundException; 10 | boolean updateCustomer(CustomerDto dto) throws SQLException, ClassNotFoundException; 11 | boolean deleteCustomer(String id) throws SQLException, ClassNotFoundException; 12 | List allCustomers() throws SQLException, ClassNotFoundException; 13 | CustomerDto searchCustomer(String id); 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/AppInitializer.java: -------------------------------------------------------------------------------- 1 | import javafx.application.Application; 2 | import javafx.fxml.FXMLLoader; 3 | import javafx.scene.Scene; 4 | import javafx.stage.Stage; 5 | 6 | import java.io.IOException; 7 | 8 | public class AppInitializer extends Application { 9 | 10 | public static void main(String[] args) { 11 | launch(args); 12 | } 13 | 14 | @Override 15 | public void start(Stage primaryStage) throws IOException { 16 | primaryStage.setScene(new Scene(FXMLLoader.load(getClass().getResource("view/DashboardForm.fxml")))); 17 | primaryStage.centerOnScreen(); 18 | primaryStage.setResizable(false); 19 | primaryStage.show(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/dto/tm/ItemTm.java: -------------------------------------------------------------------------------- 1 | package dto.tm; 2 | 3 | import com.jfoenix.controls.JFXButton; 4 | import com.jfoenix.controls.datamodels.treetable.RecursiveTreeObject; 5 | import lombok.*; 6 | 7 | @AllArgsConstructor 8 | @NoArgsConstructor 9 | @ToString 10 | @Getter 11 | @Setter 12 | public class ItemTm extends RecursiveTreeObject { 13 | private String code; 14 | private String desc; 15 | private double unitPrice; 16 | private int qty; 17 | private JFXButton btn; 18 | 19 | public ItemTm(String code, String desc, double unitPrice, int qty) { 20 | this.code = code; 21 | this.desc = desc; 22 | this.unitPrice = unitPrice; 23 | this.qty = qty; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/db/DBConnection.java: -------------------------------------------------------------------------------- 1 | package db; 2 | 3 | import java.sql.Connection; 4 | import java.sql.DriverManager; 5 | import java.sql.SQLException; 6 | 7 | public class DBConnection { 8 | private static DBConnection dbConnection; 9 | private Connection connection; 10 | private DBConnection() throws ClassNotFoundException, SQLException { 11 | Class.forName("com.mysql.cj.jdbc.Driver"); 12 | connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/thogakade","root","1234"); 13 | } 14 | 15 | public static DBConnection getInstance() throws ClassNotFoundException, SQLException { 16 | return dbConnection!=null ? dbConnection : (dbConnection=new DBConnection()); 17 | } 18 | 19 | public Connection getConnection(){ 20 | return connection; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst: -------------------------------------------------------------------------------- 1 | dto\tm\CustomerTm.class 2 | controller\PlaceOrderFormController.class 3 | model\ItemModel.class 4 | Main.class 5 | controller\ItemFormController$1.class 6 | model\OrderModel.class 7 | controller\ItemFormController.class 8 | model\impl\CustomerModelImpl.class 9 | controller\DashboardFormController.class 10 | db\DBConnection.class 11 | dto\tm\OrderTm.class 12 | dto\OrderDto.class 13 | controller\ItemFormController$1$1.class 14 | dto\CustomerDto.class 15 | dto\ItemDto.class 16 | controller\CustomerFormController.class 17 | model\impl\OrderDetailsModelImpl.class 18 | model\OrderDetailsModel.class 19 | model\impl\ItemModelImpl.class 20 | model\CustomerModel.class 21 | dto\OrderDetailsDto.class 22 | AppInitializer.class 23 | model\impl\OrderModelImpl.class 24 | dto\tm\ItemTm.class 25 | -------------------------------------------------------------------------------- /.idea/jarRepositories.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 14 | 15 | 19 | 20 | -------------------------------------------------------------------------------- /src/main/java/model/impl/OrderDetailsModelImpl.java: -------------------------------------------------------------------------------- 1 | package model.impl; 2 | 3 | import db.DBConnection; 4 | import dto.OrderDetailsDto; 5 | import model.OrderDetailsModel; 6 | 7 | import java.sql.PreparedStatement; 8 | import java.sql.SQLException; 9 | import java.util.List; 10 | 11 | public class OrderDetailsModelImpl implements OrderDetailsModel { 12 | @Override 13 | public boolean saveOrderDetails(List list) throws SQLException, ClassNotFoundException { 14 | boolean isDetailsSaved = true; 15 | for (OrderDetailsDto dto:list) { 16 | String sql = "INSERT INTO orderdetail VALUES(?,?,?,?)"; 17 | PreparedStatement pstm = DBConnection.getInstance().getConnection().prepareStatement(sql); 18 | pstm.setString(1,dto.getOrderId()); 19 | pstm.setString(2,dto.getItemCode()); 20 | pstm.setInt(3,dto.getQty()); 21 | pstm.setDouble(4,dto.getUnitPrice()); 22 | 23 | if(!(pstm.executeUpdate()>0)){ 24 | isDetailsSaved = false; 25 | } 26 | } 27 | return isDetailsSaved; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/dto/CustomerDto.java: -------------------------------------------------------------------------------- 1 | package dto; 2 | 3 | public class CustomerDto { 4 | private String id; 5 | private String name; 6 | private String address; 7 | private double salary; 8 | 9 | public CustomerDto(String id, String name, String address, double salary) { 10 | this.id = id; 11 | this.name = name; 12 | this.address = address; 13 | this.salary = salary; 14 | } 15 | 16 | public CustomerDto() { 17 | } 18 | 19 | @Override 20 | public String toString() { 21 | return "Customer{" + 22 | "id='" + id + '\'' + 23 | ", name='" + name + '\'' + 24 | ", address='" + address + '\'' + 25 | ", salary=" + salary + 26 | '}'; 27 | } 28 | 29 | public String getId() { 30 | return id; 31 | } 32 | 33 | public void setId(String id) { 34 | this.id = id; 35 | } 36 | 37 | public String getName() { 38 | return name; 39 | } 40 | 41 | public void setName(String name) { 42 | this.name = name; 43 | } 44 | 45 | public String getAddress() { 46 | return address; 47 | } 48 | 49 | public void setAddress(String address) { 50 | this.address = address; 51 | } 52 | 53 | public double getSalary() { 54 | return salary; 55 | } 56 | 57 | public void setSalary(double salary) { 58 | this.salary = salary; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /target/classes/view/DashboardForm.fxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |