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 | 	 * Creates new form OnTransact | ||||||
| 	 */ | 	 */ | ||||||
| 	private OnTransact() { | 	private OnTransact() { | ||||||
| 		transact.init(); |  | ||||||
| 		initComponents(); | 		initComponents(); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | @ -382,12 +381,12 @@ public class OnTransact extends javax.swing.JFrame { | ||||||
| 		transact.init(); | 		transact.init(); | ||||||
| 		refresh_inventory_list(); | 		refresh_inventory_list(); | ||||||
| 		refresh_data(); | 		refresh_data(); | ||||||
| 		product_information_refresh(); | 		refresh_interface(); | ||||||
| 	}; | 	}; | ||||||
| 	 | 	 | ||||||
| 	public static void reset() { | 	public static void reset() { | ||||||
| 		/* Reset the transaction. */ | 		/* Reset the transaction. */ | ||||||
| 		Boolean DISCARD_STATE = confirm_discard(); | 		Boolean DISCARD_STATE = (!transact.progress || confirm_discard()); | ||||||
| 		if (DISCARD_STATE) { | 		if (DISCARD_STATE) { | ||||||
| 			init(); | 			init(); | ||||||
| 		}; | 		}; | ||||||
|  | @ -403,6 +402,7 @@ public class OnTransact extends javax.swing.JFrame { | ||||||
| 		set_discard(); | 		set_discard(); | ||||||
| 		set_clear(); | 		set_clear(); | ||||||
| 		set_payment(); | 		set_payment(); | ||||||
|  | 		set_modifiable(); | ||||||
| 	}; | 	}; | ||||||
| 
 | 
 | ||||||
| 	private static boolean set_clear() { | 	private static boolean set_clear() { | ||||||
|  | @ -421,15 +421,23 @@ public class OnTransact extends javax.swing.JFrame { | ||||||
| 		 | 		 | ||||||
| 		Returns: (boolean) the payment status */ | 		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()); | 		return(transact.check()); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	private static boolean set_discard() { | 	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); | 		return(!receipt.clear); | ||||||
| 	}; | 	}; | ||||||
| 
 | 
 | ||||||
|  | 	private static boolean set_modifiable() { | ||||||
|  | 		jSpinner_price_tip_value.setEnabled(transact.progress); | ||||||
|  | 
 | ||||||
|  | 		return(transact.progress); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
| 	// The discarding of data | 	// The discarding of data | ||||||
| 	private static boolean confirm_discard() { | 	private static boolean confirm_discard() { | ||||||
| 		/* Confirm discarding items.  | 		/* Confirm discarding items.  | ||||||
|  | @ -465,8 +473,7 @@ public class OnTransact extends javax.swing.JFrame { | ||||||
| 
 | 
 | ||||||
| 	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. */ | ||||||
| 		@SuppressWarnings("unchecked") | 		Dictionary<String, Float> prices = transact.calculate();  | ||||||
| 		Dictionary<String, String> prices = transact.calculate();  |  | ||||||
| 		 | 		 | ||||||
| 		jTextField_price_subtotal_value.setText(String.valueOf(prices.get("subtotal"))); | 		jTextField_price_subtotal_value.setText(String.valueOf(prices.get("subtotal"))); | ||||||
| 		jTextField_price_total_value.setText(String.valueOf(prices.get("total"))); | 		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(); | 		Integer ITEM_SELECTED = jList1_Inventory.getSelectedIndex(); | ||||||
| 		 | 		 | ||||||
| 		// Set the initial values.  | 		// Set the initial values.  | ||||||
| 		jSpinner_item_quantity.setEnabled((ITEM_SELECTED >= 0)); | 		jSpinner_item_quantity.setEnabled((ITEM_SELECTED >= 0 && transact.progress)); | ||||||
| 		jButton_item_void.setEnabled((ITEM_SELECTED >= 0));  | 		jButton_item_void.setEnabled((ITEM_SELECTED >= 0 && transact.progress));  | ||||||
| 		jButton_item_add.setEnabled((ITEM_SELECTED >= 0));  | 		jButton_item_add.setEnabled((ITEM_SELECTED >= 0 && transact.progress));  | ||||||
| 		 | 		 | ||||||
| 		if (ITEM_SELECTED < 0) { | 		if (ITEM_SELECTED < 0) { | ||||||
| 			// Stop when there is no value selected.  | 			// 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.  | 		// 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.  | 		// Place the corresponding information.  | ||||||
| 		jTextField_ItemDetails_SKU.setText(ITEM_SELECTED_DETAILS_PROCESSED.get("SKU")); | 		jTextField_ItemDetails_SKU.setText(ITEM_SELECTED_DETAILS_PROCESSED.get("SKU")); | ||||||
|  | @ -522,9 +532,11 @@ public class OnTransact extends javax.swing.JFrame { | ||||||
| 		return (true); | 		return (true); | ||||||
| 	}; | 	}; | ||||||
| 	 | 	 | ||||||
| 	private static void receipt_refresh() { | 	private static String receipt_refresh() { | ||||||
| 		receipt.refresh(); | 		receipt.refresh(); | ||||||
| 		jTextArea1.setText(receipt.content); | 		jTextArea1.setText(receipt.content); | ||||||
|  | 		System.out.println(receipt.content); | ||||||
|  | 		return(receipt.content); | ||||||
| 	}; | 	}; | ||||||
| 	 | 	 | ||||||
| 	// Cart items | 	// Cart items | ||||||
|  | @ -603,11 +615,12 @@ public class OnTransact extends javax.swing.JFrame { | ||||||
| 		public void actionPerformed(ActionEvent e) { | 		public void actionPerformed(ActionEvent e) { | ||||||
| 			transact.pay(); | 			transact.pay(); | ||||||
| 			OnPayment.display(); | 			OnPayment.display(); | ||||||
|  | 			refresh_data(); | ||||||
|  | 			refresh_interface(); | ||||||
| 		}; | 		}; | ||||||
| 	}; | 	}; | ||||||
| 	 | 	 | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| 	// Variables declaration - do not modify | 	// Variables declaration - do not modify | ||||||
| 	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; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue