欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

完整版银行ATM机的实现

程序员文章站 2024-02-27 19:21:57
...

本文章是模拟银行ATM机,全程手工代码。

代码:

数据库连接及查询设计:(我用的是SQL SERVER2014,具体的数据库名字什么的你们还是要改成自己的)

完整版银行ATM机的实现

数据库我就不上传了,具体我定义了6个表,截图如下:

完整版银行ATM机的实现

Eclipse代码布局:

完整版银行ATM机的实现

(1)JDBC(连接数据库)

package com.mwq.dao.dao;

import java.sql.Connection;
import java.sql.DriverManager;

public class JDBC {
	  private static final String driverName="com.microsoft.sqlserver.jdbc.SQLServerDriver";
	  private static final String URL="jdbc:sqlserver://localhost:1433;DatabaseName=20174390407顾凌嫣_银行管理";
	  private static final String USERNAME="sa";
	  private static final String PASSWORD="123456";
	  static {
		  try
			{
			    Class.forName(driverName).newInstance();
			    System.out.println("加载驱动成功!");
			}catch(Exception e){
			    e.printStackTrace();
			    System.out.println("加载驱动失败!");
			}
	  }
	 public static Connection getConnection() {//连接数据库
		 Connection conn=null;
		 try{
			    conn=DriverManager.getConnection(URL,USERNAME,PASSWORD);
			    System.out.println("连接数据库成功!");
			}catch(Exception e)
			{
			    e.printStackTrace();
			    System.out.print("SQL Server连接失败!");
			}        
		 return conn;
	 }
	 public static boolean closeConnection() {//关闭数据库
		 boolean isClose=true;
		 Connection conn=JDBC.getConnection();
		 if(conn!=null) {
			 try{
				    conn.close();
				    System.out.println("关闭数据库成功!");
				}catch(Exception e)
				{
					isClose=false;
				    e.printStackTrace();
				    System.out.print("SQL Server关闭失败!");
				}  
		 }
		      
		 return isClose;
	 }
	
}

(2)BaseDao(用于数据库查询)

package com.mwq.dao.dao;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Vector;

public class BaseDao {
	private Vector<Object> vector;
	/*
	 * 查询多个记录,并且保存在Vector中
	 */
	protected Vector<Vector<Object>> selectSomeNote(String sql) {
		Vector<Vector<Object>> vector=new Vector<Vector<Object>> ();
		Connection conn=JDBC.getConnection();
		try {
			Statement stat=conn.createStatement();
			ResultSet rs=stat.executeQuery(sql);
			int columnCount=rs.getMetaData().getColumnCount();
			int row=1;
			while(rs.next()) {
				Vector<Object> rowV=new Vector<Object>();
				rowV.add(String.valueOf(row++));
				for(int column=1;column<=columnCount;column++) {
					rowV.add(rs.getString(column));
				}
				vector.add(rowV);
			}
			rs.close();
			stat.close();
			JDBC.closeConnection();
		}catch(SQLException e) {
			e.printStackTrace();
			System.out.println("SomeNote未能查询成功");
		}
		return vector;
	}
	/*
	 * 查询符合条件的记录
	 */
	protected Vector<Object> selectOnlyNote(String sql) {
		vector=new Vector<Object>();
		Connection conn=JDBC.getConnection();
		try {
			Statement stat=conn.createStatement();
			ResultSet rs=stat.executeQuery(sql);
			int columnCount=rs.getMetaData().getColumnCount();
			while(rs.next()) {
				for(int column=1;column<=columnCount;column++) {
					vector.add(rs.getString(column));
				}
			}
			rs.close();
			stat.close();
		}catch(SQLException e) {
			e.printStackTrace();
			System.out.println("OnlyNote未能查询成功");
		}
		return vector;
	}
	/*
	 * 查询多个记录的指定值
	 */
	protected Vector selectSomeValue(String sql) {
		Vector<Object> vector=new Vector<Object>();
		Connection conn=JDBC.getConnection();
		try {
			Statement stat=conn.createStatement();
			ResultSet rs=stat.executeQuery(sql);
			while(rs.next()) {
				vector.add(rs.getObject(1));
			}
			rs.close();
			stat.close();
			JDBC.closeConnection();
		}catch(SQLException e) {
			e.printStackTrace();
		}
		return vector;
	}
	/*
	 * 查询指定记录的指定值
	 */
	protected Object selectOnlyValue(String sql) {
		Object value=null;
		Connection conn=JDBC.getConnection();
		try {
			Statement stat=conn.createStatement();
			ResultSet rs=stat.executeQuery(sql);
			while(rs.next()) {
				value=rs.getObject(1);
			}
			rs.close();
			stat.close();
			JDBC.closeConnection();
		}catch(SQLException e) {
			e.printStackTrace();
		}
		return value;
	}
	/*
	 * 添加、删除和修改记录
	 */
	protected boolean longHaul(String sql) {
		boolean isLongHaul=true;
		Connection conn=JDBC.getConnection();
		try {
			conn.setAutoCommit(false);//手动提交
			Statement stat=conn.createStatement();
			stat.executeUpdate(sql);
			conn.commit();
			stat.close();
			JDBC.closeConnection();
			
		}catch(SQLException e) {
			isLongHaul=false;
			try {
				conn.rollback();
			}catch(SQLException el){
				el.printStackTrace();
			}
			e.printStackTrace();
		}
		System.out.print(isLongHaul);
		return isLongHaul;
	}
}

(3)Dao类(查询具体数据库,每个人设计的数据库不同,要根据自己设计的数据库列名改变相应的语句 ,Basedao的子类)

package com.mwq.dao.dao;

import java.util.Calendar;
import java.util.Vector;

/*
 * Dao类发送sql语句
 */
public class Dao extends BaseDao {
	/*
	 * 饿汉模式
	 */
	private static Dao dao;
	static {
		dao=new Dao();
		
	}
	private Dao() {
		
	}
	public static Dao getInstance() {
		return dao;
	}
	public java.util.Vector<Object> sCardIDofNotFreeze() {
		return selectSomeValue("select card_ID from Card where status=1");
	}
	
	
	
	public boolean writeInmoney(String cardID,String name,String dealdate,String money) {
		String sql="insert into Savemoney (card_ID,name,dealdate,money) VALUES('"+cardID+"','"+name+"','"+dealdate+"','"+money+"')";
		return longHaul(sql);
		
	}
	
	public Vector<Object> sYear() {
		String sql="select consume_date from tb_order_form";
		return selectSomeValue(sql);
	}
	
	public Vector<Object> sStateOfCard(String cardID) {
		return selectOnlyNote("select * from Card where card_ID='"+cardID+"'");
		// TODO 自动生成的方法存根
		
	}
	public boolean uStateByNum(String cardID) {
		return longHaul("update Card set status=1 where card_ID='"+cardID+"'");
		
	}
	public boolean upStateByNum(String cardID) {
		return longHaul("update Card set status=0 where card_ID='"+cardID+"'");
		
	}
	public Vector<Object> sPasswordOfCard(String cardID) {
		return selectOnlyNote("select * from Account where card_ID='"+cardID+"'");
	}
	public Vector<Object> sNameByCard(String cardID) {
		
		return selectOnlyNote("select * from Account where card_ID='"+cardID+"'");
	}
	public boolean writemoneyOfSavemoney(int startmoney,String name) {
		String sql="update Account set Money='"+startmoney+"' where name='"+name+"'";
		return longHaul(sql);
	}
	public Vector<Object> smoneyOfCard(String name) {
		return selectOnlyNote("select * from Account where name='"+name+"'");
	}
	public boolean writemoneyOfOutmoney(String cardID, String name, String dealdate, String money) {
		String sql="insert into Outmoney (card_ID,name,dealdate,money) VALUES('"+cardID+"','"+name+"','"+dealdate+"','"+money+"')";
		return longHaul(sql);
	}
	public boolean swriteTransfer(String cardID, String name, String TransferID,String Transfername, String dealdate, String money) {
		String sql="insert into Transfer (card_ID,name,Transfer_card_ID,Transfer_name,dealdate,money) VALUES('"+cardID+"','"+name+"','"+TransferID+"','"+Transfername+"','"+dealdate+"','"+money+"')";
		return longHaul(sql);
		
	}
	public boolean uMoneyOfAccount(String name,int endmoney) {
		String sql="update Account set Money='"+endmoney+"' where name='"+name+"'";
		return longHaul(sql);
		
	}
	public Vector<Object> smoneyOfNum(String num) {
		return selectOnlyNote("select * from Account where card_ID='"+num+"'");
	}
	public boolean uPasswordOfCard(String cardID, String checkpassword) {
		String sql="update Account set password='"+checkpassword+"' where card_ID='"+cardID+"'";
		return longHaul(sql);
		
	}
	public Vector<Vector<Object>> sdateOfNum(String num,String startdate,String enddate) {
		//查询该时间段内的银行消费单
		//return selectSomeNote("select * from Transfer where dealdate between '"+startdate+"00:00:00' and  '"+enddate+"23:59:59' and card_ID='"+num+"'");
		return selectSomeNote("select * from Transfer where card_ID='"+num+"'");
	}
	public Vector<Vector<Object>> sSaveOfNum(String num, String startdate, String enddate) {
		return selectSomeNote("select * from Savemoney where card_ID='"+num+"'");
		//return selectSomeNote("select * from Savemoney where dealdate between '"+startdate+"00:00:00' and  '"+enddate+"23:59:59' and card_ID='"+num+"'");
		
	}
	public Vector<Vector<Object>> sOutOfNum(String num, String startdate, String enddate) {
		return selectSomeNote("select * from Outmoney where card_ID='"+num+"'");
		//return selectSomeNote("select * from Outmoney where dealdate between '"+startdate+"00:00:00' and  '"+enddate+"23:59:59' and card_ID='"+num+"'");
		
	}
	
}

各界面的设计:

(1)登录界面:

