private void saveOrderItems( OrderItem[] orderItems, long transactionId, String cashier, Student student) throws DAOException { String timeStamp = currentTimeStamp(); for (OrderItem orderItem : orderItems) { String sql = "insert into " + posTablesPrefix + "trans_item ( " + "ti_itemid, ti_tmid, ti_pricesold, ti_registerid, ti_cashier, ti_studentid, ti_isfree, ti_isreduced, ti_datetime, " + "ti_istypea ) values(" + orderItem.getDBID() + ", " + transactionId + ", " + orderItem.getEffectivePrice() + ", '" + Utils.getHostName() + "', '" + cashier + "', '" + student.getStudentNumber() + "', '" + bool2int(orderItem.isSoldAsFree()) + "', '" + bool2int(orderItem.isSoldAsReduced()) + "', '" + timeStamp + "', '" + bool2int(orderItem.isTypeA()) + "')"; if (executeUpdateSql(sql) != 1) { throw new TransactionManagerException( "Sql statement [" + sql + "] wasn't executed successfully"); } } }
public int compare(OrderItem o1, OrderItem o2) { return o1.getDBID() - o2.getDBID(); }