温馨提示由于代码太多只是上传了ATM客户端部分,管理员和超级管理员还有数据库部分上传了工程包,可以直接点击
https://i.cnblogs.com/Files.aspx去里面找。
package Atm; import java.awt.GridLayout;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton; public class ChooseIdentity extends FatherFrame{
JRadioButton jrb1;
JRadioButton jrb2;
JRadioButton jrb3;
public ChooseIdentity(){
setInterface();
}
public void initJLabel(){
jb1 = new JLabel();
jb2 = new JLabel();
jb3 = new JLabel();
jb4 = new JLabel(new ImageIcon("image/确认2.png"));
jb5 = new JLabel();
jb6 = new JLabel();
jb7 = new JLabel();
jb8 = new JLabel();
}
public void setListener(){
jb4.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
if (jrb1.isSelected()) {
dispose();
new MainFra();
}else if(jrb2.isSelected()){
dispose();
new MainFraManager();
}else{
dispose();
new MainFraAdministrator();
}
}
});
}
public void setJLabelVisible(){
jb4.setVisible(true);
}
public void setInterface(){
JPanel p1=new JPanel();
JPanel p2=new JPanel();
JLabel j=new MyJLabel1("请选择您的登录身份");
// 设置三个单选框
jrb1 = new JRadioButton("普通用户", true);// 单选框默认选择普通用户
jrb2 = new JRadioButton("普通管理员");
jrb3 = new JRadioButton("超级管理员");
ButtonGroup btg = new ButtonGroup();
// 设置单选框
jrb1.setContentAreaFilled(false);
jrb2.setContentAreaFilled(false);
jrb3.setContentAreaFilled(false);
btg.add(jrb1);
btg.add(jrb2);
btg.add(jrb3); p2.setLayout(new GridLayout(3, 1, 0, 40));
p2.add(jrb1);
p2.add(jrb2);
p2.add(jrb3);
p1.add(j); p1.setOpaque(false);
p2.setOpaque(false); setLayout(null);
p1.setBounds(250, 150, 300, 60);
p2.setBounds(355, 250, 120, 140);
add(p1);
add(p2);
setVisible(true);
}
}

  

package Atm;
//客户端类
public class Client {
public static void main(String[] args) {
new ChooseIdentity();
} }

  

package Atm;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet; public class DatabaseOperation { PreparedStatement ps;
Connection dbConn;
ResultSet rs;
String driverName;
String dbURL;
String userName;
String userPwd; public DatabaseOperation() {
driverName = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
dbURL = "jdbc:sqlserver://localhost:1433;DatabaseName=ATM";
userName = "sa";
userPwd = "123456";
try {
Class.forName(driverName);
dbConn = DriverManager.getConnection(dbURL, userName, userPwd);
} catch (Exception e1) {
e1.printStackTrace();
System.out.print("抛出异常");
}
}// 构造方法 public void create(String sql) { // 增
ExecuteUpdate(sql);
} public void delete(String sql) { // 删
ExecuteUpdate(sql);
} public void update(String sql) { // 改
ExecuteUpdate(sql);
} public ResultSet search(String sql) { // 查
try {
ps = dbConn.prepareStatement(sql,
ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
rs = ps.executeQuery();
} catch (Exception e1) {
e1.printStackTrace();
System.out.print("抛出异常");
} finally {
return rs;
}
} private void ExecuteUpdate(String sql) {
try {
ps = dbConn.prepareStatement(sql);
ps.executeUpdate();
} catch (Exception e1) {
e1.printStackTrace();
System.out.print("抛出异常");
}
} public void close() { // 关闭连接
try {
ps.close();
dbConn.close();
} catch (Exception e1) {
e1.printStackTrace();
System.out.print("抛出异常");
}
}
}// 类

  

package Atm;
import java.util.regex.Matcher;
import java.util.regex.Pattern; import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
import javax.swing.text.PlainDocument;
//用于TransferSecond 类
class DecimalOnlyDocument extends PlainDocument {
public void insertString(int offs, String str, AttributeSet a) throws BadLocationException {
StringBuffer tmp = new StringBuffer(super.getText(0, super.getLength()));
tmp.insert(offs, str);
Pattern p = Pattern.compile("^-?\\d*(\\.)?\\d*$");
Matcher m = p.matcher(tmp.toString());
if (m.find())
super.insertString(offs, str, a);
}
}

  

package Atm;

//查询交易明细

import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet; import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants; public class Detail extends FatherFrame { DatabaseOperation databaseOperation;
ResultSet rs;
JPanel p1, p2_1, p2_2, p2_3, p2_4, p3;
JLabel j1, j3;
JLabel[] jj1;
JLabel[] jj2;
JLabel[] jj3;
JLabel[] jj4;
JButton b3, b4;
int tag_mount = 0;// 标识交易详情有多少条
int tag_page = 1;// 标识第几页
int tag_maxPage = 1;// 标识最多第几页 public Detail() {
super(60);
databaseOperation = new DatabaseOperation();
setInterface();
showInformation();
addButtonsListener();
}
private void addButtonsListener() {
//上一页
b3.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
b4.setVisible(true);
tag_page--;
try {
p2_1.removeAll();
p2_2.removeAll();
p2_3.removeAll();
p2_4.removeAll(); p2_1.setLayout(new GridLayout(11, 0));
p2_1.add(new MyJLabel4("序号"));
p2_2.setLayout(new GridLayout(11, 0));
p2_2.add(new MyJLabel4(" 交易日期"));
p2_3.setLayout(new GridLayout(11, 0));
p2_3.add(new MyJLabel4("交易类型"));
p2_4.setLayout(new GridLayout(11, 0));
p2_4.add(new MyJLabel4(" 交易金额")); int i = 0; int begin = (tag_page - 1) * 10 + 1;
System.out.println("begin=" + begin);
rs.absolute(begin);
do {
if (tag_page == 1)
jj1[i] = new MyJLabel5(" " + String.valueOf(i + 1));
else
jj1[i] = new MyJLabel5(" "
+ String.valueOf(tag_page * 10 + i + 1));
jj2[i] = new MyJLabel5(rs.getString("CRdate"));
jj3[i] = new MyJLabel5(" " + rs.getString("CRtype"));
if (rs.getString("CRtype").equals("支出"))
jj4[i] = new MyJLabel5("-"
+ rs.getString("CRmoney") + "CNY");
else
jj4[i] = new MyJLabel5(rs.getString("CRmoney")
+ "CNY");
jj4[i].setHorizontalAlignment(SwingConstants.RIGHT);// 使标签内的文字右对齐!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1
p2_1.add(jj1[i]);
p2_2.add(jj2[i]);
p2_3.add(jj3[i]);
p2_4.add(jj4[i]);
i++;
if (i == 10) {// 一次最多只能输出10条信息
b4.setVisible(true);
break;
} } while (rs.next());
validate();// 要调用JFrame的validate()方法才会刷新控件,要调用JFrame的validate()方法才会刷新控件,要调用JFrame的validate()方法才会刷新控件 } catch (Exception e1) {
e1.printStackTrace();
System.out.print("抛出异常");
} if (tag_page == 1)
b3.setVisible(false);
}
});
//下一页
b4.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
b3.setVisible(true);
tag_page++; try {
p2_1.removeAll();
p2_2.removeAll();
p2_3.removeAll();
p2_4.removeAll(); p2_1.setLayout(new GridLayout(11, 0));
p2_1.add(new MyJLabel4("序号"));
p2_2.setLayout(new GridLayout(11, 0));
p2_2.add(new MyJLabel4(" 交易日期"));
p2_3.setLayout(new GridLayout(11, 0));
p2_3.add(new MyJLabel4("交易类型"));
p2_4.setLayout(new GridLayout(11, 0));
p2_4.add(new MyJLabel4(" 交易金额")); int i = 0;
int begin = (tag_page - 1) * 10 + 1;
System.out.println("begin=" + begin);
rs.absolute(begin);
do { jj1[i] = new MyJLabel5(" "
+ String.valueOf(tag_page * 10 + i + 1));
jj2[i] = new MyJLabel5(rs.getString("CRdate"));
jj3[i] = new MyJLabel5(" " + rs.getString("CRtype"));
if (rs.getString("CRtype").equals("支出")) {
jj4[i] = new MyJLabel5("-"
+ rs.getString("CRmoney") + "CNY");
} else
jj4[i] = new MyJLabel5(rs.getString("CRmoney")
+ "CNY");
jj4[i].setHorizontalAlignment(SwingConstants.RIGHT);// 使标签内的文字右对齐!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1
p2_1.add(jj1[i]);
p2_2.add(jj2[i]);
p2_3.add(jj3[i]);
p2_4.add(jj4[i]);
i++;
if (i == 10) {// 一次最多只能输出10条信息
b4.setVisible(true);
break;
}
} while (rs.next());
validate();// 要调用JFrame的validate()方法才会刷新控件,要调用JFrame的validate()方法才会刷新控件,要调用JFrame的validate()方法才会刷新控件 } catch (Exception e1) {
e1.printStackTrace();
System.out.print("抛出异常");
} if (tag_page == tag_maxPage)
b4.setVisible(false);
}
});
} private void setInterface() {
p1 = new JPanel();
p2_1 = new JPanel();
p2_2 = new JPanel();
p2_3 = new JPanel();
p2_4 = new JPanel();
p3 = new JPanel(); b3 = new JButton("上一页");
b4 = new JButton("下一页");
b3.setVisible(false);
b4.setVisible(false);
b3.setBounds(420, 500, 80, 25);
b4.setBounds(500, 500, 80, 25);
add(b3);
add(b4); j1 = new MyJLabel1("历史交易明细");
p1.add(j1); j3 = new MyJLabel5("本查询结果为账户历史交易,但不包含银行收费交易费用交易");
p3.add(j3); setLayout(null);
p1.setBounds(199, 90+50, 400, 40);
p2_1.setBounds(175, 190, 144, 270);
p2_2.setBounds(255, 190, 144, 270);
p2_3.setBounds(398, 190, 144, 270);
p2_4.setBounds(467, 190, 154, 270);
p3.setBounds(100, 455, 600, 40); p1.setOpaque(false);// 设置背景透明
p2_1.setOpaque(false);
p2_2.setOpaque(false);
p2_3.setOpaque(false);
p2_4.setOpaque(false);
p3.setOpaque(false); add(p1);
add(p2_1);
add(p2_2);
add(p2_3);
add(p2_4);
add(p3);
setVisible(true);
} protected void initJLabel() {
jb1 = new JLabel();
jb2 = new JLabel();
jb3 = new JLabel(new ImageIcon("image/按钮背景左.png"));
jb4 = new JLabel(new ImageIcon("image/返回.png"));
jb5 = new JLabel();
jb6 = new JLabel();
jb7 = new JLabel(new ImageIcon("image/按钮背景右.png"));
jb8 = new JLabel(new ImageIcon("image/回主菜单右.png"));
} protected void setJLabelVisible() {
jb3.setVisible(false);
jb4.setVisible(true);
jb7.setVisible(false);
jb8.setVisible(true);
} protected void setListener() {
jb4.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
databaseOperation.close();
dispose();
new Balance();
timeThread.stop();
}
});
jb8.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
databaseOperation.close();
dispose();
new AtmFrame();
timeThread.stop();
}
});
/* //上一页
jb3.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
jb7.setVisible(true);
tag_page--;
try {
p2_1.removeAll();
p2_2.removeAll();
p2_3.removeAll();
p2_4.removeAll(); p2_1.setLayout(new GridLayout(11, 0));
p2_1.add(new MyJLabel4("序号"));
p2_2.setLayout(new GridLayout(11, 0));
p2_2.add(new MyJLabel4(" 交易日期"));
p2_3.setLayout(new GridLayout(11, 0));
p2_3.add(new MyJLabel4("交易类型"));
p2_4.setLayout(new GridLayout(11, 0));
p2_4.add(new MyJLabel4(" 交易金额")); int i = 0; int begin = (tag_page - 1) * 10 + 1;
System.out.println("begin=" + begin);
rs.absolute(begin);
do {
if (tag_page == 1)
jj1[i] = new MyJLabel5(" " + String.valueOf(i + 1));
else
jj1[i] = new MyJLabel5(" "
+ String.valueOf(tag_page * 10 + i + 1));
jj2[i] = new MyJLabel5(rs.getString("CRdate"));
jj3[i] = new MyJLabel5(" " + rs.getString("CRtype"));
if (rs.getString("CRtype").equals("支出"))
jj4[i] = new MyJLabel5("-"
+ rs.getString("CRmoney") + "CNY");
else
jj4[i] = new MyJLabel5(rs.getString("CRmoney")
+ "CNY");
jj4[i].setHorizontalAlignment(SwingConstants.RIGHT);// 使标签内的文字右对齐!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1
p2_1.add(jj1[i]);
p2_2.add(jj2[i]);
p2_3.add(jj3[i]);
p2_4.add(jj4[i]);
i++;
if (i == 10) {// 一次最多只能输出10条信息
jb7.setVisible(true);
break;
} } while (rs.next());
validate();// 要调用JFrame的validate()方法才会刷新控件,要调用JFrame的validate()方法才会刷新控件,要调用JFrame的validate()方法才会刷新控件 } catch (Exception e1) {
e1.printStackTrace();
System.out.print("抛出异常");
} if (tag_page == 1)
jb3.setVisible(false);
}
});
//下一页
jb7.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
jb3.setVisible(true);
tag_page++; try {
p2_1.removeAll();
p2_2.removeAll();
p2_3.removeAll();
p2_4.removeAll(); p2_1.setLayout(new GridLayout(11, 0));
p2_1.add(new MyJLabel4("序号"));
p2_2.setLayout(new GridLayout(11, 0));
p2_2.add(new MyJLabel4(" 交易日期"));
p2_3.setLayout(new GridLayout(11, 0));
p2_3.add(new MyJLabel4("交易类型"));
p2_4.setLayout(new GridLayout(11, 0));
p2_4.add(new MyJLabel4(" 交易金额")); int i = 0;
int begin = (tag_page - 1) * 10 + 1;
System.out.println("begin=" + begin);
rs.absolute(begin);
do { jj1[i] = new MyJLabel5(" "
+ String.valueOf(tag_page * 10 + i + 1));
jj2[i] = new MyJLabel5(rs.getString("CRdate"));
jj3[i] = new MyJLabel5(" " + rs.getString("CRtype"));
if (rs.getString("CRtype").equals("支出")) {
jj4[i] = new MyJLabel5("-"
+ rs.getString("CRmoney") + "CNY");
} else
jj4[i] = new MyJLabel5(rs.getString("CRmoney")
+ "CNY");
jj4[i].setHorizontalAlignment(SwingConstants.RIGHT);// 使标签内的文字右对齐!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1
p2_1.add(jj1[i]);
p2_2.add(jj2[i]);
p2_3.add(jj3[i]);
p2_4.add(jj4[i]);
i++;
if (i == 10) {// 一次最多只能输出10条信息
jb7.setVisible(true);
break;
}
} while (rs.next());
validate();// 要调用JFrame的validate()方法才会刷新控件,要调用JFrame的validate()方法才会刷新控件,要调用JFrame的validate()方法才会刷新控件 } catch (Exception e1) {
e1.printStackTrace();
System.out.print("抛出异常");
} if (tag_page == tag_maxPage)
jb7.setVisible(false);
}
});*/
} private void showInformation() {
try {
rs = databaseOperation
.search("SELECT CustomerRecord.CRdate,CustomerRecord.CRtype,CustomerRecord.CRmoney FROM ATM.dbo.CustomerRecord WHERE CustomerRecord.CRcard="
+ MainFra.getBcard()+"and CustomerRecord.CRtype not like"+"'修改密码'");
int num = 0;
while (rs.next())
num++;
tag_mount = num;
tag_maxPage = tag_mount / 10 + 1; jj1 = new MyJLabel5[num];
jj2 = new MyJLabel5[num];
jj3 = new MyJLabel5[num];
jj4 = new MyJLabel5[num]; p2_1.setLayout(new GridLayout(11, 0));
p2_1.add(new MyJLabel4("序号"));
p2_2.setLayout(new GridLayout(11, 0));
p2_2.add(new MyJLabel4(" 交易日期"));
p2_3.setLayout(new GridLayout(11, 0));
p2_3.add(new MyJLabel4("交易类型"));
p2_4.setLayout(new GridLayout(11, 0));
p2_4.add(new MyJLabel4(" 交易金额")); // 打开数据库,记录等于1时,将数据放到jj1[1],jj2[1],jj3[1],jj4[1]
// ,再将label标签投射到屏幕上,等于2时也是如此,如此循环直至数据库next为空
rs = databaseOperation
.search("SELECT CustomerRecord.CRdate,CustomerRecord.CRtype,CustomerRecord.CRmoney FROM ATM.dbo.CustomerRecord WHERE CustomerRecord.CRcard="
+ MainFra.getBcard()+"and CustomerRecord.CRtype not like"+"'修改密码'"
+ " ORDER BY CustomerRecord.CRno DESC");
int i = 0;
rs.first();
do {
jj1[i] = new MyJLabel5(" " + String.valueOf(i + 1));
jj2[i] = new MyJLabel5(rs.getString("CRdate"));
jj3[i] = new MyJLabel5(" " + rs.getString("CRtype"));
if (rs.getString("CRtype").equals("支出"))
jj4[i] = new MyJLabel5("-" + rs.getString("CRmoney")
+ "CNY");
else
jj4[i] = new MyJLabel5(rs.getString("CRmoney") + "CNY");
jj4[i].setHorizontalAlignment(SwingConstants.RIGHT);// 使标签内的文字右对齐!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1
p2_1.add(jj1[i]);
p2_2.add(jj2[i]);
p2_3.add(jj3[i]);
p2_4.add(jj4[i]);
i++;
if (i == 10) {// 一次最多只能输出10条信息
b4.setVisible(true);
tag_page = 1;
break;
}
} while (rs.next()); } catch (Exception e1) {
e1.printStackTrace();
System.out.print("抛出异常");
}
}
}

  