package com.ATM.frame;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Image;
import java.awt.Insets;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.net.URL;
import java.util.Vector;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;

import com.mwq.dao.dao.Dao;
import com.ATM.swing.MPanel;

@SuppressWarnings("serial")
public class LandFrame extends JFrame{

	public static void main(String[] args) {
		new LandFrame().setVisible(true);
	}
	private JComboBox<String> usernameComboBox;
	private JPasswordField passwordField;
	private JLabel cardlabel;
	private JTextField cardtextField;
	private JLabel passwordlabel;
	private ImageIcon image;
	private JButton login;
	private JPanel buttonpanel;
	private Dao dao=Dao.getInstance();
	private int j=0;
	private JButton exitbutton;
	private int count=0;
	private Vector<Object> checkpassword;
	public LandFrame() {
		this.setTitle("登录ATM窗口");
		this.setResizable(false);
		Dimension screenSize=Toolkit.getDefaultToolkit().getScreenSize();
		this.setBounds((screenSize.width-428)/2,(screenSize.height-292)/2,500,350);
		this.validate();
        this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
		
		this.addWindowListener(new WindowAdapter() {
			@Override
			public void windowClosing(WindowEvent e) {
				if(count==0) {
					if(checkpassword!=null) {
						JOptionPane.showMessageDialog(null, "请先退卡!否则不能退出当前系统!",
								"友情提示",JOptionPane.INFORMATION_MESSAGE);
					}
					else {
						System.exit(0);
					}
				}else {

					JOptionPane.showMessageDialog(null, "您已退卡!",
							"友情提示",JOptionPane.INFORMATION_MESSAGE);
					System.exit(0);
				}
				super.windowClosing(e);
			}
		});
		
		//自定义MPanle,通过绘制的方式添加背景图片
		MPanel panel=new MPanel(this.getClass().getResource("/img/Login.jpg"));
		this.add(panel,BorderLayout.CENTER);
		
		
		//添加组件
		cardlabel=new JLabel("卡号:");
		cardlabel.setFont(new Font("",Font.BOLD,15));
		cardlabel.setBounds(190,140,80,20);
		panel.add(cardlabel);
		
		cardtextField=new JTextField(20);
		cardtextField.setBounds(240,140,100,20);
		panel.add(cardtextField);
		
		
		//查询插卡状态,若为1则可以登录,若为0则需要插卡(输入卡号)
		Vector<Object> userNameV=Dao.getInstance().sCardIDofNotFreeze();
		
		passwordlabel=new JLabel("密码:");
		passwordlabel.setFont(new Font("",Font.BOLD,15));
		passwordlabel.setBounds(190, 165, 70, 20);
		panel.add(passwordlabel);
		
		passwordField = new JPasswordField();
		passwordField.setBounds(240,165,70,20);
		passwordField.addFocusListener(new FocusAdapter(){
			public void focusGained(FocusEvent e) {
				passwordField.setText("");
		}
		});
		panel.add(passwordField);
		
		buttonpanel=new JPanel();
		
		//添加登录按钮
		login=new JButton("登录");
		login.setFont(new Font("",Font.BOLD,12));
		
		//登录按钮事件处理
		login.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				
				if(cardtextField.getText().equals("")) {
					JOptionPane.showMessageDialog(null, "请输入卡号!","友情提示 ",JOptionPane.OK_OPTION);
				}else {
					
					char[] passwords=passwordField.getPassword();
					String inputPassword=String.valueOf(passwords);
					if(inputPassword.length()==0) {
						JOptionPane.showMessageDialog(null, "请输入密码!","友情提示 ",JOptionPane.OK_OPTION);
						passwordField.requestFocus();
					}else {
						String cardID=cardtextField.getText();
						checkpassword=dao.sPasswordOfCard(cardID);
						if(checkpassword.size()==0) {
							JOptionPane.showMessageDialog(null, "您输入的卡号不正确!请重新输入!","友情提示 ",JOptionPane.YES_NO_OPTION);
							cardtextField.setText("");
							passwordField.setText("");
						}
						else {
							String check=checkpassword.get(2).toString();
							if(inputPassword.equals(check)) {
								Vector<Object> name=dao.sNameByCard(cardID);
								int i=JOptionPane.showConfirmDialog(null, name.get(1).toString()+"欢迎您!","友情提示 ",JOptionPane.INFORMATION_MESSAGE);
								if(i==0) {
									new Menu(name).setVisible(true);
									dao.uStateByNum(cardID);
								}else {
									new LandFrame().setVisible(true);
									cardtextField.setText("");
									passwordField.setText("");
								}
							}else {
								j++;
								if(j>=3) {
									JOptionPane.showMessageDialog(null, "您输入错误密码的次数已经超过3次!已吞卡!","友情提示 ",JOptionPane.YES_NO_OPTION);
									cardtextField.setText("");
									passwordField.setText("");
									
								}else {
									JOptionPane.showMessageDialog(null, "您输入的密码有误!请重新输入!","友情提示 ",JOptionPane.YES_NO_OPTION);
								}
								
							}
						}
						
						
					}
					
				}
				
				
			}
		});

		//将两个按钮添加到面板中
		buttonpanel.add(login);
		exitbutton=new JButton("退卡");
		exitbutton.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				count++;
				JOptionPane.showMessageDialog(null, "您已退卡!","友情提示 ",JOptionPane.INFORMATION_MESSAGE);
				dao.upStateByNum(cardtextField.getText());
				System.exit(0);
				
			}
		});
		buttonpanel.add(exitbutton);
		buttonpanel.setBounds(180,205,140,34);
		panel.add(buttonpanel);	
		
	}
	
}

(2)主菜单界面:

package com.ATM.frame;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.net.URL;
import java.util.Vector;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;

import com.ATM.frame.mframe.Correctpassword;
import com.ATM.frame.mframe.InquiryHistory;
import com.ATM.frame.mframe.InquiryMoney;
import com.ATM.swing.MPanel;
import com.mwq.dao.dao.Dao;

//主界面的实现
public class Menu extends JFrame{

	public static void main(String[] args) {
		new Menu(null).setVisible(true);

	}
	private JButton Inmoney;
	private JButton Outmoney;
	private JPanel Buttonpanel1;
	private JButton Transfer;
	private JButton Inquiry;
	private JPanel Buttonpanel2;
	private JPanel Buttonpanel3;
	private JPanel Buttonpanel4;
	private JButton balance;
	private JPanel Buttonpanel5;
	private JButton Exit;
	private JPanel Buttonpanel6;
	private JButton Correct;
	private JPanel Buttonpanel7;
	private int count=0;
	private Dao dao=Dao.getInstance();
	public Menu(final Vector<Object> name) {
		this.setTitle("个人界面");
		Dimension screenSize=Toolkit.getDefaultToolkit().getScreenSize();
		this.setBounds((screenSize.width-600)/2,(screenSize.height-550)/2,600,580);
		this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
		
		this.addWindowListener(new WindowAdapter() {
			@Override
			public void windowClosing(WindowEvent e) {
				if(count==0) {
					JOptionPane.showMessageDialog(null, "请先退卡!否则不能退出当前系统!",
							"友情提示",JOptionPane.INFORMATION_MESSAGE);
				}else {
					JOptionPane.showMessageDialog(null, "您已退卡!",
							"友情提示",JOptionPane.INFORMATION_MESSAGE);
					System.exit(0);
				}
				super.windowClosing(e);
			}
		});

		
		final JLabel topLabel=new JLabel();
		topLabel.setPreferredSize(new Dimension(0,150));
		URL topUrl=this.getClass().getResource("/img/背景.jpg");
		ImageIcon topIcon=new ImageIcon(topUrl);
		topIcon.setImage(topIcon.getImage().getScaledInstance(600, 400, Image.SCALE_DEFAULT));
		topLabel.setIcon(topIcon);
		add(topLabel,BorderLayout.NORTH);
		
		MPanel Centerpanel=new MPanel(this.getClass().getResource("/img/主界面背景.jpg"));
		this.add(Centerpanel,BorderLayout.CENTER);
		
		Buttonpanel1=new JPanel();
		Buttonpanel2=new JPanel();
		Buttonpanel3=new JPanel();
		Buttonpanel4=new JPanel();
		Buttonpanel5=new JPanel();
		Buttonpanel6=new JPanel();
		Buttonpanel7=new JPanel();
		Inmoney=new JButton("存款");
		Inmoney.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				new com.ATM.frame.mframe.Inmoney(name).setVisible(true);
				
			}
		});
		Buttonpanel1.add(Inmoney);
		
		Outmoney=new JButton("取款");
		Outmoney.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				new com.ATM.frame.mframe.Outmoney(name).setVisible(true);
				
			}
		});
		Buttonpanel2.add(Outmoney);
		
		Transfer=new JButton("转账");
		Transfer.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				new com.ATM.frame.mframe.Transfer(name).setVisible(true);
				
			}
		});
		Buttonpanel3.add(Transfer);
		
		Correct=new JButton("修改密码");
		Correct.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				new Correctpassword(name).setVisible(true);
				
				
			}
		});
		Buttonpanel7.add(Correct);
		
		balance=new JButton("查询余额");
		balance.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				new InquiryMoney(name).setVisible(true);
				
			}
		});
		Buttonpanel4.add(balance);
		
		Inquiry=new JButton("查询历史记录");
		Inquiry.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				new InquiryHistory(name).setVisible(true);
				
			}
		});
		Buttonpanel5.add(Inquiry);
		
		count=0;
		
		Exit=new JButton("退卡");
		Exit.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				count++;
				JOptionPane.showMessageDialog(null,"您已退卡!","友情提示",JOptionPane.INFORMATION_MESSAGE);
				dao.upStateByNum(name.get(0).toString());
				System.exit(0);
			}
		});
		
		Buttonpanel6.add(Exit);
		
		Inmoney.setBounds(-10, 0, 60, 33);
		Buttonpanel1.setBounds(150, 100, 60, 33);
		Buttonpanel2.setBounds(150,160,60,33);
		Buttonpanel3.setBounds(150,220,60,33);
		Buttonpanel4.setBounds(360, 100, 86, 33);
		Buttonpanel5.setBounds(360, 220, 112, 33);
		//Buttonpanel6.setBounds(360, 220, 60, 33);
		Buttonpanel7.setBounds(360, 160, 86, 33);
		Buttonpanel6.setBounds(150, 285, 60, 33);
		
		Centerpanel.add(Buttonpanel1);
		Centerpanel.add(Buttonpanel2);
		Centerpanel.add(Buttonpanel3);
		Centerpanel.add(Buttonpanel4);
		Centerpanel.add(Buttonpanel5);
		Centerpanel.add(Buttonpanel6);
		Centerpanel.add(Buttonpanel7);
		
		
		
		
		
	}

}

