// Try to update
if (new PreparedSentence(s,
"UPDATE PRODUCTS SET REFERENCE = ?, CODE = ?, NAME = ?, PRICEBUY = ?, PRICESELL = ?, CATEGORY = ?, TAXCAT = ?, IMAGE = ? WHERE ID = ?",
SerializerWriteParams.INSTANCE
).exec(new DataParams() { public void writeValues() throws BasicException {
setString(1, prod.getReference());
setString(2, prod.getCode());
setString(3, prod.getName());
// setBoolean(x, p.isCom());
// setBoolean(x, p.isScale());
setDouble(4, prod.getPriceBuy());
setDouble(5, prod.getPriceSell());
setString(6, prod.getCategoryID());
setString(7, prod.getTaxCategoryID());
setBytes(8, ImageUtils.writeImage(prod.getImage()));
// setDouble(x, 0.0);
// setDouble(x, 0.0);
setString(9, prod.getID());
}}) == 0) {
// If not updated, try to insert
new PreparedSentence(s,
"INSERT INTO PRODUCTS (ID, REFERENCE, CODE, NAME, ISCOM, ISSCALE, PRICEBUY, PRICESELL, CATEGORY, TAXCAT, IMAGE, STOCKCOST, STOCKVOLUME) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
SerializerWriteParams.INSTANCE
).exec(new DataParams() { public void writeValues() throws BasicException {
setString(1, prod.getID());
setString(2, prod.getReference());
setString(3, prod.getCode());
setString(4, prod.getName());
setBoolean(5, prod.isCom());