Java项目:银行管理系统(java+Gui+文档)

功能介绍:

事件处理、挂失、打印、改密、查询、存款、取款、转账、挂失、退卡

 

 

 

账户余额业务操作:

package com.shao.iframe;

import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.DecimalFormat;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

import com.shao.DAO.ExecuteSQL;
import com.shao.model.user;

public class atmFrame extends JFrame {

	private JPanel contentPane;
	private user user;
//	private LoginFrame lf;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					atmFrame frame = new atmFrame(null);
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}


	/**
	 * Create the frame.
	 */
	public atmFrame(final String name) {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 518, 434);
		contentPane = new JPanel();
		setTitle(name);
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setLocationRelativeTo(null);
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JButton queryButton = new JButton("\u67E5\u8BE2");
		queryButton.setBounds(99, 101, 113, 27);
		contentPane.add(queryButton);
		queryButton.addActionListener(new ActionListener(){
		public void actionPerformed(ActionEvent e) {
			user = ExecuteSQL.query(name);
			DecimalFormat df = new DecimalFormat( "0.00 "); 
			JOptionPane.showMessageDialog(null,
		              "您的账户名:"+user.getName()+"\n"+"当前余额:¥"+user.getbalance()+"\n","信息提示",
		              JOptionPane.INFORMATION_MESSAGE);		
		}
		});
		
		JButton depositButton = new JButton("\u5B58\u6B3E");
		depositButton.setBounds(99, 223, 113, 27);
		contentPane.add(depositButton);
		depositButton.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				depositFrame df = new depositFrame(name);
				setVisible(false);
				df.setVisible(true);
			}
			
		});
		
		JButton withdrawButton = new JButton("\u53D6\u6B3E");
		withdrawButton.setBounds(288, 101, 113, 27);
		contentPane.add(withdrawButton);
		withdrawButton.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				withdrawFrame wf = new withdrawFrame(name);
				setVisible(false);
				wf.setVisible(true);
			}
			
		});
		
		JButton transferButton = new JButton("\u8F6C\u8D26");
		transferButton.setBounds(288, 223, 113, 27);
		contentPane.add(transferButton);
		transferButton.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				transferFrame wf = new transferFrame(name);
				setVisible(false);
				wf.setVisible(true);
			}
			
		});
	}

}

转账业务操作:

package com.shao.iframe;

import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.DecimalFormat;

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 javax.swing.border.EmptyBorder;

import com.shao.DAO.ExecuteSQL;

public class transferFrame extends JFrame {

	private JPanel contentPane;
	private JTextField out_nameField;
	private JTextField out_moneyField;
	//private com.shao.model.user user;
	private com.shao.model.user user_query_deposit;
	private com.shao.model.user user_modMoney_deposit;
	private com.shao.model.user user_query_withdraw;
	private com.shao.model.user user_modMoney_withdraw;
	
	/**
	 * Create the frame.
	 */
	public transferFrame(final String name) {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 527, 358);
		setTitle(name);
		setLocationRelativeTo(null);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JLabel lblNewLabel = new JLabel("\u8F6C\u8D26\u7528\u6237\u540D\uFF1A");
		lblNewLabel.setFont(new Font("新宋体", Font.BOLD, 20));
		lblNewLabel.setBounds(105, 72, 126, 30);
		contentPane.add(lblNewLabel);
		
		out_nameField = new JTextField();
		out_nameField.setBounds(245, 77, 150, 24);
		contentPane.add(out_nameField);
		out_nameField.setColumns(10);
		
		JLabel lblNewLabel_1 = new JLabel("\u8F6C\u8D26\u91D1\u989D\uFF1A");
		lblNewLabel_1.setFont(new Font("新宋体", Font.BOLD, 20));
		lblNewLabel_1.setBounds(105, 141, 112, 30);
		contentPane.add(lblNewLabel_1);
		
		out_moneyField = new JTextField();
		out_moneyField.setBounds(243, 146, 152, 24);
		contentPane.add(out_moneyField);
		out_moneyField.setColumns(10);
		
		JButton OKButton = new JButton("\u786E\u8BA4");
		OKButton.setFont(new Font("新宋体", Font.BOLD, 17));
		OKButton.setBounds(104, 225, 113, 27);
		contentPane.add(OKButton);
		OKButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				int res = JOptionPane.showConfirmDialog(null, "确认此次转账?", "转账确认", JOptionPane.YES_NO_OPTION);
				if (res == JOptionPane.YES_OPTION) {
					user_query_deposit = ExecuteSQL.query(out_nameField.getText());//转出钱
					if (out_nameField.getText().equals(user_query_deposit.getName())) {
						if (Float.parseFloat(out_moneyField.getText()) < 100000) {
							if(Float.parseFloat(out_moneyField.getText())%100==0) {
								user_query_withdraw = ExecuteSQL.query(name);
								// user_1 = ExecuteSQL.query(out_nameField);
								if (user_query_withdraw.getbalance() > Double.parseDouble(out_moneyField.getText())) {
									double temp = user_query_withdraw.getbalance() - Double.parseDouble(out_moneyField.getText());
									double temp_1 = user_query_deposit.getbalance() + Double.parseDouble(out_moneyField.getText());
									DecimalFormat df = new DecimalFormat("0.00 ");
									int i_withdraw = ExecuteSQL.modifyMoney(name, temp);
									int i_deposit = ExecuteSQL.modifyMoney(out_nameField.getText(), temp_1);
									if(i_withdraw>0 && i_deposit>0){
										setVisible(false);
										atmFrame frame = new atmFrame(name);
										frame.setVisible(true);
										JOptionPane.showMessageDialog(null, "转账交易成功!" + "\n" + "剩余余额为:" + df.format(temp));
									}else{
										JOptionPane.showMessageDialog(null, "转账交易失败!" + "\n" + "剩余余额为:" + df.format(temp));						
									}														
								} else {
									JOptionPane.showMessageDialog(null,
											"余额不足,请重新输入!" + "\n" + "当前余额为:" + user_query_withdraw.getbalance());
									out_moneyField.setText("");
								}
							}else {
								JOptionPane.showMessageDialog(null, "输入金额大于1000000,请重新输入!");
								out_moneyField.setText("");
							}

						
						} else {
							JOptionPane.showMessageDialog(null, "转账金额必须10000,请重新输入!");
							out_moneyField.setText("");
						}
					} else {
						JOptionPane.showMessageDialog(null, "找不到该转账用户!");
						out_nameField.setText("");
					}
				} else {
					return;
				}
			}
		});
		
		JButton backButton_1 = new JButton("\u8FD4\u56DE");
		backButton_1.setFont(new Font("新宋体", Font.BOLD, 18));
		backButton_1.setBounds(282, 225, 113, 27);
		contentPane.add(backButton_1);
		backButton_1.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e) {
				atmFrame af = new atmFrame(name);
				setVisible(false);
				af.setVisible(true);			
			}		
		});
	}

}

交易业务操作:

package com.shao.iframe;

import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.DecimalFormat;

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 javax.swing.border.EmptyBorder;

import com.shao.DAO.ExecuteSQL;

public class withdrawFrame extends JFrame {

	private JPanel contentPane;
	private JTextField outputField;
	private com.shao.model.user user_query;
	private com.shao.model.user user_modMoney;

	/**
	 * Create the frame.
	 */
	public withdrawFrame(final String name) {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		setTitle(name);
		setLocationRelativeTo(null);
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JLabel lblNewLabe = new JLabel("\u53D6\u6B3E\u91D1\u989D\uFF1A");
		lblNewLabe.setFont(new Font("新宋体", Font.BOLD, 20));
		lblNewLabe.setBounds(84, 75, 117, 38);
		contentPane.add(lblNewLabe);
		
		outputField = new JTextField();
		outputField.setBounds(199, 84, 117, 24);
		contentPane.add(outputField);
		outputField.setColumns(10);
		
		JButton OKButton = new JButton("\u786E\u5B9A");
		OKButton.setFont(new Font("新宋体", Font.BOLD, 15));
		OKButton.setBounds(84, 159, 113, 27);
		contentPane.add(OKButton);
		OKButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				System.out.println("withdrawFrame.withdrawFrame(...).new ActionListener() {...}.actionPerformed()"+outputField.getText());
				if (Float.parseFloat(outputField.getText()) < 100000) {
					if(Float.parseFloat(outputField.getText())%100==0) {
						user_query = ExecuteSQL.query(name);
						if (user_query.getbalance() > Double.parseDouble(outputField.getText())) {
							double temp = user_query.getbalance() - Double.parseDouble(outputField.getText());
							DecimalFormat df = new DecimalFormat( "0.00 ");   
							int i = ExecuteSQL.modifyMoney(name, temp);	
							if(i>0){
								setVisible(false);
								atmFrame frame = new atmFrame(name);
								frame.setVisible(true);
								JOptionPane.showMessageDialog(null, "取钱交易成功!"+"\n" + "剩余余额为:" + df.format(temp));
							}else{
								JOptionPane.showMessageDialog(null, "取钱交易失败!"+"\n" + "剩余余额为:" + df.format(temp));
							}
													
						} else {
							JOptionPane.showMessageDialog(null, "余额不足,请重新输入!" + "\n" + "当前余额为:" + user_query.getbalance());
							outputField.setText("");
						}
					}else {
						JOptionPane.showMessageDialog(null, "系统不支持非100元整钞,请重新输入!");
						outputField.setText("");
					}
					
				} else {
					JOptionPane.showMessageDialog(null, "输入金额大于100000,请重新输入!");
					outputField.setText("");
				}

			}

		});
		
		JButton backButton_1 = new JButton("\u8FD4\u56DE");
		backButton_1.setFont(new Font("新宋体", Font.BOLD, 15));
		backButton_1.setBounds(233, 159, 113, 27);
		contentPane.add(backButton_1);
		backButton_1.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e) {
				atmFrame af = new atmFrame(name);
				setVisible(false);
				af.setVisible(true);			
			}		
		});
		
		JLabel remindLabel = new JLabel("*\u5355\u7B14\u6700\u5927\u53EF\u53D610000");
		remindLabel.setForeground(Color.RED);
		remindLabel.setBounds(199, 126, 138, 18);
		contentPane.add(remindLabel);
	}

}

猜你喜欢

转载自blog.csdn.net/m0_59687645/article/details/121695604
今日推荐