(3)取款界面:

package com.ATM.frame.mframe;

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Vector;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;

import com.ATM.frame.Menu;
import com.ATM.swing.MPanel;
import com.mwq.dao.dao.Dao;

public class Outmoney extends JFrame{

	public static void main(String[] args) {
		
		new Outmoney(null).setVisible(true);
	}
	private JButton money2;
	private JButton money3;
	private JButton money4;
	private JPanel buttonpanel;
	private JPanel buttonpanel2;
	private JPanel buttonpanel3;
	private JPanel buttonpanel4;
	private JPanel buttonpanel5;
	private JTextField money1;
	private JButton submit;
	private Dao dao=Dao.getInstance();
	private JButton exit;
	private JPanel buttonpanel6;
	private JPanel buttonpanel7;
	private JButton returnbutton;
	private JButton money5;
	private JPanel buttonpanel8;
	private int count=0;
	public Outmoney(final Vector<Object> name) {
		this.setTitle("取款界面");
		Dimension screenSize=Toolkit.getDefaultToolkit().getScreenSize();
		this.setBounds((screenSize.width-650)/2,(screenSize.height-450)/2,580,400);
		this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
		
		this.addWindowListener(new WindowAdapter() {
			@Override
			public void windowClosing(WindowEvent e) {
				if(count==0) {
					JOptionPane.showMessageDialog(null, "请先退卡!否则不能退出当前系统!",
							"友情提示",JOptionPane.INFORMATION_MESSAGE);
				}else {
					JOptionPane.showMessageDialog(null, "您已退卡!",
							"友情提示",JOptionPane.INFORMATION_MESSAGE);
				}
				super.windowClosing(e);
			}
		});
		
		MPanel panel=new MPanel(this.getClass().getResource("/img/存取款背景3.jpg"));
		this.add(panel,BorderLayout.CENTER);
		
		buttonpanel=new JPanel();
		buttonpanel4=new JPanel();
		buttonpanel2=new JPanel();
		buttonpanel3=new JPanel();
		buttonpanel5=new JPanel();
		buttonpanel6=new JPanel();
		buttonpanel7=new JPanel();
		buttonpanel8=new JPanel();
		
		money1=new JTextField(6);
		
		money2=new JButton("500");
		money2.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				money1.setText("500");
			}
		});
		
		money3=new JButton("1000");
		money3.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				money1.setText("1000");
			}
		});
		money4=new JButton("5000");
		money4.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				money1.setText("5000");
			}
		});
		//money5=new JButton("10000");
		
		buttonpanel.add(money2);
		buttonpanel.setBounds(100, 70, 59, 33);
		panel.add(buttonpanel);
		
		buttonpanel2.add(money3);
		buttonpanel2.setBounds(100, 150, 63, 33);
		panel.add(buttonpanel2);
		
		buttonpanel3.add(money4);
		buttonpanel3.setBounds(100, 230, 63, 33);
		panel.add(buttonpanel3);
		
		buttonpanel4.add(money1);
		buttonpanel4.setBounds(251, 255, 69, 26);
		panel.add(buttonpanel4);
		
		//buttonpanel8.add(money5);
		//buttonpanel8.setBounds(100, 200, 69, 33);
		//panel.add(buttonpanel8);
		
		
		submit=new JButton("确定");
		submit.addActionListener(new ActionListener() {
			
			private Calendar date=Calendar.getInstance();

			@Override
			public void actionPerformed(ActionEvent e) {
				if(money1.getText()!="") {
					
					String money=name.get(4).toString();
					Vector<Object> extramoney=dao.smoneyOfCard(name.get(0).toString());
					int startmoney=Integer.parseInt(money);
					int inmoney=Integer.parseInt(money1.getText());
					int endmoney=startmoney-inmoney;
					if(endmoney<0) {
						JOptionPane.showConfirmDialog(null, "您卡里的余额不足!","友情提示",JOptionPane.YES_NO_OPTION);
					}else {
						DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
						Date today1=date.getTime();
					    String dealdate = format.format(today1); 
					    dao.writemoneyOfOutmoney(name.get(0).toString(), name.get(1).toString(), dealdate, money1.getText());
					    JOptionPane.showConfirmDialog(null, "您取了"+money1.getText()+"钱!","友情提示",JOptionPane.INFORMATION_MESSAGE);
					}
					
				}else {
					JOptionPane.showConfirmDialog(null, "您取了"+money1.getText()+"钱!","友情提示",JOptionPane.YES_NO_OPTION);
				}
				
			}
		});
		buttonpanel5.add(submit);
		buttonpanel5.setBounds(400, 150, 69, 33);
		panel.add(buttonpanel5);
		
		returnbutton=new JButton("返回");
		returnbutton.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				new Menu(name).setVisible(true);
				
			}
		});
		buttonpanel6.add(returnbutton);
		buttonpanel6.setBounds(400, 70, 69, 33);
		panel.add(buttonpanel6);
		
		exit=new JButton("退卡");
		exit.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				JOptionPane.showMessageDialog(null,"您已退卡!","友情提示",JOptionPane.INFORMATION_MESSAGE);
				count++;
				dao.upStateByNum(name.get(0).toString());
				System.exit(0);
			}
		});
		buttonpanel7.add(exit);
		buttonpanel7.setBounds(400, 230, 69, 33);
		panel.add(buttonpanel7);
		
		
	}

}

(4)存款界面:

package com.ATM.frame.mframe;

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Vector;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;

import com.ATM.frame.Menu;
import com.ATM.swing.MPanel;
import com.mwq.dao.dao.Dao;

public class Inmoney extends JFrame{

	public static void main(String[] args) {
		
		new Inmoney(null).setVisible(true);
	}
	private JButton money2;
	private JButton money3;
	private JButton money4;
	private JPanel buttonpanel;
	private JPanel buttonpanel2;
	private JPanel buttonpanel3;
	private JPanel buttonpanel4;
	private JPanel buttonpanel5;
	private JTextField money1;
	private JButton submit;
	private Dao dao=Dao.getInstance();
	private JButton exit;
	private JPanel buttonpanel6;
	private JPanel buttonpanel7;
	private JButton returnbutton;
	private int startmoney=0;
	private int count=0;
	private Calendar date=Calendar.getInstance();
	public Inmoney(final Vector<Object> name) {
		this.setTitle("存款界面");
		Dimension screenSize=Toolkit.getDefaultToolkit().getScreenSize();
		this.setBounds((screenSize.width-650)/2,(screenSize.height-450)/2,580,380);
		this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
		
		this.addWindowListener(new WindowAdapter() {
			@Override
			public void windowClosing(WindowEvent e) {
				if(count==0) {
					JOptionPane.showMessageDialog(null, "请先退卡!否则不能退出当前系统!",
							"友情提示",JOptionPane.INFORMATION_MESSAGE);
				}else {
					JOptionPane.showMessageDialog(null, "您已退卡!",
							"友情提示",JOptionPane.INFORMATION_MESSAGE);
				}
				super.windowClosing(e);
			}
		});
		
		
		
		MPanel panel=new MPanel(this.getClass().getResource("/img/存取款背景3.jpg"));
		this.add(panel,BorderLayout.CENTER);
		
		buttonpanel=new JPanel();
		buttonpanel4=new JPanel();
		buttonpanel2=new JPanel();
		buttonpanel3=new JPanel();
		buttonpanel5=new JPanel();
		buttonpanel6=new JPanel();
		buttonpanel7=new JPanel();
		
		money1=new JTextField(6);
		
		money2=new JButton("500");
		money2.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				money1.setText("500");
			}
		});
		
		money3=new JButton("1000");
		money3.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				money1.setText("1000");
			}
		});
		money4=new JButton("5000");
		money4.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				money1.setText("5000");
			}
		});
		
		buttonpanel.add(money2);
		buttonpanel.setBounds(100, 50, 59, 33);
		panel.add(buttonpanel);
		
		buttonpanel2.add(money3);
		buttonpanel2.setBounds(100, 130, 63, 33);
		panel.add(buttonpanel2);
		
		buttonpanel3.add(money4);
		buttonpanel3.setBounds(100, 210, 63, 33);
		panel.add(buttonpanel3);
		
		buttonpanel4.add(money1);
		buttonpanel4.setBounds(100, 290, 69, 26);
		panel.add(buttonpanel4);
		
		submit=new JButton("确定");
		submit.addActionListener(new ActionListener() {
			
			
			@Override
			public void actionPerformed(ActionEvent e) {
				String money=name.get(4).toString();
				startmoney=Integer.parseInt(money);
				int endmoney=0;
				if(money1.getText()!="") {
					if(Integer.parseInt(money1.getText())>5000) {
						JOptionPane.showMessageDialog(null, "存款一次不能超过5000元!","友情提示",JOptionPane.YES_NO_OPTION);
					}else {
					int inmoney=Integer.parseInt(money1.getText());
					endmoney=startmoney+inmoney;
					dao.writemoneyOfSavemoney(endmoney, name.get(1).toString());
					DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
					Date today1=date.getTime();
				    String dealdate = format.format(today1); 
				    dao.writeInmoney(name.get(0).toString(), name.get(1).toString(), dealdate, money1.getText());
					JOptionPane.showConfirmDialog(null, "您存了"+money1.getText()+"钱!","友情提示",JOptionPane.INFORMATION_MESSAGE);
				}
			}else {
					System.out.print(Integer.parseInt(money1.getText()));	
				}
				money1.setText("");
			}
		});
		
		buttonpanel5.add(submit);
		buttonpanel5.setBounds(400, 130, 69, 33);
		panel.add(buttonpanel5);
		
		returnbutton=new JButton("返回");
		returnbutton.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				new Menu(name).setVisible(true);
				
			}
		});
		buttonpanel6.add(returnbutton);
		buttonpanel6.setBounds(400, 50, 69, 33);
		panel.add(buttonpanel6);
		
		exit=new JButton("退卡");
		exit.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				JOptionPane.showMessageDialog(null,"您已退卡!","友情提示",JOptionPane.INFORMATION_MESSAGE);
				count++;
				System.exit(0);
			}
		});
		buttonpanel7.add(exit);
		buttonpanel7.setBounds(400, 210, 69, 33);
		panel.add(buttonpanel7);
		
		
	}

}

