categorised functions
converted spaces to tabs
This commit is contained in:
parent
3d79074efa
commit
5137cf68b6
1 changed files with 607 additions and 592 deletions
|
@ -75,7 +75,7 @@ public class OnTransact extends javax.swing.JFrame {
|
||||||
setPreferredSize(new java.awt.Dimension(1000, 800));
|
setPreferredSize(new java.awt.Dimension(1000, 800));
|
||||||
addWindowListener(new java.awt.event.WindowAdapter() {
|
addWindowListener(new java.awt.event.WindowAdapter() {
|
||||||
public void windowClosing(java.awt.event.WindowEvent evt) {
|
public void windowClosing(java.awt.event.WindowEvent evt) {
|
||||||
transaction_check(evt);
|
close_precheck(evt);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ public class OnTransact extends javax.swing.JFrame {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
jPanel_statusinfo.add(jToggleButton_Discard, java.awt.BorderLayout.LINE_START);
|
jPanel_statusinfo.add(jToggleButton_Discard, java.awt.BorderLayout.LINE_START);
|
||||||
jToggleButton_Discard.setVisible(interface_adjust_clear());
|
jToggleButton_Discard.setVisible(set_clear());
|
||||||
|
|
||||||
jButton_Action_Pay.setText("Payment");
|
jButton_Action_Pay.setText("Payment");
|
||||||
jPanel_statusinfo.add(jButton_Action_Pay, java.awt.BorderLayout.LINE_END);
|
jPanel_statusinfo.add(jButton_Action_Pay, java.awt.BorderLayout.LINE_END);
|
||||||
|
@ -319,43 +319,28 @@ public class OnTransact extends javax.swing.JFrame {
|
||||||
getContentPane().add(jPanel_Main, java.awt.BorderLayout.CENTER);
|
getContentPane().add(jPanel_Main, java.awt.BorderLayout.CENTER);
|
||||||
|
|
||||||
pack();
|
pack();
|
||||||
}// </editor-fold>//GEN-END:initComponents
|
}// </editor-fold>
|
||||||
|
|
||||||
private void jButton_item_voidActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_item_voidActionPerformed
|
// Window events
|
||||||
cart_remove();
|
private void close_precheck(java.awt.event.WindowEvent evt) {
|
||||||
}//GEN-LAST:event_jButton_item_voidActionPerformed
|
boolean CLOSING_STATE = receipt.clear;
|
||||||
|
if (!receipt.clear) {CLOSING_STATE = confirm_discard();};
|
||||||
private void jButton_item_addActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_item_addActionPerformed
|
|
||||||
cart_add();
|
|
||||||
}//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 (!transact.check()) {
|
|
||||||
CLOSING_STATE = true;
|
|
||||||
} else {
|
|
||||||
CLOSING_STATE = confirm_discard();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (CLOSING_STATE) {evt.getWindow().dispose();};
|
if (CLOSING_STATE) {evt.getWindow().dispose();};
|
||||||
}//GEN-LAST:event_transaction_check
|
}
|
||||||
|
|
||||||
private void jList1_InventoryValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_jList1_InventoryValueChanged
|
private void jList1_InventoryValueChanged(javax.swing.event.ListSelectionEvent evt) {
|
||||||
// TODO add your handling code here:
|
|
||||||
product_information_refresh();
|
product_information_refresh();
|
||||||
}//GEN-LAST:event_jList1_InventoryValueChanged
|
}
|
||||||
|
|
||||||
private void jToggleButton_DiscardActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButton_DiscardActionPerformed
|
private boolean jToggleButton_DiscardActionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
boolean CLOSING_STATE = false;
|
// When the discard button is clicked
|
||||||
|
boolean user_choice = confirm_discard();
|
||||||
if (transact.check()) {
|
if (user_choice) {init();};
|
||||||
CLOSING_STATE = confirm_discard();
|
jToggleButton_Discard.setSelected(false);
|
||||||
|
return (user_choice);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (CLOSING_STATE) {init();};
|
|
||||||
}//GEN-LAST:event_jToggleButton_DiscardActionPerformed
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param args the command line arguments
|
* @param args the command line arguments
|
||||||
*/
|
*/
|
||||||
|
@ -397,9 +382,59 @@ public class OnTransact extends javax.swing.JFrame {
|
||||||
display();
|
display();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void init() {
|
||||||
|
transact.init();
|
||||||
|
refresh_inventory_list();
|
||||||
|
refresh_data();
|
||||||
|
product_information_refresh();
|
||||||
|
};
|
||||||
|
|
||||||
|
public static void reset() {
|
||||||
|
/* Reset the transaction. */
|
||||||
|
Boolean DISCARD_STATE = confirm_discard();
|
||||||
|
if (DISCARD_STATE) {
|
||||||
|
init();
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
private SpinnerNumberModel model_price = new SpinnerNumberModel(0, 0, Integer.MAX_VALUE, .01);
|
private SpinnerNumberModel model_price = new SpinnerNumberModel(0, 0, Integer.MAX_VALUE, .01);
|
||||||
private SpinnerNumberModel model_counting = new SpinnerNumberModel(1, 1, Integer.MAX_VALUE, 1);
|
private SpinnerNumberModel model_counting = new SpinnerNumberModel(1, 1, Integer.MAX_VALUE, 1);
|
||||||
|
|
||||||
|
|
||||||
|
// Adjusting the interface
|
||||||
|
private static void refresh_interface() {
|
||||||
|
set_discard();
|
||||||
|
set_clear();
|
||||||
|
set_payment();
|
||||||
|
};
|
||||||
|
|
||||||
|
private static boolean set_clear() {
|
||||||
|
/* Adjust the ability to reset.
|
||||||
|
|
||||||
|
Returns: (boolean) the new state of the appearance
|
||||||
|
*/
|
||||||
|
|
||||||
|
boolean CLEARABLE_STATE = (!receipt.clear);
|
||||||
|
jToggleButton_Discard.setVisible(CLEARABLE_STATE);
|
||||||
|
return (jToggleButton_Discard.isVisible());
|
||||||
|
};
|
||||||
|
|
||||||
|
public static boolean set_payment() {
|
||||||
|
/* Adjust the ability to pay.
|
||||||
|
|
||||||
|
Returns: (boolean) the payment status */
|
||||||
|
|
||||||
|
jButton_Action_Pay.setEnabled(transact.check());
|
||||||
|
return(transact.check());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean set_discard() {
|
||||||
|
jToggleButton_Discard.setVisible(!receipt.clear);
|
||||||
|
return(!receipt.clear);
|
||||||
|
};
|
||||||
|
|
||||||
|
// The discarding of data
|
||||||
private static boolean confirm_discard() {
|
private static boolean confirm_discard() {
|
||||||
/* Confirm discarding items.
|
/* Confirm discarding items.
|
||||||
|
|
||||||
|
@ -411,26 +446,7 @@ public class OnTransact extends javax.swing.JFrame {
|
||||||
return (USER_CHOICE);
|
return (USER_CHOICE);
|
||||||
};
|
};
|
||||||
|
|
||||||
private static boolean interface_adjust_clear() {
|
// Inventories
|
||||||
/* Adjust the ability to reset.
|
|
||||||
|
|
||||||
Returns: (boolean) the new state of the appearance
|
|
||||||
*/
|
|
||||||
|
|
||||||
boolean CLEARABLE_STATE = (transact.check());
|
|
||||||
jToggleButton_Discard.setVisible(CLEARABLE_STATE);
|
|
||||||
return (jToggleButton_Discard.isVisible());
|
|
||||||
};
|
|
||||||
|
|
||||||
public static boolean interface_adjust_payment() {
|
|
||||||
/* Adjust the ability to pay.
|
|
||||||
|
|
||||||
Returns: (boolean) the payment status */
|
|
||||||
|
|
||||||
jButton_Action_Pay.setEnabled(transact.check());
|
|
||||||
return(transact.check());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static AbstractListModel<String> refresh_inventory_list() {
|
private static AbstractListModel<String> refresh_inventory_list() {
|
||||||
/* Pull the list from inventory.
|
/* Pull the list from inventory.
|
||||||
*/
|
*/
|
||||||
|
@ -444,6 +460,13 @@ public class OnTransact extends javax.swing.JFrame {
|
||||||
return(INVENTORY_LIST);
|
return(INVENTORY_LIST);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//# Refreshing of data
|
||||||
|
private static void refresh_data() {
|
||||||
|
cart_calculation_refresh();
|
||||||
|
product_information_refresh();
|
||||||
|
receipt_refresh();
|
||||||
|
};
|
||||||
|
|
||||||
private static void cart_calculation_refresh() {
|
private static void cart_calculation_refresh() {
|
||||||
/* Refresh the cart's details, such as the total cost. */
|
/* Refresh the cart's details, such as the total cost. */
|
||||||
Dictionary<String, String> prices = transact.calculate();
|
Dictionary<String, String> prices = transact.calculate();
|
||||||
|
@ -453,10 +476,8 @@ public class OnTransact extends javax.swing.JFrame {
|
||||||
jTextField_price_discounted.setText(String.valueOf(prices.get("discount")));
|
jTextField_price_discounted.setText(String.valueOf(prices.get("discount")));
|
||||||
jTextField_price_VAT_value.setText(String.valueOf(prices.get("tax")));
|
jTextField_price_VAT_value.setText(String.valueOf(prices.get("tax")));
|
||||||
|
|
||||||
receipt_refresh();
|
set_payment();
|
||||||
product_information_refresh();
|
set_clear();
|
||||||
interface_adjust_payment();
|
|
||||||
interface_adjust_clear();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
private static boolean product_information_refresh() {
|
private static boolean product_information_refresh() {
|
||||||
|
@ -508,6 +529,15 @@ public class OnTransact extends javax.swing.JFrame {
|
||||||
jTextArea1.setText(receipt.content);
|
jTextArea1.setText(receipt.content);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Cart items
|
||||||
|
private void jButton_item_voidActionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
|
cart_remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void jButton_item_addActionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
|
cart_add();
|
||||||
|
}
|
||||||
|
|
||||||
private boolean cart_add() {
|
private boolean cart_add() {
|
||||||
/* Add the item to the cart.
|
/* Add the item to the cart.
|
||||||
|
|
||||||
|
@ -528,7 +558,8 @@ public class OnTransact extends javax.swing.JFrame {
|
||||||
state = transact.add(ITEM_SELECTED_SKU, ITEM_SELECTED_QUANTITY);
|
state = transact.add(ITEM_SELECTED_SKU, ITEM_SELECTED_QUANTITY);
|
||||||
|
|
||||||
// Refresh the data.
|
// Refresh the data.
|
||||||
cart_calculation_refresh();
|
refresh_data();
|
||||||
|
refresh_interface();
|
||||||
};
|
};
|
||||||
return(state);
|
return(state);
|
||||||
};
|
};
|
||||||
|
@ -538,7 +569,7 @@ public class OnTransact extends javax.swing.JFrame {
|
||||||
|
|
||||||
transact.price.put("tip", Float.valueOf(String.valueOf(jSpinner_price_tip_value.getValue())));
|
transact.price.put("tip", Float.valueOf(String.valueOf(jSpinner_price_tip_value.getValue())));
|
||||||
transact.calculate();
|
transact.calculate();
|
||||||
cart_calculation_refresh();
|
refresh_data();
|
||||||
};
|
};
|
||||||
|
|
||||||
private boolean cart_remove() {
|
private boolean cart_remove() {
|
||||||
|
@ -561,33 +592,17 @@ public class OnTransact extends javax.swing.JFrame {
|
||||||
state = transact.remove(ITEM_SELECTED_SKU, ITEM_SELECTED_QUANTITY);
|
state = transact.remove(ITEM_SELECTED_SKU, ITEM_SELECTED_QUANTITY);
|
||||||
|
|
||||||
// Refresh the data.
|
// Refresh the data.
|
||||||
cart_calculation_refresh();
|
refresh_data();
|
||||||
|
refresh_interface();
|
||||||
};
|
};
|
||||||
return(state);
|
return(state);
|
||||||
};
|
};
|
||||||
|
|
||||||
public static void reset() {
|
|
||||||
/* Reset the transaction. */
|
|
||||||
Boolean DISCARD_STATE = confirm_discard();
|
|
||||||
if (DISCARD_STATE) {
|
|
||||||
init();
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void init() {
|
|
||||||
transact.init();
|
|
||||||
refresh_inventory_list();
|
|
||||||
cart_calculation_refresh();
|
|
||||||
receipt_refresh();
|
|
||||||
product_information_refresh();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Variables declaration - do not modify
|
||||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
|
||||||
private static javax.swing.JButton jButton_Action_Pay;
|
private static javax.swing.JButton jButton_Action_Pay;
|
||||||
private static javax.swing.JButton jButton_item_add;
|
private static javax.swing.JButton jButton_item_add;
|
||||||
private static javax.swing.JButton jButton_item_void;
|
private static javax.swing.JButton jButton_item_void;
|
||||||
|
@ -623,5 +638,5 @@ public class OnTransact extends javax.swing.JFrame {
|
||||||
private static javax.swing.JToggleButton jToggleButton_Discard;
|
private static javax.swing.JToggleButton jToggleButton_Discard;
|
||||||
private static javax.swing.JToolBar jToolBar_Information;
|
private static javax.swing.JToolBar jToolBar_Information;
|
||||||
private static javax.swing.JToolBar jToolBar_Inventory;
|
private static javax.swing.JToolBar jToolBar_Inventory;
|
||||||
// End of variables declaration//GEN-END:variables
|
// End of variables declaration
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue