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

📄 login_check.java

📁 很好的Java绘图程序源代码
💻 JAVA
字号:
package project;

import java.sql.ResultSet;
import java.sql.*;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JDialog;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2007</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class Login_check {
  DataBase db = null;
  JFrame mainframe = null;
  JDialog login = null;

  public Login_check(JFrame mainframe, JDialog login) {
    this.mainframe = mainframe;
    this.login = login;
    db = new DataBase();
  }

  public void check_login(String login_name, String password) {
    int res = -1;
    String userName = null;
    String sql = "select * from login_table where loginName='" + login_name +
        "' and password= '" + password + "'";
    ResultSet rs = db.executeQuery(sql);
    if (rs == null) {
      JOptionPane.showMessageDialog(this.login, "数据库连接错误!", "提示",
                                    JOptionPane.ERROR_MESSAGE);
      return;
    }
    try {
      if (rs.next()) {
        userName = rs.getString(1);
        res = rs.getInt(3);
      }
    }
    catch (SQLException ex) {
      ex.printStackTrace();
    }
    finally {
      try {
        rs.close();
        db.close();
      }
      catch (SQLException ex1) {
        ex1.printStackTrace();
      }
      finally {
        Frame1 temp = (Frame1)this.mainframe;
        Login_View tmp = (Login_View)this.login;
        switch (res) {
          case 0:
          case 1:
          case 2:
            temp.set_userName(userName);
            temp.set_privilege_int(res);
            JOptionPane.showMessageDialog(this.login,
                                          "尊敬的" + userName + " ,欢迎使用人事管理软件!",
                                          "提示", JOptionPane.INFORMATION_MESSAGE);
            this.login.dispose();
            break;
          default:
            JOptionPane.showMessageDialog(this.login, "用户名或密码错误!", "提示",
                                          JOptionPane.ERROR_MESSAGE);
            tmp.set_focus();
        }
      }

    }

  }

}

⌨️ 快捷键说明

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