(5)转账界面:

package com.ATM.frame.mframe;

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Vector;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;

import com.ATM.frame.Menu;
import com.ATM.swing.MPanel;
import com.mwq.dao.dao.Dao;

public class Transfer extends JFrame{

	public static void main(String[] args) {
		
		new Transfer(null).setVisible(true);
	}
	private JButton money2;
	private JButton money3;
	private JButton money4;
	private JPanel buttonpanel;
	private JPanel buttonpanel2;
	private JPanel buttonpanel3;
	private JPanel buttonpanel4;
	private JPanel buttonpanel5;
	private JTextField money1;
	private JButton submit;
	private Dao dao=Dao.getInstance();
	private JButton exit;
	private JPanel buttonpanel6;
	private JPanel buttonpanel7;
	private JButton returnbutton;
	private JButton money5;
	private JPanel buttonpanel8;
	private JPanel buttonpanel9;
	private JLabel cardlabel;
	private JTextField cardtextField;
	private int count=0;
	public Transfer(final Vector<Object> name) {
		
		setTitle("转账界面");
		Dimension screenSize=Toolkit.getDefaultToolkit().getScreenSize();
		this.setBounds((screenSize.width-650)/2,(screenSize.height-450)/2,580,400);
		this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
		
		this.addWindowListener(new WindowAdapter() {
			@Override
			public void windowClosing(WindowEvent e) {
				if(count==0) {
					JOptionPane.showMessageDialog(null, "请先退卡!否则不能退出当前系统!",
							"友情提示",JOptionPane.INFORMATION_MESSAGE);
				}else {
					JOptionPane.showMessageDialog(null, "您已退卡!",
							"友情提示",JOptionPane.INFORMATION_MESSAGE);
					System.exit(0);
				}
				super.windowClosing(e);
			}
		});

		
		MPanel panel=new MPanel(this.getClass().getResource("/img/存取款背景3.jpg"));
		this.add(panel,BorderLayout.CENTER);
		
		buttonpanel=new JPanel();
		buttonpanel4=new JPanel();
		buttonpanel2=new JPanel();
		buttonpanel3=new JPanel();
		buttonpanel5=new JPanel();
		buttonpanel6=new JPanel();
		buttonpanel7=new JPanel();
		buttonpanel8=new JPanel();
		buttonpanel9=new JPanel();
		
		
		money1=new JTextField(6);
		
		money2=new JButton("500");
		money2.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				money1.setText("500");
			}
		});
		
		money3=new JButton("1000");
		money3.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				money1.setText("1000");
			}
		});
		money4=new JButton("5000");
		money4.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				money1.setText("5000");
			}
		});
		//money5=new JButton("10000");
		
		buttonpanel.add(money2);
		buttonpanel.setBounds(100, 60, 59, 33);
		panel.add(buttonpanel);
		
		buttonpanel2.add(money3);
		buttonpanel2.setBounds(100, 152, 62, 33);
		panel.add(buttonpanel2);
		
		buttonpanel3.add(money4);
		buttonpanel3.setBounds(100, 240, 63, 33);
		panel.add(buttonpanel3);
		
		buttonpanel4.add(money1);
		buttonpanel4.setBounds(253, 251, 69, 33);
		panel.add(buttonpanel4);
		
		cardlabel=new JLabel("卡号:");
		cardlabel.setFont(new Font("",Font.BOLD,15));
		cardlabel.setBounds(100,140,80,20);
		buttonpanel9.add(cardlabel);
		
		cardtextField=new JTextField(20);
		cardtextField.setBounds(230,123,100,20);
		buttonpanel9.add(cardtextField);
		buttonpanel9.setBounds(100, 20, 360, 33);
		panel.add(buttonpanel9);
		
		
		submit=new JButton("确定");
		submit.addActionListener(new ActionListener() {
			
			private Calendar date=Calendar.getInstance();

			@Override
			public void actionPerformed(ActionEvent e) {
				if(!money1.getText().equals("")) {
					String money=name.get(4).toString();
					Vector<Object> extramoney=dao.smoneyOfCard(name.get(0).toString());
					int startmoney=Integer.parseInt(money);//原来登录用户的余额
					int inmoney=Integer.parseInt(money1.getText());//转账的钱数
					if(inmoney>5000) {
						JOptionPane.showConfirmDialog(null, "一次交易不能超过5000元!","友情提示",JOptionPane.INFORMATION_MESSAGE);
						money1.setText("");
					}else {
						int endmoney=startmoney-inmoney;//现在用户的余额 
						
						System.out.print(cardtextField.getText());
						//根据卡号查询转账用户的余额
						Vector<Object> transferyue=dao.smoneyOfNum(cardtextField.getText().toString());//转账用户
						if(transferyue.size()==0) {
							JOptionPane.showConfirmDialog(null, "您输入的卡号不存在!请重新输入!","友情提示",JOptionPane.YES_NO_OPTION);
						}
						else {
							String yue=transferyue.get(4).toString();//转账用户的余额
							if(endmoney<0) {
								JOptionPane.showConfirmDialog(null, "您卡里的余额不足!","友情提示",JOptionPane.YES_NO_OPTION);
							}else {
								if(!cardtextField.getText().equals("")) {
									DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
									Date today1=date.getTime();
								    String dealdate = format.format(today1); 
									//int month=date.get(Calendar.MONTH)+1;
									//String dealdate=date.get(Calendar.YEAR)+"-"+month+"-"+date.get(Calendar.DAY_OF_MONTH)+"  "+date.getTime().toString().substring(11, 19);
									
									//转账人的信息
									Vector<Object> transfer=dao.sNameByCard(cardtextField.getText());
									String transferID=transfer.get(1).toString();
									if(transferID.equals(name.get(1).toString())) {
										JOptionPane.showConfirmDialog(null, "您不能向自己转钱!","友情提示",JOptionPane.WARNING_MESSAGE);
									}else {
										int i=JOptionPane.showConfirmDialog(null, "确定向"+transferID+"转账"+money1.getText().toString()+"钱吗?","友情提示",JOptionPane.YES_NO_OPTION);
										if(i==0) {
											dao.uMoneyOfAccount(name.get(1).toString(),endmoney);
											System.out.print("更新金额:"+dao.uMoneyOfAccount(transferID,Integer.parseInt(yue)+inmoney));
											//写入转账表中
										    dao.swriteTransfer(name.get(0).toString(), name.get(1).toString(),cardtextField.getText().toString(),transfer.get(1).toString(),dealdate,money1.getText().toString());
										    JOptionPane.showConfirmDialog(null, "您已向"+transferID+"转账"+money1.getText().toString()+"钱!","友情提示",JOptionPane.INFORMATION_MESSAGE);
										
										}else {
											cardtextField.setText("");
											money1.setText("");
										}
										
									}
								}else {
									JOptionPane.showConfirmDialog(null, "请输入转账人的卡号!","友情提示",JOptionPane.YES_NO_OPTION);
								}
							}
						}
					}
				}else {
					JOptionPane.showConfirmDialog(null, "请输入转账金额!","友情提示",JOptionPane.YES_NO_OPTION);
				}
				
			}
		});
		buttonpanel5.add(submit);
		buttonpanel5.setBounds(400, 152, 69, 33);
		panel.add(buttonpanel5);
		
		returnbutton=new JButton("返回");
		returnbutton.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				new Menu(name).setVisible(true);
				
			}
		});
		buttonpanel6.add(returnbutton);
		buttonpanel6.setBounds(400, 60, 69, 33);
		panel.add(buttonpanel6);
		
		count=0;
		exit=new JButton("退卡");
		exit.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				JOptionPane.showMessageDialog(null,"您已退卡!","友情提示",JOptionPane.INFORMATION_MESSAGE);
				count++;
				dao.upStateByNum(name.get(0).toString());
				System.exit(0);
			}
		});
		buttonpanel7.add(exit);
		buttonpanel7.setBounds(400, 240, 69, 33);
		panel.add(buttonpanel7);
		
		
	}

}

(6)查询余额界面:

package com.ATM.frame.mframe;

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.Calendar;
import java.util.Vector;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;

import com.ATM.frame.Menu;
import com.ATM.swing.MPanel;
import com.mwq.dao.dao.Dao;

public class InquiryMoney extends JFrame{