package Atm;
//退出窗口exitFrame.java import javax.swing.*; import java.awt.*; public class ExitFrame extends FatherFrame{
public ExitFrame(){
show2();
try {
Thread.sleep (2000 ) ;
dispose();
new MainFra();
} catch (InterruptedException ie){
} } public void show2(){ //这里很不解,写成show运行不显示任何东西,连Frame都没有,但不报错,同时我只是写了这个方法但是没有调用。而且父类FatherFrame中也没有这个方法。然后把方法改成show2就没问题了,这是为什么???
Font font1 = new Font("宋体", Font.BOLD, 30);
JLabel j1 = new JLabel("谢谢使用");
JPanel p1 = new JPanel();
p1.setOpaque(false);
j1.setFont(font1);
p1.add(j1);
setLayout(null);
p1.setBounds(300, 240, 200, 60);
add(p1);
} protected void initJLabel(){
jb1 = new JLabel();
jb2 = new JLabel();
jb3 = new JLabel();
jb4 = new JLabel();
jb5 = new JLabel();
jb6 = new JLabel();
jb7 = new JLabel();
jb8 = new JLabel();
}
protected void setListener(){ }
protected void setJLabelVisible(){ }
}

  

package Atm;
//界面父类
import javax.swing.*;
import java.awt.*;
import java.util.Timer;
import java.util.TimerTask; public abstract class FatherFrame extends JFrame{
public ImageIcon img1 = new ImageIcon("image/背景图.png");
public JLabel imgLabel = new JLabel(img1);
public JLabel texTime = new JLabel();
public JLabel time = new JLabel();
JLabel jb1;
JLabel jb2;
JLabel jb3;
JLabel jb4;
JLabel jb5;
JLabel jb6;
JLabel jb7;
JLabel jb8;
JPanel fp1 = new JPanel();
JPanel fp2 = new JPanel(); private LedNumber led;
private int timepassed;
protected TimeThread timeThread;
Font font = new Font("Calibri", Font.BOLD, 16); abstract protected void initJLabel();
abstract protected void setJLabelVisible();
abstract protected void setListener(); public void createFrame(){
setInterfaceAndSetListener();
imgLabel.setBounds(0, 0, img1.getIconWidth(), img1.getIconHeight());
// 将图片添加到第二层
getLayeredPane().add(imgLabel, new Integer(Integer.MIN_VALUE));
// 将最上层设置为透明
JPanel jp = (JPanel) this.getContentPane();
jp.setOpaque(false);// 设置为透明 setTitle("中行ATM系统");
setSize(815, 625); // 设置窗口大小
setResizable(false); // 锁定窗口大小
setLocationRelativeTo(null); // 为了使窗口显示在屏幕中央
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
} protected void setInterfaceAndSetListener(){
setLayout(null);
fp1.setLayout(new GridLayout(4,1,0,0));
fp2.setLayout(new GridLayout(4,1,0,0));
fp1.setOpaque(false);
fp2.setOpaque(false);
fp1.setBounds(0,165,180,400);
fp2.setBounds(635,165,180,400);
add(fp1);
add(fp2);
setVisible(true); initJLabel(); //抽象方法 //这一个方法必须放在下面八个方法前面,否则会因为JLabel没有实例化而直接将它放进面板而出错
fp1.add(jb1);
fp1.add(jb2);
fp1.add(jb3);
fp1.add(jb4);
fp2.add(jb5);
fp2.add(jb6);
fp2.add(jb7);
fp2.add(jb8);
setJLabelVisible(); //抽象方法
setListener(); //抽象方法
} public FatherFrame(){
createFrame(); setLayout(null);
time.setBounds(650, 95, 150, 40);
time.setFont(font);
add(time);
NowTime nt = new NowTime();
nt.setTimer(time);
} //带参数的构造方法用来实现倒计时
public FatherFrame(int rtime){
createFrame(); timepassed = rtime;
timeThread = new TimeThread();
led = new LedNumber(); texTime.setBorder(BorderFactory.createLoweredBevelBorder());
texTime.setIcon(new ImageIcon(led.getLedImage(timepassed, 2))); JPanel p = new JPanel();
p.setOpaque(false);
p.add(texTime); setLayout(null);
time.setFont(font);
time.setBounds(650, 95, 150, 40);
add(time);
NowTime nt = new NowTime();
nt.setTimer(time); p.setBounds((815 - 80)/2, 35, 80, 80); add(p); timeThread.start();
Timer timer = new Timer();
timer.schedule(new TimerTask() {//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!这个方法不知道有什么用!!!它里面有个run方法,注意他跟倒计时那里的run方法是没有关系的。之前倒计时的stop方法无法运行就是因为我们把start的方法写到了这个run方法中,正确的做法是写到倒计时TimeThread类中的run方法中
// 启动其他程序
public void run() { }
},rtime * 1000);
} class TimeThread extends Thread { public TimeThread() {} public void run() {
while (timepassed > 0 && timepassed < 1000 && Thread.currentThread() == timeThread) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
texTime.setIcon(new ImageIcon(led
.getLedImage(timepassed, 2))); }
});
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
System.out.println("interupped");
e.printStackTrace();
}
timepassed--;
}
dispose();//销毁当前frame
new MainFra();
}
} }

  

