62,628
社区成员
发帖
与我相关
我的任务
分享
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(e.getSource()==btn1){
sid = "401";
}
if(e.getSource()==btn2){
sid = "402";
}
if(e.getSource()==btn3){
sid = "403";
}
if(e.getSource()==btn4){
sid = "404";
}
if(e.getSource()==btn5){
sid = "405";
}
if(e.getSource()==btn6){
sid = "406";
}
if(e.getSource()==btn7){
sid = "407";
}
if(e.getSource()==btn8){
sid = "408";
}
if(e.getSource()==btn9){
sid = "409";
}
if(e.getSource()==btn10){
sid = "410";
}
if(e.getSource()==btn11){
sid = "411";
}
if(e.getSource()==btn12){
sid = "412";
}
String url = "jdbc:odbc:hosiptal";
String SQL = "SELECT * FROM Patient";
Connection conn;
PreparedStatement sql;
ResultSet rs;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
} catch (ClassNotFoundException e2) {
// TODO: handle exception
}
try {
conn = DriverManager.getConnection(url);
sql = conn.prepareStatement(SQL);
rs = sql.executeQuery();
// while(rs.next()){
if(rs.next()){
String sid1 = rs.getString(12);
if(sid.equals(sid1)){
JOptionPane.showMessageDialog(null, "该病房已满!");
}
else{
JOptionPane.showMessageDialog(null, "该病房空闲!");
this.setVisible(false);
}
}
} catch (SQLException e2) {
// TODO: handle exception
e2.printStackTrace();
}
}
}