如何在删除表单中验证

时间:2017-05-27 13:49:42

标签: java

我试图按顺序获取消息,但似乎有些不对劲,当我测试删除不在数据库中的数据时,我将确认删除该数据的消息,它会说数据被删除。

private void deleteTeacherActionPerformed(java.awt.event.ActionEvent evt) {                                           

    String id = tfTeacherID.getText();

    if (Validation.textNotEmpty(tfTeacherID)) {             
        int f = JOptionPane.showConfirmDialog(null, "are you sure want to delete teacher ID: "+id+"?", "Delete", JOptionPane.YES_NO_OPTION);

        if (f==0) {             
            try {
                if (id.equals(null)) {  
                    JOptionPane.showMessageDialog(null, "NO teacher with this ID!"); 
                }

                databas.delete("delete from teacher where teacher_id = ("+id+");");

                JOptionPane.showMessageDialog(rootPane, "teacher deleted");

            } catch(InfException ex) {  
                System.out.println(ex.getMessage());
            }           
        }
    }
}

0 个答案:

没有答案