	public static void main(String[] args) {
		
		new InquiryMoney(null).setVisible(true);
	}
	private JPanel buttonpanel;
	private JTextField money1;
	private JButton submit;
	private Dao dao=Dao.getInstance();
	private JButton exit;
	private JButton returnbutton;
	private int startmoney=0;
	private int count=0;
	private Calendar date=Calendar.getInstance();
	private JPanel buttonpanel1;
	private JPanel buttonpanel2;
	private JLabel Label;
	private JLabel NameLabel;
	private JLabel cardlabel;
	public InquiryMoney(final Vector<Object> name) {
		this.setTitle("存款界面");
		Dimension screenSize=Toolkit.getDefaultToolkit().getScreenSize();
		this.setBounds((screenSize.width-650)/2,(screenSize.height-450)/2,580,380);
		this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
		
		this.addWindowListener(new WindowAdapter() {
			@Override
			public void windowClosing(WindowEvent e) {
				if(count==0) {
					JOptionPane.showMessageDialog(null, "请先退卡!否则不能退出当前系统!",
							"友情提示",JOptionPane.INFORMATION_MESSAGE);
				}else {
					JOptionPane.showMessageDialog(null, "您已退卡!",
							"友情提示",JOptionPane.INFORMATION_MESSAGE);
				}
				super.windowClosing(e);
			}
		});
		
		MPanel panel=new MPanel(this.getClass().getResource("/img/Login.jpg"));
		this.add(panel,BorderLayout.CENTER);
		
		Vector<Object> money=dao.smoneyOfNum(name.get(0).toString());
		//System.out.print(money.get(4).toString());
		cardlabel=new JLabel("您账户余额为:"+money.get(4).toString());
		cardlabel.setFont(new Font("",Font.BOLD,12));
		cardlabel.setBounds(200,140,150,20);
		panel.add(cardlabel);
		
		returnbutton=new JButton("返回");
		returnbutton.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				new Menu(name).setVisible(true);
				
			}
		});
		
		returnbutton.setBounds(130, 210, 69, 33);
		panel.add(returnbutton);
		
		buttonpanel=new JPanel();
		exit=new JButton("退卡");
		exit.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				JOptionPane.showMessageDialog(null,"您已退卡!","友情提示",JOptionPane.INFORMATION_MESSAGE);
				count++;
				dao.upStateByNum(name.get(0).toString());
				System.exit(0);
			}
		});
		
		exit.setBounds(330, 210, 69, 33);
		panel.add(exit);
		
		
	}

}

(7)查询历史记录界面:

package com.ATM.frame.mframe;

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.ScrollPane;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Vector;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.border.TitledBorder;
import javax.swing.table.DefaultTableModel;

import com.ATM.frame.Menu;
import com.ATM.swing.MPanel;
import com.mwq.dao.dao.Dao;
import com.ATM.swing.MTable;

public class InquiryHistory extends JFrame{

