上传者: xqh881122
|
上传时间: 2019-12-21 18:57:56
|
文件大小: 4.13MB
|
文件类型: zip
java项目package project.action.dialogAction;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JOptionPane;
import project.dao.common.DbException;
import project.dao.dataDao.LoginInfoDao;
import project.dao.dataDaoImpl.LoginInfoDaoImpl;
import project.view.dialog.AddLoginInfoDialog;
import project.vo.LoginInfoVo;
/**
* 添加登录账号action
*
* @author Administrator
*
*/
public class AddLoginInfoAction implements ActionListener {
private AddLoginInfoDialog dialog;
public AddLoginInfoAction(AddLoginInfoDialog dialog) {
this.dialog = dialog;
}
public void actionPerformed(ActionEvent e) {
String name = e.getActionCommand();
if (name.equals("确定")) {
// 检验输入是否正确
if (dialog.checkInputValue()) {
LoginInfoDao dao = null;
LoginInfoVo vo = null;
try {
// 获得界面输入信息
vo = dialog.getInputInfo();
String confirm = dialog.getConfirm();
if (vo.getLog_pwd().equals(confirm)) {
dao = new LoginInfoDaoImpl();
if (dao.insertLoginInfo(vo)) {
// 打印提示信息
JOptionPane.showMessageDialog(null, "添加登录人员成功", "提示信息",
JOptionPane.YES_OPTION);
dialog.dispose();
} else {
// 打印提示信息
JOptionPane.showMessageDialog(null, "添加登录人员失败", "提示信息",
JOptionPane.YES_OPTION);
}
} else {
// 如果密码确认输入错误,打印提示信息
JOptionPane.showMessageDialog(null, "密码确认错误,请重新输入", "提示信息",
JOptionPane.YES_OPTION);
}
} catch (DbException ex) {
JOptionPane.showMessageDialog(null, ex.getMessage(), "提示信息",
JOptionPane.YES_OPTION);
}
} else {
JOptionPane.showMessageDialog(null, "请确认输入是否完整正确", "提示信息",
JOptionPane.YES_OPTION);
}
} else if (name.equals("取消")) {
dialog.dispose();
}
}
}