package Atm;
//此类是显示倒计时中数字字体的工具类 import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Polygon;
import java.awt.image.BufferedImage; public class LedNumber extends Component{
private Polygon segmentPolygon[];
private int numberSegment[][] = { { 0, 1, 2, 3, 4, 5 }, // 0
{ 1, 2 }, // 1
{ 0, 1, 3, 4, 6 }, // 2
{ 0, 1, 2, 3, 6 }, // 3
{ 1, 2, 5, 6 }, // 4
{ 0, 2, 3, 5, 6 }, // 5
{ 0, 2, 3, 4, 5, 6 }, // 6
{ 0, 1, 2 }, // 7
{ 0, 1, 2, 3, 4, 5, 6 }, // 8
{ 0, 1, 2, 3, 5, 6 } // 9
}; private int div[] = {1,10,100,1000,10000,100000};
private Image numberImage[];
private Color fontColor = Color.green; //the color of number
private Color bgColor = Color.black; //背景颜色为黑色
private Color maskColor = Color.darkGray;
private int dWidth = 20;
private int dHeight = 38; public LedNumber(){
init();
} public LedNumber(Color fc){
fontColor=fc;
init();
} public LedNumber(Color fc,Color bgc){
fontColor=fc;
bgColor=bgc;
init();
} public LedNumber(Color fc,Color bgc,Color mc){
fontColor=fc;
bgColor=bgc;
maskColor=mc;
init();
} public void setBackGround(Color bgc){
this.bgColor=bgc;
} public void setFontColor(Color fc){
this.fontColor=fc;
} public void setMaskColor(Color mc){
this.maskColor=mc;
} public void setDigitalWidth(int dWidth){
this.dWidth=dWidth;
} public void setDigitalHeight(int dHeight){
this.dHeight=dHeight;
} public Image getLedImage(int dg,int bound){
dg%=div[bound];
Image image=new BufferedImage(dWidth*bound,dHeight,BufferedImage.TYPE_INT_RGB);
Graphics g=image.getGraphics();
bound--;
for (int i = bound; i >= 0; i--) {
g.drawImage(numberImage[dg / div[i]], (bound - i) * dWidth, 0, this);
dg %= div[i];
}
return image;
} public void init(){
segmentPolygon=new Polygon[7];
numberImage=new Image[10];
setNumberPolygon();
setNumberImage(); } public void setNumberImage(){
int i=0;
int j=0;
int k;
Graphics g;
while(i<10){
numberImage[i]=new BufferedImage(35,40,BufferedImage.TYPE_INT_RGB);
g=numberImage[i].getGraphics();
g.setColor(bgColor);
g.fillRect(0, 0, 35, 40);
g.setColor(Color.DARK_GRAY);
j=0;
while(j<numberSegment[8].length){
k=numberSegment[8][j];
g.fillPolygon(segmentPolygon[k]);
j++;
}
g.setColor(fontColor);
j=0;
while(j<numberSegment[i].length){
k=numberSegment[i][j];
g.fillPolygon(segmentPolygon[k]);
j++;
}
i++;
}
} public void setNumberPolygon(){
int mid=dHeight/2+1;
segmentPolygon[0]=new Polygon();
segmentPolygon[0].addPoint(2, 1);
segmentPolygon[0].addPoint(dWidth-2, 1);
segmentPolygon[0].addPoint(dWidth-5, 4);
segmentPolygon[0].addPoint(4, 4);
segmentPolygon[1]=new Polygon();
segmentPolygon[1].addPoint(dWidth-1, 1);
segmentPolygon[1].addPoint(dWidth-1, mid-1);
segmentPolygon[1].addPoint(dWidth-2, mid-1);
segmentPolygon[1].addPoint(dWidth-4, mid-3);
segmentPolygon[1].addPoint(dWidth-4, 4);
segmentPolygon[2] = new Polygon();
segmentPolygon[2].addPoint(dWidth-1, mid);
segmentPolygon[2].addPoint(dWidth-1, dHeight-2);
segmentPolygon[2].addPoint(dWidth-4, dHeight-5);
segmentPolygon[2].addPoint(dWidth-4, mid+1);
segmentPolygon[2].addPoint(dWidth-3, mid);
segmentPolygon[3] = new Polygon();
segmentPolygon[3].addPoint(dWidth-2, dHeight-1);
segmentPolygon[3].addPoint(1, dHeight-1);
segmentPolygon[3].addPoint(4, dHeight-4);
segmentPolygon[3].addPoint(dWidth-4, dHeight-4);
segmentPolygon[4] = new Polygon();
segmentPolygon[4].addPoint(1, dHeight-2);
segmentPolygon[4].addPoint(1, mid);
segmentPolygon[4].addPoint(3, mid);
segmentPolygon[4].addPoint(4, mid+1);
segmentPolygon[4].addPoint(4, dHeight-5);
segmentPolygon[5] = new Polygon();
segmentPolygon[5].addPoint(1, mid-1);
segmentPolygon[5].addPoint(1, 1);
segmentPolygon[5].addPoint(4, 4);
segmentPolygon[5].addPoint(4, mid-3);
segmentPolygon[5].addPoint(2, mid-1);
segmentPolygon[6] = new Polygon();
segmentPolygon[6].addPoint(3, mid-1);
segmentPolygon[6].addPoint(4, mid-2);
segmentPolygon[6].addPoint(dWidth-4, mid-2);
segmentPolygon[6].addPoint(dWidth-3, mid-1);
segmentPolygon[6].addPoint(dWidth-5, mid+1);
segmentPolygon[6].addPoint(4, mid+1);
} }

  

package Atm;
//工具类,限制文本框的长度和格式 import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
import javax.swing.text.PlainDocument; public class LimitedDocument extends PlainDocument{
private int _maxLength = -1;
private String _allowCharAsString = null; public LimitedDocument(){
super();
} public LimitedDocument( int maxLength ){
super();
this._maxLength = maxLength;
} public void insertString( int offset, String str, AttributeSet attrSet) throws BadLocationException{
if(str == null) {
return;
}
if(_allowCharAsString != null && str.length() == 1) {
if(_allowCharAsString.indexOf(str) == -1){
return;
}
}
char[] charVal = str.toCharArray();
String strOldValue = getText(0, getLength());
byte[] tmp = strOldValue.getBytes();
if(_maxLength != -1 && (tmp.length + charVal.length > _maxLength)){
return;
}
super.insertString(offset, str, attrSet);
} public void setAllowChar(String str) {
_allowCharAsString = str;
} }

  

package Atm;

//ATM机前端窗口,也就是登录界面

import javax.swing.*;

import java.awt.*;
import java.awt.event.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet; public class MainFra extends FatherFrame {
PreparedStatement ps = null;
Connection dbConn = null;
ResultSet rs = null; // 文本框
private JTextField jtf1 = new JTextField(18);
private JPasswordField password = new JPasswordField(18);
// 限制文本框输入长度
LimitedDocument ld = new LimitedDocument(16);
LimitedDocument ld1 = new LimitedDocument(6); // 调节字体
Font font1 = new Font("宋体", Font.BOLD, 30);
Font font2 = new Font("宋体", Font.BOLD, 25);
String text = "欢迎您使用中国银行ATM"; // 面板
JPanel p1 = new JPanel();
JPanel p2 = new JPanel();
JPanel p3 = new JPanel();
JPanel p4 = new JPanel(); private static String bcard = null; public static String getBcard() {
return bcard;
} public MainFra() {
// 将p1,p2,p3,p4面板都设置为透明的
p1.setOpaque(false);
p2.setOpaque(false);
p3.setOpaque(false);
p4.setOpaque(false); // 下面对账号的文本框进行格式化
ld.setAllowChar("0123456789");// 只能输入的字符
jtf1.setDocument(ld);// 运用到文本框中 // 下面对密码框进行格式化
ld1.setAllowChar("0123456789");// 只能输入数字字符
password.setDocument(ld1);// 运用到密码框中 jtf1.setFont(font2);// 设置账号文本框内的字体
password.setFont(font2);// 设置密码框内的字体 JLabel j1 = new JLabel(text);
j1.setFont(font1);
JLabel j2 = new JLabel("账号:");
JLabel j3 = new JLabel("密码:");
j2.setFont(font2);
j3.setFont(font2); p1.add(j1, BorderLayout.CENTER);
p2.setLayout(new GridLayout(2, 1, 0, 10));
p2.add(j2);
p2.add(j3);
p3.add(jtf1);
p4.add(password); setLayout(null);
p1.setBounds((825 - 400) / 2, 150, 400, 40);// 欢迎语
p2.setBounds(240, 240, 90, 80);
p3.setBounds(310, 240, 260, 70);
p4.setBounds(310, 280, 260, 70); add(p1);
add(p2);
add(p3);
add(p4); setVisible(true); // 给按钮添加监听器 } protected void initJLabel() {
jb1 = new JLabel();
jb2 = new JLabel();
jb3 = new JLabel();
jb4 = new JLabel(new ImageIcon("image/登录.png"));
jb5 = new JLabel();
jb6 = new JLabel();
jb7 = new JLabel();
jb8 = new JLabel(new ImageIcon("image/退出.png")); } protected void setJLabelVisible() {
jb4.setVisible(true);
jb8.setVisible(true);
} protected void setListener() {
jb4.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
if(jtf1.getText().length()==0||password.getText().length()==0){
JOptionPane.showMessageDialog(null, "请输入账号和密码"," ", JOptionPane.WARNING_MESSAGE);
}
else{
DatabaseOperation da = new DatabaseOperation();
String sql = "SELECT BankCard.Bcard,BankCard.Bpassword,BankCard.Buse,BankCard.Bdongjie,BankCard.Bguashi,BankCard.Bxiaohu FROM ATM.dbo.BankCard WHERE BankCard.Bcard="
+ jtf1.getText();
rs = da.search(sql);
try {
if (rs.next()) {
int bUse = rs.getInt("Buse");
if(rs.getBoolean("Bxiaohu")||rs.getBoolean("Bguashi")){
JOptionPane.showMessageDialog(null, "该账号处于异常状态,无法登录","提示", JOptionPane.ERROR_MESSAGE);
jtf1.setText("");
password.setText("");
}
else if (bUse < 3
&& rs.getString("Bcard").equals(
jtf1.getText())
&& rs.getString("Bpassword").equals(
new String(password.getPassword()))) {
bcard = jtf1.getText();
//da.close();
jtf1.setText("");
password.setText(""); dispose();
new AtmFrame();
} else if (bUse == 3) {
// 弹出对话框,提示该账号输入密码错误3次,当天无法再登录
JOptionPane.showMessageDialog(null, "该账号输入密码错误3次,无法再登录。若要解除锁定,请移步中国银行","提示", JOptionPane.ERROR_MESSAGE);
} else {
// 弹出对话框,提示密码输入错误,请重新输入密码
JOptionPane.showMessageDialog(null, "账号/密码输入错误,请重新输入","提示", JOptionPane.ERROR_MESSAGE);
password.setText("");
// 将新的Buse写入数据库
bUse++;
System.out.println(bUse);
String sql1 = "UPDATE ATM.dbo.BankCard SET BankCard.Buse="
+ bUse
+ "WHERE BankCard.Bcard="
+ jtf1.getText();
da.update(sql1);
} } else {
JOptionPane.showMessageDialog(null, "账号/密码输入错误,请重新输入","提示", JOptionPane.ERROR_MESSAGE);
// 弹出dialog,提示该账号不存在,请重新输入。
jtf1.setText("");
password.setText("");
}
} catch (Exception e1) {
e1.printStackTrace();
System.out.print("抛出异常");
}
}
}
}); // 退出按钮的监听事件
jb8.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
dispose();
new ChooseIdentity();
}
});
} }

  

