java餐厅餐卡管理系统课程设计.doc_第1页
java餐厅餐卡管理系统课程设计.doc_第2页
java餐厅餐卡管理系统课程设计.doc_第3页
java餐厅餐卡管理系统课程设计.doc_第4页
java餐厅餐卡管理系统课程设计.doc_第5页
已阅读5页,还剩33页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

山东建筑大学计算机科学与技术学院程序设计实用案例选讲大作业说明书题 目: 某高校餐厅餐卡管理系统课 程: 程序设计实用案例选讲 院 (部): 计算机科学与技术专 业: 网络工程班 级: 网络121学生姓名: *琳学 号: 指导教师: 袁*华完成日期: 2014/01/01第 1 页 共 38 页山东建筑大学计算机学院大作业设计说明书目 录某高校餐厅餐卡管理系统1一、问题描述2二、设计思想2三、系统结构2四、程序流程(或模块划分)3五、源程序1六、系统测试及操作界面1结 论2参考文献3第 2 页 共 38 页山东建筑大学计算机学院大作业设计说明书某高校餐厅餐卡管理系统一、问题描述某高校餐厅餐卡管理系统,主要实现下列操作: 一、生成一张新卡,卡号自动生成如“2012*”,将卡号与学生姓名绑定,并能输入其总金额,并能在系统中存储这些系统。 二、查询操作:输入卡号,能查询出其余额。 三、挂失操作:某卡被挂失后,其金额不能再增加或减少。 四、消费操作:输入一个消费金额(消费金额有上限,如一次最多消费20元),能够从卡的总金额中减去被消费的金额。2、 设计思想 系统需求:win7 eclipseJDK1.7 系统设计:首先做好界面布局,出现登陆页面,实现触发事件处理,连接数据库,完成数据库处理功能,返回退出。3、 系统结构Class Loadfirst()只有此类含有main()方法,登陆页面;Class Load()登陆进去时,系统的主页面,功能的主目录Class Into()实现注册功能,后台数据库自动生成卡号;Class Find()实现输入卡号,查询数据库信息功能;Class Lost()实现挂失信息操作,挂失信息不能再修改。四、程序流程(或模块划分)这里是系统的主要流程图和流程图的语言介绍流程图如下:流程图图1 登陆主界面图2 系统运行主界面图3 注册主界面图4 注册界面图5 我的卡号图6 挂失卡号5、 源程序登陆主页面:public final class Loadfirst extends JFrame implements ActionListener,Runnableprivate static Thread Scoll = null;private static Thread coll = null;JButton yes,no;TextField text;JLabel label,wel,timer ,time;JPanel p1,p2,p3;boolean stop,on;private JPasswordField password;public Loadfirst()JFrame j=new JFrame(餐卡信息管理系统登陆界面);p1=new JPanel();p2=new JPanel();p3=new JPanel();timer=new JLabel(亲,您目前访问的时间是:);time=new JLabel();label=new JLabel( 请输入登录密码: );wel=new JLabel(亲!欢迎进入餐卡信息管理系统!); text=new TextField();text.setEchoChar(*); /JPasswordField password = new JPasswordField(8);/password.setEchoChar(*);setLayout(new FlowLayout();setBounds(500, 50, 250, 100);yes=new JButton(登录系统);no=new JButton(退出查询);p1.add(label);p1.add(text);p1.add(yes);p1.add(no);p2.add(wel);p3.add(timer);p3.add(time);p1.setLayout(new GridLayout(2,2);p3.setLayout(new GridLayout(1,2);j.setBounds(500, 200, 450, 400);j.add(BorderLayout.NORTH,p1);j.add(BorderLayout.CENTER,p2);j.add(BorderLayout.SOUTH,p3);Font font = new Font(楷体,Font.BOLD,25);Font nt = new Font(楷体,Font.BOLD,15);wel.setFont(font);timer.setFont(nt);label.setFont(nt);time.setFont(nt);yes.setFont(nt);no.setFont(nt);setLayout(new FlowLayout();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=new Thread(this);coll=new Thread(this);Scoll.start();coll.start();public void run()if(Thread.currentThread()=Scoll)while(true)int x=wel.getBounds().x;int y = 120;x +=10;wel.setLocation(x, y);if (x 300) x =5;wel.setLocation(x, y);tryThread.sleep(100);catch(InterruptedException er)er.printStackTrace();if(stop=true)return;else if(Thread.currentThread()=coll)Date date = new Date();String timeStr = date.toString().substring(11, 19);time.setText(timeStr);try Thread.sleep(1000);catch(InterruptedException er)er.printStackTrace();if(on=true)return; public void actionPerformed(ActionEvent e) if(e.getSource()=yes&text.getText().toString().equals(123)new Load();dispose();else if(e.getSource()=no)stop=false;dispose();System.exit(0);/else if(!password.getPassword() .equals(123) )else if(!text.getText().toString() .equals(123) )JOptionPane.showMessageDialog(this,亲,您的密码怎么输入错误了啊!);text.setText();System.out.println(密码输入错了怎么办呢?);public static void main(String args) new Loadfirst();查询页面:public class Find extends JFrame implements ActionListenerString DBDriver = com.mysql.jdbc.Driver;String connectionStr = jdbc:mysql:/localhost:3306/canterbury;Connection con = null;PreparedStatement stmt = null;ResultSet rs = null;JLabel l1,l2,l3,l4;JTextField t1,t2,t3,t4;JButton yes,no;JPanel p1,p2,p3;JTextArea result;JLabel label,timer ,time;boolean judge = false;Find()JFrame j=new JFrame(查询信息:);p1=new JPanel();p2=new JPanel();p3=new JPanel();t1=new JTextField();t2=new JTextField();t3=new JTextField();t4=new JTextField();timer=new JLabel(亲,您目前访问的时间是:2014年1月2日);time=new JLabel();l1=new JLabel(卡号:);l2=new JLabel(姓名:);l3=new JLabel(充值余额:);l4=new JLabel(最低消费余额:);setLayout(new FlowLayout();setBounds(500, 50, 250, 100);yes=new JButton(点击查询);no=new JButton(退出系统);result=new JTextArea();p1.add(l1);p1.add(t1);p1.add(yes);p1.add(no);p3.add(timer);p3.add(time);p1.setLayout(new GridLayout(2,2);/p3.setLayout(new GridLayout(1,2);j.setBounds(500, 200, 450, 400);j.add(BorderLayout.NORTH,p1);j.add(BorderLayout.SOUTH,p3);Font into = new Font(楷体,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(new FlowLayout();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);Date date = new Date();String timeStr = date.toString().substring(11, 19);time.setText(timeStr);public void actionPerformed(ActionEvent e) if(e.getSource() = no) dispose();System.exit(0);if(t1.getText().equals()JOptionPane.showMessageDialog(this, 亲,这样是不可以查询信息的呦!);else if(e.getSource() = yes)tryClass.forName(DBDriver);con = DriverManager.getConnection(connectionStr,root,123malin);String select = select * from cante where id = ?;stmt = con.prepareStatement(select);stmt.setString(1,t1.getText();rs = stmt.executeQuery();String t1,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(ClassNotFoundException er)er.printStackTrace();catch(SQLException er)er.printStackTrace();注册主页面:public class Into extends JFrame implements ActionListenerString DBDriver = com.mysql.jdbc.Driver;String connectionStr = jdbc:mysql:/localhost:3306/canterbury;Connection con = null;PreparedStatement stmt = null;ResultSet rs = null;JLabel l1,l2,l3,l4,l5,l6;JTextField t1,t2,t3,t4,t5,t6;JButton yes,no;JPanel p1,p2,p3;JTextArea result;JLabel label,wel,timer ,time,sert;Into()JFrame j=new JFrame(注册新餐厅卡:);p1=new JPanel();p2=new JPanel();p3=new JPanel();t1=new JTextField();t1.setEnabled(false);t1.setText(卡号是不需要输入的!);t2=new JTextField();t3=new JTextField();t4=new JTextField();timer=new JLabel(亲,您目前访问的时间是:);time=new JLabel();l1=new JLabel(卡号:);l2=new JLabel(姓名:);l3=new JLabel(充值余额:);l4=new JLabel(最低消费余额:);setLayout(new FlowLayout();setBounds(500, 50, 250, 100);yes=new JButton(注册);no=new JButton(返回);result=new JTextArea();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(new GridLayout(5,2);p3.setLayout(new FlowLayout();j.setBounds(500, 200, 450, 400);j.add(BorderLayout.NORTH,p1);j.add(BorderLayout.SOUTH,p3);Font into = new Font(楷体,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(new FlowLayout();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);Date date = new Date();String timeStr = date.toString().substring(11, 19);GregorianCalendar calender=new GregorianCalendar();int year=calender.get(Calendar.YEAR);int month=calender.get(Calendar.MONTH)+1;int day=calender.get(Calendar.DAY_OF_MONTH);String str=(year+年+month+月+day+日+timeStr);time.setText(str);public void actionPerformed(ActionEvent e) if(e.getSource() = no) dispose();new Load();if(e.getSource() = yes)tryClass.forName(DBDriver);con = DriverManager.getConnection(connectionStr,root,123malin);catch(ClassNotFoundException er)er.printStackTrace();catch(SQLException er)er.printStackTrace();tryString n = insert into cante(id,name,sur,only) values(?,?,?,?);PreparedStatement stmt = con.prepareStatement(n); double i = 0;stmt.setDouble(1,i);stmt.setString(2, t2.getText();stmt.setString(3, t3.getText(); stmt.setString(4, t4.getText();stmt.executeUpdate();/rs = stmt.executeQuery();JOptionPane.showMessageDialog(this, 成功添加信息!nn注册信息如下:+n姓名:+t2.getText()+n充值金额+t3.getText()+n最低消费额:+t4.getText();System.out.println(成功添加信息!nn注册信息如下:+n姓名:+t2.getText()+n充值金额+t3.getText()+n最低消费额:+t4.getText();dispose();stmt.close();con.close();setVisible(false);catch(SQLException er)er.printStackTrace();系统主页面:public class Load extends JFrame implements ActionListener,Runnableprivate static Thread Scoll = null;private static Thread coll = null;JButton yes,no,select,res,lost,my;JTextField text;JLabel label,wel,timer ,time,sert,date;JPanel p1,p2,p3;JTextArea result;String DBDriver = com.mysql.jdbc.Driver;String connectionStr = jdbc:mysql:/localhost:3306/canterbury;Connection con = null;PreparedStatement stmt = null;ResultSet rs = null;boolean stop,on;public Load()JFrame j=new JFrame(餐厅管理系统主界面);p1=new JPanel();p2=new JPanel();p3=new JPanel();timer=new JLabel(亲,您目前访问的时间是:2014年1月2日);time=new JLabel();sert=new JLabel();date=new JLabel();wel=new JLabel(亲!欢迎进入餐厅管理系统!);text=new JTextField();setLayout(new FlowLayout();setBounds(500, 50, 250, 100);yes=new JButton(关于我们);no=new JButton(退出系统);res=new JButton(注册新卡);lost=new JButton(挂失餐卡);select=new JButton(查询信息);my=new JButton(我的餐卡);result=new JTextArea();p1.add(res);p1.add(lost);p1.add(select);p1.add(my);p1.add(yes);p1.add(no);p2.add(wel);p2.add(sert);p2.add(date);p3.add(timer);p3.add(time);p1.setLayout(new GridLayout(3,2);p2.setLayout(new FlowLayout();j.setBounds(450, 100,600, 550);j.add(BorderLayout.NORTH,p1);j.add(BorderLayout.CENTER,p2);j.add(BorderLayout.SOUTH,p3);Font font = new Font(楷体,Font.BOLD,25);Font into = new Font(楷体,Font.BOLD,15);wel.setFont(font);date.setFont(font);yes.setFont(into);no.setFont(into);select.setFont(into);my.setFont(into);lost.setFont(into);res.setFont(into);sert.setFont(into);timer.setFont(into);setLayout(new FlowLayout();wel.setForeground(Color.RED);date.setForeground(Color.GREEN);yes.setForeground(Color.BLUE);no.setForeground(Color.DARK_GRAY);yes.setBackground(Color.green);res.setBackground(Color.green);lost.setBackground(Color.green);select.setBackground(Color.green);my.setBackground(Color.green);no.setBackground(Color.RED);res.addActionListener(this);lost.addActionListener(this);select.addActionListener(this);yes.addActionListener(this);no.addActionListener(this);my.addActionListener(this);j.setVisible(true);j.setBackground(Color.GREEN);j.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);GregorianCalendar calender=new GregorianCalendar();int year=calender.get(Calendar.YEAR);int month=calender.get(Calendar.MONTH)+1;int day=calender.get(Calendar.DAY_OF_MONTH);String da=(现在是+year+年+month+月+day+日啦!你准备好了么!);date.setText(da);Date date = new Date();String timeStr = date.toString().substring(11, 19);String str=(year+年+month+月+day+日+timeStr);time.setText(str);Scoll=new Thread(this);coll=new Thread(this);Scoll.start();coll.start();public void run()if(Thread.currentThread()=Scoll)while(true)int x=wel.getBounds().x;int y = 150;x +=9;wel.setLocation(x, y+25);date.setLocation(x-20, y-15);if (x 380) x =10;wel.setLocation(x, y+20);date.setLocation(x, y-29);tryThread.sleep(100);catch(InterruptedException er)er.printStackTrace();if(stop=true)return;else if(Thread.currentThread()=coll)try Thread.sleep(1000);catch(InterruptedException er)er.printStackTrace();if(on=true)return; public void actionPerformed(ActionEvent e) if(e.getSource()=no)stop=false;dispose();on=true;System.exit(0);else if(e.getSource()=yes)JOptionPane.showMessageDialog(this,亲,这是网络121班学号为:20121113020的马琳,也就是在下 +编写的课程设计题目:餐卡信息管理系统!);else if(e.getSource()=res)new Into();else if(e.getSource()=lost)new Lost();else if(e.getSource()=select )new Find();else if(e.getSource()=my )tryClass.forName(DBDriver);con = DriverManager.getConnection(connectionStr,root,123malin);String select = select * from cante where id = 20121113020;stmt = con.prepareStatement(select);rs = stmt.executeQuery();String t1,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();catch(ClassNotFoundException er)er.printStackTrace();catch(SQLException er)er.printStackTrace();挂失主页面:public class Lost extends JFrame implements ActionListenerString DBDriver = com.mysql.jdbc.Driver;String connectionStr = jdbc:mysql:/localhost:3306/canterbury;Connection con = null;PreparedStatement stmt = null;ResultSet rs = null;JButton yes,no;JPanel p1,p2,p3;JLabel label,timer ,time,input;JTextField in;Lost() JFrame j=new JFrame(挂失卡信息:);label=new JLabel(亲,挂失后就不能再用咯!记得哦!);input=new JLabel(请输入卡号:);in=new JTextField();p1=new JPanel();p2=new JPanel();p3=new JPanel();timer=new JLabel(亲,您目前访问的时间是:);time=new JLabel();setLayout(new FlowLayout();setBounds(500, 50, 250, 100);yes=new JButton(确定挂失);no=new JButton(退出系统);p3.add(timer);p3.add(time);p2.add(label);p1.add(input);p1.add(in);p1.add(yes);p1.add(no);p1.setLayout(new GridLayout(2,2);p3.setLayout(new FlowLayout();j.setBounds(500, 200, 450, 400);j.add(BorderLayout.NORTH,p1);j.add(BorderLayout.CENTER,p2);j.add(BorderLayout.SOUTH,p3);Font into = new Font(楷体,Font.BOLD,15);Font labell = new Font(楷体,Font.BOLD,25);yes.setFont(into);label.setFont(labell);no.setFont(into);input.setFont(into);timer.setFont(into);setLayout(new FlowLayout();yes.setForeground(Color.BLUE);label.setForeground(Color.GRAY);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);Date date = new Date();String timeStr = date.toString().substring(11, 19);GregorianCalendar calender=new GregorianCalendar();int year=calender.get(Calendar.YEAR);int month=calender.get(Calendar.MONTH)+1;int day=calender.get(Calendar.DAY_OF_MONTH);String str=(year+年+month+月+day+日+timeStr);time.setText(str);System.out.println(现在北京时间是+str);public void actionPerformed(ActionEvent e) if(e.getSource() = no) dispose(); JOptionPane.showMessageDialog(this, 亲,下次再见!); System.exit(0); else if(e.ge

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论