📄 loginhandler.java
字号:
package card;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2007</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class LoginHandler implements ActionListener {
LoginFrame lf;
usermodel um = new usermodel();
DatabaseOperate dop=new DatabaseOperate();
public LoginHandler() {
}
public void actionPerformed(ActionEvent e) {
if (e.getSource().equals(lf.btnLogin)) {
if (checkInput()) {
if(checkInfo()){
Static.setUmodel(um);//程序共享属性 以便得知当前操作员的用户名
new SelectFrame();//替换主窗口类
lf.dispose();
Static.getTodayBirthdayDialog();
}
}
}
if (e.getSource().equals(lf.btnRes)) {
System.exit(0);
}
}
public boolean checkInfo() {
boolean b = true;
um.setUsername(lf.txtUserName.getText().trim());
um.setPassword(String.valueOf(lf.psUserPassword.getPassword()).trim());
int e=dop.checkLoginInfo(um);
if (e != 0) {
if (e == 1) {
showErr(4);
} else if (e == 2) {
showErr(3);
}
return false;
}
return b;
}
public boolean checkInput() {
boolean b = true;
if (lf.txtUserName.getText().equals("")) {
showErr(1);
b = false;
} else if (lf.psUserPassword.getPassword().length == 0) {
showErr(2);
b = false;
}
return b;
}
public void showErr(int i) {
String[] err = {"请输入用户名!", "请输入密码!", "无此用户名!", "密码不正确!"};
for (int j = 0; j < err.length; j++) {
if (j == i - 1) {
lf.lblErr.setText(err[j]);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -