import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.event.*;
import java.sql.*;
public class ATM extends JFrame implements ActionListener
{
private String ID = "123456";
private String password = "123456";
private int money = 10000;
private Connection con = null;
private Statement stmt = null;
private ResultSet rs = null;
private String id_no ="";
public static void main(String args[])
{
ATM A = new ATM();
A.setSize(400, 300);
A.setBackground(Color.blue);
A.setLocation(300,200);
A.setTitle("欢迎使用ATM柜员机!!!");
A.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
A.setVisible(true);
A.showCardLayout();
}
public ATM()
{
super();
}
public ATM(String ID, String password,int money)
{
this.ID = ID;
this.password = password;
this.money = money;
}
private void getRecord()
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch (ClassNotFoundException ex)
{
System.out.println("数据库驱动出错或不存在");
System.exit(-1);
}
try
{
String URL = "jdbc:odbc:ATM";
con = DriverManager.getConnection(URL);
stmt =con.createStatement();
}
catch(SQLException ex)
{
System.out.println("连接数据库失败");
}
}
protected boolean get_ID(String id_no)
{
String id1;
String id2;
id1 = id_no;
getRecord();
String sql = "select ID from atm where ID ='" + id1 + "'";
try
{
rs = stmt.executeQuery(sql);
if (rs.next())
{
id2 = rs.getString("ID");
if (id1.equals(id2))
{
return true;
}
}
rs.close();
stmt.close();
con.close();
}
catch (Exception e)
{
}
return false;
}
protected boolean get_password(String ID, String password)
{
String pwd;
getRecord();
String sql = "select password from atm where ID ='" + ID + "'";
try
{
rs = stmt.executeQuery(sql);
if (rs.next())
{
pwd = rs.getString("password");
if (password.equals(pwd))
{
return true;
}
}
rs.close();
stmt.close();
con.close();
}
catch (Exception ex) { }
return false;
}
protected int get_money(String ID)
{
int money = 0;
getRecord();
String sql = "select money from atm where ID ='" + ID + "'";
try
{
rs = stmt.executeQuery(sql);
if(rs.next())
{
money = Integer.parseInt(rs.getString("money"));
}
rs.close();
stmt.close();
con.close();
}
catch(Exception ex)
{
}
return money;
}
public boolean set_balance4(String pass)
{
StringBuffer buffer = new StringBuffer(pass);
if (buffer.charAt(0) == buffer.charAt(1) && buffer.charAt(1) ==buffer.charAt(2) && buffer.charAt(2) ==buffer.charAt(3) && buffer.charAt(3) == buffer.charAt(4) && buffer.charAt(4) == buffer.charAt(5))
{
return true;
}
else
{
return false;
}
}
JPanel p1 = new JPanel(); //主界面
JPanel a1 = new JPanel();
JPanel a2 = new JPanel();
JPanel p2 = new JPanel(); //帐号密码输入界面
JPanel b1 = new JPanel();
JPanel b2 = new JPanel();
JPanel b3 = new JPanel();
JPanel b4 = new JPanel();
JPanel p3 = new JPanel(); //选择服务
JPanel c1 = new JPanel();
JPanel c2 = new JPanel();
JPanel c3 = new JPanel();
JPanel c4 = new JPanel();
JPanel p4 = new JPanel(); //取款
JPanel d1 = new JPanel();
JPanel d2 = new JPanel();
JPanel d3 = new JPanel();
JPanel p5 = new JPanel(); //取款成功
JPanel e1 = new JPanel();
JPanel e2 = new JPanel();
JPanel p6 = new JPanel(); //存款
JPanel f1 = new JPanel();
JPanel f2 = new JPanel();
JPanel f3 = new JPanel();
JPanel p7 = new JPanel(); //存款成功
JPanel g1 = new JPanel();
JPanel g2 = new JPanel();
JPanel p8 = new JPanel(); //查询余额
JPanel h1 = new JPanel();
JPanel h2 = new JPanel();
JPanel p9 = new JPanel(); //修改密码
JPanel i1 = new JPanel();
JPanel i2 = new JPanel();
JPanel i3 = new JPanel();
JPanel i4 = new JPanel();
JPanel p10 = new JPanel(); //转帐
JPanel j1 = new JPanel();
JPanel j2 = new JPanel();
JPanel j3 = new JPanel();
JPanel j4 = new JPanel();
JLabel t1 = new JLabel("欢迎使用ATM机");
JLabel t2 = new JLabel("帐号:");
JLabel t3 = new JLabel("密码:");
JLabel t4 = new JLabel("");
JLabel t5 = new JLabel("请选择您要的服务:");
JLabel t6 = new JLabel("请输入取款金额");
JLabel t7 = new JLabel("");
JLabel t8 = new JLabel("取款成功!");
JLabel t9 = new JLabel("请输入存款金额");
JLabel t10 = new JLabel("");
JLabel t11 = new JLabel("存款成功!");
JLabel t12 = new JLabel("您所剩余额:");
JLabel t13 = new JLabel("新密码:");
JLabel t14 = new JLabel("");
JLabel t15 = new JLabel("确认密码");
JLabel t16 = new JLabel("");
JLabel t17 = new JLabel("");
JLabel t18 = new JLabel("请输入转帐卡号:");
JLabel t19 = new JLabel("请输入转帐金额:");
JLabel t20 = new JLabel("");
JButton z1 = new JButton("进入");
JButton z2 = new JButton("确认");
JButton z3 = new JButton("返回");
JButton z4 = new JButton("取款");
JButton z5 = new JButton("存款");
JButton z6 = new JButton("查询余额");
JButton z7 = new JButton("修改密码");
JButton z8 = new JButton("退卡");
JButton z9 = new JButton("确认");
JButton z10 = new JButton("返回");
JButton z11 = new JButton("返回");
JButton z12 = new JButton("确定");
JButton z13 = new JButton("返回");
JButton z14 = new JButton("返回");
JButton z15 = new JButton("返回");
JButton z16 = new JButton("确定");
JButton z17 = new JButton("返回");
JButton z18 = new JButton("查询");
JButton z19 = new JButton("确定");
JButton z20 = new JButton("返回");
JButton z21 = new JButton("转帐");
JTextField text1 = new JTextField(6);
JTextField text2 = new JTextField(4);
JTextField text3 = new JTextField(4);
JTextField text4 = new JTextField(6);
JTextField text5 = new JTextField(4);
JPasswordField pw1 = new JPasswordField(6);
JPasswordField pw2 = new JPasswordField(6);
JPasswordField pw3 = new JPasswordField(6);
Container c = this.getContentPane();
CardLayout cl = new CardLayout();
GridLayout gl = new GridLayout(4,1,20,30);
public void showCardLayout()
{
c.setLayout(cl);
p1.setLayout(gl);
p2.setLayout(gl);
p3.setLayout(gl);
p4.setLayout(gl);
p5.setLayout(gl);
p6.setLayout(gl);
p7.setLayout(gl);
p8.setLayout(gl);
p9.setLayout(gl);
p10.setLayout(gl);
p1.add(a1);
a1.add(t1);
p1.add(a2);
a2.add(z1);
p2.add(b1);
b1.add(t2);
b1.add(text1);
p2.add(b2);
b2.add(t3);
b2.add(pw1);
p2.add(b3);
b3.add(t4);
p2.add(b4);
b4.add(z2);
b4.add(z3);
p3.add(c1);
c1.add(t5);
p3.add(c2);
c2.add(z4);
c2.add(z5);
p3.add(c3);
c3.add(z6);
c3.add(z7);
p3.add(c4);
c4.add(z21);
c4.add(z8);
p4.add(d1);
d1.add(t6);
d1.add(text2);
p4.add(d2);
d2.add(t7);
p4.add(d3);
d3.add(z9);
d3.add(z10);
p5.add(e1);
e1.add(t8);
p5.add(e2);
e2.add(z11);
p6.add(f1);
f1.add(t9);
f1.add(text3);
p6.add(f2);
f2.add(t10);
p6.add(f3);
f3.add(z12);
f3.add(z13);
p7.add(g1);
g1.add(t11);
p7.add(g2);
g2.add(z14);
p8.add(h1);
h1.add(t12);
h1.add(t17);
p8.add(h2);
h2.add(z18);
h2.add(z15);
p9.add(i1);
i1.add(t13);
i1.add(pw2);
i1.add(t14);
p9.add(i2);
i2.add(t15);
i2.add(pw3);
p9.add(i3);
i3.add(t16);
p9.add(i4);
i4.add(z16);
i4.add(z17);
p10.add(j1);
j1.add(t18);
j1.add(text4);
p10.add(j2);
j2.add(t19);
j2.add(text5);
p10.add(j3);
j3.add(t20);
p10.add(j4);
j4.add(z19);
j4.add(z20);
c.add(p1,"1");
c.add(p2,"2");
c.add(p3,"3");
windysi
- 粉丝: 0
- 资源: 4
最新资源
- dnSpy-net-win32-222.zip
- mongoose-free-6.9
- 德普微一级代理 DP100N06MGL PDFN3.3*3.3 TRMOS N-MOSFET 60V, 8mΩ, 45A
- 【java毕业设计】SpringBoot+Vue幼儿园管理系统 源码+sql脚本+论文 完整版
- 德普微一级代理 DP021N03FGLI DFN5*6 DPMOS N-MOSFET 30V 180A 1.8mΩ
- 巨潮资讯网5000只股票orgId-dict加密字典
- 基于java实现的快速排序代码
- 德普微一级代理 DP3145D SOT23-6 USB PD 协议单口控制器
- 【一文搞懂:什么是集成学习-原理+python代码】
- 国际象棋检测7-YOLO(v5至v9)、COCO、CreateML、Darknet、Paligemma、TFRecord数据集合集.rar
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