public void actionPerformed(final ActionEvent e) {
List list = new ArrayList();
list = searchInfo(list);
updateTable(list, dftm);
}
private List searchInfo( List list) {
String sql = "select * from Tb_Spinfo where 1 = 1 ";
if (conditionName.getSelectedItem() != null &&
!conditionName.getSelectedItem().equals("---选择--")) {
sql = sql + " and category ='" + conditionName.getSelectedItem() +
"'";
}
String pyStr = ((JTextField) conditionContent.getEditor().
getEditorComponent()).getText().toString();
for (int i=0;i<=0;i++) {
if (!pyStr.equals("") || pyStr != null) {
sql = sql + " and spname like '" +pyStr + "%'";
} else if (conditionContent.getSelectedItem() != null &&
!conditionContent.getSelectedItem().equals("")) {
sql = sql + " and spname = '" +
conditionContent.getSelectedItem() +
"'";
} else {
sql =sql+"";
} }
System.out.println("search="+sql);
list = Dao.findForList(sql); {
return list;
}
}
}
conditionContent.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
queryButton.doClick();
}
});
List list = new ArrayList();
list = searchInfo(list);
updateTable(list, dftm);
}
private List searchInfo( List list) {
String sql = "select * from Tb_Spinfo where 1 = 1 ";
if (conditionName.getSelectedItem() != null &&
!conditionName.getSelectedItem().equals("---选择--")) {
sql = sql + " and category ='" + conditionName.getSelectedItem() +
"'";
}
String pyStr = ((JTextField) conditionContent.getEditor().
getEditorComponent()).getText().toString();
for (int i=0;i<=0;i++) {
if (!pyStr.equals("") || pyStr != null) {
sql = sql + " and spname like '" +pyStr + "%'";
} else if (conditionContent.getSelectedItem() != null &&
!conditionContent.getSelectedItem().equals("")) {
sql = sql + " and spname = '" +
conditionContent.getSelectedItem() +
"'";
} else {
sql =sql+"";
} }
System.out.println("search="+sql);
list = Dao.findForList(sql); {
return list;
}
}
}
conditionContent.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
queryButton.doClick();
}
});
public void actionPerformed(ActionEvent e) {
initSpComboBox();
}
});