⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 adminmanageframe.java

📁 酒店管理系统后台数据库存储过程
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            this.pswokpassword.requestFocus();
            return;
        }

        if(!pswpassword.getText().equals(pswokpassword.getText()))
        {
            JOptionPane.showMessageDialog(null,"两次输入的密码不一置!请重新输入!");
            this.pswokpassword.setText("");
            this.pswokpassword.requestFocus();
            return;
        }

        //判断该员工是不是该酒店的注册员工

        String select = "select id from employee where id='"+txtid.getText()+"'";
        ResultSet rst = dbo.returnQuery(select);
        try {
            if (!rst.next())
            {
                JOptionPane.showMessageDialog(null,"该员工不存在!请重新输入正确的员工ID号");
                txtid.setText("");
                return;
            }
              rst.close();
        } catch (SQLException ex) {
            ex.printStackTrace();
        }
        //判断该员工是不是已经注册为管理员
        String sqls = "select id from admin where id='"+txtid.getText()+"'";
        ResultSet rsty = dbo.returnQuery(sqls);
        try {
            if (rsty.next()==true) {
                JOptionPane.showMessageDialog(this,"该员工已经注册为管理员!!管理员不能二次注册!!","提示",JOptionPane.INFORMATION_MESSAGE);
                return;
            }

        } catch (SQLException ex) {
            ex.printStackTrace();
        }

        String sql = "select name from admin where name ='"+txtusername1.getText()+"'";
        ResultSet rs=dbo.returnQuery(sql);
        try {
            if (rs.next())
            {
                JOptionPane.showMessageDialog(null,"帐户已存在,请重新输入");
                this.txtusername1.setText("");
                return;
            }
            else
            {
                String insert="insert admin(id,name,password,remark) values('"+txtid.getText()+"','"+ txtusername1.getText()+"','"+pswpassword.getText()+"','"+cboClass.getSelectedItem()+"')";
                dbo.updateNoReturn(insert);
                System.out.println(insert);
                JOptionPane.showMessageDialog(null,"注册成功!");

                this.txtusername1.setText("");
                this.txtid.setText("");
                this.pswpassword.setText("");
                this.pswokpassword.setText("");

            }

        }  catch (SQLException ex) {
            ex.printStackTrace();
        }



    }


    public void btnrescript_actionPerformed(ActionEvent e) {
        txtusername1.setText("");
        pswpassword.setText("");
        pswokpassword.setText("");
        txtid.setText("");
    }



    public void btnlogin_actionPerformed(ActionEvent e) {
        registPan.setVisible(true);
        deletePan.setVisible(false);
        resetPan.setVisible(false);
    }

    public void btndelete_actionPerformed(ActionEvent e) {
        registPan.setVisible(false);
        deletePan.setVisible(true);
        resetPan.setVisible(false);
    }

    public void btnupdate_actionPerformed(ActionEvent e) {
        registPan.setVisible(false);
        deletePan.setVisible(false);
        resetPan.setVisible(true);

    }

    public void btnok_actionPerformed(ActionEvent e) {
        if(this.txtusername2.getText().equals(""))
        {
            JOptionPane.showMessageDialog(null,"管理员帐号不能为空!");
            this.txtusername2.requestFocus();
            return;
        }
        if(this.txtpsw.getText().equals(""))
        {
            JOptionPane.showMessageDialog(null,"管理员密码不能为空!");
            this.txtpsw.requestFocus();
            return;
        }
        String select= "select name,password from admin where name='"+txtusername2.getText()+"' and password='"+txtpsw.getText()+"'";
        ResultSet rs = dbo.returnQuery(select);
        try {
            if (rs.next())
            {
                Object [] op = {"确定","取消"};
             int option =   JOptionPane.showOptionDialog(this,"确认要删除该管理员吗??","确认",
                                             JOptionPane.OK_CANCEL_OPTION,JOptionPane.QUESTION_MESSAGE,null,op,op[1]);
               if(option==0)
               {
                   String del = "delete from admin where name='" +
                                txtusername2.getText() + "' and password = '" +
                                txtpsw.getText() + "'";
                   if (dbo.updateNoReturn(del)) {
                       JOptionPane.showMessageDialog(this, "删除成功!");
                   } else {
                       JOptionPane.showMessageDialog(this, "删除失败!");
                   }
               }
               else
               {
                   return;
               }
            }
            else
            {
                JOptionPane.showMessageDialog(this,"用户名或密码错误!请重新输入");
                txtusername2.setText("");
                txtpsw.setText("");
            }
        } catch (SQLException ex) {
            ex.printStackTrace();
        }

    }

    public void jButton1_actionPerformed(ActionEvent e) {

        if(txtUserName3.getText().equals(""))
        {
            JOptionPane.showMessageDialog(this,"管理员帐号不能为空!");
            this.txtUserName3.requestFocus();
            return;
        }
        if(txtOldPsw.getText().equals(""))
        {
            JOptionPane.showMessageDialog(this,"旧密码不能为空!");
            this.txtOldPsw.requestFocus();
            return;
        }
        if(txtNewPsw.getText().equals(""))
        {
            JOptionPane.showMessageDialog(this,"新密码不能为空!");
            this.txtNewPsw.requestFocus();
            return;
        }
        if(txtNewConfirPsw.getText().equals(""))
        {
            JOptionPane.showMessageDialog(this,"确认新密码不能为空!");
            this.txtNewConfirPsw.requestFocus();
            return;
        }
        if(!txtNewPsw.getText().equals(txtNewConfirPsw.getText()))
        {
            JOptionPane.showMessageDialog(this,"两次输入的密码不一置,请重新输入!");

            txtNewConfirPsw.setText("");
            this.txtNewConfirPsw.requestFocus();
            return;
        }
        //查询该管理员是否存在
        String select= "select name,password from admin where name='"+
                        txtUserName3.getText()+"' and password='"+
        this.txtOldPsw.getText()+"'";
        ResultSet rs = dbo.returnQuery(select);
        try {
            if (rs.next())
            {
                //如果存在可以对其进行修改
                String update="update admin set password='"+
    this.txtNewPsw.getText()+"' where name='"+this.txtUserName3.getText()+"' and password='"+ txtOldPsw.getText()+"'";
                dbo.updateNoReturn(update);
                JOptionPane.showMessageDialog(this,"修改已成功!");
                return;
            }
            else
            {
                //如果不存在提示用户,输入错误
                JOptionPane.showMessageDialog(null,"用户名或密码错误!请重新输入");
                txtusername2.setText("");
                txtpsw.setText("");
            }
        } catch (SQLException ex) {
            ex.printStackTrace();
        }

    }

    public void btnExit_actionPerformed(ActionEvent e) {
        this.dispose();
    }
    //设置重置按钮事件
    public void btnResetRe_actionPerformed(ActionEvent e) {
          this.txtUserName3.setText("");
          this.txtOldPsw.setText("");
          this.txtNewPsw.setText("");
          this.txtNewConfirPsw.setText("");
    }

    public void btnResetDel_actionPerformed(ActionEvent e) {
    this.txtusername2.setText("");
    this.txtpsw.setText("");

    }
}