package Atm;

//ATM机前端窗口,也就是登录界面

import SupManager.*;
import javax.swing.*; import java.awt.*;
import java.awt.event.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet; public class MainFraAdministrator extends FatherFrame {
PreparedStatement ps = null;
Connection dbConn = null;
ResultSet rs = null; // 文本框
private JTextField jtf1 = new JTextField(18);
private JPasswordField password = new JPasswordField(18);
// 限制文本框输入长度
LimitedDocument ld = new LimitedDocument(12);
LimitedDocument ld1 = new LimitedDocument(8); JButton jbtExit = new JButton("退出"); // 调节字体
Font font1 = new Font("宋体", Font.BOLD, 30);
Font font2 = new Font("宋体", Font.BOLD, 25);
String text = "欢迎您使用超级管理员端"; // 面板
JPanel p1 = new JPanel();
JPanel p2 = new JPanel();
JPanel p3 = new JPanel();
JPanel p4 = new JPanel(); private static String bcard = null; public static String getBcard() {
return bcard;
} public MainFraAdministrator() {
// 将p1,p2,p3,p4面板都设置为透明的
p1.setOpaque(false);
p2.setOpaque(false);
p3.setOpaque(false);
p4.setOpaque(false); // 下面对账号的文本框进行格式化
ld.setAllowChar("0123456789");// 只能输入的字符
jtf1.setDocument(ld);// 运用到文本框中 // 下面对密码框进行格式化
ld1.setAllowChar("0123456789");// 只能输入数字字符
password.setDocument(ld1);// 运用到密码框中 jtf1.setFont(font2);// 设置账号文本框内的字体
password.setFont(font2);// 设置密码框内的字体 JLabel j1 = new JLabel(text);
j1.setFont(font1);
JLabel j2 = new JLabel("账号:");
JLabel j3 = new JLabel("密码:");
j2.setFont(font2);
j3.setFont(font2); p1.add(j1, BorderLayout.CENTER);
p2.setLayout(new GridLayout(2, 1, 0, 10));
p2.add(j2);
p2.add(j3);
// p3.setLayout(new GridLayout(2, 1, 0, 4));
p3.add(jtf1);
p4.add(password); setLayout(null);
p1.setBounds((825 - 400) / 2, 150, 400, 40);// 欢迎语
p2.setBounds(240, 240, 90, 80);
p3.setBounds(310, 240, 260, 70);
p4.setBounds(310, 280, 260, 70); add(p1);
add(p2);
add(p3);
add(p4); setVisible(true); // 给按钮添加监听器 } protected void initJLabel() {
jb1 = new JLabel();
jb2 = new JLabel();
jb3 = new JLabel();
jb4 = new JLabel(new ImageIcon("image/登录.png"));
jb5 = new JLabel();
jb6 = new JLabel();
jb7 = new JLabel();
jb8 = new JLabel(new ImageIcon("image/退出.png")); } protected void setJLabelVisible() {
jb4.setVisible(true);
jb8.setVisible(true);
} protected void setListener() {
jb4.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) { if(jtf1.getText().length()==0||password.getText().length()==0){
JOptionPane.showMessageDialog(null, "请输入账号和密码"," ", JOptionPane.WARNING_MESSAGE);
}
else{
DatabaseOperation da = new DatabaseOperation();
String sql = "SELECT Administrator.Ano,Administrator.Apassword1,Administrator.Apassword2 FROM ATM.dbo.Administrator WHERE Administrator.Ano="
+ jtf1.getText();
rs = da.search(sql);
System.out.println("连接成功");
try {
if (rs.next()) {
if (rs.getString("Ano").equals(jtf1.getText())
&& rs.getString("Apassword1").equals(
new String(password.getPassword()))) {
da.close();
setVisible(false);
new SuperMannager();
} else {
// 弹出对话框,提示密码输入错误,请重新输入密码
password.setText("");
System.out.println("密码输入错误,请重新输入");
} } else {
// 弹出dialog,提示该账号不存在,请重新输入。
System.out.println("该账号不存在,请重新输入");
jtf1.setText("");
password.setText("");
}
} catch (Exception e1) {
e1.printStackTrace();
System.out.print("抛出异常");
}
}
}
}); // 退出按钮的监听事件
jb8.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
dispose();
new ChooseIdentity();
}
});
} }

  

package Atm;

//ATM机前端窗口,也就是登录界面

import Manager.*;
import javax.swing.*; import java.awt.*;
import java.awt.event.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet; public class MainFraManager extends FatherFrame {
PreparedStatement ps = null;
Connection dbConn = null;
ResultSet rs = null; // 文本框
private JTextField jtf1 = new JTextField(18);
private JPasswordField password = new JPasswordField(18);
// 限制文本框输入长度
LimitedDocument ld = new LimitedDocument(12);
LimitedDocument ld1 = new LimitedDocument(8); JButton jbtExit = new JButton("退出"); // 调节字体
Font font1 = new Font("宋体", Font.BOLD, 30);
Font font2 = new Font("宋体", Font.BOLD, 25);
String text = "欢迎您使用普通管理员端"; // 面板
JPanel p1 = new JPanel();
JPanel p2 = new JPanel();
JPanel p3 = new JPanel();
JPanel p4 = new JPanel(); private static String bcard = null; public static String getBcard() {
return bcard;
} public MainFraManager() {
// 将p1,p2,p3,p4面板都设置为透明的
p1.setOpaque(false);
p2.setOpaque(false);
p3.setOpaque(false);
p4.setOpaque(false); // 下面对账号的文本框进行格式化
ld.setAllowChar("0123456789");// 只能输入的字符
jtf1.setDocument(ld);// 运用到文本框中 // 下面对密码框进行格式化
ld1.setAllowChar("0123456789");// 只能输入数字字符
password.setDocument(ld1);// 运用到密码框中 jtf1.setFont(font2);// 设置账号文本框内的字体
password.setFont(font2);// 设置密码框内的字体 JLabel j1 = new JLabel(text);
j1.setFont(font1);
JLabel j2 = new JLabel("账号:");
JLabel j3 = new JLabel("密码:");
j2.setFont(font2);
j3.setFont(font2); p1.add(j1, BorderLayout.CENTER);
p2.setLayout(new GridLayout(2, 1, 0, 10));
p2.add(j2);
p2.add(j3);
// p3.setLayout(new GridLayout(2, 1, 0, 4));
p3.add(jtf1);
p4.add(password); setLayout(null);
p1.setBounds((825 - 400) / 2, 150, 400, 40);// 欢迎语
p2.setBounds(240, 240, 90, 80);
p3.setBounds(310, 240, 260, 70);
p4.setBounds(310, 280, 260, 70); add(p1);
add(p2);
add(p3);
add(p4); setVisible(true); // 给按钮添加监听器 } protected void initJLabel() {
jb1 = new JLabel();
jb2 = new JLabel();
jb3 = new JLabel();
jb4 = new JLabel(new ImageIcon("image/登录.png"));
jb5 = new JLabel();
jb6 = new JLabel();
jb7 = new JLabel();
jb8 = new JLabel(new ImageIcon("image/退出.png")); } protected void setJLabelVisible() {
jb4.setVisible(true);
jb8.setVisible(true);
} protected void setListener() {
jb4.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
if(jtf1.getText().length()==0||password.getText().length()==0){
JOptionPane.showMessageDialog(null, "请输入账号和密码"," ", JOptionPane.WARNING_MESSAGE);
}
else{
DatabaseOperation da = new DatabaseOperation();
String sql = "SELECT Manager.Mno,Manager.Mpassword,Manager.Muse,Manager.Mdongjie FROM ATM.dbo.Manager WHERE Manager.Mno="
+ jtf1.getText();
rs = da.search(sql);
try {
if (rs.next()) {
int mUse = rs.getInt("Muse");
if (mUse < 3
&& rs.getString("Mno").equals(
jtf1.getText())
&& rs.getString("Mpassword").equals(
new String(password.getPassword()))) {
// bcard = jtf1.getText();
da.close();
// System.out.println("验证通过");
setVisible(false);
new NormalMannager();
} else if (mUse == 3) {
// 弹出对话框,提示该账号输入密码错误3次,当天无法再登录
System.out.println("该账号输入密码错误3次,已冻结");
} else {
// 弹出对话框,提示密码输入错误,请重新输入密码
password.setText("");
System.out.println("密码输入错误,你还有x次机会");
// 将新的Muse写入数据库
mUse++;
System.out.println(mUse);
String sql1 = "UPDATE ATM.dbo.Manager SET Manager.Muse="
+ mUse
+ "WHERE Manager.Mno="
+ jtf1.getText();
da.update(sql1);
} } else {
// 弹出dialog,提示该账号不存在,请重新输入。
System.out.println("该账号不存在,请重新输入");
jtf1.setText("");
password.setText("");
}
} catch (Exception e1) {
e1.printStackTrace();
System.out.print("抛出异常");
}
}
}
}); // 退出按钮的监听事件
jb8.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
dispose();
new ChooseIdentity();
}
});
} }

  

package Atm;
//获取当前时间 import java.text.SimpleDateFormat;
import java.util.Date; public class MyDate { public static String getDate(){
Date date=new Date();
SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd");
return df.format(date);
}
}

  

package Atm;
//标签字体大小 import java.awt.Color;
import java.awt.Font; import javax.swing.JLabel; class MyJLabel1 extends JLabel{
public MyJLabel1(String arg){
super(arg);//这句不能少,少了就出问题了。子类构造方法若有参数,则一定要先在构造方法里调用父类的构造方法
setFont(new Font("宋体", Font.BOLD, 30));
setForeground(Color.black);
}
}
class MyJLabel2 extends JLabel{
public MyJLabel2(String arg){
super(arg);//这句不能少,少了就出问题了。子类构造方法若有参数,则一定要先在构造方法里调用父类的构造方法
setFont(new Font("宋体", Font.BOLD, 28));
setForeground(Color.red);
}
}
class MyJLabel3 extends JLabel{
public MyJLabel3(String arg){
super(arg);//这句不能少,少了就出问题了。子类构造方法若有参数,则一定要先在构造方法里调用父类的构造方法
setFont(new Font("宋体", Font.BOLD, 28));
setForeground(Color.black);
}
}
class MyJLabel4 extends JLabel{
public MyJLabel4(String arg){
super(arg);//这句不能少,少了就出问题了。子类构造方法若有参数,则一定要先在构造方法里调用父类的构造方法
setFont(new Font("宋体", Font.BOLD, 17));
setForeground(Color.red);
}
}
class MyJLabel5 extends JLabel{
public MyJLabel5(String arg){
super(arg);//这句不能少,少了就出问题了。子类构造方法若有参数,则一定要先在构造方法里调用父类的构造方法
setFont(new Font("宋体", Font.BOLD, 17));
setForeground(Color.black);
}
}
/*原本是这样写的,但是这样写不对,这样写的话j只是作为一个对象
public class MyJLabel1 extends JLabel{
JLabel j;
Font font;
public MyJLabel1(String arg){
super(arg);//这句不能少,少了就出问题了。子类构造方法若有参数,则一定要先在构造方法里调用父类的构造方法
j=new JLabel(arg);
font = new Font("宋体", Font.BOLD, 30);
j.setFont(font);
j.setForeground(Color.red);
}
}
*/

  

