コード例 #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
  // 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;
  }