电脑桌面
添加蜗牛文库到电脑桌面
安装后可以在桌面快捷访问

银行ATM系统软件工程设计报告

栏目:合同范文发布:2025-01-28浏览:1收藏

银行ATM系统软件工程设计报告

第一篇:银行ATM系统软件工程设计报告

西安邮电学院

学院名称学生姓名专业名称班级软件工程报告

计算机学院

网络工程

: : : :

Part A: • What is Software Engineering(SE)软件工程是一门工程学科,涉及软件生产的各个方面,从最初的系统描述一直到使用后的维护,都属于其学科范畴。软件工程人员运用的是系统的、有组织的的工作方法,这种方法对于制作高质量的软件是最有效的。

• How many different parts in SE development(1).问题的定义以及规划;(2).需求分析;(3).软件设计;(4).程序编码;(5).软件测试;(6).软件维护。

• What is Software Processes 软件过程是指制作软件产品的一组活动及其结果。所有的软件工程都包含:(1).软件描述;(2)软件开发;

(3)软件的有效性验证;(4)软件进化。

• Software development(Technology and method)软件工程方法是一种软件开发的结构化方法,其目的在于提高软件质量的同时,使其性价比较高。结构化分析方法(DeMarco,1978)和JSD方法(Jackson,1983)在20世纪70年代首次开发出来,这些方法旨在识别系统中基本的功能模块,面向功能的方法现在仍被广泛应用。在20世纪80到90年代,Booch(1994)和Rumbaugh(1991)等人又提出了面向对象的方法。现在这些不同的方法已经被集成了一种方法——统一建模语言(UML)。

• Project and Project management

软件项目管理者和其他的工程项目管理者的工作性质是相同的,然而,软件工程管理与其他的工程管理相比,在很多方面是有显著的区别的。(1).软件产品是无形的;(2).没有标准的软件过程;

(3).大型软件项目常常是“一次性”项目。

一、需求分析

由于经济社会发展速度的大幅提高,几乎所有的银行都配备了不用繁琐的人工操作的ATM自动取款机。人们可以随时随地进行交易,不再受银行的服务时间的约束,取款时也为人们节省了很多时间,方便快捷。

这个项目的开发是为银行提供一套高效稳定可靠的终端服务平台,为储户登录,存款,取款,查询,打印凭条等操作提供便利,尤其是在ATM机出现故障的情况下,提供了故障恢复的功能。

二、软件设计

本系统相应的需求有以下方面:

(1)能够读取和存储客户账户中的存取款信息,并方便有效地进行客户选择的交易操作。这主要包括以下内容:

① 自动调用银行总系统中客户原有信息 ② 银行客户账户中的信息的查询、读取 ③ 客户操作的识别,及信息的录入、更新、存储

(2)能够将客户输入的信息及时上传到银行总系统中,并将客户原有信息进行自动更新。这其中主要包括以下内容:

① 汇总客户更新的信息,直接上传到银行总系统中 ② 抽调银行总系统中客户原有信息,并进行修改

③ 将银行总系统中客户原有信息更新为客户最新输入的信息,并存储(3)提供客户信息访问的权限和管理。其中包括: ① 客户访问普通信息的权限

② 银行系统管理员对客户信息的录入、更改和删除

需要补充说明的几点有:

(1)数据保存:需要长期保存的数据信息有

① 客户信息:客户开通银行账户的基本信息 ② 账户信息:客户在银行的存取款信息(2)系统用户:银行系统管理员和客户

① 银行系统管理员:对ATM机中的信息可进行录入、更改和删除等操作 ② 客户:在ATM机上可进行存取交易操作

系统的总体规划

登陆界面否验证是选择操作界面是查询存款取款是否出现故障否否是是否故障恢复成功打印是是否打印凭条否否是否交易结束是退卡

客户端流程

三、软件开发与运行维护

由于本人水平有限以及时间仓促,暂时用C语言来实现,后期的运行维护也尚未展开。

#include “stdio.h” /*读取文件 将内容存放到内存*/ #include “stdlib.h” #include “string.h” fscanf(fp,“#%s %s %fn”,atm[m].zhan#include “conio.h” ghao,atm[m].password,&atm[m].allmon ey);int No=0,m,n=0;fclose(fp);/*记录用户账号次序变量*/ FILE *fp,*fp1;struct atmsystem { char zhanghao[9];

/*账号*/ char password[11];

/*密码*/ float allmoney;

/*总金额*/ }atm[30],atmtemp;/*定义30个帐户与一个临时帐户*/

main()

/*主函数*/ { void kaihu();

/*声明开户函数*/ int check();

/*声明密码验证函数*/ void service();

/*声明服务菜单函数*/ void zhuanzhang();

/*声明转帐函数*/ void changepw();

/*声明更改密码函数*/ void quit();/*声明退出函数*/ char a;/*菜单选择用的变量*/ if((fp=fopen(“USER.txt”,“r”))==NULL)/*打开文件*/ {

printf(“File cannot be openedn”);

system(“pause”);

return 0;} for(m=0;!feof(fp);m++)/*关闭文件*/ No=m+1;for(;;)

/*循环主菜单*/ { system(“cls”);

/*设置清屏*/ printf(“***********Welcome to ATM System*************nn”);

printf(“Please select:n1.Create a new accountn2.Customer Servicen3.Exit Systemn”);/*输出主菜单*/

printf(“-------------n”);

scanf(“%c”,&a);

/*接收一个数字字符*/

if(a=='1')

/*判断是否是1*/

{

printf(“Setting user informationn”);

kaihu();

/*调用新开户的函数*/

printf(“nPress any key to continue”);

getch();

system(“cls”);

/*设置清屏*/

}

else if(a=='2')

/*判断是否是2*/

{

if(check()==1)/*调用检查账户函数*/

service();/*认证后 开始服务*/

else 已经存在,请重新输入*/

{

getch();

printf(“nSorry,you

break;have been wrong for 3 times.”);

}

else if(n==29)quit();/*输入的帐户不存在,开建新帐户*/ }

flag=1;

} }

else if(a=='3')

if(flag==1)break;

/*判断是否是3*/ quit();/*退出*/ }

system(“pause”);return 0;} void kaihu()

