private void buildSQL() {
JDBQuery2.closeStatement(listStatement);
JDBQuery2 q2 = new JDBQuery2(Common.selectedHostID, Common.sessionID);
q2.applyWhat("*");
q2.applyFrom("{schema}VIEW_PALLET_HISTORY_EXPIRY");
if (jCheckBoxTransactionDate.isSelected())
{
q2.applyWhere("transaction_date>=", JUtility.getTimestampFromDate(transactionDateFrom.getDate()));
q2.applyWhere("transaction_date<=", JUtility.getTimestampFromDate(transactionDateTo.getDate()));
}
if (jTextFieldTransaction_Ref.getText().equals("") == false)
{
q2.applyWhere("transaction_ref = ", jTextFieldTransaction_Ref.getText());
}
if (jTextFieldSSCC.getText().equals("") == false)
{
q2.applyWhere("sscc = ", jTextFieldSSCC.getText());
}
if (jTextFieldMaterial.getText().equals("") == false)
{
q2.applyWhere("material = ", jTextFieldMaterial.getText());
}
if (jTextFieldBatch.getText().equals("") == false)
{
q2.applyWhere("batch_number like ", jTextFieldBatch.getText());
}
if (jTextFieldProcessOrder.getText().equals("") == false)
{
q2.applyWhere("process_order = ", jTextFieldProcessOrder.getText());
}
if (jTextFieldLocation.getText().equals("") == false)
{
q2.applyWhere("location_id = ", jTextFieldLocation.getText());
}
if (jTextFieldUser.getText().equals("") == false)
{
q2.applyWhere("user_id = ", jTextFieldUser.getText());
}
if (jTextFieldEAN.getText().equals("") == false)
{
q2.applyWhere("EAN = ", jTextFieldEAN.getText());
}
if (jTextFieldDespatch_No.getText().equals("") == false)
{
q2.applyWhere("DESPATCH_NO = ", jTextFieldDespatch_No.getText());
}
if (jTextFieldVariant.getText().equals("") == false)
{
q2.applyWhere("variant = ", jTextFieldVariant.getText());
}
q2.applyWhere("transaction_type=", (String) comboBoxTransactionType.getSelectedItem());
q2.applyWhere("transaction_subtype=", (String) comboBoxTransactionSubtype.getSelectedItem());
q2.applyWhere("uom=", ((JDBUom) jComboBoxUOM.getSelectedItem()).getInternalUom());
q2.applyWhere("status=", ((String) jComboBoxPalletStatus.getSelectedItem()).toString());
if (jCheckBoxQuantity.isSelected())
{
if (jFormattedTextFieldQuantity.getText().equals("") == false)
{
q2.applyWhere("quantity=",JUtility.stringToBigDecimal(jFormattedTextFieldQuantity.getText().toString()));
}
}
Integer i;
try
{
i = Integer.valueOf(jFormattedTextFieldQuantity.getText());
q2.applyWhere("quantity=", i);
}
catch (Exception e)
{
}
q2.applySort(jComboBoxSortBy.getSelectedItem().toString(), jToggleButtonSequence.isSelected());
q2.applyRestriction(jCheckBoxLimit.isSelected(), jSpinnerLimit.getValue());
q2.applySQL();
listStatement = q2.getPreparedStatement();
}