Java程序设计课程设计产品管理系统 第8页

JAVA产品管理系统

 xYLayout1.setHeight(239);

    this.setTitle("用户登录");

    getContentPane().add(panel1,  new XYConstraints(0, 0, -1, -1));

    this.getContentPane().add(jLabel1,  new XYConstraints(86, 49, 99, 34));

    this.getContentPane().add(jLabel2, new XYConstraints(88, 98, 80, 34));

    this.getContentPane().add(jTextFieldusername,   new XYConstraints(203, 50, 111, 31));

    this.getContentPane().add(jPasswordold,  new XYConstraints(204, 93, 110, 33));

    this.getContentPane().add(jButtonCancel,  new XYConstraints(201, 162, 94, 32));

    this.getContentPane().add(jButtonOK,  new XYConstraints(89, 163, 91, 31));

  }

  void jButtonCancel_mouseClicked(MouseEvent e) {

            this.dispose();

  }

//操作员登陆

  void jButtonOK_mouseClicked(MouseEvent e) {

    //检验用户名是否为空

    if(jTextFieldusername.getText().toString().trim().equals("") )

               { JOptionPane.showMessageDialog(null,"用户名不可为空!");

                    return;}

    //检验密码是否为空

       if(jPasswordold.getText().toString().trim().equals("") )

               {JOptionPane.showMessageDialog(null,"密码不可为空!");

                   return;}

      //定义字符串对象,代表sql语句

    String strSQL ;

    //生成sql语句,用户名和密码从相应文本框取得

strSQL="select*fromuserwhere Username='"+jTextFieldusername.getText().toString().trim() +"' and Password='"+jPasswordold.getText().toString().trim()+"'";

       //DBManager对象执行查询过程

     rs=db.getResult(strSQL) ;

      //判断结果集是否为空

                 boolean  isexist=false;

                try {

                  isexist = rs.first();

                }

                catch (SQLException ex1) {

                }

        //若为空,则说明用户名不存在或密码不正确,弹出警告信息,并设定主窗体权限为无

         if(!isexist )

            {JOptionPane.showMessageDialog(null,"用户名不存在,或密码不正确!");

               myMain.setEnable(false,false);

            }

       //若不为空,则说明用户名存在且密码正确,设定主窗体权限为有

          else

            {

              try {

                rs.first();

                //若为管理员...

                if (rs.getString("Power").equals("管理员")) {

                  myMain.setEnable(true, true);

                  this.dispose();

                 }

                 //若为操作员

                else {

                  myMain.setEnable(true, false);

                  this.dispose();

                }

              }

              catch (SQLException ex) {

              }

        }

  }

}若图片无法显示请联系QQ3249114,本论文免费,转发请注明源于www.751com.cn

  }

  public void mouseClicked(MouseEvent e) {

    adaptee.jButtonCancel_mouseClicked(e);

  }

}

class userLogin_jButtonOK_mouseAdapter extends java.awt.event.MouseAdapter {

  userLogin adaptee;

  userLogin_jButtonOK_mouseAdapter(userLogin adaptee) {

    this.adaptee = adaptee;

  }

  public void mouseClicked(MouseEvent e) {

    adaptee.jButtonOK_mouseClicked(e);

  }

}

上一页  [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]  ... 下一页  >> 

  • 上一篇文章:
  • 下一篇文章:
  • Copyright © 2007-2012 www.chuibin.com 六维论文网 版权所有