java餐厅餐卡管理系统课程设计.docx

上传人:b****1 文档编号:20104050 上传时间:2023-04-25 格式:DOCX 页数:36 大小:346KB
下载 相关 举报
java餐厅餐卡管理系统课程设计.docx_第1页
第1页 / 共36页
java餐厅餐卡管理系统课程设计.docx_第2页
第2页 / 共36页
java餐厅餐卡管理系统课程设计.docx_第3页
第3页 / 共36页
java餐厅餐卡管理系统课程设计.docx_第4页
第4页 / 共36页
java餐厅餐卡管理系统课程设计.docx_第5页
第5页 / 共36页
点击查看更多>>
下载资源
资源描述

java餐厅餐卡管理系统课程设计.docx

《java餐厅餐卡管理系统课程设计.docx》由会员分享,可在线阅读,更多相关《java餐厅餐卡管理系统课程设计.docx(36页珍藏版)》请在冰豆网上搜索。

java餐厅餐卡管理系统课程设计.docx

java餐厅餐卡管理系统课程设计

 

山东建筑大学计算机科学与技术学院

程序设计实用案例选讲

大作业说明书

 

题目:

某高校餐厅餐卡管理系统

课程:

程序设计实用案例选讲

院(部):

计算机科学与技术

专业:

网络工程

班级:

网络121

学生姓名:

*琳

学号:

指导教师:

袁*华

完成日期:

2014/01/01

某高校餐厅餐卡管理系统

一、问题描述

某高校餐厅餐卡管理系统,主要实现下列操作:

一、生成一张新卡,卡号自动生成如“2012******”,将卡号与学生姓名绑定,并能输入其总金额,并能在系统中存储这些系统。

二、查询操作:

输入卡号,能查询出其余额。

三、挂失操作:

某卡被挂失后,其金额不能再增加或减少。

四、消费操作:

输入一个消费金额(消费金额有上限,如一次最多消费20元),能够从卡的总金额中减去被消费的金额。

2、设计思想

系统需求:

win7eclipseJDK1.7

系统设计:

首先做好界面布局,出现登陆页面,实现触发事件处理,连接数据库,完成数据库处理功能,返回退出。

3、系统结构

ClassLoadfirst(){}

只有此类含有main()方法,登陆页面;

ClassLoad(){}

登陆进去时,系统的主页面,功能的主目录

ClassInto(){}

实现注册功能,后台数据库自动生成卡号;

ClassFind(){}

实现输入卡号,查询数据库信息功能;

ClassLost(){}

实现挂失信息操作,挂失信息不能再修改。

四、程序流程(或模块划分)

这里是系统的主要流程图和流程图的语言介绍

流程图如下:

 

 

流程图

 

图1登陆主界面

图2系统运行主界面

 

图3注册主界面

图4注册界面

 

图5我的卡号

 

图6挂失卡号

5、源程序

登陆主页面:

