Пример #1
0
  @Override
  public boolean deleteOrder(Order order) {
    boolean completedDelete = false;

    try {
      cs = bd.getConn().prepareCall("{call deleteOrder(?, ?, ?)}");
      cs.setDate(1, (Date) order.getDate());
      cs.setDouble(2, order.getSubtotal());
      cs.setDouble(3, order.getTotal());

      cs.executeUpdate();

      completedDelete = true;

    } catch (Exception e) {
      System.out.println(e);
    }
    return completedDelete;
  }
Пример #2
0
  @Override
  public Order getOrdersByName(String orderNameToCheck) {
    Order requestedOrder = null;
    try {

      cs = bd.getConn().prepareCall("{call getOrder(?)}");
      cs.setString(1, orderNameToCheck);
      ResultSet rs = cs.executeQuery();

      while (rs.next()) {

        requestedOrder.setIdOrder(rs.getInt("id_order"));
        requestedOrder.setDate(rs.getDate("date"));
        requestedOrder.setSubtotal(rs.getDouble("subtotal"));
        requestedOrder.setTotal(rs.getDouble("total"));
      }
    } catch (Exception e) {
      System.out.println(e);
    }
    return requestedOrder;
  }
Пример #3
0
  @Override
  public boolean updateOrder(
      Order order, java.util.Date oldDate, Double oldSubTotal, Double oldTotal) {
    boolean updateOrder = false;
    try {
      cs = bd.getConn().prepareCall("{call updateOrder(?, ?, ?, ?, ?, ?)}");
      cs.setDate(1, (Date) order.getDate());
      cs.setDouble(2, order.getSubtotal());
      cs.setDouble(3, order.getTotal());
      cs.setDate(4, (Date) oldDate);
      cs.setDouble(5, oldSubTotal);
      cs.setDouble(6, oldTotal);

      cs.executeUpdate();

      updateOrder = true;
    } catch (Exception e) {
      System.out.println(e);
    }
    return updateOrder;
  }
Пример #4
0
  @Override
  public ArrayList<Order> getAll() {
    ArrayList<Order> orderList = new ArrayList<>();

    try {

      cs = bd.getConn().prepareCall("{call getAllOrders()}");
      ResultSet rs = cs.executeQuery();

      while (rs.next()) {
        Order orderToBeAdded = null;
        orderToBeAdded.setIdOrder(rs.getInt("id_order"));
        orderToBeAdded.setDate(rs.getDate("date"));
        orderToBeAdded.setSubtotal(rs.getDouble("subtotal"));
        orderToBeAdded.setTotal(rs.getDouble("Total"));

        orderList.add(orderToBeAdded);
      }
    } catch (Exception e) {

    }
    return orderList;
  }