package Atm;
import java.awt.Font;
//获取当前时间的类
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.SimpleDateFormat;
import java.util.Date; import javax.swing.JLabel;
import javax.swing.Timer;
import javax.swing.JFrame; public class NowTime
{
public NowTime(){
} //设置Timer 1000ms实现一次动作 实际是一个线程
public void setTimer(JLabel time){
final JLabel varTime = time;
Timer timeAction = new Timer(1000, new ActionListener() { public void actionPerformed(ActionEvent e) {
long timemillis = System.currentTimeMillis();
//转换日期显示格式
String n = "yyyy/MM/dd HH:mm:ss";
SimpleDateFormat df = new SimpleDateFormat(n);
varTime.setText(df.format(new Date(timemillis)));
}
});
timeAction.start();
}
}

  

package Atm;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet; import javax.swing.JOptionPane; public class SaveAction { public SaveAction(String savemoney) {
PreparedStatement ps=null;
Connection dbConn=null;
ResultSet rs=null;
String driverName="com.microsoft.sqlserver.jdbc.SQLServerDriver";
String dbURL="jdbc:sqlserver://localhost:1433;DatabaseName=ATM";
String userName="sa";
String userPwd="123456"; try
{
Class.forName(driverName);
dbConn=DriverManager.getConnection(dbURL,userName,userPwd);
System.out.println("MainFra类-连接数据库成功");
ps=dbConn.prepareStatement("SELECT BankCard.Bmoney,BankCard.Bcked FROM ATM.dbo.BankCard WHERE BankCard.Bcard=?");
ps.setString(1,MainFra.getBcard());//这行代码跟上面的问号相关联
rs=ps.executeQuery();//如果结果集rs开始的位置是0 那么刚查出来的结果集的指针应该指向在-1的位置
rs.next(); //前
double bMoneysave = rs.getDouble("Bmoney");
double bCunkuanedu=rs.getDouble("Bcked");
if(savemoney.length()==0){
JOptionPane.showMessageDialog(null, "请输入模拟的存款金额"," ", JOptionPane.WARNING_MESSAGE);
SaveFrame.setJudgeFlag1(false);
}
else if(Integer.parseInt(savemoney) < 100 || Integer.parseInt(savemoney) % 100 != 0){
//弹出对话框,提示输入不合法,存款失败,请重新输入存款金额
JOptionPane.showMessageDialog(null, "本机仅接收100或100的正整数倍的存款操作,请重新输入模拟的存款金额"," ", JOptionPane.WARNING_MESSAGE);
System.out.println("本机仅接收100或100的正整数倍的存款操作,请重新输入模拟的存款金额");
SaveFrame.setJudgeFlag1(false);
}
else if(bCunkuanedu<Integer.parseInt(savemoney)){
JOptionPane.showMessageDialog(null, "单笔存款金额上限为"+(int)bCunkuanedu+"元,请重新输入模拟的存款金额"," ", JOptionPane.WARNING_MESSAGE);
SaveFrame.setJudgeFlag1(false);
}
else{
bMoneysave = bMoneysave + Double.parseDouble(savemoney);
//修改数据,存入的账号金额增加
ps=dbConn.prepareStatement("UPDATE ATM.dbo.BankCard SET BankCard.Bmoney=? WHERE BankCard.Bcard=?");//
ps.setDouble(1,bMoneysave);
ps.setString(2,MainFra.getBcard());//这行代码跟上面的问号相关联
ps.executeUpdate(); //将这次操作的记录保存起来 ps=dbConn.prepareStatement("INSERT INTO ATM.dbo.CustomerRecord (CustomerRecord.CRcard,CustomerRecord.CRdate,CustomerRecord.CRtype,CustomerRecord.CRmoney,CustomerRecord.CRfee) VALUES (?,?,?,?,?)");
ps.setString(1,MainFra.getBcard());//这行代码跟上面的问号相关联
ps.setString(2,MyDate.getDate());
ps.setString(3,"存款");
ps.setString(4,savemoney);
ps.setString(5, String.valueOf( Double.parseDouble( savemoney ) *0 ) );
ps.executeUpdate(); ps.close();
dbConn.close();
//setVisible(false);
JOptionPane.showMessageDialog(null, "存款成功.", " ",
JOptionPane.PLAIN_MESSAGE);
System.out.println("存款成功!");
SaveFrame.setJudgeFlag1(true);
} }
catch(Exception e1)
{
e1.printStackTrace();
System.out.print("抛出异常");
}
} }

  

package Atm;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet; import javax.swing.JOptionPane; public class SaveDatabaseAction { public SaveDatabaseAction(String savemoney) {
PreparedStatement ps=null;
Connection dbConn=null;
ResultSet rs=null;
String driverName="com.microsoft.sqlserver.jdbc.SQLServerDriver";
String dbURL="jdbc:sqlserver://localhost:1433;DatabaseName=ATM";
String userName="sa";
String userPwd="123456"; try
{
Class.forName(driverName);
dbConn=DriverManager.getConnection(dbURL,userName,userPwd);
System.out.println("MainFra类-连接数据库成功");
ps=dbConn.prepareStatement("SELECT BankCard.Bmoney,BankCard.Bcked FROM ATM.dbo.BankCard WHERE BankCard.Bcard=?");
ps.setString(1,MainFra.getBcard());//这行代码跟上面的问号相关联
rs=ps.executeQuery();//如果结果集rs开始的位置是0 那么刚查出来的结果集的指针应该指向在-1的位置
rs.next(); //前
double bMoneysave = rs.getDouble("Bmoney");
double bCunkuanedu=rs.getDouble("Bcked");
if(savemoney.length()==0){
JOptionPane.showMessageDialog(null, "请输入模拟的存款金额"," ", JOptionPane.WARNING_MESSAGE);
SaveFrame.setJudgeFlag1(false);
}
else if(Integer.parseInt(savemoney) < 100 || Integer.parseInt(savemoney) % 100 != 0){
//弹出对话框,提示输入不合法,存款失败,请重新输入存款金额
JOptionPane.showMessageDialog(null, "本机仅接收100或100的正整数倍的存款操作,请重新输入模拟的存款金额"," ", JOptionPane.WARNING_MESSAGE);
System.out.println("本机仅接收100或100的正整数倍的存款操作,请重新输入模拟的存款金额");
SaveFrame.setJudgeFlag1(false);
}
else if(bCunkuanedu<Integer.parseInt(savemoney)){
JOptionPane.showMessageDialog(null, "单笔存款金额上限为"+(int)bCunkuanedu+"元,请重新输入模拟的存款金额"," ", JOptionPane.WARNING_MESSAGE);
SaveFrame.setJudgeFlag1(false);
}
else{
bMoneysave = bMoneysave + Double.parseDouble(savemoney);
//修改数据,存入的账号金额增加
ps=dbConn.prepareStatement("UPDATE ATM.dbo.BankCard SET BankCard.Bmoney=? WHERE BankCard.Bcard=?");//
ps.setDouble(1,bMoneysave);
ps.setString(2,MainFra.getBcard());//这行代码跟上面的问号相关联
ps.executeUpdate(); //将这次操作的记录保存起来 ps=dbConn.prepareStatement("INSERT INTO ATM.dbo.CustomerRecord (CustomerRecord.CRcard,CustomerRecord.CRdate,CustomerRecord.CRtype,CustomerRecord.CRmoney,CustomerRecord.CRfee) VALUES (?,?,?,?,?)");
ps.setString(1,MainFra.getBcard());//这行代码跟上面的问号相关联
ps.setString(2,MyDate.getDate());
ps.setString(3,"存款");
ps.setString(4,savemoney);
ps.setString(5, String.valueOf( Double.parseDouble( savemoney ) *0 ) );
ps.executeUpdate(); ps.close();
dbConn.close();
//setVisible(false);
JOptionPane.showMessageDialog(null, "存款成功.", " ",
JOptionPane.PLAIN_MESSAGE);
System.out.println("存款成功!");
SaveFrame.setJudgeFlag1(true);
new AtmFrame();
} }
catch(Exception e1)
{
e1.printStackTrace();
System.out.print("抛出异常");
}
} }

  

package Atm;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingConstants; public class SaveFrame extends FatherFrame { private static boolean judgeFlag1; JTextField jtf = new JTextField(18);
LimitedDocument ld = new LimitedDocument(5); JPanel p1 = new JPanel();
JPanel p2 = new JPanel(); JLabel j1 = new JLabel("请您输入存款金额", SwingConstants.CENTER);// 文本是以居中的方式对齐 Font font = new Font("宋体", Font.BOLD, 28); public SaveFrame() {
super(60);
j1.setFont(font);// 设置标签j1的字体 ld.setAllowChar("0123456789");// 只能输入的字符
jtf.setDocument(ld);// 运用到文本框中
jtf.setFont(new Font("宋体", Font.BOLD, 25)); // 将p1,p2,p3面板都设置为透明的
p1.setOpaque(false);
p2.setOpaque(false); p1.add(j1);
p2.add(jtf); setLayout(null);
p1.setBounds((678 - 200) / 2+20, 140, 280, 50);
p2.setBounds((678 - 200) / 2+25, 200, 270, 40); add(p1);
add(p2); } public static boolean getJudgeFlag1(){
return judgeFlag1;
}
public static void setJudgeFlag1(boolean flag){
judgeFlag1=flag;
} protected void setListener() {
// 按钮回主菜单的监听器
jb4.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
new AtmFrame();
dispose();
timeThread.stop();
// 此处加入事件的类的对象
}
});
// 按钮确认的监听器
jb8.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) { new SaveAction(jtf.getText()); //先
if(getJudgeFlag1()) { //后 为什么要用这样的先后顺序?你反过来试试。
dispose(); //加入判断,如果存款成功就销毁SavaFrame,如果不成功,就不销毁啊
timeThread.stop();
new AtmFrame();
}
else
jtf.setText(""); }
});
} protected void initJLabel() {
jb1 = new JLabel();
jb2 = new JLabel();
jb3 = new JLabel();
jb4 = new JLabel(new ImageIcon("image/回主菜单.png"));
jb5 = new JLabel();
jb6 = new JLabel();
jb7 = new JLabel();
jb8 = new JLabel(new ImageIcon("image/确认.png"));
} protected void setJLabelVisible() {
jb4.setVisible(true);
jb8.setVisible(true);
} }

  

package Atm;