class AdminManageFrame_btnResetDel_actionAdapter implements ActionListener {
    private AdminManageFrame adaptee;
    AdminManageFrame_btnResetDel_actionAdapter(AdminManageFrame adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {

        adaptee.btnResetDel_actionPerformed(e);
    }
}


class AdminManageFrame_btnResetRe_actionAdapter implements ActionListener {
    private AdminManageFrame adaptee;
    AdminManageFrame_btnResetRe_actionAdapter(AdminManageFrame adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {

        adaptee.btnResetRe_actionPerformed(e);
    }
}


class AdminManageFrame_btnExit_actionAdapter implements ActionListener {
    private AdminManageFrame adaptee;
    AdminManageFrame_btnExit_actionAdapter(AdminManageFrame adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.btnExit_actionPerformed(e);
    }
}


class AdminManageFrame_jButton1_actionAdapter implements ActionListener {
    private AdminManageFrame adaptee;
    AdminManageFrame_jButton1_actionAdapter(AdminManageFrame adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.jButton1_actionPerformed(e);
    }
}


class AdminManageFrame_btnok_actionAdapter implements ActionListener {
    private AdminManageFrame adaptee;
    AdminManageFrame_btnok_actionAdapter(AdminManageFrame adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.btnok_actionPerformed(e);
    }
}


class AdminManageFrame_btnupdate_actionAdapter implements ActionListener {
    private AdminManageFrame adaptee;
    AdminManageFrame_btnupdate_actionAdapter(AdminManageFrame adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.btnupdate_actionPerformed(e);
    }
}


class AdminManageFrame_btndelete_actionAdapter implements ActionListener {
    private AdminManageFrame adaptee;
    AdminManageFrame_btndelete_actionAdapter(AdminManageFrame adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.btndelete_actionPerformed(e);
    }
}


class AdminManageFrame_btnlogin_actionAdapter implements ActionListener {
    private AdminManageFrame adaptee;
    AdminManageFrame_btnlogin_actionAdapter(AdminManageFrame adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.btnlogin_actionPerformed(e);
    }
}


class AdminManageFrame_btnrescript_actionAdapter implements ActionListener {
    private AdminManageFrame adaptee;
    AdminManageFrame_btnrescript_actionAdapter(AdminManageFrame adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.btnrescript_actionPerformed(e);
    }
}


class AdminManageFrame_tbnok_actionAdapter implements ActionListener {
    private AdminManageFrame adaptee;
    AdminManageFrame_tbnok_actionAdapter(AdminManageFrame adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {

        adaptee.tbnok_actionPerformed(e);
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -