コード例 #1
0
 @Override
 public void onInit() {
   List<ComboBoxItem> customers = Services.listCurrentRecordRefernces(Services.TYPE_CUSTOMER);
   for (ComboBoxItem item : customers) {
     txtCustomer.addItem(item);
   }
   List<ComboBoxItem> products = Services.listCurrentRecordRefernces(Services.TYPE_PRODUCT);
   for (ComboBoxItem item : products) {
     txtProduct.addItem(item);
   }
 }
コード例 #2
0
 public void addRow() {
   ComboBoxItem comboBoxItem = (ComboBoxItem) txtProduct.getSelectedItem();
   if (comboBoxItem == null) {
     JOptionPane.showMessageDialog(this, "You must select a product");
     return;
   }
   String productCode = comboBoxItem.getKey();
   double price = Services.getProductPrice(productCode);
   Integer qty = 0;
   try {
     qty = Integer.parseInt(txtQuantity.getText());
   } catch (Exception e) {
     LOGGER.error("", e);
     JOptionPane.showMessageDialog(this, "Invalid number format in Qty field");
     return;
   }
   double totalPrice = qty * price;
   defaultTableModel.addRow(new String[] {productCode, "" + qty, "" + price, "" + totalPrice});
   double currentValue = Utils.parseDouble(txtTotalPrice.getText());
   currentValue += totalPrice;
   txtTotalPrice.setText("" + currentValue);
 }