コード例 #1
0
  @Override
  public void initialize() throws Exception {
    dao = new RestaurantDAO();
    restaurant = dao.get(Integer.valueOf(1));

    tfRestaurantName.setText(restaurant.getName());
    tfAddressLine1.setText(restaurant.getAddressLine1());
    tfAddressLine2.setText(restaurant.getAddressLine2());
    tfAddressLine3.setText(restaurant.getAddressLine3());
    tfTelephone.setText(restaurant.getTelephone());
    tfCapacity.setText(String.valueOf(restaurant.getCapacity()));
    tfTable.setText(String.valueOf(restaurant.getTables()));
    tfCurrencyName.setText(restaurant.getCurrencyName());
    tfCurrencySymbol.setText(restaurant.getCurrencySymbol());

    setInitialized(true);
  }
コード例 #2
0
  @Override
  public boolean save() throws Exception {
    if (!isInitialized()) {
      return true;
    }

    String name = null;
    String addr1 = null;
    String addr2 = null;
    String addr3 = null;
    String telephone = null;
    String currencyName = null;
    String currencySymbol = null;

    int capacity = 299;
    int tables = 74;

    name = tfRestaurantName.getText();
    addr1 = tfAddressLine1.getText();
    addr2 = tfAddressLine2.getText();
    addr3 = tfAddressLine3.getText();
    telephone = tfTelephone.getText();
    currencyName = tfCurrencyName.getText();
    currencySymbol = tfCurrencySymbol.getText();

    if (StringUtils.isEmpty(currencyName)) {
      currencyName = com.floreantpos.POSConstants.DOLLAR;
    }
    if (StringUtils.isEmpty(currencySymbol)) {
      currencySymbol = "$";
    }

    try {
      capacity = Integer.parseInt(tfCapacity.getText());
    } catch (Exception e) {
      POSMessageDialog.showError(this, com.floreantpos.POSConstants.CAPACITY_IS_NOT_VALID_);
      return false;
    }

    try {
      tables = Integer.parseInt(tfTable.getText());
    } catch (Exception e) {
      POSMessageDialog.showError(this, com.floreantpos.POSConstants.NUMBER_OF_TABLES_IS_NOT_VALID);
      return false;
    }

    restaurant.setName(name);
    restaurant.setAddressLine1(addr1);
    restaurant.setAddressLine2(addr2);
    restaurant.setAddressLine3(addr3);
    restaurant.setTelephone(telephone);
    restaurant.setCapacity(capacity);
    restaurant.setTables(tables);
    restaurant.setCurrencyName(currencyName);
    restaurant.setCurrencySymbol(currencySymbol);

    dao.saveOrUpdate(restaurant);

    Application.getInstance().refreshRestaurant();

    return true;
  }