//login.java
//package bankclass;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;
//系统登录后主界面
public class login extends JFrame implements ActionListener{
//数据库连接变量
private Statement st=null;
private Connection con=null;
private ResultSet rs=null;
private String command=null;
private boolean flag1=true;
private boolean flag2=false;
private String getCardNum=null;
private String getpswd=null;
//布局变量
private JLabel cardInfo=new JLabel("请输入卡号和口令");
private JLabel cardNumLabel=new JLabel("卡 号:");
private JTextField cardNum=new JTextField(19);
private JLabel cardpswdLabel=new JLabel("口 令:");
private JButton confirmpswd=new JButton("确认口令");
private JPasswordField cardpswd=new JPasswordField(8);
private JButton queryBalance=new JButton("查询余额");
private JButton withDraw=new JButton("取 款");
private JButton desposit=new JButton("存 款");
private JButton transfer=new JButton("转 账");
private JButton chpswd=new JButton("修改密码");
private JLabel resultLabel=new JLabel("操 作 结 果");
//private JButton isOK=new JButton("确认");
private JButton reEnter=new JButton("重新输入");
private JButton addUser=new JButton("注册用户");
private JButton delUser=new JButton("注销用户");
private JButton addNewCard=new JButton("办卡");
private JButton delOldCard=new JButton("销卡");
private JButton userInfo=new JButton("用户信息");
private JButton endOperation=new JButton("结束操作");
private JButton helpFile=new JButton("帮助信息");
private JButton backupAll=new JButton("完全备份");
private JButton backupLogs=new JButton("日志备份");
private JButton restore=new JButton("数据恢复");
private String endOperationmsg=new String("真的要结束操作吗?");
private JButton image1;
private JTextArea resultArea=new JTextArea(10,300);
//菜单变量
//文件菜单变量
private JMenuItem fileChAdminpswd=new JMenuItem("修改Admin密码");
private JMenuItem fileRelog=new JMenuItem("重新登录...");
private JMenuItem fileExit=new JMenuItem("退出...");
private JMenu file=new JMenu("文件(F)");
//操作菜单变量
private JMenuItem operAddNewUser=new JMenuItem("注册用户");
private JMenuItem operDelUser=new JMenuItem("注销用户");
private JMenuItem operAddNewCard=new JMenuItem("办 卡");
private JMenuItem operDelOldCard=new JMenuItem("销 卡");
private JMenuItem operUserInfo=new JMenuItem("用户信息");
private JMenuItem operQueryBalance=new JMenuItem("查询余额");
private JMenuItem operWithDraw=new JMenuItem("取 款");
private JMenuItem operDesposit=new JMenuItem("存 款");
private JMenuItem operTransfer=new JMenuItem("转 账");
private JMenuItem operChpswd=new JMenuItem("修改密码");
private JMenuItem operBackupAll=new JMenuItem("完全备份");
private JMenuItem operBackupLogs=new JMenuItem("日志备份");
private JMenuItem operRestore=new JMenuItem("数据恢复");
private JMenu operation=new JMenu("操作(O)");
//帮助菜单变量
private JMenuItem helpHelp=new JMenuItem("帮 助");
private JMenuItem helpAbout=new JMenuItem("关于...");
private JMenu help=new JMenu("帮助(H)");
//构造方法
public login(){
setTitle(" 银行存储管理系统(BSMS)");
setSize(800,600);
setLocation(200,250);
initMenu(); //初始化菜单
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
int opt=JOptionPane.showConfirmDialog(null,"你还没有备份数据库和日志,真的要退出吗?","退出",JOptionPane.YES_NO_OPTION,JOptionPane.INFORMATION_MESSAGE);
if(opt==JOptionPane.YES_OPTION){
System.exit(0);
}
}
});
resultArea.setEditable(false);
resultArea.setLineWrap(true);
Container c=getContentPane();
c.setLayout(null);
//用户卡号信息Label
c.add(cardInfo);
cardInfo.setFont(new Font("华文行楷",Font.BOLD,23));
cardInfo.setBounds(200,5,200,60);
//卡号相关
c.add(cardNumLabel);
cardNumLabel.setBounds(140,60,40,40);
c.add(cardNum);
cardNum.setBounds(190,60,230,40);
//口令相关
c.add(cardpswdLabel);
cardpswdLabel.setBounds(140,115,40,40);
c.add(cardpswd);
cardpswd.setBounds(190,115,230,40);
c.add(confirmpswd);
confirmpswd.setBounds(435,60,90,40);
confirmpswd.addActionListener(this);
c.add(reEnter);
reEnter.setBounds(435,115,90,40);
reEnter.addActionListener(this);
//存,取,查,转账,修改密码按钮
c.add(queryBalance);
queryBalance.setBounds(25,260,90,40);
queryBalance.addActionListener(this);
c.add(withDraw);
withDraw.setBounds(25,310,90,40);
withDraw.addActionListener(this);
c.add(desposit);
desposit.setBounds(25,360,90,40);
desposit.addActionListener(this);
c.add(transfer);
transfer.setBounds(25,410,90,40);
transfer.addActionListener(this);
c.add(chpswd);
chpswd.setBounds(25,460,90,40);
chpswd.addActionListener(this);
//办卡与用户相关按钮
c.add(addUser);
addUser.setBounds(115,180,90,40);
addUser.addActionListener(this);
c.add(delUser);
delUser.setBounds(230,180,90,40);
delUser.addActionListener(this);
c.add(userInfo);
userInfo.setBounds(345,180,90,40);
userInfo.addActionListener(this);
c.add(addNewCard);
addNewCard.setBounds(460,180,90,40);
addNewCard.addActionListener(this);
c.add(delOldCard);
delOldCard.setBounds(575,180,90,40);
delOldCard.addActionListener(this);
//备份与恢复及结束操作相关
c.add(backupAll);
backupAll.setBounds(665,260,90,40);
backupAll.addActionListener(this);
c.add(backupLogs);
backupLogs.setBounds(665,310,90,40);
backupLogs.addActionListener(this);
c.add(restore);
restore.setBounds(665,360,90,40);
restore.addActionListener(this);
c.add(endOperation);
endOperation.setBounds(665,410,90,40);
endOperation.addActionListener(this);
c.add(helpFile);
helpFile.setBounds(665,460,90,40);
helpFile.addActionListener(this);
//操作结果相关
c.add(resultLabel);
resultLabel.setFont(new Font("华文行楷",Font.BOLD,18));
resultLabel.setBounds(340,220,100,45);
JScrollPane scrollpane=new JScrollPane(resultArea);
c.add(scrollpane);
scrollpane.setBounds(160,260,460,240);
image1=new JButton(new ImageIcon("..\\image\\bbyu.jpg"));
c.add(image1);
image1.setBounds(590,10,160,125);
image1.addActionListener(this);
show();
}
//初始化菜单方法initMenu
public void initMenu(){
//添加文件菜单
file.add(fileChAdminpswd);
fileChAdminpswd.setEnabled(true);
fileChAdminpswd.addActionListener(this);
file.add(fileRelog);
fileRelog.setEnabled(true);
fileRelog.addActionListener(this);
file.add(fileExit);
fileExit.setEnabled(true);
fileExit.addActionListener(this);
//添加操作菜单
operation.add(operAddNewUser);
operAddNewUser.setEnabled(true);
operAddNewUser.addActionListener(this);
operation.add(operDelUser);
operDelUser.setEnabled(true);
operDelUser.addActionListener(this);
operation.add(operUserInfo);
operUserInfo.setEnabled(true);
operUserInfo.addActionListener(this);
operation.add(operQueryBalance);
operQueryBalance.setEnabled(true);
operQueryBalance.addActionListener(this);
operation.add(operChpswd);
operChpswd.setEnabled(true);
operChpswd.addActionListener(this);
//数据库完全备份菜单
operation.add(operBackupAll);
operBackupAll.setEnabled(true);
operBackupAll.addActionListener(this);
//数据库日志备份菜单
operation.add(operBackupLogs);
operBackupLogs.setEnabled(true);
operBackupLogs.addActionListener(this);
//数据库日志备份菜单
operation.add(operRestore);
operRestore.setEnabled(true);
operRestore.addActionListener(this);
operation.add(operAddNewCard);
operAddNewCard.setEnabled(true);
operAddNewCard.addActionListener(this);
operation.add(operDelOldCard);
operDel