PreparedStatement pyHistory = prepareStatement(
"INSERT INTO HISTORY(H_C_ID, H_C_D_ID, H_C_W_ID, H_D_ID, H_W_ID, " +
"H_DATE, H_AMOUNT, H_DATA) " +
"VALUES (?, ?, ?, ?, ?, CURRENT TIMESTAMP, ?, ?)");
Customer customer = new Customer();
customer.setWarehouse(cw);
customer.setDistrict(cd);
customer.setId(c);
// Update the customer assuming that they have good credit
pyCustomerPayment.setString(1, amount);
pyCustomerPayment.setString(2, amount);
pyCustomerPayment.setShort(3, cw);
pyCustomerPayment.setShort(4, cd);
pyCustomerPayment.setInt(5, c);
pyCustomerPayment.executeUpdate();
// Get the customer information
pyCustomerInfoId.setShort(1, cw);
pyCustomerInfoId.setShort(2, cd);
pyCustomerInfoId.setInt(3, c);
ResultSet rs = pyCustomerInfoId.executeQuery();
rs.next();
customer.setFirst(rs.getString("C_FIRST"));
customer.setMiddle(rs.getString("C_MIDDLE"));
customer.setLast(rs.getString("C_LAST"));
customer.setBalance(rs.getString("C_BALANCE"));
customer.setAddress(getAddress(rs, "C_STREET_1"));
customer.setPhone(rs.getString("C_PHONE"));
customer.setSince(rs.getTimestamp("C_SINCE"));
customer.setCredit(rs.getString("C_CREDIT"));
customer.setCredit_lim(rs.getString("C_CREDIT_LIM"));
customer.setDiscount(rs.getString("C_DISCOUNT"));
reset(pyCustomerInfoId);
// additional work for bad credit customers.
if ("BC".equals(customer.getCredit()))
{
pyCustomerUpdateBadCredit.setShort(1, w);
pyCustomerUpdateBadCredit.setShort(2, d);
pyCustomerUpdateBadCredit.setString(3, amount);
pyCustomerUpdateBadCredit.setShort(4, cw);
pyCustomerUpdateBadCredit.setShort(5, cd);
pyCustomerUpdateBadCredit.setInt(6, c);
pyCustomerUpdateBadCredit.executeUpdate();
reset(pyCustomerUpdateBadCredit);
// Need to display the first 200 characters
// of C_DATA information if the customer has
// bad credit.
pyCustomerGetData.setShort(1, cw);
pyCustomerGetData.setShort(2, cd);
pyCustomerGetData.setInt(3, c);
rs = pyCustomerGetData.executeQuery();
rs.next();
customer.setData(rs.getString("C_DATA_200"));
reset(pyCustomerGetData);
}
district.clear();
district.setWarehouse(w);