	public static void main(String[] args) {
		new InquiryHistory(null).setVisible(true);
	}
	private JPanel buttonpanel;
	private JTextField money1;
	private JButton submit;
	private Dao dao=Dao.getInstance();
	private JButton exit;
	private JButton returnbutton;
	private int startmoney=0;
	private int count=0;
	private Calendar date=Calendar.getInstance();
	private JPanel buttonpanel1;
	private JPanel buttonpanel2;
	private JLabel Label;
	private JLabel NameLabel;
	private JLabel cardlabel;
	private Vector<String> tableColumnV;
	private Vector<Vector<Object>> tableValueV;
	private DefaultTableModel tableModel;
	private com.ATM.swing.MTable table;    
    private JComboBox YEAR; 
    private JComboBox MONTH; 
    private JComboBox DAY;   
    private int daysOfMonth[]={0,31,28,31,30,31,30,31,31,30,31,30,31};   
	private JPanel Northpanel;
	private JPanel panel;
	private JPanel panel1;
	private JPanel Southpanel;
	private JButton timebutton1;   
	private JButton timebutton2;
	private JButton timebutton3;
	private JButton timebutton4;
	private JTextArea history;
	private JButton Submit;
	private int year;
	private JComboBox YEAR1;
	private JComboBox MONTH1;
	private JComboBox DAY1;  
	public InquiryHistory(final Vector<Object> name) {
		this.setTitle("查询历史记录界面");
		Dimension screenSize=Toolkit.getDefaultToolkit().getScreenSize();
		this.setBounds((screenSize.width-400)/2,(screenSize.height-450)/2,580,380);
		this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
		
		this.addWindowListener(new WindowAdapter() {
			@Override
			public void windowClosing(WindowEvent e) {
				if(count==0) {
					JOptionPane.showMessageDialog(null, "请先退卡!否则不能退出当前系统!",
							"友情提示",JOptionPane.INFORMATION_MESSAGE);
				}else {
					JOptionPane.showMessageDialog(null, "您已退卡!",
							"友情提示",JOptionPane.INFORMATION_MESSAGE);
				}
				super.windowClosing(e);
			}
		});
		
		panel=new JPanel();
		Northpanel=new JPanel();
		Southpanel=new JPanel();
		
		Calendar calendar=Calendar.getInstance();
        
        year=calendar.get(calendar.YEAR);  
        int month = calendar.get(calendar.MONTH)+1;  
		int day = calendar.get(calendar.DAY_OF_MONTH);
        
        JLabel arrive=new JLabel("      至      ");
        
		
        //添加组件
        YEAR=new JComboBox();             
        YEAR.addItem(year);   
        YEAR.setSelectedItem(year);   
        //对年份进行判断
        if (year%100==0&&year%4==0||year%400==0) 
                daysOfMonth[2] = 29;   
            else   
                daysOfMonth[2] = 28;   
        YEAR.addActionListener(new ActionListener() {   
            public void actionPerformed(ActionEvent e) {   
                int year = (Integer) YEAR.getSelectedItem();
                int month = (Integer) YEAR.getSelectedItem();   
                if (month == 2) { 
                    int itemCount = DAY.getItemCount();   
                    if (itemCount != daysOfMonth[2]) {  
                        if (itemCount == 28)   
                        	DAY.addItem(29);
                        else   
                        	DAY.removeItem(29);
                    }   
                }   
            }   
        });   
        Northpanel.add(YEAR);   
   
        final JLabel yearLabel = new JLabel();   
        yearLabel.setText("年");   
        Northpanel.add(yearLabel);   
   
        MONTH = new JComboBox();   
        MONTH.setMaximumRowCount(12);   
        for (int m = 1; m < 13; m++) {   
        	MONTH.addItem(m);   
        }   
        MONTH.setSelectedItem(month);   
        MONTH.addActionListener(new ActionListener() {   
            public void actionPerformed(ActionEvent e) {   
                int month = (Integer) MONTH.getSelectedItem();
                int itemCount = DAY.getItemCount();
                while (itemCount != daysOfMonth[month]) {   
                    if (itemCount > daysOfMonth[month]) {
                        DAY.removeItem(itemCount);
                        itemCount--;
                    } else {
                        itemCount++;
                        DAY.addItem(itemCount);
                    }   
                }   
            }   
        });   
        Northpanel.add(MONTH);   
   
        final JLabel monthLabel = new JLabel();   
        monthLabel.setText("月");   
        Northpanel.add(monthLabel);   
   
        DAY = new JComboBox();   
        DAY.setMaximumRowCount(10);   
        int days = daysOfMonth[month];   
        for (int d = 1; d <= days; d++) {   
        	DAY.addItem(d);   
        }   
        DAY.setSelectedItem(day);   
        Northpanel.add(DAY);   
   
        final JLabel dayLabel = new JLabel();   
        dayLabel.setText("日");   
        Northpanel.add(dayLabel); 
        
        Northpanel.add(arrive);
        
        YEAR1=new JComboBox();             
        YEAR1.addItem(year);   
        YEAR1.setSelectedItem(year);   
        //对年份进行判断
        if (year%100==0&&year%4==0||year%400==0) 
                daysOfMonth[2] = 29;   
            else   
                daysOfMonth[2] = 28;   
        YEAR1.addActionListener(new ActionListener() {   
            public void actionPerformed(ActionEvent e) {   
                int year = (Integer) YEAR1.getSelectedItem();
                int month = (Integer) YEAR1.getSelectedItem();   
                if (month == 2) { 
                    int itemCount = DAY1.getItemCount();   
                    if (itemCount != daysOfMonth[2]) {  
                        if (itemCount == 28)   
                        	DAY.addItem(29);
                        else   
                        	DAY.removeItem(29);
                    }   
                }   
            }   
        });   
        Northpanel.add(YEAR1);   
   
        final JLabel yearLabel1 = new JLabel();   
        yearLabel1.setText("年");   
        Northpanel.add(yearLabel1);   
   
        MONTH1 = new JComboBox();   
        MONTH1.setMaximumRowCount(12);   
        for (int m = 1; m < 13; m++) {   
        	MONTH1.addItem(m);   
        }   
        MONTH1.setSelectedItem(month);   
        MONTH1.addActionListener(new ActionListener() {   
            public void actionPerformed(ActionEvent e) {   
                int month = (Integer) MONTH1.getSelectedItem();
                int itemCount = DAY1.getItemCount();
                while (itemCount != daysOfMonth[month]) {   
                    if (itemCount > daysOfMonth[month]) {
                        DAY1.removeItem(itemCount);
                        itemCount--;
                    } else {
                        itemCount++;
                        DAY1.addItem(itemCount);
                    }   
                }   
            }   
        });   
        Northpanel.add(MONTH1);   
   
        final JLabel monthLabel1 = new JLabel();   
        monthLabel1.setText("月");   
        Northpanel.add(monthLabel1);   
   
        DAY1 = new JComboBox();   
        DAY1.setMaximumRowCount(10);   
        int days1 = daysOfMonth[month];   
        for (int d = 1; d <= days; d++) {   
        	DAY1.addItem(d);   
        }   
        DAY1.setSelectedItem(day);   
        Northpanel.add(DAY1);   
   
        final JLabel dayLabel1 = new JLabel();   
        dayLabel1.setText("日");   
        Northpanel.add(dayLabel1); 
   
        submit = new JButton("确定");   
        submit.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				String starttime="";
				String endtime="";
				if(MONTH.getSelectedItem().toString().length()==1) {
					if(DAY.getSelectedItem().toString().length()==1) {
						starttime=YEAR.getSelectedItem().toString()+"-0"+MONTH.getSelectedItem().toString()+"-0"+DAY.getSelectedItem()+"  ";
					}else {
						starttime=YEAR.getSelectedItem().toString()+"-0"+MONTH.getSelectedItem().toString()+"-"+DAY.getSelectedItem()+"  ";
					}
				}else {
					if(DAY.getSelectedItem().toString().length()==1) {
						starttime=YEAR.getSelectedItem().toString()+"-"+MONTH.getSelectedItem().toString()+"-0"+DAY.getSelectedItem()+"  ";
					}else {
						starttime=YEAR.getSelectedItem().toString()+"-"+MONTH.getSelectedItem().toString()+"-"+DAY.getSelectedItem()+"  ";
					}
				}
				
				if(MONTH1.getSelectedItem().toString().length()==1) {
					if(DAY1.getSelectedItem().toString().length()==1) {
						endtime=YEAR1.getSelectedItem().toString()+"-0"+MONTH1.getSelectedItem().toString()+"-0"+DAY1.getSelectedItem()+"  ";
					}else {
						endtime=YEAR1.getSelectedItem().toString()+"-0"+MONTH1.getSelectedItem().toString()+"-"+DAY1.getSelectedItem()+"  ";
					}
				}else {
					if(DAY1.getSelectedItem().toString().length()==1) {
						endtime=YEAR1.getSelectedItem().toString()+"-"+MONTH1.getSelectedItem().toString()+"-0"+DAY1.getSelectedItem()+"  ";
					}else {
						endtime=YEAR1.getSelectedItem().toString()+"-"+MONTH1.getSelectedItem().toString()+"-"+DAY1.getSelectedItem()+"  ";
					}
				}
				Vector<Vector<Object>> inquiry1=dao.sdateOfNum(name.get(0).toString(), starttime+"00:00:00", endtime+"23:59:59");
				Vector<Vector<Object>> inquiry2=dao.sSaveOfNum(name.get(0).toString(), starttime+"00:00:00", endtime+"23:59:59");
				Vector<Vector<Object>> inquiry3=dao.sOutOfNum(name.get(0).toString(), starttime+"00:00:00", endtime+"23:59:59");
				int flag1=0,flag2=0,flag3=0;
				int count=0;
				if(inquiry1.size()==0) {
					flag1=1;
				}
				if(inquiry2.size()==0) {
					flag2=1;
				}
				if(inquiry3.size()==0) {
					flag3=1;
				}
				for(int i=0;i<inquiry1.size();i++) {
					Vector<Object> value1=inquiry1.get(i);
					if(value1.get(3).toString().compareTo(endtime)<=0&&value1.get(3).toString().compareTo(starttime)>=0) {
					history.append(""+value1.get(5)+"向"+value1.get(4)+" 转 账"+value1.get(6)+" 元");	
					history.append("\n");
					}else {
						count++;
						if(count==inquiry1.size()-1) {
							flag1=1;
						}
					}
				}
				count=0;
				for(int j=0;j<inquiry2.size();j++) {
					Vector<Object> value2=inquiry2.get(j);
					
					if(value2.get(3).toString().compareTo(endtime)<=0&&value2.get(3).toString().compareTo(starttime)>=0) {
					history.append(" "+value2.get(3)+" 存 了"+value2.get(4)+" 元");
					history.append("\n");
					}else {
						count++;
						if(count==inquiry2.size()-1) {
							flag2=1;
						}
						
					}
				}	
				
				count=0;
				for(int k=0;k<inquiry3.size();k++) {
					Vector<Object> value3=inquiry3.get(k);
					
					if(value3.get(3).toString().compareTo(endtime)<=0&&value3.get(3).toString().compareTo(starttime)>=0) {
					history.append(" "+value3.get(3)+" 取 了"+value3.get(4)+" 元 ");
					history.append("\n");
					}else {
						count++;
						if(count==inquiry2.size()-1) {
							flag3=1;
						}
					}
				}
				//System.out.print("flag1:"+flag1+"flag2:"+flag2+"flag3:"+flag3);
			if(flag1==1&&flag2==1&&flag3==1) {
				JOptionPane.showMessageDialog(null,"这段时间内无记录!","友情提示",JOptionPane.INFORMATION_MESSAGE);
			}
			}
		});
        Northpanel.add(submit);
		
		
		this.add(Northpanel,BorderLayout.NORTH);
		
		history=new JTextArea(15,20);
		history.setLineWrap(true);
		this.add(history,BorderLayout.CENTER);
		
		returnbutton=new JButton("返回");
		returnbutton.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				new Menu(name).setVisible(true);
				
			}
		});
		
		returnbutton.setBounds(0, 210, 69, 33);
		panel.add(returnbutton);
		
		int todayyear=date.YEAR;
		int todaymonth=date.MONTH+1;
		int todayday=date.DAY_OF_MONTH;
		
		
		
		timebutton1=new JButton("七天内");
		timebutton1.addActionListener(new ActionListener() {
			
			private Vector<Vector<Object>> inquirysevendaysdate1;
			private Vector<Vector<Object>> inquirysevendaysdate2;
			private Vector<Vector<Object>> inquirysevendaysdate3;

			@Override
			public void actionPerformed(ActionEvent e) {
				history.setText("");
				int count=0;
				int flag1=0;int flag2=0;int flag3=0;
				inquirysevendaysdate1=new Vector<Vector<Object>>();
				inquirysevendaysdate2=new Vector<Vector<Object>>();
				inquirysevendaysdate3=new Vector<Vector<Object>>();
				date.set(date.DAY_OF_YEAR, (date.get(Calendar.DAY_OF_YEAR)-7));
				DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
				Date today1=date.getTime();
			    String result = format.format(today1); 
			    Calendar date2=Calendar.getInstance();
			    Date today2=date2.getTime();
				String endtime=format.format(today2);
			    inquirysevendaysdate1=dao.sdateOfNum(name.get(0).toString(),result,endtime);
				inquirysevendaysdate2=dao.sSaveOfNum(name.get(0).toString(),result,endtime);
				inquirysevendaysdate3=dao.sOutOfNum(name.get(0).toString(),result,endtime);
				System.out.println(inquirysevendaysdate1);
				System.out.println(inquirysevendaysdate2);
				System.out.println(inquirysevendaysdate3);
				if(inquirysevendaysdate1.size()==0) {
					flag1=1;
				}
				if(inquirysevendaysdate2.size()==0) {
					flag2=1;
				}
				if(inquirysevendaysdate3.size()==0) {
					flag3=1;
				}
				for(int i=0;i<inquirysevendaysdate1.size();i++) {
						Vector<Object> value1=inquirysevendaysdate1.get(i);
						System.out.println(value1);
						if(value1.get(5).toString().compareTo(endtime)<=0&&value1.get(5).toString().compareTo(result)>=0)
						{
							history.append(""+value1.get(5)+"向"+value1.get(4)+" 转 账"+value1.get(6)+" 元");	
							history.append("\n");
						}else {
							count++;
							if(count==inquirysevendaysdate1.size()-1) {
								flag1=1;
							}
							
						}
					}
					count=0;
					for(int j=0;j<inquirysevendaysdate2.size();j++) {
						Vector<Object> value2=inquirysevendaysdate2.get(j);
						System.out.println(value2);
						if(value2.get(3).toString().compareTo(endtime)<=0&&value2.get(3).toString().compareTo(result)>=0) {
						history.append(" "+value2.get(3)+" 存 了"+value2.get(4)+" 元");
						history.append("\n");
						}else {
							count++;
							if(count==inquirysevendaysdate2.size()-1) {
								flag2=1;
							}
							
						}
					}	
					count=0;
					
					for(int k=0;k<inquirysevendaysdate3.size();k++) {
						Vector<Object> value3=inquirysevendaysdate3.get(k);
						System.out.println(value3);
						if(value3.get(3).toString().compareTo(endtime)<=0&&value3.get(3).toString().compareTo(result)>=0) {
						history.append(" "+value3.get(3)+" 取 了"+value3.get(4)+" 元 ");
						history.append("\n");
						}else {
							count++;
							if(count==inquirysevendaysdate2.size()-1) {
								flag3=1;
							}
						}
					}
					System.out.print("flag1:"+flag1+"flag2:"+flag2+"flag3:"+flag3);
				if(flag1==1&&flag2==1&&flag3==1) {
					JOptionPane.showMessageDialog(null,"近七天内无记录!","友情提示",JOptionPane.INFORMATION_MESSAGE);
				}
			}
		});
		timebutton2=new JButton("一个月内");
		timebutton2.addActionListener(new ActionListener() {
			
			private Vector<Vector<Object>> inquirysevendaysdate1;
			private Vector<Vector<Object>> inquirysevendaysdate2;
			private Vector<Vector<Object>> inquirysevendaysdate3;

			@Override
			public void actionPerformed(ActionEvent e) {
				history.setText("");
				int count=0;
				int flag1=0;int flag2=0;int flag3=0;
				inquirysevendaysdate1=new Vector<Vector<Object>>();
				inquirysevendaysdate2=new Vector<Vector<Object>>();
				inquirysevendaysdate3=new Vector<Vector<Object>>();
				date.set(date.DAY_OF_YEAR, (date.get(Calendar.DAY_OF_YEAR)-30));
				DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
				Date today1=date.getTime();
			    String result = format.format(today1); 
			    Calendar date2=Calendar.getInstance();
			    Date today2=date2.getTime();
				String endtime=format.format(today2);
			    inquirysevendaysdate1=dao.sdateOfNum(name.get(0).toString(),result,endtime);
				inquirysevendaysdate2=dao.sSaveOfNum(name.get(0).toString(),result,endtime);
				inquirysevendaysdate3=dao.sOutOfNum(name.get(0).toString(),result,endtime);
				System.out.println(inquirysevendaysdate1);
				System.out.println(inquirysevendaysdate2);
				System.out.println(inquirysevendaysdate3);
				if(inquirysevendaysdate1.size()==0) {
					flag1=1;
				}
				if(inquirysevendaysdate2.size()==0) {
					flag2=1;
				}
				if(inquirysevendaysdate3.size()==0) {
					flag3=1;
				}
				for(int i=0;i<inquirysevendaysdate1.size();i++) {
						Vector<Object> value1=inquirysevendaysdate1.get(i);
						System.out.println(value1);
						if(value1.get(5).toString().compareTo(endtime)<=0&&value1.get(5).toString().compareTo(result)>=0)
						{
							history.append(""+value1.get(5)+"向"+value1.get(4)+" 转 账"+value1.get(6)+" 元");	
							history.append("\n");
						}else {
							count++;
							if(count==inquirysevendaysdate1.size()-1) {
								flag1=1;
							}
							
						}
					}
					count=0;
					for(int j=0;j<inquirysevendaysdate2.size();j++) {
						Vector<Object> value2=inquirysevendaysdate2.get(j);
						System.out.println(value2);
						if(value2.get(3).toString().compareTo(endtime)<=0&&value2.get(3).toString().compareTo(result)>=0) {
						history.append(" "+value2.get(3)+" 存 了"+value2.get(4)+" 元");
						history.append("\n");
						}else {
							count++;
							if(count==inquirysevendaysdate2.size()-1) {
								flag2=1;
							}
							
						}
					}	
					count=0;
					
					for(int k=0;k<inquirysevendaysdate3.size();k++) {
						Vector<Object> value3=inquirysevendaysdate3.get(k);
						System.out.println(value3);
						if(value3.get(3).toString().compareTo(endtime)<=0&&value3.get(3).toString().compareTo(result)>=0) {
						history.append(" "+value3.get(3)+" 取 了"+value3.get(4)+" 元 ");
						history.append("\n");
						}else {
							count++;
							if(count==inquirysevendaysdate2.size()-1) {
								flag3=1;
							}
						}
					}
					System.out.print("flag1:"+flag1+"flag2:"+flag2+"flag3:"+flag3);
				if(flag1==1&&flag2==1&&flag3==1) {
					JOptionPane.showMessageDialog(null,"近一个月内无记录!","友情提示",JOptionPane.INFORMATION_MESSAGE);
				}
			}
		});
		
		timebutton3=new JButton("三个月内");
		timebutton3.addActionListener(new ActionListener() {
			
			private Vector<Vector<Object>> inquirysevendaysdate1;
			private Vector<Vector<Object>> inquirysevendaysdate2;
			private Vector<Vector<Object>> inquirysevendaysdate3;

			@Override
			public void actionPerformed(ActionEvent e) {
				history.setText("");
				int count=0;
				int flag1=0;int flag2=0;int flag3=0;
				inquirysevendaysdate1=new Vector<Vector<Object>>();
				inquirysevendaysdate2=new Vector<Vector<Object>>();
				inquirysevendaysdate3=new Vector<Vector<Object>>();
				date.set(date.DAY_OF_YEAR, (date.get(Calendar.DAY_OF_YEAR)-date.DAY_OF_YEAR/4));
				DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
				Date today1=date.getTime();
			    String result = format.format(today1); 
			    Calendar date2=Calendar.getInstance();
			    Date today2=date2.getTime();
				String endtime=format.format(today2);
			    inquirysevendaysdate1=dao.sdateOfNum(name.get(0).toString(),result,endtime);
				inquirysevendaysdate2=dao.sSaveOfNum(name.get(0).toString(),result,endtime);
				inquirysevendaysdate3=dao.sOutOfNum(name.get(0).toString(),result,endtime);
				System.out.println(inquirysevendaysdate1);
				System.out.println(inquirysevendaysdate2);
				System.out.println(inquirysevendaysdate3);
				if(inquirysevendaysdate1.size()==0) {
					flag1=1;
				}
				if(inquirysevendaysdate2.size()==0) {
					flag2=1;
				}
				if(inquirysevendaysdate3.size()==0) {
					flag3=1;
				}
				for(int i=0;i<inquirysevendaysdate1.size();i++) {
						Vector<Object> value1=inquirysevendaysdate1.get(i);
						System.out.println(value1);
						if(value1.get(5).toString().compareTo(endtime)<=0&&value1.get(5).toString().compareTo(result)>=0)
						{
							history.append(""+value1.get(5)+"向"+value1.get(4)+" 转 账"+value1.get(6)+" 元");	
							history.append("\n");
						}else {
							count++;
							if(count==inquirysevendaysdate1.size()-1) {
								flag1=1;
							}
							
						}
					}
					count=0;
					for(int j=0;j<inquirysevendaysdate2.size();j++) {
						Vector<Object> value2=inquirysevendaysdate2.get(j);
						System.out.println(value2);
						if(value2.get(3).toString().compareTo(endtime)<=0&&value2.get(3).toString().compareTo(result)>=0) {
						history.append(" "+value2.get(3)+" 存 了"+value2.get(4)+" 元");
						history.append("\n");
						}else {
							count++;
							if(count==inquirysevendaysdate2.size()-1) {
								flag2=1;
							}
							
						}
					}	
					count=0;
					
					for(int k=0;k<inquirysevendaysdate3.size();k++) {
						Vector<Object> value3=inquirysevendaysdate3.get(k);
						System.out.println(value3);
						if(value3.get(3).toString().compareTo(endtime)<=0&&value3.get(3).toString().compareTo(result)>=0) {
						history.append(" "+value3.get(3)+" 取 了"+value3.get(4)+" 元 ");
						history.append("\n");
						}else {
							count++;
							if(count==inquirysevendaysdate2.size()-1) {
								flag3=1;
							}
						}
					}
					System.out.print("flag1:"+flag1+"flag2:"+flag2+"flag3:"+flag3);
				if(flag1==1&&flag2==1&&flag3==1) {
					JOptionPane.showMessageDialog(null,"近三个月内无记录!","友情提示",JOptionPane.INFORMATION_MESSAGE);
				}
			}
		});
		
		timebutton4=new JButton("半年内");
		timebutton4.addActionListener(new ActionListener() {
			
			private Vector<Vector<Object>> inquirysevendaysdate1;
			private Vector<Vector<Object>> inquirysevendaysdate2;
			private Vector<Vector<Object>> inquirysevendaysdate3;

			@Override
			public void actionPerformed(ActionEvent e) {
				history.setText("");
				int count=0;
				int flag1=0;int flag2=0;int flag3=0;
				inquirysevendaysdate1=new Vector<Vector<Object>>();
				inquirysevendaysdate2=new Vector<Vector<Object>>();
				inquirysevendaysdate3=new Vector<Vector<Object>>();
				date.set(date.DAY_OF_YEAR, (date.get(Calendar.DAY_OF_YEAR)-date.DAY_OF_YEAR/2));
				DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
				Date today1=date.getTime();
			    String result = format.format(today1); 
			    Calendar date2=Calendar.getInstance();
			    Date today2=date2.getTime();
				String endtime=format.format(today2);
			    inquirysevendaysdate1=dao.sdateOfNum(name.get(0).toString(),result,endtime);
				inquirysevendaysdate2=dao.sSaveOfNum(name.get(0).toString(),result,endtime);
				inquirysevendaysdate3=dao.sOutOfNum(name.get(0).toString(),result,endtime);
				System.out.println(inquirysevendaysdate1);
				System.out.println(inquirysevendaysdate2);
				System.out.println(inquirysevendaysdate3);
				if(inquirysevendaysdate1.size()==0) {
					flag1=1;
				}
				if(inquirysevendaysdate2.size()==0) {
					flag2=1;
				}
				if(inquirysevendaysdate3.size()==0) {
					flag3=1;
				}
				for(int i=0;i<inquirysevendaysdate1.size();i++) {
						Vector<Object> value1=inquirysevendaysdate1.get(i);
						System.out.println(value1);
						if(value1.get(5).toString().compareTo(endtime)<=0&&value1.get(5).toString().compareTo(result)>=0)
						{
							history.append(""+value1.get(5)+"向"+value1.get(4)+" 转 账"+value1.get(6)+" 元");	
							history.append("\n");
						}else {
							count++;
							if(count==inquirysevendaysdate1.size()-1) {
								flag1=1;
							}
							
						}
					}
					count=0;
					for(int j=0;j<inquirysevendaysdate2.size();j++) {
						Vector<Object> value2=inquirysevendaysdate2.get(j);
						System.out.println(value2);
						if(value2.get(3).toString().compareTo(endtime)<=0&&value2.get(3).toString().compareTo(result)>=0) {
						history.append(" "+value2.get(3)+" 存 了"+value2.get(4)+" 元");
						history.append("\n");
						}else {
							count++;
							if(count==inquirysevendaysdate2.size()-1) {
								flag2=1;
							}
							
						}
					}	
					count=0;
					
					for(int k=0;k<inquirysevendaysdate3.size();k++) {
						Vector<Object> value3=inquirysevendaysdate3.get(k);
						System.out.println(value3);
						if(value3.get(3).toString().compareTo(endtime)<=0&&value3.get(3).toString().compareTo(result)>=0) {
						history.append(" "+value3.get(3)+" 取 了"+value3.get(4)+" 元 ");
						history.append("\n");
						}else {
							count++;
							if(count==inquirysevendaysdate2.size()-1) {
								flag3=1;
							}
						}
					}
					System.out.print("flag1:"+flag1+"flag2:"+flag2+"flag3:"+flag3);
				if(flag1==1&&flag2==1&&flag3==1) {
					JOptionPane.showMessageDialog(null,"近半年内无记录!","友情提示",JOptionPane.INFORMATION_MESSAGE);
				}
			}
		});
		
		exit=new JButton("退卡");
		exit.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				JOptionPane.showMessageDialog(null,"您已退卡!","友情提示",JOptionPane.INFORMATION_MESSAGE);
				count++;
				dao.upStateByNum(name.get(0).toString());
				System.exit(0);
			}
		});
		
		panel1=new JPanel();
		final JPanel aButtonPanel=new JPanel();
		aButtonPanel.setLayout(new GridLayout(0,1));
		aButtonPanel.add(new JLabel("        "));
		aButtonPanel.add(new JLabel("        "));
		aButtonPanel.add(timebutton1);
		aButtonPanel.add(new JLabel("        "));
		aButtonPanel.add(new JLabel("        "));
		aButtonPanel.add(timebutton2);
		aButtonPanel.add(new JLabel("        "));
		aButtonPanel.add(new JLabel("        "));
		aButtonPanel.add(returnbutton);
		panel.add(aButtonPanel);
		
		final JPanel bButtonPanel=new JPanel();
		//bButtonPanel.setBorder(new TitledBorder(null,"",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION));//设置边框
		bButtonPanel.setLayout(new GridLayout(0,1));
		bButtonPanel.add(new JLabel("        "));
		bButtonPanel.add(new JLabel("        "));
		bButtonPanel.add(timebutton3);
		bButtonPanel.add(new JLabel("        "));
		bButtonPanel.add(new JLabel("        "));
		bButtonPanel.add(timebutton4);
		bButtonPanel.add(new JLabel("        "));
		bButtonPanel.add(new JLabel("        "));
		bButtonPanel.add(exit);
		panel1.add(bButtonPanel);
		
		this.add(Southpanel,BorderLayout.SOUTH);
		this.add(panel1,BorderLayout.EAST);
		this.add(panel,BorderLayout.WEST);
		
	}

}

