PreparedStatement result;
String temp = "";
JDBQuery query = new JDBQuery(Common.selectedHostID, Common.sessionID);
query.clear();
temp = Common.hostList.getHost(Common.selectedHostID).getSqlstatements().getSQL("JDBProcessOrder.selectWithLimit");
query.addText(temp);
query.addParamtoSQL("process_order=", jTextFieldProcessOrder.getText());
query.addParamtoSQL("material=", jTextFieldMaterial.getText());
query.addParamtoSQL("status=", jComboBoxStatus.getSelectedItem());
query.addParamtoSQL("location_id=", jTextFieldLocation.getText());
query.addParamtoSQL("recipe_id=", jTextFieldRecipe.getText());
query.addParamtoSQL("description like ", "%" + jTextFieldDescription.getText() + "%");
query.addParamtoSQL("required_resource = ", jTextFieldRequiredResource.getText());
query.addParamtoSQL("customer_id=", jTextFieldCustomer.getText());
query.addParamtoSQL("customer_id=",jTextFieldCustomerID.getText());
query.addParamtoSQL("required_uom=", ((JDBUom) jComboBoxUOM.getSelectedItem()).getInternalUom());
if (jCheckBoxDueDateFrom.isSelected())
{
query.addParamtoSQL("due_date>=", JUtility.getTimestampFromDate(dueDateFrom.getDate()));
}
if (jCheckBoxDueDateTo.isSelected())
{
query.addParamtoSQL("due_date<=", JUtility.getTimestampFromDate(dueDateTo.getDate()));
}
if (jCheckBoxQuantity.isSelected())
{
if (jFormattedTextFieldQuantity.getText().equals("") == false)
{
query.addParamtoSQL("required_quantity=", JUtility.stringToBigDecimal(jFormattedTextFieldQuantity.getText().toString()));
}
}
query.appendSort(jComboBoxSortBy.getSelectedItem().toString(), jToggleButtonSequence.isSelected());
query.applyRestriction(jCheckBoxLimit.isSelected(),Common.hostList.getHost(Common.selectedHostID).getDatabaseParameters().getjdbcDatabaseSelectLimit(), jSpinnerLimit.getValue());
query.bindParams();
result = query.getPreparedStatement();
return result;
}