import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet; import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField; public class TransferFirst extends FatherFrame {
JButton b1, b2, b3;
JTextField jtf1;
ResultSet rs;
DatabaseOperation databaseOperation;
private static String bcard2 = null; // 构造方法
public TransferFirst() {
super(60);
databaseOperation = new DatabaseOperation();
setInterface();
}// 构造方法 public static String getBcard2() {
return bcard2;
} private void setInterface() {
JPanel p1, p2;
LimitedDocument ld; p1 = new JPanel();
p2 = new JPanel(); p1.setOpaque(false);
p2.setOpaque(false); jtf1 = new JTextField(18);
ld = new LimitedDocument(16);
ld.setAllowChar("0123456789");// 设置只能输入数字
jtf1.setDocument(ld);
jtf1.setFont(new Font("宋体", Font.BOLD, 25));// 设置文本框内的字体,同时文本框的大小也会改变 p1.add(new MyJLabel3("请输入存款卡号"));
p2.add(jtf1); setLayout(null);
p1.setBounds(204, 140, 400, 40);
p2.setBounds(274, 190, 260, 50);
add(p1);
add(p2);
setVisible(true);
} private void reaction() {
if(jtf1.getText().length()==0){
JOptionPane.showMessageDialog(null, "请输入转款转入的账号"," ", JOptionPane.WARNING_MESSAGE);
}
else{
rs = databaseOperation
.search("SELECT BankCard.Bcard FROM ATM.dbo.BankCard WHERE BankCard.Bcard="
+ jtf1.getText());
getInformationFromResultSetAndThenReact();
}
} private void getInformationFromResultSetAndThenReact() {
try {
// 获取ResultSet结果
if (rs.next()) { // 若返回的ResultSet不为空------------------------ // ---不为空的话要做出反应----------------------------------
if (rs.getString("Bcard").equals(MainFra.getBcard())) {
JOptionPane.showMessageDialog(null, "不能转账给自己", " ",
JOptionPane.WARNING_MESSAGE);
// 弹出对话框,提示不能转账给自己
System.out.println("自己转账给自己?傻逼吗?");
jtf1.setText("");
} else {
bcard2 = jtf1.getText();
databaseOperation.close();
dispose();
new TransferSecond();
timeThread.stop();
}
// ------------------------------------------------ } else { // 若返回的ResultSet为空-----------------------------
// 弹出对话框,提示账号不存在,请重新输入
JOptionPane.showMessageDialog(null, "输入的账户无效,请重新输入", " ",
JOptionPane.WARNING_MESSAGE);
System.out.println("输入账号不存在,请重新输入");
jtf1.setText("");
}
} catch (Exception e1) {
e1.printStackTrace();
System.out.print("抛出异常");
}
}// getInformationFromResultSetAndThenReact()方法 protected void setListener() {
jb7.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
System.out.println("更正");
jtf1.setText("");
}
});
jb4.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
System.out.println("返回");
//databaseOperation.close();若没有点击确认按钮,close方法是无法执行的。因为DatabaseOperation类中的ps属性都不存在,只有在调用了增删查找方法后ps对象才是存在的,存在才能调用该方法
dispose();
new AtmFrame();
timeThread.stop();
}
});
jb8.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
reaction();
}
});// b3.addActionListener注册监听方法
} protected void initJLabel() {
jb1 = new JLabel();
jb2 = new JLabel();
jb3 = new JLabel();
jb4 = new JLabel(new ImageIcon("image/返回.png"));
jb5 = new JLabel();
jb6 = new JLabel();
jb7 = new JLabel(new ImageIcon("image/更正.png"));
jb8 = new JLabel(new ImageIcon("image/确认.png"));
} protected void setJLabelVisible() {
jb4.setVisible(true);
jb7.setVisible(true);
jb8.setVisible(true);
}
}// class

  

package Atm;

import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet; import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField; public class TransferSecond extends FatherFrame {
JButton b1, b2, b3;
JTextField jtf1;
int tag = 0;// 用来标识小数点的个数
DatabaseOperation databaseOperation = new DatabaseOperation();
ResultSet rs; // 构造方法
public TransferSecond() {
super(60);
setInterface();
} private void setInterface() {
JPanel p1, p2;
DecimalOnlyDocument ld; jtf1 = new JTextField(16);
ld = new DecimalOnlyDocument();
// ld1.setAllowChar("0123456789.");//设置只能输入数字
jtf1.setDocument(ld);
jtf1.setFont(new Font("宋体", Font.BOLD, 25));// 设置文本框内的字体,同时文本框的大小也会改变 p1 = new JPanel();
p2 = new JPanel(); p1.setOpaque(false);
p2.setOpaque(false); p1.add(new MyJLabel3("请输入转账金额"));
p2.add(jtf1); setLayout(null);
p1.setBounds(204, 140, 400, 40);
p2.setBounds(274, 190, 260, 50);
add(p1);
add(p2);
setVisible(true);
} private void reaction() {
rs = databaseOperation
.search("SELECT BankCard.Bmoney,BankCard.Bzzed FROM ATM.dbo.BankCard WHERE BankCard.Bcard="
+ MainFra.getBcard());
getInformationFromResultSetAndThenReact(); } private void getInformationFromResultSetAndThenReact() {
try {
rs.next();
double zhuanzhangedu=rs.getDouble("Bzzed");
double money_zhuanzhangzhe = rs.getDouble("Bmoney"); // money_zhuanzhangzhe,
// 即转账者账户中的余额
// 做出反应
if(jtf1.getText().length()==0)
JOptionPane.showMessageDialog(null, "请输入转账金额"," ", JOptionPane.WARNING_MESSAGE);
else if(jtf1.getText().equals(".")||jtf1.getText().equals("-")){
JOptionPane.showMessageDialog(null, "请输入有效的转账金额",
" ", JOptionPane.WARNING_MESSAGE);
jtf1.setText("");
}
else if(Double.parseDouble(jtf1.getText())<0){//这一个else if判断必须放在上一个else if判断的后面,//因为你转化成double型的前提是它为数值型变量
JOptionPane.showMessageDialog(null, "请输入有效的转账金额",
" ", JOptionPane.WARNING_MESSAGE);
jtf1.setText("");
}
else if (money_zhuanzhangzhe < Double.parseDouble(jtf1.getText())) {
JOptionPane.showMessageDialog(null, "账户余额不足,转账失败。请重新输入转账金额",
" ", JOptionPane.WARNING_MESSAGE);
// 弹出对话框,提示账户余额不足,转账失败,请重新输入转账金额
System.out.println("账户余额不足,转账失败,请重新输入转账金额");
jtf1.setText("");
} else {
if(Double.parseDouble(jtf1.getText())>zhuanzhangedu){
JOptionPane.showMessageDialog(null, "转账失败,您当天最多还可转账"+(int)zhuanzhangedu+"元,请重新输入转账金额"," ", JOptionPane.WARNING_MESSAGE);
}
else{
rs = databaseOperation
.search("SELECT BankCard.Bmoney FROM ATM.dbo.BankCard WHERE BankCard.Bcard="
+ TransferFirst.getBcard2());
rs.next();
double money_shoukuanzhe = rs.getDouble("Bmoney"); // money_shoukuanzhe即收款者账户中的余额
money_zhuanzhangzhe = money_zhuanzhangzhe
- Double.parseDouble(jtf1.getText());
money_shoukuanzhe = money_shoukuanzhe
+ Double.parseDouble(jtf1.getText());
zhuanzhangedu=zhuanzhangedu-Double.parseDouble(jtf1.getText());
// 修改数据,存入的账号金额增加
databaseOperation
.update("UPDATE ATM.dbo.BankCard SET BankCard.Bmoney="
+ money_shoukuanzhe + " WHERE BankCard.Bcard="
+ TransferFirst.getBcard2());
// 修改数据,转账的账号金额减少,并且当天的转账剩余度也要改变
databaseOperation
.update("UPDATE ATM.dbo.BankCard SET BankCard.Bmoney="
+ money_zhuanzhangzhe+",BankCard.Bzzed="+zhuanzhangedu
+ " WHERE BankCard.Bcard=" + MainFra.getBcard()); // 将这两个账号的这次的操作记录保存到交易明细表中
recordTheseTwoOperationsIntoCustomerRecord(); // ps.close();
// dbConn.close();
JOptionPane.showMessageDialog(null, "转账成功.", " ",
JOptionPane.PLAIN_MESSAGE);
databaseOperation.close();
dispose();
System.out.println("转账成功!");
new AtmFrame();
timeThread.stop();
}
}
} catch (Exception e1) {
e1.printStackTrace();
System.out.print("抛出异常");
}
} private void recordTheseTwoOperationsIntoCustomerRecord() {
double shouxufeibaifenbi = 0;
databaseOperation
.create("INSERT INTO ATM.dbo.CustomerRecord (CustomerRecord.CRcard,CustomerRecord.CRdate,CustomerRecord.CRtype,CustomerRecord.CRmoney,CustomerRecord.CRfee) VALUES ('"
+ MainFra.getBcard()
+ "','"
+ MyDate.getDate()
+ "','"
+ "转出"
+ "','"
+ jtf1.getText()
+ "','"
+ String.valueOf(Double.parseDouble(jtf1.getText())
* shouxufeibaifenbi) + "')");
databaseOperation
.create("INSERT INTO ATM.dbo.CustomerRecord (CustomerRecord.CRcard,CustomerRecord.CRdate,CustomerRecord.CRtype,CustomerRecord.CRmoney,CustomerRecord.CRfee) VALUES ('"
+ TransferFirst.getBcard2()
+ "','"
+ MyDate.getDate()
+ "','"
+ "转入"
+ "','"
+ jtf1.getText()
+ "','"
+ "0"
+ "')");
} protected void setListener() {
jb7.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
System.out.println("更正");
jtf1.setText("");
}
});
jb4.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
System.out.println("返回");
//databaseOperation.close();
dispose();
new AtmFrame();
timeThread.stop();
}
});
jb8.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
reaction();
}
});// b3.addActionListener注册监听方法
} protected void initJLabel() {
jb1 = new JLabel();
jb2 = new JLabel();
jb3 = new JLabel();
jb4 = new JLabel(new ImageIcon("image/返回.png"));
jb5 = new JLabel();
jb6 = new JLabel();
jb7 = new JLabel(new ImageIcon("image/更正.png"));
jb8 = new JLabel(new ImageIcon("image/确认.png"));
} protected void setJLabelVisible() {
jb4.setVisible(true);
jb7.setVisible(true);
jb8.setVisible(true);
}
}

  

package Atm;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet; import javax.swing.JOptionPane; public class WithdrawAction { public WithdrawAction(String mon) {
PreparedStatement ps = null;
Connection dbConn = null;
ResultSet rs = null;
String driverName = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
String dbURL = "jdbc:sqlserver://localhost:1433;DatabaseName=ATM";
String userName = "sa";
String userPwd = "123456"; try {
Class.forName(driverName);
dbConn = DriverManager.getConnection(dbURL, userName, userPwd);
System.out.println("MainFra类-连接数据库成功");
ps = dbConn.prepareStatement("SELECT BankCard.Bmoney,BankCard.Bqxed FROM ATM.dbo.BankCard WHERE BankCard.Bcard=?");
ps.setString(1, MainFra.getBcard());// 这行代码跟上面的问号相关联
rs = ps.executeQuery();// 如果结果集rs开始的位置是0 那么刚查出来的结果集的指针应该指向在-1的位置
rs.next(); // 前
double bMoneyOut = rs.getDouble("Bmoney"); // 后
double bQuxianedu=rs.getDouble("Bqxed");
if(mon.length()==0){
JOptionPane.showMessageDialog(null, "请输入取款金额"," ", JOptionPane.WARNING_MESSAGE);
WithdrawFrame.setJudgeFlag2(false);
}
else if(Integer.parseInt(mon) < 100 || Integer.parseInt(mon) % 100 != 0){
//弹出对话框,提示输入不合法,存款失败,请重新输入存款金额
JOptionPane.showMessageDialog(null, "请输入100或100的正整数倍的取款操作,请重新输入取款金额"," ", JOptionPane.WARNING_MESSAGE);
WithdrawFrame.setJudgeFlag2(false);
}
else if (bMoneyOut < Double.parseDouble(mon)){
JOptionPane.showMessageDialog(null, "账户余额不足,取款失败,请重新输入取款金额"," ", JOptionPane.WARNING_MESSAGE);
WithdrawFrame.setJudgeFlag2(false);
}
else {
if(bQuxianedu<Double.parseDouble(mon)){
JOptionPane.showMessageDialog(null, "取款失败,您当天最多还可取款"+(int)bQuxianedu+"元,请重新输入取款金额"," ", JOptionPane.WARNING_MESSAGE);
WithdrawFrame.setJudgeFlag2(false);
}
else{
ps = dbConn.prepareStatement("SELECT BankCard.Bmoney FROM ATM.dbo.BankCard WHERE BankCard.Bcard=?");
ps.setString(1, TransferFirst.getBcard2());// 这行代码跟上面的问号相关联
rs = ps.executeQuery();// 如果结果集rs开始的位置是0 那么刚查出来的结果集的指针应该指向在-1的位置
rs.next();
bMoneyOut = bMoneyOut - Integer.parseInt(mon);
bQuxianedu=bQuxianedu- Integer.parseInt(mon);
// 修改数据,取款的账号金额减少,同时更改取现额度(当天取现剩余金额值)
ps = dbConn.prepareStatement("UPDATE ATM.dbo.BankCard SET BankCard.Bmoney=?,BankCard.Bqxed=? WHERE BankCard.Bcard=?");//
ps.setDouble(1, bMoneyOut);
ps.setDouble(2, bQuxianedu);
ps.setString(3, MainFra.getBcard());// 这行代码跟上面的问号相关联
ps.executeUpdate(); // 将这次的取款记录保存起来
ps = dbConn.prepareStatement(
"INSERT INTO ATM.dbo.CustomerRecord (CustomerRecord.CRcard,CustomerRecord.CRdate,CustomerRecord.CRtype,CustomerRecord.CRmoney,CustomerRecord.CRfee) VALUES (?,?,?,?,?)");
ps.setString(1, MainFra.getBcard());// 这行代码跟上面的问号相关联
ps.setString(2, MyDate.getDate());
ps.setString(3, "取款");
ps.setString(4, mon);
ps.setString(5, String.valueOf(Integer.parseInt(mon) * 0));
ps.executeUpdate(); ps.close();
dbConn.close();
System.out.println("取款成功!");
JOptionPane.showMessageDialog(null, "取款成功.", " ",
JOptionPane.PLAIN_MESSAGE);
WithdrawFrame.setJudgeFlag2(true);
} } } catch (Exception e1) {
e1.printStackTrace();
System.out.print("抛出异常");
}
} }

  