(10)修改密码界面:

package com.ATM.frame.mframe;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Image;
import java.awt.Insets;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.net.URL;
import java.util.Vector;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;

import com.mwq.dao.dao.Dao;
import com.ATM.frame.Menu;
import com.ATM.swing.MPanel;

@SuppressWarnings("serial")
public class Correctpassword extends JFrame{

	public static void main(String[] args) {
		new Correctpassword(null).setVisible(true);
	}
	private JComboBox<String> usernameComboBox;
	private JPasswordField passwordField;
	private JLabel cardlabel;
	private JPasswordField cardtextField;
	private JLabel passwordlabel;
	private ImageIcon image;
	private JButton login;
	private JPanel buttonpanel;
	private Dao dao=Dao.getInstance();
	private int j=0;
	private JButton exitbutton;
	private int count=0;
	private Vector<Object> checkpassword;
	private JLabel correctlabel;
	private JPasswordField correctField;
	private JLabel whitelabel;
	private JPasswordField passwordtextField1;
	private JPasswordField passwordField2;
	private JPasswordField passwordField3;
	private JButton returnbutton;
	public Correctpassword(Vector<Object> name) {
		this.setTitle("修改密码窗口");
		this.setResizable(false);
		Dimension screenSize=Toolkit.getDefaultToolkit().getScreenSize();
		this.setBounds((screenSize.width-428)/2,(screenSize.height-292)/2,500,380);
		this.validate();
        this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
		
		this.addWindowListener(new WindowAdapter() {
			@Override
			public void windowClosing(WindowEvent e) {
				if(count==0) {
					if(checkpassword!=null) {
						JOptionPane.showMessageDialog(null, "请先退卡!否则不能退出当前系统!",
								"友情提示",JOptionPane.INFORMATION_MESSAGE);
					}
					else {
						System.exit(0);
					}
				}else {

					JOptionPane.showMessageDialog(null, "您已退卡!",
							"友情提示",JOptionPane.INFORMATION_MESSAGE);
					System.exit(0);
				}
				super.windowClosing(e);
			}
		});
		
		//自定义MPanle,通过绘制的方式添加背景图片
		MPanel panel=new MPanel(this.getClass().getResource("/img/Login.jpg"));
		this.add(panel,BorderLayout.CENTER);
		
		
		//添加组件
		cardlabel=new JLabel("请输入原始密码:    ");
		cardlabel.setFont(new Font("",Font.BOLD,12));
		cardlabel.setBounds(140,100,110,20);
		panel.add(cardlabel);
		
		passwordtextField1=new JPasswordField();
		passwordtextField1.setBounds(240,100,110,20);
		panel.add(passwordtextField1);
		
		//查询插卡状态,若为1则可以登录,若为0则需要插卡(输入卡号)
		Vector<Object> userNameV=Dao.getInstance().sCardIDofNotFreeze();
		
		passwordlabel=new JLabel("请输入修改密码:");
		passwordlabel.setFont(new Font("",Font.BOLD,12));
		passwordlabel.setBounds(140, 130, 110, 20);
		panel.add(passwordlabel);
		
		passwordField2 = new JPasswordField();
		passwordField2.setBounds(240,130,110,20);
		
		panel.add(passwordField2);
		
		correctlabel=new JLabel("请确认修改密码:");
		correctlabel.setFont(new Font("",Font.BOLD,12));
		correctlabel.setBounds(140, 160, 110, 20);
		panel.add(correctlabel);
		
		passwordField3 = new JPasswordField();
		passwordField3.setBounds(240,160,110,20);
		panel.add(passwordField3);
		
		buttonpanel=new JPanel();
		
		returnbutton=new JButton("返回");
		returnbutton.setFont(new Font("",Font.BOLD,12));
		returnbutton.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				new Menu(name).setVisible(true);
				
			}
		});
		returnbutton.setBounds(100, 230, 69, 33);
		panel.add(returnbutton);
		
		//添加登录按钮
		login=new JButton("确定");
		login.setFont(new Font("",Font.BOLD,12));
		//登录按钮事件处理
		login.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				//System.out.print(passwordtextField1.getPassword());
					char[] passwords=passwordtextField1.getPassword();
					String inputPassword=String.valueOf(passwords);
					if(inputPassword.length()==0) {
						JOptionPane.showMessageDialog(null, "请输入原始密码!","友情提示 ",JOptionPane.OK_OPTION);
					}else {
							String check=name.get(2).toString();
							if(inputPassword.equals(check)) {
								char[] checkPassword=passwordField2.getPassword();//修改的密码
								String checkpassword=String.valueOf(checkPassword);
								System.out.print(checkpassword);
								char[] correctPassword=passwordField3.getPassword();//确认修改密码
								String correctpassword=String.valueOf(correctPassword);
								System.out.print(correctpassword);
								if(correctpassword.length()==0) {
									JOptionPane.showMessageDialog(null, "确认密码不能为空!","友情提示 ",JOptionPane.INFORMATION_MESSAGE);
									
								}else {
									if(correctpassword.equals(checkpassword)) {
										JOptionPane.showMessageDialog(null, "修改密码成功!","友情提示 ",JOptionPane.INFORMATION_MESSAGE);
										dao.uPasswordOfCard(name.get(0).toString(),checkpassword);
									}else {
										JOptionPane.showMessageDialog(null, "两次输入的确认密码不一致!请重新输入!","友情提示 ",JOptionPane.INFORMATION_MESSAGE);
										passwordField2.setText("");
										passwordField3.setText("");
									}
								}
							}else {
								j++;
								if(j>=3) {
									JOptionPane.showMessageDialog(null, "您输入错误密码的次数已经超过3次!已吞卡!","友情提示 ",JOptionPane.YES_NO_OPTION);
									cardtextField.setText("");
									passwordField.setText("");
									
								}else {
									JOptionPane.showMessageDialog(null, "您输入的密码有误!请重新输入!","友情提示 ",JOptionPane.YES_NO_OPTION);
								}
								
							}
						
						
					}
					
				
				
			}
		});

		login.setBounds(220, 230, 70, 33);
		panel.add(login);	
		//将两个按钮添加到面板中

		exitbutton=new JButton("退卡");
		exitbutton.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				count++;
				JOptionPane.showMessageDialog(null, "您已退卡!","友情提示 ",JOptionPane.INFORMATION_MESSAGE);
				dao.upStateByNum(name.get(0).toString());
				System.exit(0);
				
			}
		});
		exitbutton.setBounds(340, 230, 70, 33);
		panel.add(exitbutton);	
		
		
	}
	
}

