コード例 #1
0
 /**
  * gets the information from the panel
  *
  * @return
  */
 public Membership getModel() {
   Membership membership = new Membership();
   try {
     membership.setDiscountPercentage(Integer.parseInt(newRate.getText()));
   } catch (NumberFormatException e) {
     MyFuelUtils.createPopUp("rate is invalid");
     return null;
   }
   membership.setMembershipType((EMembershipTypes) membershipCombo.getSelectedItem());
   return membership;
 }
コード例 #2
0
ファイル: FuelDAL.java プロジェクト: BraudeTeam13/try1
  /**
   * @param fuelType is the name of the fuel we look for
   * @return Fuel entity of the correct fuel with the information, if didn't find the fuel return
   *     null
   */
  public Fuel select(String fuelType) {
    Statement stmt = null;
    ResultSet rs = null;
    Fuel fuel = null;
    try {
      stmt = connection.createStatement();
      StringBuilder query = new StringBuilder();
      query.append("SELECT * FROM ");
      query.append(TABLE_NAME);
      query.append(" WHERE ");
      query.append(MyFuelUtils.generateQueryPartWithString(FUEL_TYPE, fuelType));
      String string = query.toString();
      rs = stmt.executeQuery(string);
      if (rs.next()) {
        fuel = new Fuel();
        fuel.setFuelType(MyFuelUtils.parseFuelStringToFuelEnum(rs.getString(FUEL_TYPE)));
        fuel.setMaxPrice(rs.getFloat(MAX_PRICE));
        fuel.setFuelSupplier(rs.getString(FUEL_SUPPLIER));
      }
    } catch (SQLException e) {
      e.printStackTrace();
      return null;
    } finally {
      if (rs != null) {
        try {
          rs.close();
        } catch (SQLException e) {
          e.printStackTrace();
        }
      }
      if (stmt != null) {
        try {
          stmt.close();
        } catch (SQLException e) {
          e.printStackTrace();
        }
      }
    }

    return fuel;
  }
コード例 #3
0
 /** activates select requested orders by manager id and return all requested orders */
 @Override
 public MyFuelMessage handleMessage(User message) {
   MyFuelMessage myFuelMessage = new MyFuelMessage();
   ArrayList<OrderForFuelSupplier> orders = new ArrayList<OrderForFuelSupplier>();
   try {
     orders = m_orderForFuelSupplierDAL.selectRequestedOrdersByManagerID(message.getUserID());
   } catch (Exception e) {
     MyFuelUtils.createPopUp("Could not perform get order by manager id query");
     e.getStackTrace();
   }
   myFuelMessage.setMessageType(MyFuelMessageType.GetAllRequestedOrders);
   OrderListWraper list = new OrderListWraper();
   list.setOrders(orders);
   myFuelMessage.setMessage(list);
   return myFuelMessage;
 }
コード例 #4
0
  @Override
  public MessageWithStatus handleMessage(OrderForFuelSupplier message) {
    MessageWithStatus status = new MessageWithStatus();
    boolean success = false;

    try {
      success = m_orderForFuelSupplierDAL.updateOrderStatus(message);
    } catch (Exception e) {
      MyFuelUtils.createPopUp("Could not perform update order status query");
      e.getStackTrace();
    }
    status.setStatus(success);
    if (success) {
      status.setMessageToDisplay(
          "Order " + message.getOrderNumber() + " was " + message.getOrderStatus());
    } else {
      status.setMessageToDisplay("Order update failed");
    }
    return status;
  }