If values in input fields of the form Customer orders are changed, the list of the total results must be computed again.
For this into the STableElementen of job orders, job order parts and workers and others, as ValueChangedMakro and as ValuesChangedMakro the Command RefreshResult is set.
This Command is converted by the class RefreshResult, which implements the interface SystemCommand:
public class RefreshResult implements SystemCommand { ... public Object action(Object[] args, Macro macro) { if (SWindowUtils.isSWindowOpened("Formulare/KundenAuftraege.form")) { try { SWindow window = SWindowUtils .getSWindow("Formulare/KundenAuftraege.form"); SFormattedField textTotalPrice = (SFormattedField) window .getObject("txt_Gesamtpreis"); SFormattedField textSalestaxPercent = (SFormattedField) window .getObject("txt_UmsatzsteuerProzent"); SFormattedField textSalestax = (SFormattedField) window .getObject("txt_Umsatzsteuer"); SFormattedField textOrderAmount = (SFormattedField) window .getObject("txt_Bestellsumme"); SFormattedField textPayments = (SFormattedField) window .getObject("txt_Gezahlt"); SFormattedField textPayableAmount = (SFormattedField) window .getObject("txt_Gesamtbetrag"); QueryDescriptor queryDescriptor = ObjectLoader .getQueryDescriptor("Ergebnis"); HSRecordSet recordSet = new HSRecordSet(queryDescriptor); int totalWorkHours = 0; int totalPieces = 0; double payedAmount = 0; if (recordSet.next()) { totalWorkHours = recordSet.getObject(1) != null ? ((Number) recordSet .getObject(1)).intValue() : 0; totalPieces = recordSet.getObject(2) != null ? ((Number) recordSet .getObject(2)).intValue() : 0; payedAmount = recordSet.getObject(3) != null ? ((Number) recordSet .getObject(3)).doubleValue() : 0; } int totalValue = totalWorkHours + totalPieces; textTotalPrice.setControlledValue(String.valueOf(totalValue)); int salesTaxPercent = textSalestaxPercent.getControlledValue() != null && textSalestax.getText().length() > 0 ? ((Number) textSalestaxPercent .getControlledValue()).intValue() : 0; double salestax = ((float) totalValue / (float) 100) * (float) salesTaxPercent; textSalestax.setControlledValue(String.valueOf(salestax)); textOrderAmount.setControlledValue(String.valueOf(totalValue + salestax)); textPayments.setControlledValue(String.valueOf(payedAmount)); textPayableAmount.setControlledValue(String.valueOf(totalValue + salestax - payedAmount)); SWindow mainForm = SWindowUtils .getSWindow("Formulare/Eingabe.form"); STableElement customerElement = (STableElement) mainForm .getObject("Kundenauftraege"); customerElement.refresh(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } return null; } }
Here the values from the SQL-query result are taken and registered into the appropriate text fields.