还有一些自定义的类:

(1)MPanel类(设置背景图片的类)

package com.ATM.swing;

import java.awt.Graphics;
import java.awt.Image;
import java.net.URL;

import javax.swing.ImageIcon;
import javax.swing.JPanel;

@SuppressWarnings("serial")
public class MPanel extends JPanel{

	private ImageIcon imageIcon;
	public MPanel(URL url) {
		this.setLayout(null);
		imageIcon=new ImageIcon(url);
		this.setSize(imageIcon.getIconWidth(),imageIcon.getIconHeight());
	}
	protected void paintComponent(Graphics g) {
		super.paintComponent(g);
		Image image=imageIcon.getImage();
		g.drawImage(image, 0, 0, this.getWidth(), this.getHeight(), this);
	}
}

(2)MTable类:

package com.ATM.swing;

import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableCellRenderer;

public class MTable extends JTable{

	public MTable() {
		super();
	}
	public MTable(DefaultTableModel tableModel) {
		super(tableModel);
	}
	
	public TableCellRenderer getDefaultRender(Class<?> columnClass) {
		DefaultTableCellRenderer tableRenderer=(DefaultTableCellRenderer) super.getDefaultEditor(columnClass);
		tableRenderer.setHorizontalAlignment(DefaultTableCellRenderer.CENTER);
		return tableRenderer;
	}
	
	public void setRowSelectionInterval(int row) {
		setRowSelectionInterval(row, row);
	}
	
	public boolean isCellEditable(int row,int column) {
		return false;
	}
	
	@Override
	public ListSelectionModel getSelectionModel() {
		ListSelectionModel selectionModel=super.getSelectionModel();
		selectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		return selectionModel;
	}
}

运行效果图:

完整版银行ATM机的实现

完整版银行ATM机的实现

完整版银行ATM机的实现

完整版银行ATM机的实现

完整版银行ATM机的实现

完整版银行ATM机的实现

完整版银行ATM机的实现

完整版银行ATM机的实现

希望我这个编程小白能帮到你们!