publicfinalclassLoadfirstextendsJFrameimplementsActionListener,Runnable{

privatestaticThreadScoll=null;

privatestaticThreadcoll=null;

JButtonyes,no;

TextFieldtext;

JLabellabel,wel,timer,time;

JPanelp1,p2,p3;

booleanstop,on;

privateJPasswordFieldpassword;

publicLoadfirst(){

JFramej=newJFrame("餐卡信息管理系统登陆界面");

p1=newJPanel();

p2=newJPanel();

p3=newJPanel();

timer=newJLabel("亲,您目前访问的时间是:

");

time=newJLabel();

label=newJLabel("请输入登录密码:

");

wel=newJLabel("亲!

欢迎进入餐卡信息管理系统!

");

text=newTextField("");

text.setEchoChar('*');

//JPasswordFieldpassword=newJPasswordField(8);

//password.setEchoChar('*');

setLayout(newFlowLayout());

setBounds(500,50,250,100);

yes=newJButton("登录系统");

no=newJButton("退出查询");

p1.add(label);

p1.add(text);

p1.add(yes);

p1.add(no);

p2.add(wel);

p3.add(timer);

p3.add(time);

p1.setLayout(newGridLayout(2,2));

p3.setLayout(newGridLayout(1,2));

j.setBounds(500,200,450,400);

j.add(BorderLayout.NORTH,p1);

j.add(BorderLayout.CENTER,p2);

j.add(BorderLayout.SOUTH,p3);

Fontfont=newFont("楷体",Font.BOLD,25);

Fontnt=newFont("楷体",Font.BOLD,15);

wel.setFont(font);

timer.setFont(nt);

label.setFont(nt);

time.setFont(nt);

yes.setFont(nt);

no.setFont(nt);

setLayout(newFlowLayout());

wel.setForeground(Color.RED);

yes.setForeground(Color.BLUE);

no.setForeground(Color.DARK_GRAY);

yes.setBackground(Color.green);

no.setBackground(Color.RED);

yes.addActionListener(this);

no.addActionListener(this);

j.setVisible(true);

j.setBackground(Color.GREEN);

j.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

Scoll=newThread(this);

coll=newThread(this);

Scoll.start();

coll.start();

}

publicvoidrun(){

if(Thread.currentThread()==Scoll){

while(true){

intx=wel.getBounds().x;

inty=120;

x+=10;

wel.setLocation(x,y);

if(x>300){

x=5;

wel.setLocation(x,y);

}try{

Thread.sleep(100);

}catch(InterruptedExceptioner){

er.printStackTrace();

}if(stop==true){

return;

}

}

}elseif(Thread.currentThread()==coll){

Datedate=newDate();

StringtimeStr=date.toString().substring(11,19);

time.setText(timeStr);

try{

Thread.sleep(1000);

}catch(InterruptedExceptioner){

er.printStackTrace();

}if(on==true){

return;

}

}

}

publicvoidactionPerformed(ActionEvente){

if(e.getSource()==yes&&text.getText().toString().equals("123")){

newLoad();

dispose();

}elseif(e.getSource()==no){

stop=false;

dispose();

System.exit(0);

//}elseif(!

password.getPassword().equals("123")){

}elseif(!

text.getText().toString().equals("123")){

JOptionPane.showMessageDialog(this,"亲,您的密码怎么输入错误了啊!

");

text.setText("");

System.out.println("密码输入错了怎么办呢?

");

}

}

publicstaticvoidmain(String[]args){

newLoadfirst();

}

}

查询页面:

publicclassFindextendsJFrameimplementsActionListener{

StringDBDriver="com.mysql.jdbc.Driver";

StringconnectionStr="jdbc:

mysql:

//localhost:

3306/canterbury";

Connectioncon=null;

PreparedStatementstmt=null;

ResultSetrs=null;

JLabell1,l2,l3,l4;

JTextFieldt1,t2,t3,t4;

JButtonyes,no;

JPanelp1,p2,p3;

JTextArearesult;

JLabellabel,timer,time;

booleanjudge=false;

Find(){

JFramej=newJFrame("查询信息:

");

p1=newJPanel();

p2=newJPanel();

p3=newJPanel();

t1=newJTextField();

t2=newJTextField();

t3=newJTextField();

t4=newJTextField();

timer=newJLabel("亲,您目前访问的时间是:

2014年1月2日");

time=newJLabel();

l1=newJLabel("卡号:

");

l2=newJLabel("姓名:

");

l3=newJLabel("充值余额:

");

l4=newJLabel("最低消费余额:

");

setLayout(newFlowLayout());

setBounds(500,50,250,100);

yes=newJButton("点击查询");

no=newJButton("退出系统");

result=newJTextArea();

p1.add(l1);

p1.add(t1);

p1.add(yes);

p1.add(no);

p3.add(timer);

p3.add(time);

p1.setLayout(newGridLayout(2,2));

//p3.setLayout(newGridLayout(1,2));

j.setBounds(500,200,450,400);

j.add(BorderLayout.NORTH,p1);

j.add(BorderLayout.SOUTH,p3);

Fontinto=newFont("楷体",Font.BOLD,15);

yes.setFont(into);

no.setFont(into);

l1.setFont(into);

l2.setFont(into);

l3.setFont(into);

l4.setFont(into);

timer.setFont(into);

setLayout(newFlowLayout());

yes.setForeground(Color.BLUE);

no.setForeground(Color.DARK_GRAY);

yes.setBackground(Color.green);

l1.setBackground(Color.green);

l2.setBackground(Color.green);

l3.setBackground(Color.green);

l4.setBackground(Color.green);

no.setBackground(Color.RED);

yes.addActionListener(this);

no.addActionListener(this);

j.setVisible(true);

j.setBackground(Color.GREEN);

j.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

Datedate=newDate();

StringtimeStr=date.toString().substring(11,19);

time.setText(timeStr);

}

publicvoidactionPerformed(ActionEvente){

if(e.getSource()==no){

dispose();

System.exit(0);

}if(t1.getText().equals("")){

JOptionPane.showMessageDialog(this,"亲,这样是不可以查询信息的呦!

");

}

elseif(e.getSource()==yes){

try{

Class.forName(DBDriver);

con=DriverManager.getConnection(connectionStr,"root","123malin");

Stringselect="select*fromcantewhereid=?

";

stmt=con.prepareStatement(select);

stmt.setString(1,t1.getText());

rs=stmt.executeQuery();

Stringt1,t2,t3,t4;

if(rs.next()){

t1=rs.getString("id");

t2=rs.getString("name");

t3=rs.getString("sur");

t4=rs.getString("only");

JOptionPane.showMessageDialog(this,"\n卡号:

"+t1+"\n姓名:

"+t2+"\n剩余额度:

"+t3+"\n最高消费:

"+t4);

con.close();

stmt.close();

}if(!

rs.next()){

JOptionPane.showMessageDialog(this,"亲,对不住哟,居然没有你要的信息!

");

}

}catch(ClassNotFoundExceptioner){

er.printStackTrace();

}catch(SQLExceptioner){

er.printStackTrace();

}

}

}

}

注册主页面:

publicclassIntoextendsJFrameimplementsActionListener{

StringDBDriver="com.mysql.jdbc.Driver";

StringconnectionStr="jdbc:

mysql:

//localhost:

3306/canterbury";

Connectioncon=null;

PreparedStatementstmt=null;

ResultSetrs=null;

JLabell1,l2,l3,l4,l5,l6;

JTextFieldt1,t2,t3,t4,t5,t6;

JButtonyes,no;

JPanelp1,p2,p3;

JTextArearesult;

JLabellabel,wel,timer,time,sert;

Into(){

JFramej=newJFrame("注册新餐厅卡:

");

p1=newJPanel();

p2=newJPanel();

p3=newJPanel();

t1=newJTextField();

t1.setEnabled(false);

t1.setText("卡号是不需要输入的!

");

t2=newJTextField();

t3=newJTextField();

t4=newJTextField();

timer=newJLabel("亲,您目前访问的时间是:

");

time=newJLabel();

l1=newJLabel("卡号:

");

l2=newJLabel("姓名:

");

l3=newJLabel("充值余额:

");

l4=newJLabel("最低消费余额:

");

setLayout(newFlowLayout());

setBounds(500,50,250,100);

yes=newJButton("注册");

no=newJButton("返回");

result=newJTextArea();

p1.add(l1);

p1.add(t1);

p1.add(l2);

p1.add(t2);

p1.add(l3);

p1.add(t3);

p1.add(l4);

p1.add(t4);

p1.add(yes);

p1.add(no);

p3.add(timer);

p3.add(time);

p1.setLayout(newGridLayout(5,2));

p3.setLayout(newFlowLayout());

j.setBounds(500,200,450,400);

j.add(BorderLayout.NORTH,p1);

j.add(BorderLayout.SOUTH,p3);

Fontinto=newFont("楷体",Font.BOLD,15);

yes.setFont(into);

no.setFont(into);

l1.setFont(into);

l2.setFont(into);

l3.setFont(into);

l4.setFont(into);

t1.setFont(into);

setLayout(newFlowLayout());

yes.setForeground(Color.BLUE);

no.setForeground(Color.DARK_GRAY);

yes.setBackground(Color.green);

l1.setBackground(Color.green);

l2.setBackground(Color.green);

l3.setBackground(Color.green);

l4.setBackground(Color.green);

no.setBackground(Color.RED);

t1.setBackground(Color.RED);

yes.addActionListener(this);

no.addActionListener(this);

j.setVisible(true);

j.setBackground(Color.GREEN);

j.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

Datedate=newDate();

StringtimeStr=date.toString().substring(11,19);

GregorianCalendarcalender=newGregorianCalendar();

intyear=calender.get(Calendar.YEAR);

intmonth=calender.get(Calendar.MONTH)+1;

intday=calender.get(Calendar.DAY_OF_MONTH);

Stringstr=(year+"年"+month+"月"+day+"日"+timeStr);

time.setText(str);

}

publicvoidactionPerformed(ActionEvente){

if(e.getSource()==no){

dispose();

newLoad();

}if(e.getSource()==yes){

try{

Class.forName(DBDriver);

con=DriverManager.getConnection(connectionStr,"root","123malin");

}catch(ClassNotFoundExceptioner){

er.printStackTrace();

}catch(SQLExceptioner){

er.printStackTrace();

}

}

try{

Stringn="insertintocante(id,name,sur,only)values(?

?

?

?

)";

PreparedStatementstmt=con.prepareStatement(n);

d

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 党团工作 > 入党转正申请

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1