一个DVD管理 可登陆等
private void loginActionPerformed(ActionEvent evt) {
String userName=this.userNameTxt.getText();
String password=new String(this.passwordTxt.getPassword());
User user=new User(userName);
new UserFrm(user);
if(StringUtil.isEmpty(userName)) {
JOptionPane.showMessageDialog(null,"用户名不能为空!");
return;
}
if(StringUtil.isEmpty(password)) {
JOptionPane.showMessageDialog(null,"密码不能为空!");
return;
}
User user1=new User(userName,password);
Connection con=null;
try {
con=dbUtil.getCon();
User currentUser=userDao.longin(con, user1);
if(currentUser!=null) {
dispose();
new MainFrm().setVisible(true);
JOptionPane.showMessageDialog(null,"登录成功!");
}else {
JOptionPane.showMessageDialog(null,"用户名或者密码错误!");
}
} catch (Exception e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
}
private void loginActionPerformed1(ActionEvent evt) {
String userName=this.userNameTxt.getText();
String password=new String(this.passwordTxt.getPassword());
if(StringUtil.isEmpty(userName)) {
JOptionPane.showMessageDialog(null,"用户名不能为空!");
return;
}
if(StringUtil.isEmpty(password)) {
JOptionPane.showMessageDialog(null,"密码不能为空!");
return;
}
User user=new User(userName,password);
Connection con=null;
try {
con=dbUtil.getCon();
User currentUser=userDao.longin(con, user);
if(currentUser!=null) {
dispose();
new UserFrm(user).setVisible(true);
JOptionPane.showMessageDialog(null,"登录成功!");
}else {
JOptionPane.showMessageDialog(null,"用户名或者密码错误!");
}
} catch (Exception e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}finally{
try {
dbUtil.closeCon(con);
} catch (Exception e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}}
}
评论