package Atm;

//取款界面函数

import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingConstants; public class WithdrawFrame extends FatherFrame {
private static boolean judgeFlag2; JTextField jtf = new JTextField(18);
LimitedDocument ld = new LimitedDocument(5); JPanel p3 = new JPanel();
JPanel p4 = new JPanel(); JLabel j1 = new JLabel("请您选择或输入取款金额", SwingConstants.CENTER);// 标签内容为“您好”,并且文本是以居中的方式对齐 Font font = new Font("宋体", Font.BOLD, 28); public WithdrawFrame() {
super(60);
j1.setFont(font);// 设置标签j1的字体 ld.setAllowChar("0123456789");// 只能输入的字符
jtf.setDocument(ld);// 运用到文本框中
jtf.setFont(new Font("宋体", Font.BOLD, 25)); p3.setOpaque(false);
p4.setOpaque(false); // p3.setLayout(new GridLayout(2, 1, 0, 0));//面板p3放欢迎语
p3.add(j1);
p4.add(jtf); setLayout(null);
p3.setBounds((678 - 200) / 2-10, 140, 350, 50);
p4.setBounds((678 - 200) / 2+25, 200, 270, 40); add(p3);
add(p4); }
public static boolean getJudgeFlag2(){
return judgeFlag2;
}
public static void setJudgeFlag2(boolean flag){
judgeFlag2=flag;
} protected void setListener() { // 取款100的监听器
jb1.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
jtf.setText("100");
}
}); //取款500的监听器
jb2.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
jtf.setText("500");
}
}); //取款1000的监听器
jb3.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
jtf.setText("1000");
}
}); // 给回主菜单按钮添加监听器
jb4.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
new AtmFrame();
dispose();
timeThread.stop();
// 此处加入事件的类的对象
}
}); //取款2500的监听器
jb5.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
jtf.setText("2500");
}
}); //取款5000的监听器
jb6.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
jtf.setText("5000");
}
}); //取款1000的监听器
jb7.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
jtf.setText("10000");
}
}); // 给确认按钮添加监听器
jb8.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
new WithdrawAction(jtf.getText());
if(getJudgeFlag2()){
dispose();
new WithdrawFrame();
timeThread.stop();
}
else
jtf.setText("");
}
});
} protected void initJLabel() {
jb1 = new JLabel(new ImageIcon("image/100.png"));
jb2 = new JLabel(new ImageIcon("image/500.png"));
jb3 = new JLabel(new ImageIcon("image/1000.png"));
jb4 = new JLabel(new ImageIcon("image/回主菜单.png"));
jb5 = new JLabel(new ImageIcon("image/2500.png"));
jb6 = new JLabel(new ImageIcon("image/5000.png"));
jb7 = new JLabel(new ImageIcon("image/10000.png"));
jb8 = new JLabel(new ImageIcon("image/确认.png"));
} protected void setJLabelVisible() {
jb1.setVisible(true);
jb2.setVisible(true);
jb3.setVisible(true);
jb4.setVisible(true);
jb5.setVisible(true);
jb6.setVisible(true);
jb7.setVisible(true);
jb8.setVisible(true);
} }

  


package Atm;
//ATM登录成功界面 import javax.swing.*; import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet; public class AtmFrame extends FatherFrame{ JPanel p3 = new JPanel(); JLabel j1 = new JLabel("您好", SwingConstants.CENTER);//标签内容为“您好”,并且文本是以居中的方式对齐
JLabel j2 = new JLabel("请您选择交易", SwingConstants.CENTER);//同样以居中的方式对齐 Font font = new Font("宋体", Font.BOLD, 30); public AtmFrame(){
super(60); j1.setFont(font);//设置标签j1的字体
j2.setFont(font);//设置标签j2的字体 // 将p1,p2,p3面板都设置为透明的 p3.setOpaque(false); p3.setLayout(new GridLayout(2, 1, 0, 0));//面板p3放欢迎语
p3.add(j1);
p3.add(j2); setLayout(null); p3.setBounds(300, 140, 200, 60); add(p3); PreparedStatement ps=null;
Connection dbConn=null;
ResultSet rs=null;
String driverName="com.microsoft.sqlserver.jdbc.SQLServerDriver";
String dbURL="jdbc:sqlserver://localhost:1433;DatabaseName=ATM";
String userName="sa";
String userPwd="123456"; try
{
Class.forName(driverName);
dbConn=DriverManager.getConnection(dbURL,userName,userPwd);
System.out.println("MainFra类-连接数据库成功");
ps=dbConn.prepareStatement("SELECT BankCard.Bdongjie FROM ATM.dbo.BankCard WHERE BankCard.Bcard=?");//
ps.setString(1,MainFra.getBcard());//这行代码跟上面的问号相关联
rs=ps.executeQuery();//如果结果集rs开始的位置是0 那么刚查出来的结果集的指针应该指向在-1的位置 if(rs.next()){
if(rs.getBoolean("Bdongjie")){
jb4.setVisible(false);
jb3.setVisible(false);
jb7.setVisible(false);
} }
}
catch(Exception e1)
{
e1.printStackTrace();
System.out.print("抛出异常");
} } protected void initJLabel(){
jb1=new JLabel();
jb2=new JLabel(new ImageIcon("image/查询.png"));
jb3=new JLabel(new ImageIcon("image/改密.png"));
jb4=new JLabel(new ImageIcon("image/取款.png"));
jb5=new JLabel();
jb6=new JLabel(new ImageIcon("image/存款.png"));
jb7=new JLabel(new ImageIcon("image/转账.png"));
jb8=new JLabel(new ImageIcon("image/退出.png"));
}
protected void setJLabelVisible(){
jb2.setVisible(true);
jb3.setVisible(true);
jb4.setVisible(true);
jb6.setVisible(true);
jb7.setVisible(true);
jb8.setVisible(true);
}
protected void setListener(){
// 给查询按钮添加监听器
jb2.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
dispose();
timeThread.stop();
new Balance();
//此处加入事件的类的对象
}
}); // 给改密按钮添加监听器
jb3.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
dispose();
timeThread.stop();
new ChangePassword1();
//此处加入事件的类的对象
}
}); // 给取款按钮添加监听器
jb4.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
dispose();
timeThread.stop();
new WithdrawFrame();
//此处加入事件的类的对象
}
}); // 给存款按钮添加监听器
jb6.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
dispose();
timeThread.stop();
new SaveFrame();
//此处加入事件的类的对象
}
}); // 给转账按钮添加监听器
jb7.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
dispose();
timeThread.stop();
new TransferFirst();
//此处加入事件的类的对象
}
}); // 给退出按钮添加监听器
jb8.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
JOptionPane.showMessageDialog(null, "谢谢使用", " ",
JOptionPane.PLAIN_MESSAGE);
dispose();
timeThread.stop();
new MainFra();
//此处加入事件的类的对象
}
});
}
}

  

package Atm;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.Label;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.text.DecimalFormat; import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants; public class Balance extends FatherFrame {
JLabel j, j1, j2, j3, j4;
String arg1, arg2, arg3, arg4;
ResultSet rs;
DatabaseOperation databaseOperation;
boolean dongjieyufou; public Balance() {
super(60);
databaseOperation = new DatabaseOperation();
String sql = "SELECT BankCard.Bdongjie,BankCard.Bmoney FROM ATM.dbo.BankCard WHERE BankCard.Bcard="
+ MainFra.getBcard();
rs = databaseOperation.search(sql);
getInformationFromResultSet();
setDataFromInformation();
putDataIntoInterfaceFirst();
setInterfaceSecond();
}// 构造方法 private void getInformationFromResultSet() {
try {
rs.next();
arg1 = new DecimalFormat("######0.00")
.format(rs.getFloat("Bmoney"));
dongjieyufou = rs.getBoolean("Bdongjie");
} catch (Exception e1) {
e1.printStackTrace();
System.out.print("抛出异常");
}
} private void setDataFromInformation() {
if (dongjieyufou)
arg2 = arg3 = arg4 = "0.00";
else {
arg2 = arg3 = arg4 = arg1;
}
} private void putDataIntoInterfaceFirst() {
j1 = new MyJLabel3(arg1);
j2 = new MyJLabel3(arg2);
j3 = new MyJLabel3(arg3);
j4 = new MyJLabel3(arg4);
} private void setInterfaceSecond() { JLabel j, jj1, jj2, jj3, jj4;
JPanel p1, p2, p3, p4, p5; p1 = new JPanel();
p2 = new JPanel();
p3 = new JPanel(); j = new MyJLabel1("您的账户余额信息"); p1.setOpaque(false);// 将p1面板设置为透明的,p1用来放提示语:"您的账户余额信息"
p2.setOpaque(false);// 将p2面板设置为透明的,p2用来放红色的那些字
p3.setOpaque(false);// 将p3面板设置为透明的,p3用来放数字 p1.add(j);
p2.setLayout(new GridLayout(6, 1));
p3.setLayout(new GridLayout(6, 1)); jj1 = new MyJLabel2("账户余额:");
jj2 = new MyJLabel2("可用余额:");
jj3 = new MyJLabel2("可取现金额:");
jj4 = new MyJLabel2("可转账金额:"); jj1.setHorizontalAlignment(SwingConstants.RIGHT);
jj2.setHorizontalAlignment(SwingConstants.RIGHT);
jj3.setHorizontalAlignment(SwingConstants.RIGHT);
jj4.setHorizontalAlignment(SwingConstants.RIGHT); p2.add(jj1);
p2.add(jj2);
p2.add(jj3);
p2.add(jj4);
p3.add(j1);
p3.add(j2);
p3.add(j3);
p3.add(j4); setLayout(null); p1.setBounds(199, 140, 400, 40);
p2.setBounds(208, 200, 200, 240);
p3.setBounds(409, 200, 250, 240); add(p1);
add(p2);
add(p3);
setVisible(true);
} protected void setListener() {
jb4.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
databaseOperation.close();
timeThread.stop();
dispose();
new AtmFrame();
}
}); jb8.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
databaseOperation.close();
timeThread.stop();
dispose();
new Detail();
}
});
} protected void initJLabel() {
jb1 = new JLabel();
jb2 = new JLabel();
jb3 = new JLabel();
jb4 = new JLabel(new ImageIcon("image/返回.png"));
jb5 = new JLabel();
jb6 = new JLabel();
jb7 = new JLabel();
jb8 = new JLabel(new ImageIcon("image/查询交易明细.png"));
} protected void setJLabelVisible() {
jb4.setVisible(true);
jb8.setVisible(true);
} }

  

