// Sync the Product in a transaction
// Try to update
if (new PreparedSentence(s,
"UPDATE PRODUCTS SET REFERENCE = ?, NAME = ?, ISSCALE = ?, PRICEBUY = ?, PRICESELL = ?, CATEGORY = ?, TAXCAT = ?, IMAGE = ?, ATTRIBUTESET_ID = ? WHERE CODE = ?",
SerializerWriteParams.INSTANCE
).exec(new DataParams() { public void writeValues() throws BasicException {
setString(1, prod.getReference());
setString(2, prod.getName());
// setBoolean(x, p.isCom());
setBoolean(3, prod.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.getAttributeSetID());
setString(10, prod.getCode());
}}) == 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, ATTRIBUTESET_ID) 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());