diff --git a/src/main/java/tech/iBeans/POSware/Lite/OnTransact.java b/src/main/java/tech/iBeans/POSware/Lite/OnTransact.java new file mode 100644 index 0000000..e1fbf26 --- /dev/null +++ b/src/main/java/tech/iBeans/POSware/Lite/OnTransact.java @@ -0,0 +1,307 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template + */ +package tech.iBeans.POSware.Lite; +import tech.iBeans.POSware.Lite.transaction; +import tech.iBeans.POSware.Lite.WindowManagement; + +/** + * + * @author eleven + */ +public class OnTransact extends javax.swing.JFrame { + + /** + * Creates new form OnTransact + */ + private OnTransact() { + initComponents(); + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + java.awt.GridBagConstraints gridBagConstraints; + + jPanel1 = new javax.swing.JPanel(); + jComboBox1 = new javax.swing.JComboBox<>(); + jLabel1 = new javax.swing.JLabel(); + jPanel_Main = new javax.swing.JPanel(); + jPanel_Items = new javax.swing.JPanel(); + jScrollPane1 = new javax.swing.JScrollPane(); + jTextArea1 = new javax.swing.JTextArea(); + jToolBar_Information = new javax.swing.JToolBar(); + jPanel_Information = new javax.swing.JPanel(); + jLabel_price_VAT = new javax.swing.JLabel(); + jLabel_price_tip = new javax.swing.JLabel(); + jLabel_price_subtotal = new javax.swing.JLabel(); + jLabel_price_total = new javax.swing.JLabel(); + jSpinner_price_tip_value = new javax.swing.JSpinner(); + jTextField_price_VAT_value = new javax.swing.JTextField(); + jTextField_price_subtotal_value = new javax.swing.JTextField(); + jTextField_price_total_value = new javax.swing.JTextField(); + jComboBox_information_discount_selections = new javax.swing.JComboBox<>(); + jLabel2_information_discount = new javax.swing.JLabel(); + jToolBar_Inventory = new javax.swing.JToolBar(); + jPanel2 = new javax.swing.JPanel(); + jPanel_Inventory_Actions = new javax.swing.JPanel(); + jButton_item_void = new javax.swing.JButton(); + jSpinner_item_quantity = new javax.swing.JSpinner(); + jButton_item_add = new javax.swing.JButton(); + jScrollPane_Inventory = new javax.swing.JScrollPane(); + jList1_Inventory = new javax.swing.JList<>(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); + setTitle("POSware Lite: Transaction"); + setPreferredSize(new java.awt.Dimension(1000, 800)); + addWindowListener(new java.awt.event.WindowAdapter() { + public void windowClosing(java.awt.event.WindowEvent evt) { + transaction_check(evt); + } + }); + + jPanel1.setLayout(new java.awt.BorderLayout()); + + jComboBox1.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); + jPanel1.add(jComboBox1, java.awt.BorderLayout.EAST); + + jLabel1.setText("jLabel1"); + jPanel1.add(jLabel1, java.awt.BorderLayout.LINE_START); + + getContentPane().add(jPanel1, java.awt.BorderLayout.PAGE_END); + + jPanel_Main.setLayout(new java.awt.BorderLayout()); + + jPanel_Items.setLayout(new java.awt.BorderLayout()); + + jTextArea1.setColumns(20); + jTextArea1.setLineWrap(true); + jTextArea1.setRows(5); + jTextArea1.setEnabled(false); + jScrollPane1.setViewportView(jTextArea1); + + jPanel_Items.add(jScrollPane1, java.awt.BorderLayout.CENTER); + + jToolBar_Information.setRollover(true); + + jPanel_Information.setLayout(new java.awt.GridBagLayout()); + + jLabel_price_VAT.setText("VAT"); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 0; + jPanel_Information.add(jLabel_price_VAT, gridBagConstraints); + + jLabel_price_tip.setText("Tip"); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 1; + jPanel_Information.add(jLabel_price_tip, gridBagConstraints); + + jLabel_price_subtotal.setText("Subtotal"); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 2; + gridBagConstraints.gridy = 0; + jPanel_Information.add(jLabel_price_subtotal, gridBagConstraints); + + jLabel_price_total.setText("Grand Total"); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 2; + gridBagConstraints.gridy = 1; + gridBagConstraints.gridheight = 2; + jPanel_Information.add(jLabel_price_total, gridBagConstraints); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 1; + gridBagConstraints.gridy = 1; + jPanel_Information.add(jSpinner_price_tip_value, gridBagConstraints); + + jTextField_price_VAT_value.setText("0"); + jTextField_price_VAT_value.setEnabled(false); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 1; + gridBagConstraints.gridy = 0; + jPanel_Information.add(jTextField_price_VAT_value, gridBagConstraints); + + jTextField_price_subtotal_value.setText("0"); + jTextField_price_subtotal_value.setEnabled(false); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 3; + gridBagConstraints.gridy = 0; + jPanel_Information.add(jTextField_price_subtotal_value, gridBagConstraints); + + jTextField_price_total_value.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N + jTextField_price_total_value.setText("0"); + jTextField_price_total_value.setEnabled(false); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 3; + gridBagConstraints.gridy = 1; + gridBagConstraints.gridheight = 2; + jPanel_Information.add(jTextField_price_total_value, gridBagConstraints); + + jComboBox_information_discount_selections.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 1; + gridBagConstraints.gridy = 2; + jPanel_Information.add(jComboBox_information_discount_selections, gridBagConstraints); + + jLabel2_information_discount.setText("Discount"); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 2; + jPanel_Information.add(jLabel2_information_discount, gridBagConstraints); + + jToolBar_Information.add(jPanel_Information); + + jPanel_Items.add(jToolBar_Information, java.awt.BorderLayout.SOUTH); + + jPanel_Main.add(jPanel_Items, java.awt.BorderLayout.CENTER); + + jToolBar_Inventory.setRollover(true); + + jPanel2.setLayout(new java.awt.BorderLayout()); + + jButton_item_void.setText("Void"); + jButton_item_void.setFocusable(false); + jButton_item_void.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); + jButton_item_void.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + jButton_item_void.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton_item_voidActionPerformed(evt); + } + }); + jPanel_Inventory_Actions.add(jButton_item_void); + jPanel_Inventory_Actions.add(jSpinner_item_quantity); + + jButton_item_add.setText("Add"); + jButton_item_add.setFocusable(false); + jButton_item_add.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); + jButton_item_add.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + jButton_item_add.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton_item_addActionPerformed(evt); + } + }); + jPanel_Inventory_Actions.add(jButton_item_add); + + jPanel2.add(jPanel_Inventory_Actions, java.awt.BorderLayout.SOUTH); + + jList1_Inventory.setModel(new javax.swing.AbstractListModel() { + String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" }; + public int getSize() { return strings.length; } + public String getElementAt(int i) { return strings[i]; } + }); + jScrollPane_Inventory.setViewportView(jList1_Inventory); + + jPanel2.add(jScrollPane_Inventory, java.awt.BorderLayout.CENTER); + + jToolBar_Inventory.add(jPanel2); + + jPanel_Main.add(jToolBar_Inventory, java.awt.BorderLayout.EAST); + + getContentPane().add(jPanel_Main, java.awt.BorderLayout.CENTER); + + pack(); + }// //GEN-END:initComponents + + private void jButton_item_voidActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_item_voidActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_jButton_item_voidActionPerformed + + private void jButton_item_addActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_item_addActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_jButton_item_addActionPerformed + + private void transaction_check(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_transaction_check + boolean CLOSING_STATE = false; + + if (transaction.items_count > 0) { + CLOSING_STATE = true; + } else { + CLOSING_STATE = confirm_discard(); + } + + if (CLOSING_STATE) {evt.getWindow().dispose();}; + }//GEN-LAST:event_transaction_check + + /** + * @param args the command line arguments + */ + + public static void display() { + /* Display the transaction. */ + + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + new OnTransact().setVisible(true); + } + }); + } + + public static void main(String args[]) { + /* Set the Nimbus look and feel */ + // + /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. + * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html + */ + try { + for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { + if ("Nimbus".equals(info.getName())) { + javax.swing.UIManager.setLookAndFeel(info.getClassName()); + break; + } + } + } catch (ClassNotFoundException ex) { + java.util.logging.Logger.getLogger(OnTransact.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (InstantiationException ex) { + java.util.logging.Logger.getLogger(OnTransact.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (IllegalAccessException ex) { + java.util.logging.Logger.getLogger(OnTransact.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (javax.swing.UnsupportedLookAndFeelException ex) { + java.util.logging.Logger.getLogger(OnTransact.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } + // + + display(); + } + + private static boolean confirm_discard() { + Boolean USER_CHOICE = WindowManagement.confirm("Discrding Items", "There are currently items in the cart. Would you want to discard this?", true); + return (USER_CHOICE); + }; + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton jButton_item_add; + private javax.swing.JButton jButton_item_void; + private javax.swing.JComboBox jComboBox1; + private javax.swing.JComboBox jComboBox_information_discount_selections; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2_information_discount; + private javax.swing.JLabel jLabel_price_VAT; + private javax.swing.JLabel jLabel_price_subtotal; + private javax.swing.JLabel jLabel_price_tip; + private javax.swing.JLabel jLabel_price_total; + private javax.swing.JList jList1_Inventory; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel_Information; + private javax.swing.JPanel jPanel_Inventory_Actions; + private javax.swing.JPanel jPanel_Items; + private javax.swing.JPanel jPanel_Main; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JScrollPane jScrollPane_Inventory; + private javax.swing.JSpinner jSpinner_item_quantity; + private javax.swing.JSpinner jSpinner_price_tip_value; + private javax.swing.JTextArea jTextArea1; + private javax.swing.JTextField jTextField_price_VAT_value; + private javax.swing.JTextField jTextField_price_subtotal_value; + private javax.swing.JTextField jTextField_price_total_value; + private javax.swing.JToolBar jToolBar_Information; + private javax.swing.JToolBar jToolBar_Inventory; + // End of variables declaration//GEN-END:variables +} diff --git a/src/main/java/tech/iBeans/POSware/Lite/SimplePOS.java b/src/main/java/tech/iBeans/POSware/Lite/SimplePOS.java new file mode 100644 index 0000000..bd838aa --- /dev/null +++ b/src/main/java/tech/iBeans/POSware/Lite/SimplePOS.java @@ -0,0 +1,19 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + */ + +package tech.iBeans.POSware.Lite; + +import tech.iBeans.POSware.Lite.*; + + +/** + * + * @author eleven + */ +public class SimplePOS { + + public static void main(String[] args) { + OnTransact.display(); + } +}