package Atm;

//重置密码

import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet; import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField; public class ChangePassword1 extends FatherFrame {
DatabaseOperation databaseOperation;
ResultSet rs;
JPasswordField password; public ChangePassword1() {
super(60);
databaseOperation = new DatabaseOperation();
password = new JPasswordField(18);// 这里的4不是限制输入的长度,而是密码文本框的长度
setInterface(); } private void setInterface() {
JPanel p1, p2, p3;
LimitedDocument ld; ld = new LimitedDocument(6);// 这里的6才是限制输入的长度
password.setDocument(ld);
password.setFont(new Font("宋体", Font.BOLD, 25));// 设置文本框内的字体,同时文本框的大小也会改变 p1 = new JPanel();
p2 = new JPanel();
p3 = new JPanel(); p1.setOpaque(false);
p2.setOpaque(false);
p3.setOpaque(false); p1.add(new MyJLabel3("请输入你的密码"));
p2.add(password);
p3.add(new MyJLabel5("请输入6位密码")); setLayout(null);
p1.setBounds(204, 140, 400, 40);
p2.setBounds(275, 200, 260, 70);
p3.setBounds(249, 390, 300, 40); add(p1);
add(p2);
add(p3); setVisible(true);
} private void checkPassword() {
try {
rs.next();
if (password.getText().equals(rs.getString("Bpassword"))) {
databaseOperation.close();
dispose();
timeThread.stop();
new ChangePassword2();
} else {
password.setText("");
JOptionPane.showMessageDialog(null, "密码输入错误,请重新输入", " ",
JOptionPane.WARNING_MESSAGE);
}
} catch (Exception e1) {
e1.printStackTrace();
System.out.print("抛出异常");
}
} protected void initJLabel() {
jb1 = new JLabel();
jb2 = new JLabel();
jb3 = new JLabel();
jb4 = new JLabel(new ImageIcon("image/退出登录.png"));
jb5 = new JLabel();
jb6 = new JLabel();
jb7 = new JLabel();
jb8 = new JLabel(new ImageIcon("image/确认.png"));
} protected void setListener() {
jb4.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
//databaseOperation.close();
dispose();
timeThread.stop();
new MainFra();
}
}); jb8.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
rs = databaseOperation
.search("SELECT BankCard.Bpassword FROM ATM.dbo.BankCard WHERE BankCard.Bcard="
+ MainFra.getBcard());
checkPassword();
}
});
} protected void setJLabelVisible() {
jb4.setVisible(true);
jb8.setVisible(true);
}
}

  

package Atm;

import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet; import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField; public class ChangePassword2 extends FatherFrame {
DatabaseOperation databaseOperation;
private JPasswordField password;
private LimitedDocument ld;
JButton b1, b2; public ChangePassword2() {
super(60);
databaseOperation = new DatabaseOperation();
password = new JPasswordField(18);// 这里的4不是限制输入的长度,而是密码文本框的长度
ld = new LimitedDocument(6);// 这里的6才是限制输入的长度
password.setFont(new Font("宋体", Font.BOLD, 25));// 设置文本框内的字体,同时文本框的大小也会改变
password.setDocument(ld); setInterface(); } private void setInterface() {
JPanel p1, p2, p3; p1 = new JPanel();
p2 = new JPanel();
p3 = new JPanel(); p1.setOpaque(false);
p2.setOpaque(false);
p3.setOpaque(false); p1.add(new MyJLabel3("请输入您的新个人密码"));
p2.add(password);
p3.setLayout(new GridLayout(3, 1));
p3.add(new MyJLabel5("请输入6位密码"));
p3.add(new MyJLabel5("温馨提示:为了加强保密性,提请您尽量避免使用身份证号、出生年月日"));
p3.add(new MyJLabel5("号码作为您账户或者银行卡的密码")); setLayout(null);
p1.setBounds(205, 140, 400, 40);
p2.setBounds(275, 200, 260, 70);
p3.setBounds(115, 390, 600, 60); add(p1);
add(p2);
add(p3);
setVisible(true);
} private void check() {
if (password.getText().length() == 6) {
databaseOperation
.update("UPDATE ATM.dbo.BankCard SET BankCard.Bpassword="
+ password.getText() + " WHERE BankCard.Bcard="
+ MainFra.getBcard());
JOptionPane.showMessageDialog(null, "更改密码成功.", " ",
JOptionPane.PLAIN_MESSAGE);
databaseOperation
.create("INSERT INTO ATM.dbo.CustomerRecord (CustomerRecord.CRcard,CustomerRecord.CRdate,CustomerRecord.CRtype,CustomerRecord.CRmoney,CustomerRecord.CRfee) VALUES ('"
+ MainFra.getBcard()
+ "','"
+ MyDate.getDate()
+ "','"
+ "修改密码"
+ "','"
+ "0"
+ "','"
+ "0" + "')");
databaseOperation.close();
dispose();
timeThread.stop();
new AtmFrame();
} else {
// 弹出对话框,提示密码设置错误,请重新输入
JOptionPane.showMessageDialog(null, "密码设置错误,请重新输入", " ",
JOptionPane.WARNING_MESSAGE);
System.out.println("密码设置错误,请重新输入");
password.setText("");
}
} protected void initJLabel() {
jb1 = new JLabel();
jb2 = new JLabel();
jb3 = new JLabel();
jb4 = new JLabel(new ImageIcon("image/退出登录.png"));
jb5 = new JLabel();
jb6 = new JLabel();
jb7 = new JLabel();
jb8 = new JLabel(new ImageIcon("image/确认.png"));
} protected void setListener() {
jb4.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
//databaseOperation.close();
dispose();
new MainFra();
timeThread.stop();
}
});
jb8.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
check();
}
});
} protected void setJLabelVisible() {
jb4.setVisible(true);
jb8.setVisible(true);
}
}

  

高仿中国银行ATM系统的更多相关文章

  1. 安卓开发笔记——Fragment+ViewPager组件(高仿微信界面)

    什么是ViewPager? 关于ViewPager的介绍和使用,在之前我写过一篇相关的文章<安卓开发复习笔记——ViewPager组件(仿微信引导界面)>,不清楚的朋友可以看看,这里就不再 ...

  2. iOS高仿app源码:纯代码打造高仿优质《内涵段子》

    iOS高仿app源码:纯代码打造高仿优质<内涵段子>收藏下来 字数1950 阅读4999 评论173 喜欢133 Github 地址 https://github.com/Charlesy ...

  3. iOS视频直播初窥:高仿<喵播APP>

    视频直播初窥 视频直播,可以分为 采集,前处理,编码,传输, 服务器处理,解码,渲染 采集: iOS系统因为软硬件种类不多, 硬件适配性比较好, 所以比较简单. 而Android端市面上机型众多, 要 ...

  4. 转-Fragment+ViewPager组件(高仿微信界面)

    http://www.cnblogs.com/lichenwei/p/3982302.html 什么是ViewPager? 关于ViewPager的介绍和使用,在之前我写过一篇相关的文章<安卓开 ...

  5. C#制作高仿360安全卫士窗体<二>

    继上次C#制作高仿360安全卫士窗体<一>发布之后响应还不错,我的博客放肆雷特也来了不少的新朋友,在这里先谢谢大家的支持!我自己也反复看了一下觉得对不起大家,写的非常乱而且很少文字介绍.在 ...

  6. C#制作高仿360安全卫士窗体<一>

    开始写这一系列博客之前先要向大家说声抱歉,放肆雷特建立很久却很少有更新.当然博客人气也不旺,大部分都是看的人多评论收藏的人少.一直想要改变这种状态,正好赶上了最近工作上做了一个高仿360安全卫士窗体. ...

  7. 高仿百度传课应用客户端源码iOS版

    高仿百度传课iOS版,版本号:2.4.1.2 运行环境:xcode6.3  ios8.3 (再往上系统没有测试) 转载请注明出处,不可用于商业用途及不合法用途. 如果你觉得不错,欢迎  star  哦 ...

  8. C#编写记事本(高仿)

    近一周写的关于记事本的代码,高仿记事本.本人C#入门不久,其中存在代码冗余,但懒得修改了. 经测试运行正常. 一.主窗体设计及代码 namespace BestEditor { public part ...

  9. android高仿微信拍照、多选、预览、删除(去除相片)相冊功能

    先声明授人与鱼不如授人与渔,仅仅能提供一个思路,当然须要源代码的同学能够私下有偿问我要源代码:QQ:508181017 工作了将近三年时间了,一直没正儿八经的研究系统自带的相冊和拍照,这回来个高仿微信 ...

随机推荐

  1. yii2事务运用举例

    直接上代码: $db = Yii::$app->db; $transaction = $db->beginTransaction(); //开启事务 try { // 更新member表 ...

  2. 关于int,integer初始值问题

  3. 启动apache和tomcat端口被占用解决办法

    1,打开控制台,使用命令 netstat -aon|findstr 8090  找出端口被占用的进程, 2,使用 taskkill -f -pid 4116(进程id)杀掉当前占用端口的进程

  4. Python全栈开发【基础一】

    Python全栈开发[第一篇] 本节内容: Python 的种类 Python 的环境 Python 入门(解释器.编码.变量.input输入.if流程控制与缩进.while循环) if流程控制与wh ...

  5. iOS UIStackView的理解

    iOS9 提供的UIStackview简化了布局操作,它有些像Android中的liner layout.以前不用UIStackview也是可以做出类似的效果的,不过要添加许多的约束,看得头都大了,使 ...

  6. iOS开发UI篇—核心动画简介

    转自:http://www.cnblogs.com/wendingding/p/3801036.html iOS开发UI篇—核心动画简介 一.简单介绍 Core Animation,中文翻译为核心动画 ...

  7. 【转载】scribe、chukwa、kafka、flume日志系统对比

    原文地址:http://www.ttlsa.com/log-system/scribe-chukwa-kafka-flume-log-system-contrast/ 1. 背景介绍许多公司的平台每天 ...

  8. PAT A 1119. Pre- and Post-order Traversals (30)【二叉树遍历】

    No.1119 题目:由前序后序二叉树序列,推中序,判断是否唯一后输出一组中序序列 思路:前序从前向后找,后序从后向前找,观察正反样例可知,前后序树不唯一在于单一子树是否为左右子树. 判断特征:通过查 ...

  9. linux 查看Java 进程的内存使用情况

    top -b -n 1 | grep java| awk '{print "PID:"$1",mem:"$6",CPU percent:"$ ...

  10. docker1.4版本devicemapper修改容器硬盘大小

    升级docker最新版(1.4.0)后,发现容器的硬盘空间只有10G,如果需要指定初始硬盘大小,目前的做法还比较粗暴,更改docker daemon的启动命令,然后删掉目前机器的已有镜像,重启dock ...