fix information retrieval for interface
This commit is contained in:
parent
d27be2fa39
commit
a5098d07c2
1 changed files with 27 additions and 14 deletions
|
@ -18,7 +18,6 @@ public class OnTransact extends javax.swing.JFrame {
|
|||
* Creates new form OnTransact
|
||||
*/
|
||||
private OnTransact() {
|
||||
transact.init();
|
||||
initComponents();
|
||||
}
|
||||
|
||||
|
@ -382,12 +381,12 @@ public class OnTransact extends javax.swing.JFrame {
|
|||
transact.init();
|
||||
refresh_inventory_list();
|
||||
refresh_data();
|
||||
product_information_refresh();
|
||||
refresh_interface();
|
||||
};
|
||||
|
||||
public static void reset() {
|
||||
/* Reset the transaction. */
|
||||
Boolean DISCARD_STATE = confirm_discard();
|
||||
Boolean DISCARD_STATE = (!transact.progress || confirm_discard());
|
||||
if (DISCARD_STATE) {
|
||||
init();
|
||||
};
|
||||
|
@ -403,6 +402,7 @@ public class OnTransact extends javax.swing.JFrame {
|
|||
set_discard();
|
||||
set_clear();
|
||||
set_payment();
|
||||
set_modifiable();
|
||||
};
|
||||
|
||||
private static boolean set_clear() {
|
||||
|
@ -421,14 +421,22 @@ public class OnTransact extends javax.swing.JFrame {
|
|||
|
||||
Returns: (boolean) the payment status */
|
||||
|
||||
jButton_Action_Pay.setEnabled(transact.check());
|
||||
// Can only pay when the transaction is currently active
|
||||
jButton_Action_Pay.setEnabled(transact.check() && transact.progress);
|
||||
return(transact.check());
|
||||
}
|
||||
|
||||
private static boolean set_discard() {
|
||||
jToggleButton_Discard.setVisible(!receipt.clear);
|
||||
jToggleButton_Discard.setEnabled(!receipt.clear);
|
||||
jToggleButton_Discard.setText((!transact.progress) ? "Clear" : "Discard");
|
||||
return(!receipt.clear);
|
||||
};
|
||||
|
||||
private static boolean set_modifiable() {
|
||||
jSpinner_price_tip_value.setEnabled(transact.progress);
|
||||
|
||||
return(transact.progress);
|
||||
}
|
||||
|
||||
// The discarding of data
|
||||
private static boolean confirm_discard() {
|
||||
|
@ -465,8 +473,7 @@ public class OnTransact extends javax.swing.JFrame {
|
|||
|
||||
private static void cart_calculation_refresh() {
|
||||
/* Refresh the cart's details, such as the total cost. */
|
||||
@SuppressWarnings("unchecked")
|
||||
Dictionary<String, String> prices = transact.calculate();
|
||||
Dictionary<String, Float> prices = transact.calculate();
|
||||
|
||||
jTextField_price_subtotal_value.setText(String.valueOf(prices.get("subtotal")));
|
||||
jTextField_price_total_value.setText(String.valueOf(prices.get("total")));
|
||||
|
@ -482,9 +489,9 @@ public class OnTransact extends javax.swing.JFrame {
|
|||
Integer ITEM_SELECTED = jList1_Inventory.getSelectedIndex();
|
||||
|
||||
// Set the initial values.
|
||||
jSpinner_item_quantity.setEnabled((ITEM_SELECTED >= 0));
|
||||
jButton_item_void.setEnabled((ITEM_SELECTED >= 0));
|
||||
jButton_item_add.setEnabled((ITEM_SELECTED >= 0));
|
||||
jSpinner_item_quantity.setEnabled((ITEM_SELECTED >= 0 && transact.progress));
|
||||
jButton_item_void.setEnabled((ITEM_SELECTED >= 0 && transact.progress));
|
||||
jButton_item_add.setEnabled((ITEM_SELECTED >= 0 && transact.progress));
|
||||
|
||||
if (ITEM_SELECTED < 0) {
|
||||
// Stop when there is no value selected.
|
||||
|
@ -512,7 +519,10 @@ public class OnTransact extends javax.swing.JFrame {
|
|||
};
|
||||
|
||||
// Change the void state. You can't void something that doesn't already exist in the cart.
|
||||
jButton_item_void.setEnabled((((transact.items).get(ITEM_SELECTED_DETAILS_PROCESSED.get("SKU"))) != null));
|
||||
jButton_item_void.setEnabled((((transact.items).get(ITEM_SELECTED_DETAILS_PROCESSED.get("SKU"))) != null) && transact.progress);
|
||||
|
||||
// Also stop the user from accidentally selecting the wrong amount
|
||||
jSpinner_item_quantity.setValue(1);
|
||||
|
||||
// Place the corresponding information.
|
||||
jTextField_ItemDetails_SKU.setText(ITEM_SELECTED_DETAILS_PROCESSED.get("SKU"));
|
||||
|
@ -522,9 +532,11 @@ public class OnTransact extends javax.swing.JFrame {
|
|||
return (true);
|
||||
};
|
||||
|
||||
private static void receipt_refresh() {
|
||||
private static String receipt_refresh() {
|
||||
receipt.refresh();
|
||||
jTextArea1.setText(receipt.content);
|
||||
System.out.println(receipt.content);
|
||||
return(receipt.content);
|
||||
};
|
||||
|
||||
// Cart items
|
||||
|
@ -602,11 +614,12 @@ public class OnTransact extends javax.swing.JFrame {
|
|||
ActionListener select_payment = new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
transact.pay();
|
||||
OnPayment.display();
|
||||
OnPayment.display();
|
||||
refresh_data();
|
||||
refresh_interface();
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
|
||||
// Variables declaration - do not modify
|
||||
private static javax.swing.JButton jButton_Action_Pay;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue