|
楼主 |
发表于 2020-10-12 14:30:01
|
显示全部楼层
String a = myselect.getSelectedItem().toString();
String b = con.getText();
SafeInfo ss = new SafeInfo();
MyTabelModel m;
if (!a.equals("所有信息")) {
if (a.equals("保险编号")) {
int flag = 0;
char c;
for (int i = 0; i < b.length(); i++) {
c = b.charAt(i);
if (Character.isLetter(c)) {
flag = 1;
}
}
if (flag == 1) {
javax.swing.JOptionPane.showMessageDialog(null,
"<html><font color=red>请输入一个数字!</font></html>",
"系统消息", JOptionPane.ERROR_MESSAGE);
m = null;
this.con.setText("");
this.con.requestFocus();
} else {
//我的查询语句 m = ss.getMyTabelModel("select * from SafeInfo where " + a +
"like '%" + b + "%'");
}
} else {
//我的查询语句 是这里报的错 m = ss.getMyTabelModel("select * from SafeInfo where " + a +
"like '%" + b + "%'");
}
} else {
m = ss.getMyTabelModel("select * from SafeInfo");
}
if (m != null) {
this.useTabel.setModel(m);
} else {
javax.swing.JOptionPane.showMessageDialog(null,
"<html><font color=red>没有您要找的数据,请仔细核对后再查</font></html>",
"系统消息", JOptionPane.ERROR_MESSAGE);
this.con.setText("");
this.con.requestFocus();
}
}
public void myselect_actionPerformed(ActionEvent e) {
if (this.myselect.getSelectedItem().toString().equals("所有信息")) {
this.con.setText("");
this.con.setEditable(false);
} else {
this.con.setEditable(true);
} |
|