コード例 #1
0
  // confirm a selling order by the customer
  public boolean confirmSellingOrder(List<OrderItem> list, Person person) {
    boolean flag = false;

    try {

      if (list.size() > 0) {
        DifferentOrder order1 = new DifferentOrder();
        order1.setOrderDate(new Date());
        order1.setOrderStatus("Order to be reviewed");
        order1.setOrderType("Seller Old");
        order1.setPerson(person);

        for (int i = 0; i < list.size(); i++) {
          OrderItem oi = new OrderItem();
          oi = list.get(i);
          // oi.setOrder(order);
        }

        Session session = HibernateUtil.getSessionFactory().openSession();
        Transaction tx = session.beginTransaction();
        session.save(order1);
        tx.commit();
        session.close();

        for (int i = 0; i < list.size(); i++) {
          OrderItem oi = new OrderItem();
          oi = list.get(i);
          oi.setOrderNo(order1);
          Session session1 = HibernateUtil.getSessionFactory().openSession();
          Transaction tx1 = session1.beginTransaction();
          session1.save(oi);
          tx1.commit();
          session1.close();
        }
        flag = true;
      }
    } catch (Exception e) {
      e.printStackTrace();
    }

    return flag;
  }
コード例 #2
0
  // updates the order item cost for the books to be sold by the customer
  public Boolean updateOrderitemCost(int orderitemId, Float cost) {
    Boolean flag = false;
    try {
      Session session1 = HibernateUtil.getSessionFactory().openSession();
      Transaction tx1 = session1.beginTransaction();
      OrderItem orderitem = (OrderItem) session1.get(OrderItem.class, orderitemId);
      Book book = orderitem.getBook();
      book.setProductCost(cost);
      orderitem.setBook(book);
      DifferentOrder order = orderitem.getOrderNo();
      order.setOrderAmount(orderitem.getQuantity() * orderitem.getBook().getProductCost());
      orderitem.setOrderNo(order);
      session1.update(order);
      session1.update(orderitem);
      flag = true;
      tx1.commit();
      session1.close();

    } catch (Exception e) {
      e.printStackTrace();
    }
    return flag;
  }
コード例 #3
0
  // confirm and place the order in the database
  public Boolean confirmOrder(
      List<OrderItem> list, List<OrderItem> newlist, Address address, Card card, Person person) {

    Boolean flag = false;
    float total = 0;
    try {

      if (list.size() > 0) {
        DifferentOrder order1 = new DifferentOrder();
        order1.setOrderDate(new Date());
        order1.setOrderStatus("Order to be reviewed");
        order1.setOrderType("Buyer Old");
        order1.setPerson(person);

        for (int i = 0; i < list.size(); i++) {
          OrderItem oi = new OrderItem();
          oi = list.get(i);
          // oi.setOrder(order);
          total = oi.getQuantity() * oi.getBook().getProductCost();
        }

        order1.setOrderAmount(total);
        Session session = HibernateUtil.getSessionFactory().openSession();
        Transaction tx = session.beginTransaction();
        session.save(order1);
        tx.commit();
        session.close();

        for (int i = 0; i < list.size(); i++) {
          OrderItem oi = new OrderItem();
          oi = list.get(i);
          oi.setOrderNo(order1);
          Session session1 = HibernateUtil.getSessionFactory().openSession();
          Transaction tx1 = session1.beginTransaction();
          session1.save(oi);
          tx1.commit();
          session1.close();
        }
        flag = true;
      }

      if (newlist.size() > 0) {
        DifferentOrder order1 = new DifferentOrder();
        order1.setOrderDate(new Date());
        order1.setOrderStatus("Order to be reviewed");
        order1.setOrderType("Buyer New");
        order1.setPerson(person);

        for (int i = 0; i < newlist.size(); i++) {
          OrderItem oi = new OrderItem();
          oi = newlist.get(i);
          // total= oi.getQuantity() * oi.getBook().getProductCost();
        }

        // order.setOrderAmount(total);
        Session session = HibernateUtil.getSessionFactory().openSession();
        Transaction tx = session.beginTransaction();
        session.save(order1);
        tx.commit();
        session.close();

        for (int i = 0; i < newlist.size(); i++) {
          OrderItem oi = new OrderItem();
          oi = newlist.get(i);
          oi.setOrderNo(order1);
          Session session1 = HibernateUtil.getSessionFactory().openSession();
          Transaction tx1 = session1.beginTransaction();
          session1.save(oi);
          tx1.commit();
          session1.close();
        }
        flag = true;
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
    return flag;
  }