/*定义新开帐户函数*/ { int i,j,flag=0;char pw,ch1;float money;char ch[7];

if(No<=30)/*判断是否有空间创建帐户*/ { for(;;){ printf(“Please enter your account ID:(less than 8 characters)n”);

scanf(“%s”,&atmtemp.zhanghao);

/*接收一个字符串*/ if(strcmp(atmtemp.zhanghao,“exit”)==0)exit(1);for(n=0;n<30;n++)/*验证输入的帐户和密码*/ { if(strcmp(atm[n].zhanghao,atmtemp.zhanghao)==0)/*如果输入的帐户已经存在*/

{

printf(“nAccount already exists, please re-enter.nIf you want to exit,please enter 'exit' when you enter ID.nPress any key to continue.nn”);

/*帐户/*跳出检查*/ }

printf(“n”);

for(j=0;j<3;j++){ i=0;

printf(“Please enter your password:(less than 10 characters)n”);

pw=getch();

while(pw!='r')/*接收密码*/ {

if(pw=='b')

{

printf(“b b”);

--i;

} else

{

putchar('*');

atmtemp.password[i++]=pw;

} pw=getch();

} atmtemp.password[i]='';printf(“n”);printf(“Please re-enter password”);/*再次输入密码*/ printf(“n”);

i=0;ch1=getch();while(ch1!='r'){

if(ch1=='b')

{

printf(“b b”);

--i;} else

{

putchar('*');

ch[i++]=ch1;}

} else printf(“Sorry, there can't ch1=getch();have more account.n”);} } ch[i]='';

printf(“n”);int check()

if(strcmp(atmtemp.password,ch)==0)

/*定义检查函数*/ /*两次输入密码一样,继续*/

{

strcpy(atm[No-1].zhanghao,atmtemp.zhanghao);

/*创建新账号*/

strcpy(atm[No-1].password,atmtemp.password);

atm[No-1].allmoney=0;

/*金额的初始值为0*/

for(;;)

{

printf(“Please enter the amount in the first time:n”);

scanf(“%f”,&money);

if(money>0)/*判断是否输入错误*/

{

atm[No-1].allmoney+=money;

/*总金额等于总金额加上初次存入金额*/

break;

}

else printf(“Wrong amount.Again!n”);

}

printf(“---------------------n”);

printf(“Information:nID:%snAmount:%.2fn”,atm[No-1].zhanghao,atm[No-1].allmoney);

printf(“---------------------n”);

No++;/*帐户自增*/

break;

}

else printf(“Please re-enter password.You have 3 times to try!n”);

} { int i,j,flag=0;

/*设变量*/ char pw;for(j=0;j<3;j++)

/*让密码输入循环*/ { i=0;printf(“Please enter your account ID:n”);

scanf(“%s”,&atmtemp.zhanghao);

/*输入账号*/ printf(“Please enter your password:n”);

pw=getch();while(pw!='r'){ if(pw=='b')

{

printf(“b b”);

--i;

} else

{

putchar('*');

atmtemp.password[i++]=pw;

}

pw=getch();} atmtemp.password[i]='';printf(“n”);for(n=0;n<30;n++)/*验证输入的帐户和密码*/ if(strcmp(atm[n].zhanghao,atmtemp.zhanghao)==0&&strcmp(atm[n].password,atmtemp.password)==0)/*如果输入的帐户和密码相同*/

{

printf(“n----------------Authentication Successful----------------nn”);

/*认证成功*/

flag=1;

/*而且标志为1*/ printf(“tYour choice:”);

break;scanf(“%d”,&a);

/*跳出内循环*/ /*输入选择*/

} if(a==1)

if(flag==1)break;

/*跳出外循环*/ if(flag==0)

/*如果验证密码不通过*/

printf(“Authentication failed!Please re-enter and can not be much of an error in three times!nn”);/*认证失败!请重新输入,不容许多于三次的错误!*/

} return flag;} void service()

/*声明服务菜单函数*/ { int a;

/*设定输入选择的变量*/ int flag=0;float cq,q;/*设cq存入金额的变量,q取款金额的变量*/ for(;;){ system(“cls”);

printf(“Please select..............................ID:%snn”,atm[n].zhanghao);

printf(“t------------------n”);

/*输出语句-子菜单*/ printf(“t-----------1.Deposit Services--------------------n”);printf(“t-----------2.Teller Service----------------------n”);printf(“t-----------3.Transfer----------------------------n”);printf(“t-----------4.Change Password---------------------n”);printf(“t-----------5.Check the account information-------n”);printf(“t-----------6.Log out-----------------------------n”);printf(“t------------------nn”);/*如果选择1*/

{

for(;;)

{

printf(“Please enter the amount you want deposited:”);

/*请输入您要存入的金额*/

scanf(“%f”,&cq);

/*输入存款的金额*/

if(cq>0)

{

atm[n].allmoney+=cq;

/*余额等于余额加上存款*/

break;

}

else printf(“Wrong enter.Again!n”);

}

printf(“------------------n”);

printf(“nThe amount of your deposit:%.2fnTotal amount of money are:%.2fn”,cq,atm[n].allmoney);/*输出存款和余额*/

printf(“------------------n”);

printf(“nPress any key to continue”);

getch();

system(“cls”);

/*设置清屏*/

} else if(a==2)

/*如果选择2*/

{

for(flag=0;;)

/*加入循环*/

{

if(flag)

break;/*跳出循环*/

for(;;)

{

printf(“Please enter the amount of money you want:”);

scanf(“%f”,&q);

/*输入您要取款的金额*/

if(q>0)

{

if(q>atm[n].allmoney)

/*如果取款金额大于余额*/

{

printf(“You have not enough balance!n”);

/*输出“余额不足”,继续循环*/

}

else

/*否则*/

{

atm[n].allmoney-=q;

/*余额等于原余额减去取款金额*/

printf(“-----------------------n”);

printf(“nThe amount of money you want are:%.2fnThe balance are:%.2fn”,q,atm[n].allmoney);/*输出取款金额和余额*/

printf(“-----------------------n”);

printf(“nPress any key to continue”);

getch();

system(“cls”);

/*设置清屏*/

flag=1;

break;

/*并跳出循环*/

}

}

else printf(“Wrong Enter.Again!n”);

}

} } else if(a==3)

/*如果选择3*/

{ zhuanzhang();

/*调用转账函数*/

printf(“nPress any key to continue”);

getch();

system(“cls”);

/*设置清屏*/

}

else if(a==4)

/*如果选择4.修改密码*/ {

changepw();

/*调用修改密码的函数*/ printf(“nPress any key to continue”);

getch();

system(“cls”);

/*设置清屏*/ }

else if(a==5)

/*如果选择5*/

{

printf(“---------------------n”);

printf(“ID:%sn”,atm[n].zhanghao);

/*输出清单:账号*/

printf(“Psaaword:******n”);

/*输出密码*/

printf(“Balance: %.2fn”,atm[n].allmoney);

/*输出金额*/

printf(“---------------------n”);

printf(“Press any key to continuen”);

getch();

system(“cls”);

/*设置清屏*/

}

else if(a==6)

/*如果选择是6*/

{

break;

}

} } void zhuanzhang()

/*定义转帐函数*/ { int i,flag=0,m;float s;

for(i=0;i<3;i++){

printf(“Enter the account ID to be transferred to:”);

/*输入您要转入帐号*/

scanf(“%s”,atmtemp.zhanghao);for(m=0;m<30;m++)

if(strcmp(atm[m].zhanghao,atmtemp.zhanghao)==0)/*如果输入的帐户存在*/

{

flag=1;

/*而且标志为1*/

break;

/*跳出内循环*/

} if(flag==1)break;/*跳出外循环*/ if(flag==0)printf(“nEnter the account ID is wrong.Please re-enter and can not be much of an error in three times!n”);} for(;;){

if(flag==1)printf(“nEnter the amount you want transferred to:”);

/*输入您要转入的金额*/ else

break;scanf(“%f”,&s);

/*输入转入的金额*/ if(s>0){

if(atm[n].allmoney

/*如果转出的金额大于余额*/

printf(“You have not enough balance!n”);

/*输出“余额不足”,并继续循环*/

else

{

atm[n].allmoney-=s;

/*转出的账户金额等于余额减去转出的金额*/

atm[m].allmoney+=s;

/*转入的账户金额等于余额加上转入的金额*/

printf(“n------------------n”);

printf(“Successful transfer!n”);

printf(“Your account balance are:%.2fn”,atm[n].allmoney);/*输出余额*/

printf(“------------------n”);

break;

}

} else printf(“Wrong enter.Again!n”);

} } void changepw()

/*定义修改密码的函数*/ { int i,j,p;char ch,ch1,ch2;char aa[11],cc[11],dd[11];

/*设定变量aa为输入原密码cc密码*/ for(;;)

/*循环*/ { i=0;printf(“nPlease enter the original password:”);

/*请输入原密码*/ ch=getch();while(ch!='r'){ if(ch=='b')

{

printf(“b b”);

--i;

} else

{

aa[i++]=ch;putchar('*');} ch=getch();} aa[i]='';

/*输入原密码*/ printf(“n”);if(strcmp(aa,atm[n].password)==0)

/*判断输入的密码是否与原密码相同*/

{

p=0;

j=0;

printf(“nPlease enter your new password:”);

/*请输入您的新密码*/

ch1=getch();

/*输入设定新密码*/

while(ch1!='r')

{

if(ch1=='b')

{

printf(“b b”);

--j;

} else

{

cc[j++]=ch1;

putchar('*');}

ch1=getch();

}

cc[j]='';

printf(“n”);

printf(“Please re-enter the password:”);

ch2=getch();

while(ch2!='r')

{

if(ch2=='b')

{

printf(“b b”);

--p;

} else

{

dd[p++]=ch2;

putchar('*');}

ch2=getch();

}

dd[p]='';

printf(“n”);

if(strcmp(cc,dd)==0)

{

strcpy(atm[n].password,cc);

/*将新密码复盖旧密码*/

printf(“------------------n”);

printf(“nYour password has been successfully modifiedn”);

/*您的密码已修改成功*/

printf(“------------------n”);

break;

/*跳出循环*/

}

} else

/*判断密码为不想同*/

{

printf(“nYou enter the password is not correctn”);

/*您输入的密码不正确,并且继续循环*/

printf(“*******Please re-enter********n”);

printf(“nPress any key to continue”);

getch();

system(“cls”);/*设置清屏*/

} } }

void quit(){

remove(“USER.txt”);/*删除旧文件*/

fp1=fopen(“USER.txt”,“w+”);/*重新写入文件*/

for(n=0;n

fprintf(fp1,“#%s %s %fn”,atm[n].zhanghao,atm[n].password,atm[n].allmoney);

fclose(fp1);

printf(“nGood bye!nThank you for using!n”);

getch();

exit(1);

/*跳出系统*/ }

第二篇: 《ATM模拟银行》设计报告

《C/S项目实训》

课程设计报告

题 目: ATM模拟银行

学生姓名(学号): 代小龙(20***1)安梓玮(20***7)侯硕(20***5)

专 业: 信息管理与信息系统

班 级: 18信管(一)班

指导教师: 申晨

信息管理与工程系

2019年01月02日

基于Java的ATM模拟银行开发与设计

摘要:

自动取款机又称ATM,意思是自动柜员机,因大部分用于取款,又称自动取款机。它是一种利用磁性代码卡或智能卡实现金融交易的自助服务,代替银行柜面人员的工作。可提取现金、查询存款余额、进行账户之间资金转账、余额查询等工作;还可以进行现金存款(实时入账)、中间业务等工作。持卡人可以根据密码办理自动取款、查询余额、转账、现金存款,更改密码,缴纳手机话费等业务。我们在这次课程设计上运用了JAVA以及 SQL Server 2012进行设计。.该系统是站在用户的角度来实现取款,存款,转账,修改密码,定期存款,查询余额多个页面的实现,页面的实现满足了银行基本的业务需求,使银行工作规范化,自动化,在系统页面设计方面,我们使得系统的功能操作简单,用户体验较好。

窗体底端

关键字:ATM模拟机,用户,管理员,页面设计,JAVA,sql server,Eclipse集成开发环境下开发系统

目 录 项目简介与分工 1

1.1 项目简介 1

1.1.1 系统开发需求 1

1.1.2系统具体事务 1

1.1.3 系统开发环境要求 1

1.2 项目分工 2 项目设计方案 3 项目功能实现 4

3.1数据库的实现 4

3.2主要功能实现 5

3.2.1主界面 5

3.2.2普通用户存款界面 9

3.2.3用户转账 11

3.2.4手机缴费 16

3.2.5用户取款 19

3.2.6冻结 24

3.2.7开户 26

3.2.8销户 30项目总结及展望 33 心得体会 34

参 考 文 献 35 项目简介与分工

1.1 项目简介

本系统采用JAVA语言编写测试完成,基本上在字符界面下模拟了ATM系统的相关实现。主要模拟银行ATM机系统功能,主要有查阅、转账、取款、存款、添加用户、删除用户、修改密码、冻结用户,管理员解冻、手动手机费缴费等功能

1.1.1 系统开发需求

随着市场经济的发展,经济信息化程度的不断深入,银行的传统业务己愈来

愈不能满足银行客户的需要。同时,随着国内银行机构的大量增加,我国的银行业面临更加激烈的同业竞争,如何提供更多的金融产品和更优质的服务,如何吸引更多的客户,如何利用计算机技术加强银行帐户信息管理,提高银行的工作效率和业务竟争能力是摆在各家银行面前的一个迫切需要解诀的问题。随着信息技术对银行业的渗透和促进,银行卡业务近年来得到“迅猛发展,银行卡发卡量、交易量大幅激增,ATM设备数量也随之增加。

1.1.2系统具体事务

用户:用户存款、取款、转账、余额信息查询、修改密码、手机话费的缴费并与数据库实时同步。

管理员:对用户账号的冻结以及解冻并询问是否修改密码、开户与销户、与数据库实时同步。

1.1.3 系统开发环境要求

    .操作系统:Windows系统

    .开发语言:Java、SQL server

    .数据库:SQLServer2012

    .软件:eclipse

1.2 项目分工

代小龙:管理员的开户,销户,冻结,用户明细,JDBC的连接

安梓玮:存款,转账,查询余额,电话缴费,撰写报告

侯硕:取款,用户界面美化,撰写报告 项目设计方案

实现ATM机的基本功能,包括:查询余额、存款、取款、转账、用户明细、手机缴费以及管理员开户、销户等操作,等基本功能;

查询余额:连接数据库,根据与数据库内数据相同的正确的用户名和密码登录查询对应的余额;转账,存取款的金额必须为100或者是100的整数倍,操作完成后会实时更新数据库内相应的内容。

修改密码:在旧密码相同的情况下,新密码和确认密码也相同的情况下,密码修改完成。

转账:可以转账任何金额,但是当转账金额小于余额时,转账失败。

手机缴费:需要缴费的手机号需时已经存在的,可以存任意金额。

管理员操作的基本功能包括对银行卡开户、销户、冻结、解冻、修改管理员密码等的操作,并在数据库内实时更新。项目功能实现

3.1数据库的实现

card表:主要是用户银行卡的信息,包括账号、密码、余额、是否被冻结、存款余额,其中account是varchar型的主键。

details表:主要是户主名account,日期和资金明细。

GLY表:包含所有管理员的信息。并对管理员的account设为主键。

3.2主要功能实现

3.2.1登录界面

package atm_client;

import java.awt.Font;

import java.awt.GridLayout;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStreamReader;

import java.io.PrintWriter;

import java.net.InetAddress;

import java.net.Socket;

import java.net.UnknownHostException;

import javax.swing.JButton;

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 comm.Card;

import comm.CardGLY;

public class Login extends JFrame {

JTextField tfAccount;

JPasswordField tfPwd;

JButton btOK,btCancel,btGLY;

Card currCard;

CardGLY currCardGLY;

private int count=0;

public void init(){

//界面

JLabel IAccount,IPwd,Itag;

IAccount= new JLabel(”账号:“);

IPwd= new JLabel(”密码:“);

Itag=new JLabel(”欢迎登录ATM系统“);

tfAccount = new JTextField();

tfPwd =new JPasswordField();

btOK=new JButton(”普通登录“);

btGLY=new JButton(”管理员登录“);

btCancel =new JButton(”取消“);

Itag.setFont(new Font(”“,Font.CENTER_BASELINE, 20));

btGLY.setFont(new Font(”“,Font.CENTER_BASELINE, 12));

btOK.setFont(new Font(”“,Font.CENTER_BASELINE, 12));

btCancel.setFont(new Font(”“,Font.CENTER_BASELINE, 12));

IAccount.setFont(new Font(”“,Font.CENTER_BASELINE, 18));

tfAccount.setFont(new Font(”“,Font.CENTER_BASELINE, 18));

tfPwd.setFont(new Font(”“,Font.CENTER_BASELINE, 18));

IPwd.setFont(new Font(”“,Font.CENTER_BASELINE, 18));

JPanel panelOne = new JPanel(null);

panelOne.setOpaque(false);

Itag.setBounds(120,15,350,30);

btOK.setBounds(40, 270, 100, 40);

btGLY.setBounds(160,270,100,40);

btCancel.setBounds(280,270,100,40);

tfAccount.setBounds(160,100,160,40);

IAccount.setBounds(90,105,80,40);

IPwd.setBounds(90, 165,80, 40);

tfPwd.setBounds(160,160,160,40);

panelOne.add(Itag);

panelOne.add(IPwd);

panelOne.add(IAccount);

panelOne.add(btCancel);

panelOne.add(btGLY);

panelOne.add(btOK);

panelOne.add(tfAccount);

panelOne.add(tfPwd);

this.add(panelOne);

this.setTitle(”精神小伙银行“);

this.setBounds(700, 250, 450, 400);

this.setVisible(true);

//监听

//普通用户登录

btOK.addActionListener(new ActionListener(){

@Override

public void actionPerformed(ActionEvent e){

// TODO Auto-generated method stub

String account=tfAccount.getText();

String pwd=new String(tfPwd.getPassword());

BufferedReader br=null;

PrintWriter pw=null;

String strEcho=”“;

try {

Socket s=new Socket(InetAddress.getByName(”127.0.0.1“), 8009);

br=new BufferedReader(new InputStreamReader(s.getInputStream()));

pw=new PrintWriter(s.getOutputStream());

pw.write(”Loginrn“);

pw.write(account+”rn“);

pw.write(pwd+”rn“);

pw.flush();

strEcho=br.readLine();

if(strEcho.equals(”1“)){

JOptionPane.showMessageDialog(Login.this, ”对不起,您的账号有误!“);

tfAccount.setText(”“);

tfPwd.setText(”“);

}else if(strEcho.equals(”2“)){

float money =Float.parseFloat(br.readLine());

String dongjie=br.readLine();

String name=br.readLine();

currCard=new Card(account,pwd,money,dongjie,name);

JOptionPane.showMessageDialog(Login.this, ”欢迎登录河北金苑银行!“);

Login.this.dispose();

new MainFrame(br,pw,currCard).init();

}else if(strEcho.equals(”3“)){

count++;

if(count==3){

JOptionPane.showMessageDialog(Login.this, ”对不起,密码错误3次,您的卡已被冻结!请联系管理员“);

pw.write(”dongjiern“);

pw.flush();

Login.this.dispose();

}else {

JOptionPane.showMessageDialog(Login.this,”密码错误,请重新输入“);

String c=String.valueOf(count);

pw.write(c+”rn“);

pw.flush();

}

}else if(strEcho.equals(”4“)){

JOptionPane.showMessageDialog(Login.this,”对不起,您的卡已被冻结,请联系管理员“);

Login.this.dispose();

}

} catch(UnknownHostException e1){

// TODO Auto-generated catch block

e1.printStackTrace();

} catch(IOException e1){

// TODO Auto-generated catch block

e1.printStackTrace();

}

}

});

//管理员登录

btGLY.addActionListener(new ActionListener(){

@Override

public void actionPerformed(ActionEvent e){

// TODO Auto-generated method stub

String account=tfAccount.getText();

String pwd=new String(tfPwd.getPassword());

BufferedReader br=null;

PrintWriter pw=null;

String strEcho=”“;

try {

Socket s=new Socket(InetAddress.getByName(”127.0.0.1“), 8009);

br=new BufferedReader(new InputStreamReader(s.getInputStream()));

pw=new PrintWriter(s.getOutputStream());

pw.write(”GLYrn“);

pw.write(account+”rn“);

pw.write(pwd+”rn“);

pw.flush();

strEcho=br.readLine();

if(strEcho.equals(”9“)){

JOptionPane.showMessageDialog(Login.this, ”对不起,您的账号有误!“);

tfAccount.setText(”“);

tfPwd.setText(”“);

}else if(strEcho.equals(”8“)){

JOptionPane.showMessageDialog(Login.this,”您已经以管理员身份登录!“);

Login.this.dispose();

new MainFrameGLY(br,pw,currCardGLY).init();

}else if(strEcho.equals(”7“)){

JOptionPane.showMessageDialog(Login.this,”您的密码错误“);

}

} catch(UnknownHostException e1){

// TODO Auto-generated catch block

e1.printStackTrace();

} catch(IOException e1){

// TODO Auto-generated catch block

e1.printStackTrace();

}

}

});

btCancel.addActionListener(new ActionListener(){

@Override

public void actionPerformed(ActionEvent e){

// TODO Auto-generated method stub

Login.this.dispose();

}

});

}

public static void main(String[] args){

new Login().init();

}

}

3.2.2普通存款界面

package atm_client;

import java.awt.Color;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.io.BufferedReader;

import java.io.IOException;

import java.io.PrintWriter;

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 comm.Card;

import atm_client.Take;

public class Save extends JFrame implements ActionListener{

// 存款界面按钮

JTextField tfmoney;

private JButton bt000,bt001,bt002,bt003,bt004,bt005,bt006,bt007,bt008,bt009;

private JButton bt100,bt200,bt300,bt500,bt1000;

private JButton btOK,btCancel,btRetry;

BufferedReader br;

PrintWriter pw;

Card currCard;

public Save(BufferedReader br,PrintWriter pw,Card currCard){

this.br=br;

this.pw=pw;

this.currCard=currCard;

}

public void init(){

JPanel panelTake = new JPanel(null);

panelTake.setBackground(new Color(119,119,253));

JLabel lblqukuan = new JLabel(”请输入您的存款数:“);

panelTake.add(lblqukuan);

lblqukuan.setBounds(115, 20, 150, 30);

lblqukuan=new JLabel(”提示:只能是100元或100元的整数倍。“);

panelTake.add(lblqukuan);

lblqukuan.setBounds(115, 50, 300, 30);

tfmoney=new JTextField(12);

tfmoney.setEnabled(false);

panelTake.add(tfmoney);

tfmoney.setBounds(115,90,200,30);

bt100=new JButton(”100“);

panelTake.add(bt100);

bt100.addActionListener(this);

bt100.setBounds(45,190,60,30);

bt200=new JButton(”200“);

panelTake.add(bt200);

bt200.addActionListener(this);

bt200.setBounds(115,190,60,30);

bt300=new JButton(”300“);

panelTake.add(bt300);

bt300.addActionListener(this);

bt300.setBounds(185,190,60,30);

bt500=new JButton(”500“);

panelTake.add(bt500);

bt500.addActionListener(this);

bt500.setBounds(255,190,60,30);

bt1000=new JButton(”1000“);

panelTake.add(bt1000);

bt1000.addActionListener(this);

bt1000.setBounds(325,190,65,30);

bt001=new JButton(”1“);

panelTake.add(bt001);

bt001.addActionListener(this);

bt001.setBounds(45,230,60,30);

bt002=new JButton(”2“);

panelTake.add(bt002);

bt002.addActionListener(this);

bt002.setBounds(115,230,60,30);

bt003=new JButton(”3“);

panelTake.add(bt003);

bt003.addActionListener(this);

bt003.setBounds(185,230,60,30);

bt004=new JButton(”4“);

panelTake.add(bt004);

bt004.addActionListener(this);

bt004.setBounds(255,230,60,30);

bt005=new JButton(”5“);

panelTake.add(bt005);

bt005.addActionListener(this);

bt005.setBounds(325,230,65,30);

bt006=new JButton(”6“);

panelTake.add(bt006);

bt006.addActionListener(this);

bt006.setBounds(45,270,60,30);

bt007=new JButton(”7“);

panelTake.add(bt007);

bt007.addActionListener(this);

bt007.setBounds(115,270,60,30);

bt008=new JButton(”8“);

panelTake.add(bt008);

bt008.addActionListener(this);

bt008.setBounds(185,270,60,30);

bt009=new JButton(”9“);

panelTake.add(bt009);

bt009.addActionListener(this);

bt009.setBounds(255,270,60,30);

bt000=new JButton(”0“);

panelTake.add(bt000);

bt000.addActionListener(this);

bt000.setBounds(325,270,65,30);

btOK=new JButton(”确定“);

panelTake.add(btOK);

btOK.addActionListener(this);

btOK.setBounds(70,140,80,30);

btRetry=new JButton(”重输“);

panelTake.add(btRetry);

btRetry.addActionListener(this);

btRetry.setBounds(175,140,80,30);

btCancel=new JButton(”返回“);

panelTake.add(btCancel);

btCancel.addActionListener(this);

btCancel.setBounds(280,140,80,30);

this.setTitle(”存款!“);

this.add(panelTake);

this.setSize(435,350);

this.setVisible(true);

this.setLocation(500, 250);

}

@Override

public void actionPerformed(ActionEvent arg0){

// TODO Auto-generated method stub

if(arg0.getSource()==bt100||arg0.getSource()==bt200||arg0.getSource()==bt300||arg0.getSource()==bt500||arg0.getSource()==bt1000)

tfmoney.setText(arg0.getActionCommand());

else if(arg0.getSource()==bt000||arg0.getSource()==bt001||arg0.getSource()==bt002||arg0.getSource()==bt003||arg0.getSource()==bt004||arg0.getSource()==bt005||arg0.getSource()==bt006||arg0.getSource()==bt007||arg0.getSource()==bt008||arg0.getSource()==bt009){

tfmoney.setText(tfmoney.getText()+arg0.getActionCommand());

}else if(arg0.getSource()==btOK){

int saveMoney=Integer.parseInt(tfmoney.getText());

if(saveMoney%100!=0){

JOptionPane.showMessageDialog(Save.this, ”对不起,您输入的金额不符合规定!“);

tfmoney.setText(”“);

}

else{

//发送新的账户信息给服务器

pw.write(”savern“);

pw.write(saveMoney+”rn“);

pw.flush();

//等待响应,更新当前登录账号

String strEcho=”“;

try {

strEcho = br.readLine();

if(strEcho.equals(”Success“)){

currCard.setMoney(currCard.getMoney()+saveMoney);

JOptionPane.showMessageDialog(null, ”恭喜你成功存款“+saveMoney+”元n当前账户余额为:“+currCard.getMoney());

tfmoney.setText(”“);

} else if(strEcho.equals(”Failure“)){

JOptionPane.showMessageDialog(Save.this,”存款失败“);

}

} catch(IOException e){

// TODO Auto-generated catch block

e.printStackTrace();

}

}

}else if(arg0.getSource()==btCancel){

Save.this.dispose();

new MainFrame(br,pw,currCard).init();

}else if(arg0.getSource()==btRetry){

tfmoney.setText(”“);

}

}

}

3.2.3用户转账界面

package atm_client;

import java.awt.GridLayout;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.io.BufferedReader;

import java.io.IOException;

import java.io.PrintWriter;

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 comm.Card;

public class Trans extends JFrame {

JTextField Taccount,Tmoney;

JButton btOk,btCancel;

JLabel lAccount,lMoney;

BufferedReader br;

PrintWriter pw;

Card currCard;

public Trans(BufferedReader br,PrintWriter pw,Card currCard){

this.br=br;

this.pw=pw;

this.currCard=currCard;

}

public void init(){

JPanel panelTrans=new JPanel(null);

panelTrans.setLayout(new GridLayout(3,2));

lAccount =new JLabel(”账户:“);

lMoney =new JLabel(”金额:“);

btOk = new JButton(”确定“);

btCancel = new JButton(”取消“);

Taccount=new JTextField();

Tmoney = new JTextField();

panelTrans.add(lAccount);

panelTrans.add(Taccount);

panelTrans.add(lMoney);

panelTrans.add(Tmoney);

panelTrans.add(btOk);

panelTrans.add(btCancel);

this.add(panelTrans);

this.setTitle(”转账!“);

this.setSize(300,160);

this.setLocation(500, 250);

this.setVisible(true);

//this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

btOk.addActionListener(new ActionListener(){

@Override

public void actionPerformed(ActionEvent e){

// TODO Auto-generated method stub

if(Taccount.getText().equals(”“)){

JOptionPane.showMessageDialog(Trans.this, ”请输入账号“);

}else if(Tmoney.getText().equals(”“)){

JOptionPane.showMessageDialog(Trans.this, ”请输入金额“);

}else {

pw.write(”transrn“);

pw.write(Taccount.getText()+”rn“);

pw.write(Tmoney.getText()+”rn“);

pw.flush();

String strEcho=”“;

try {

strEcho=br.readLine();

if(strEcho.equals(”Success“)){

currCard.setMoney(currCard.getMoney()-Float.parseFloat(Tmoney.getText()));

JOptionPane.showMessageDialog(Trans.this, ”转账成功“);

}else if(strEcho.equals(”1“)){

JOptionPane.showMessageDialog(Trans.this, ”账号不存在“);

}else if(strEcho.equals(”2“)){

JOptionPane.showMessageDialog(Trans.this,”不能向自己转账“);

}else if(strEcho.equals(”3“)){

JOptionPane.showMessageDialog(Trans.this,”余额不足“);

}else if(strEcho.equals(”Fuilure“)){

JOptionPane.showMessageDialog(Trans.this,”转账失败“);

}

} catch(IOException e1){

// TODO Auto-generated catch block

e1.printStackTrace();

}

}

}

});

btCancel.addActionListener(new ActionListener(){

@Override

public void actionPerformed(ActionEvent e){

// TODO Auto-generated method stub

Trans.this.dispose();

}

});

}

}

3.2.4手机缴费

package atm_client;

import java.awt.GridLayout;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.io.BufferedReader;

import java.io.IOException;

import java.io.PrintWriter;

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 comm.Card;

public class Communi extends JFrame{

JTextField TNumber,Tmoney;

JButton btOk,btCancel;

JLabel INumber,lMoney;

BufferedReader br;

PrintWriter pw;

Card currCard;

public Communi(BufferedReader br,PrintWriter pw,Card currCard){

this.br=br;

this.pw=pw;

this.currCard=currCard;

}

public void init(){

JPanel panelTrans=new JPanel(null);

panelTrans.setLayout(new GridLayout(3,2));

INumber =new JLabel(”账户:“);

lMoney =new JLabel(”金额:“);

btOk = new JButton(”确定“);

btCancel = new JButton(”取消“);

TNumber=new JTextField();

Tmoney = new JTextField();

panelTrans.add(INumber);

panelTrans.add(TNumber);

panelTrans.add(lMoney);

panelTrans.add(Tmoney);

panelTrans.add(btOk);

panelTrans.add(btCancel);

this.add(panelTrans);

this.setTitle(”手机缴费!“);

this.setSize(300,160);

this.setLocation(500, 250);

this.setVisible(true);

//this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

btOk.addActionListener(new ActionListener(){

@Override

public void actionPerformed(ActionEvent e){

// TODO Auto-generated method stub

if(TNumber.getText().equals(”“)){

JOptionPane.showMessageDialog(Communi.this, ”请输入手机号“);//导入类——消息对话框

}else if(Tmoney.getText().equals(”“)){

JOptionPane.showMessageDialog(Communi.this, ”请输入金额“);

}else {

pw.write(”communirn“);

pw.write(TNumber.getText()+”rn“);

pw.write(Tmoney.getText()+”rn“);

pw.flush();

String strEcho=”“;

try {

strEcho=br.readLine();

if(strEcho.equals(”Success“)){

currCard.setMoney(currCard.getMoney()-Float.parseFloat(Tmoney.getText()));

JOptionPane.showMessageDialog(Communi.this, ”充值成功“);

Communi.this.dispose();

}else if(strEcho.equals(”1“)){

JOptionPane.showMessageDialog(Communi.this, ”手机号不存在“);

}else if(strEcho.equals(”2“)){

JOptionPane.showMessageDialog(Communi.this,”余额不足“);

}else if(strEcho.equals(”Fuilure“)){

JOptionPane.showMessageDialog(Communi.this,”充值失败“);

}

} catch(IOException e1){

// TODO Auto-generated catch block

e1.printStackTrace();

}

}

}

});

btCancel.addActionListener(new ActionListener(){

@Override

public void actionPerformed(ActionEvent e){

// TODO Auto-generated method stub

Communi.this.dispose();

}

});

}

}

3.2.5用户取款

package atm_client;

import java.awt.Color;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.io.BufferedReader;

import java.io.IOException;

import java.io.PrintWriter;

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 comm.Card;

import atm_client.Take;

public class Take extends JFrame implements ActionListener{

// 取款界面按钮

JTextField tfmoney;

private JButton bt000,bt001,bt002,bt003,bt004,bt005,bt006,bt007,bt008,bt009;

private JButton bt100,bt200,bt300,bt500,bt1000;

private JButton btOK,btCancel,btRetry;

BufferedReader br;

PrintWriter pw;

Card currCard;

public Take(BufferedReader br,PrintWriter pw,Card currCard){

this.br=br;

this.pw=pw;

this.currCard=currCard;

}

public void init(){

JPanel panelTake = new JPanel(null);

panelTake.setBackground(new Color(119,119,253));

JLabel lblqukuan = new JLabel(”请输入您要取的钱数:“);

panelTake.add(lblqukuan);

lblqukuan.setBounds(115, 20, 150, 30);

lblqukuan=new JLabel(”提示:只能是100元或100元的整数倍。“);

panelTake.add(lblqukuan);

lblqukuan.setBounds(115, 50, 300, 30);

tfmoney=new JTextField(12);

tfmoney.setEnabled(false);

panelTake.add(tfmoney);

tfmoney.setBounds(115,90,200,30);

bt100=new JButton(”100“);

panelTake.add(bt100);

bt100.addActionListener(this);

bt100.setBounds(45,190,60,30);

bt200=new JButton(”200“);

panelTake.add(bt200);

bt200.addActionListener(this);

bt200.setBounds(115,190,60,30);

bt300=new JButton(”300“);

panelTake.add(bt300);

bt300.addActionListener(this);

bt300.setBounds(185,190,60,30);

bt500=new JButton(”500“);

panelTake.add(bt500);

bt500.addActionListener(this);

bt500.setBounds(255,190,60,30);

bt1000=new JButton(”1000“);

panelTake.add(bt1000);

bt1000.addActionListener(this);

bt1000.setBounds(325,190,65,30);

bt001=new JButton(”1“);

panelTake.add(bt001);

bt001.addActionListener(this);

bt001.setBounds(45,230,60,30);

bt002=new JButton(”2“);

panelTake.add(bt002);

bt002.addActionListener(this);

bt002.setBounds(115,230,60,30);

bt003=new JButton(”3“);

panelTake.add(bt003);

bt003.addActionListener(this);

bt003.setBounds(185,230,60,30);

bt004=new JButton(”4“);

panelTake.add(bt004);

bt004.addActionListener(this);

bt004.setBounds(255,230,60,30);

bt005=new JButton(”5“);

panelTake.add(bt005);

bt005.addActionListener(this);

bt005.setBounds(325,230,65,30);

bt006=new JButton(”6“);

panelTake.add(bt006);

bt006.addActionListener(this);

bt006.setBounds(45,270,60,30);

bt007=new JButton(”7“);

panelTake.add(bt007);

bt007.addActionListener(this);

bt007.setBounds(115,270,60,30);

bt008=new JButton(”8“);

panelTake.add(bt008);

bt008.addActionListener(this);

bt008.setBounds(185,270,60,30);

bt009=new JButton(”9“);

panelTake.add(bt009);

bt009.addActionListener(this);

bt009.setBounds(255,270,60,30);

bt000=new JButton(”0“);

panelTake.add(bt000);

bt000.addActionListener(this);

bt000.setBounds(325,270,65,30);

btOK=new JButton(”确定“);

panelTake.add(btOK);

btOK.addActionListener(this);

btOK.setBounds(70,140,80,30);

btRetry=new JButton(”重输“);

panelTake.add(btRetry);

btRetry.addActionListener(this);

btRetry.setBounds(175,140,80,30);

btCancel=new JButton(”返回“);

panelTake.add(btCancel);

btCancel.addActionListener(this);

btCancel.setBounds(280,140,80,30);

this.setTitle(”取款!“);

this.add(panelTake);

this.setSize(435,350);

this.setVisible(true);

this.setLocation(500, 250);

}

@Override

public void actionPerformed(ActionEvent arg0){

// TODO Auto-generated method stub

if(arg0.getSource()==bt100||arg0.getSource()==bt200||arg0.getSource()==bt300||arg0.getSource()==bt500||arg0.getSource()==bt1000)

tfmoney.setText(arg0.getActionCommand());

else if(arg0.getSource()==bt000||arg0.getSource()==bt001||arg0.getSource()==bt002||arg0.getSource()==bt003||arg0.getSource()==bt004||arg0.getSource()==bt005||arg0.getSource()==bt006||arg0.getSource()==bt007||arg0.getSource()==bt008||arg0.getSource()==bt009){

tfmoney.setText(tfmoney.getText()+arg0.getActionCommand());

}else if(arg0.getSource()==btOK){

int takeMoney=Integer.parseInt(tfmoney.getText());

if(currCard.getMoney()

JOptionPane.showMessageDialog(Take.this, ”对不起,您的余额不足!“);

tfmoney.setText(”“);

}else if(takeMoney%100!=0){

JOptionPane.showMessageDialog(Take.this, ”对不起,您输入的金额不符合规定!“);

tfmoney.setText(”“);

}

else{

//发送新的账户信息给服务器

pw.write(”takern“);

pw.write(takeMoney+”rn“);

pw.flush();

//等待响应,更新当前登录账号

String strEcho=”“;

try {

strEcho = br.readLine();

if(strEcho.equals(”Success“)){

currCard.setMoney(currCard.getMoney()-takeMoney);

JOptionPane.showMessageDialog(null, ”恭喜你成功取款“+takeMoney+”元n当前账户余额为:“+currCard.getMoney());

tfmoney.setText(”“);

} else if(strEcho.equals(”Failure“)){

JOptionPane.showMessageDialog(Take.this,”取款失败“);

}

} catch(IOException e){

// TODO Auto-generated catch block

e.printStackTrace();

}

}

}else if(arg0.getSource()==btCancel){

Take.this.dispose();

}else if(arg0.getSource()==btRetry){

tfmoney.setText(”“);

}

}

}

}

3.2.6冻结

package atm_client;

import java.awt.Font;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.io.BufferedReader;

import java.io.IOException;

import java.io.PrintWriter;

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 comm.CardGLY;

public class DongJie extends JFrame implements ActionListener{

JButton btOK,btCancel;

JTextField Account,Name;

BufferedReader br;

PrintWriter pw;

CardGLY currCardGLY;

public DongJie(BufferedReader br,PrintWriter pw,CardGLY currCardGLY){

this.br=br;

this.pw=pw;

this.currCardGLY=currCardGLY;

}

public void init(){

JLabel IAccount,IName,Itag;

IAccount =new JLabel(”账号“);

IName=new JLabel(”用户名“);

Itag=new JLabel(”请输入要冻结的账号及用户名“);

Account =new JTextField();

Name =new JTextField();

btOK=new JButton(”确定“);

btCancel=new JButton(”取消“);

Itag.setFont(new Font(”“,Font.CENTER_BASELINE, 20));

btOK.setFont(new Font(”“,Font.CENTER_BASELINE, 12));

btCancel.setFont(new Font(”“,Font.CENTER_BASELINE, 12));

IAccount.setFont(new Font(”“,Font.CENTER_BASELINE, 18));

Account.setFont(new Font(”“,Font.CENTER_BASELINE, 18));

Name.setFont(new Font(”“,Font.CENTER_BASELINE, 18));

IName.setFont(new Font(”“,Font.CENTER_BASELINE, 18));

JPanel panelOne = new JPanel(null);

panelOne.setOpaque(false);

Itag.setBounds(80,15,350,30);

btOK.setBounds(80, 270, 100, 40);

btCancel.setBounds(240,270,100,40);

Account.setBounds(160,100,160,40);

IAccount.setBounds(90,105,80,40);

IName.setBounds(90, 165,80, 40);

Name.setBounds(160,160,160,40);

btCancel.addActionListener(this);

btOK.addActionListener(this);

panelOne.add(Itag);

panelOne.add(IName);

panelOne.add(IAccount);

panelOne.add(btCancel);

panelOne.add(btOK);

panelOne.add(Account);

panelOne.add(Name);

this.add(panelOne);

this.setTitle(”代小龙+安梓玮+侯硕“);

this.setBounds(700, 250, 450, 400);

this.setVisible(true);

}

@Override

public void actionPerformed(ActionEvent arg0){

// TODO Auto-generated method stub

if(arg0.getSource()==btOK){

if(Account.getText().equals(”“)||Name.getText().equals(”“)){

JOptionPane.showMessageDialog(DongJie.this,”用户名和账号不能为空“);

}else {

pw.write(”dongjiern“);

pw.write(Account.getText()+”rn“);

pw.write(Name.getText()+”rn“);

pw.flush();

System.out.println(Name.getText()+Name.getText());

try {

String strEcho=br.readLine();

if(strEcho.equals(”9“)){

JOptionPane.showMessageDialog(DongJie.this, ”账号不存在,请重新输入“);

Account.setText(”“);

Name.setText(”“);

}else if(strEcho.equals(”7“)){

JOptionPane.showMessageDialog(DongJie.this, ”冻结成功“);

DongJie.this.dispose();

new Ask(br, pw, currCardGLY).init();

}else if(strEcho.equals(”5“)){

JOptionPane.showMessageDialog(DongJie.this, ”用户名错误“);

Name.setText(”“);

}else if(strEcho.equals(”6“)){

JOptionPane.showMessageDialog(DongJie.this, ”您的账号已被冻结“);

DongJie.this.dispose();

}else if(strEcho.equals(”8“)){

JOptionPane.showMessageDialog(DongJie.this, ”冻结失败“);

}

} catch(IOException e){

// TODO Auto-generated catch block

e.printStackTrace();

}

}

}else if(arg0.getSource()==btCancel){

DongJie.this.dispose();

}

}

}

3.2.7开户

package atm_client;

import java.awt.Font;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.io.BufferedReader;

import java.io.IOException;

import java.io.PrintWriter;

import javax.swing.JButton;

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 comm.CardGLY;

public class Open extends JFrame implements ActionListener{

JTextField tfname;//文本框

JTextField tfmoney;

JPasswordField tfpwd;//密码框

JPasswordField tfpwd1;

JButton btOK,btCancel;

CardGLY currCardGLY;

BufferedReader br;

PrintWriter pw;

public Open(BufferedReader br,PrintWriter pw,CardGLY currCardGLY){

this.br=br;

this.pw=pw;//文本字节流写入

this.currCardGLY=currCardGLY;

}

//初始化

public void init(){

JLabel Iname;//标签组件

JLabel Imoney;

JLabel Ipwd,Ipwd1;

JLabel Itag=new JLabel(”请输入要开户用户的基本信息“);

Ipwd=new JLabel(”密码:“);

Ipwd1=new JLabel(”确认密码“);

Iname=new JLabel(”姓名:“);

Imoney=new JLabel(”预存金额“);

tfname=new JTextField();

tfmoney=new JTextField();

btOK=new JButton(”确定“);

btCancel=new JButton(”取消“);

tfpwd=new JPasswordField();

tfpwd1=new JPasswordField();

Itag.setFont(new Font(”“,Font.CENTER_BASELINE, 20));

Iname.setFont(new Font(”“,Font.CENTER_BASELINE, 18));

tfmoney.setFont(new Font(”“,Font.CENTER_BASELINE, 18));

tfname.setFont(new Font(”“,Font.CENTER_BASELINE, 18));

tfpwd.setFont(new Font(”“,Font.CENTER_BASELINE, 18));

tfpwd1.setFont(new Font(”“,Font.CENTER_BASELINE, 18));

Ipwd.setFont(new Font(”“,Font.CENTER_BASELINE, 18));

Ipwd1.setFont(new Font(”“,Font.CENTER_BASELINE, 18));

Imoney.setFont(new Font(”“,Font.CENTER_BASELINE, 18));

btOK.setFont(new Font(”“,Font.CENTER_BASELINE, 12));

btCancel.setFont(new Font(”“,Font.CENTER_BASELINE, 12));

JPanel panelOne = new JPanel(null);

panelOne.setOpaque(false);//设置控件透明

Itag.setBounds(80,15,350,30);

Iname.setBounds(70,85,80,40);

tfname.setBounds(200,80,160,40);

Ipwd.setBounds(70, 135, 80, 40);

tfpwd.setBounds(200, 130, 160, 40);

Ipwd1.setBounds(70, 185,80, 40);

tfpwd1.setBounds(200, 180, 160, 40);

Imoney.setBounds(70, 235, 80, 40);

tfmoney.setBounds(200, 230, 160, 40);

btOK.setBounds(80, 280, 100, 40);

btCancel.setBounds(240,280,100,40);

btOK.addActionListener(this);

btCancel.addActionListener(this);

panelOne.add(Itag);

panelOne.add(Iname);

panelOne.add(Ipwd);

panelOne.add(Ipwd1);

panelOne.add(Imoney);

panelOne.add(tfname);

panelOne.add(tfpwd);

panelOne.add(tfpwd1);

panelOne.add(tfmoney);

panelOne.add(btCancel);

panelOne.add(btOK);

this.add(panelOne);

this.setTitle(”代小龙+安梓玮+侯硕“);

this.setBounds(700, 250, 450, 400);

this.setVisible(true);

}

//监听button.@Override //socket编程,client发出消息,在Server中接收,并且在接收时采用readline()方法时需要注意,//readline()方法要读到分隔符才会完成读取操作,用pw.write,或者pw.println

public void actionPerformed(ActionEvent arg0){

// TODO Auto-generated method stub

if(arg0.getSource()==btOK){ //如果事件源始按钮OK,则进行下面操作

if(tfname.getText().equals(”“)||tfpwd.getText().equals(”“)||tfpwd.getText().equals(”“)){

JOptionPane.showMessageDialog(Open.this,”账号密码不能为空“);//导入类——消息对话框

}else if(!tfpwd.getText().equals(tfpwd1.getText())){

JOptionPane.showMessageDialog(Open.this,”两次输入的密码不相同“);

tfpwd.setText(”“);

tfpwd1.setText(”“);

}else if(tfmoney.getText().equals(”“)){

JOptionPane.showMessageDialog(Open.this,”若不需要存钱,请输入0“);

}else if(tfpwd.getText().equals(tfpwd1.getText())&&!tfname.getText().equals(”“)&&!tfmoney.getText().equals(”“)){

pw.write(”openrn“);//在服务器获取输入流写入一段字符

pw.write(tfname.getText()+”rn“);

pw.write(tfpwd.getText()+”rn“);

pw.write(tfmoney.getText()+”rn“);

pw.flush();

try {

String strEcho=br.readLine();

if(strEcho.equals(”1“)){

JOptionPane.showMessageDialog(Open.this,”开户失败!有用户名重复的可能!“);

}else if(strEcho.equals(”2“)){

String account=br.readLine();

JOptionPane.showMessageDialog(Open.this,”开户成功!您的账号为“+account+”,请牢记您的账号“);

Open.this.dispose();

}

} catch(IOException e){

// TODO Auto-generated catch block

e.printStackTrace();

}

}

}else if(arg0.getSource()==btCancel){

Open.this.dispose();

}

}

}

3.2.8销户

package atm_client;

import java.awt.Font;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.io.BufferedReader;

import java.io.IOException;

import java.io.PrintWriter;

import javax.swing.JButton;

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 comm.CardGLY;

public class Close extends JFrame implements ActionListener {

BufferedReader br;

PrintWriter pw;

CardGLY currCardGLY;

private JButton btOK,btCancel;

private JTextField tfAccount;

private JPasswordField tfPwd;

public Close(BufferedReader br,PrintWriter pw,CardGLY currCardGLY){

this.br=br;

this.pw=pw;

this.currCardGLY=currCardGLY;

}

public void init(){

JLabel IAccount,IPwd,Itag;

IAccount= new JLabel(”账号:“);

IPwd= new JLabel(”密码:“);

Itag=new JLabel(”请输入要销户的账号及密码“);

tfAccount=new JTextField();

tfPwd=new JPasswordField();

btOK=new JButton(”确定“);

btCancel=new JButton(”取消“);

Itag.setFont(new Font(”“,Font.CENTER_BASELINE, 20));

btOK.setFont(new Font(”“,Font.CENTER_BASELINE, 12));

btCancel.setFont(new Font(”“,Font.CENTER_BASELINE, 12));

IAccount.setFont(new Font(”“,Font.CENTER_BASELINE, 18));

tfAccount.setFont(new Font(”“,Font.CENTER_BASELINE, 18));

tfPwd.setFont(new Font(”“,Font.CENTER_BASELINE, 18));

IPwd.setFont(new Font(”“,Font.CENTER_BASELINE, 18));

JPanel panelOne = new JPanel(null);

panelOne.setOpaque(false);

Itag.setBounds(120,15,350,30);

btOK.setBounds(80, 270, 100, 40);

btCancel.setBounds(240,270,100,40);

tfAccount.setBounds(160,100,160,4

银行ATM系统软件工程设计报告

第一篇:银行ATM系统软件工程设计报告 西安邮电学院 学院名称学生姓名专业名称班级软件工程报告 计算机学院 ...
点击下载
分享:
上一篇:实习报告下一篇:实习报告
最新文档
热门文章
    确认删除?
    QQ
    • QQ点击这里给我发消息
    微信客服
    • 微信客服
    回到顶部