package text;import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Scanner;public class function {//连接对象Connection connection=null;//创建预编译对象PreparedStatement ps=null;//创建结果集ResultSet rs = null;Scanner scan = new Scanner(System.in);public void selectcostomer() throws SQLException{connection = cwd.getCon();String sql = "select * from costomer where gno = ?";try {ps = connection.prepareStatement(sql);Scanner scan = new Scanner(System.in);System.out.println("请输入要查询的顾客的编号号:");String  gno = scan.next();ps.setString(1,gno);rs = ps.executeQuery();while (rs.next()){String Gno = rs.getString(1);String gname = rs.getString(2);String zno = rs.getString(3);String ghost = rs.getString(4);String gmember = rs.getString(5);String gremark= rs.getString(6);System.out.println("编号:"+Gno);System.out.println("姓名:"+gname);System.out.println("餐桌:"+zno);System.out.println("开单人:"+ghost);System.out.println("会员:"+gmember);System.out.println("备注:"+gremark);}System.out.printf("查询成功 ");} catch (SQLException e) {e.printStackTrace();}finally {cwd.closeCon(connection);}}public void selectoc() throws SQLException{connection = cwd.getCon();String sql = "select gname,cname,os from costomer,commodity,oc where costomer.gno=oc.gno and commodity.cno=oc.cno ";try {ps = connection.prepareStatement(sql);Scanner scan = new Scanner(System.in);rs = ps.executeQuery();while (rs.next()){String gname = rs.getString(1);String cname = rs.getString(2);String os = rs.getString(3);System.out.println("顾客姓名:"+gname);System.out.println("商品姓名:"+cname);System.out.println("满意度:"+os);}System.out.printf("查询成功 ");} catch (SQLException e) {e.printStackTrace();}finally {cwd.closeCon(connection);}}public void selectsweep() throws SQLException{connection = cwd.getCon();String sql = "select sname,zlo from staff,fanzhuo,sweep where staff.sno=sweep.sno and fanzhuo.zno=sweep.zno";try {ps = connection.prepareStatement(sql);Scanner scan = new Scanner(System.in);rs = ps.executeQuery();while (rs.next()){String sname = rs.getString(1);String zno = rs.getString(2);System.out.println("打扫职工的姓名:"+sname);System.out.println("打扫餐桌的位置:"+zno);}System.out.printf("查询成功 ");} catch (SQLException e) {e.printStackTrace();}finally {cwd.closeCon(connection);}}public int insertcostomer() throws SQLException{ int result = 0; connection =  cwd.getCon(); System.out.printf("请输入插入顾客信息");String sql = "insert into costomer values(?,?,?,?,?,?)";try { //数据库信息/*gno char(7) not null primary key,gname varchar2(50) not null,zno char(2) not null,ghost varchar2(50) not null,     gmember char(4) not null check(gmember in('是','否')),gremark varchar2(150),*/String gno=scan.next();           String gname=scan.next();        String zno=scan.next();            String ghost=scan.next();String gmember=scan.next();String g=scan.next();ps =  connection.prepareStatement(sql); ps.setString(1,gno);ps.setString(2,gname); ps.setString(3,zno); ps.setString(4,ghost);ps.setString(5,gmember);ps.setString(6,g);result = ps.executeUpdate(); System.out.printf(" 插入成功 ");} catch (SQLException e) { e.printStackTrace();}finally { cwd.closeCon(connection); } return result;}public int updatecostomer() throws SQLException{connection = cwd.getCon();String sql = "update costomer set gremark = ?,ghost = ? where gno= ? ";Scanner scan = new Scanner(System.in);System.out.println("请输入顾客编号");String  Sno = scan.next();System.out.println("请输入新的备注");String  Dno1 = scan.next();System.out.println("请输入新的开单人");String  ghost = scan.next();int result = 0;try {ps = connection.prepareStatement(sql);ps.setString(1,Dno1);ps.setString(2,ghost);ps.setString(3,Sno);result = ps.executeUpdate();System.out.printf(" 更新成功 ");} catch (SQLException e) {e.printStackTrace();}finally {cwd.closeCon(connection);}return result;}public int deletecostomer() throws SQLException{int result = 0;connection = cwd.getCon();String sql = "delete from oc where cno = ?";String sq2 = "select *from oc";try {Scanner scan = new Scanner(System.in);System.out.println("请输入删除的编号:");String  gno = scan.next();ps = connection.prepareStatement(sql);ps.setString(1,gno);result = ps.executeUpdate();System.out.println("删除成功 ");ps = connection.prepareStatement(sq2);rs = ps.executeQuery();System.out.println("删除后的信息 ");while (rs.next()){String gname = rs.getString(1);String cname = rs.getString(2);String os = rs.getString(3);System.out.println("满意度:"+os);System.out.println("顾客编号:"+cname);System.out.println("商品编号:"+gname);}} catch (SQLException e) {e.printStackTrace();}finally {cwd.closeCon(connection);}return result;}public void selectcommodity() throws SQLException{connection = cwd.getCon();String sql = "select * from commodity where cno = ?";try {ps = connection.prepareStatement(sql);Scanner scan = new Scanner(System.in);System.out.println("请输入要查询的商品的编号号:");String  cno = scan.next();ps.setString(1,cno);rs = ps.executeQuery();while (rs.next()){String Gno = rs.getString(1);String gname = rs.getString(2);String zno = rs.getString(3);String ghost = rs.getString(4);System.out.println("商品编号:"+Gno);System.out.println("商品姓名:"+gname);System.out.println("商品价格:"+zno);System.out.println("消费数量:"+ghost);}System.out.printf("查询成功 ");} catch (SQLException e) {e.printStackTrace();}finally {cwd.closeCon(connection);}}public void selectstaff() throws SQLException{connection = cwd.getCon();String sql = "select * from staff where sno = ?";try {ps = connection.prepareStatement(sql);Scanner scan = new Scanner(System.in);System.out.println("请输入要查询的职工的编号号:");String  sno = scan.next();ps.setString(1,sno);rs = ps.executeQuery();while (rs.next()){String Gno = rs.getString(1);String gname = rs.getString(2);String zno = rs.getString(3);String ghost = rs.getString(4);String gmember = rs.getString(5);String gremark= rs.getString(6);System.out.println("编号:"+Gno);System.out.println("性别:"+gname);System.out.println("名字:"+zno);System.out.println("类别:"+ghost);System.out.println("电话:"+gmember);System.out.println("工资:"+gremark);}System.out.printf("查询成功 ");} catch (SQLException e) {e.printStackTrace();}finally {cwd.closeCon(connection);}}public void selectfanzhuo() throws SQLException{connection = cwd.getCon();String sql = "select * from fanzhuo where zno = ?";try {ps = connection.prepareStatement(sql);Scanner scan = new Scanner(System.in);System.out.println("请输入要查询的饭桌的编号号:");String  sno = scan.next();ps.setString(1,sno);rs = ps.executeQuery();while (rs.next()){String Gno = rs.getString(1);String gname = rs.getString(2);String zno = rs.getString(3);String ghost = rs.getString(4);String gmember = rs.getString(5);             System.out.println("顾客人数:"+Gno);System.out.println("桌台状态:"+gname);System.out.println("桌台编号:"+zno);System.out.println("桌台位置:"+ghost);System.out.println("职工编号:"+gmember);}System.out.printf("查询成功 ");} catch (SQLException e) {e.printStackTrace();}finally {cwd.closeCon(connection);}}public int updatcommodity() throws SQLException{connection = cwd.getCon();String sql = "update commodity set cvalue = ? where cno= ? ";Scanner scan = new Scanner(System.in);System.out.println("请输入商品编号");String  cno = scan.next();System.out.println("请输入新的商品价格");String  Dno1 = scan.next();int result = 0;try {ps = connection.prepareStatement(sql);ps.setString(1,Dno1);ps.setString(2,cno);result = ps.executeUpdate();System.out.printf(" 更新成功 ");} catch (SQLException e) {e.printStackTrace();}finally {cwd.closeCon(connection);}return result;}public int updatstaff() throws SQLException{connection = cwd.getCon();String sql = "update staff set swage = ? where sno= ? ";Scanner scan = new Scanner(System.in);System.out.println("请输入职工编号");String  sno = scan.next();System.out.println("请输入新的工资");String  Dno1 = scan.next();int result = 0;try {ps = connection.prepareStatement(sql);ps.setString(1,Dno1);ps.setString(2,sno);result = ps.executeUpdate();System.out.printf(" 更新成功 ");} catch (SQLException e) {e.printStackTrace();}finally {cwd.closeCon(connection);}return result;}public int updatefanzhuo() throws SQLException{connection = cwd.getCon();String sql = "update fanzhuo set rnum = ?,zcon = ? where zno= ? ";Scanner scan = new Scanner(System.in);System.out.println("请输入饭桌编号");String  sno = scan.next();System.out.println("请输入现在桌台顾客人数");String  Dno1 = scan.next();System.out.println("请输入现在桌台状态");String  z = scan.next();int result = 0;try {ps = connection.prepareStatement(sql);ps.setString(1,Dno1);ps.setString(2,z);ps.setString(3,sno);result = ps.executeUpdate();System.out.printf(" 更新成功 ");} catch (SQLException e) {e.printStackTrace();}finally {cwd.closeCon(connection);}return result;}public int insertcommodity() throws SQLException{ int result = 0; connection =  cwd.getCon(); System.out.printf("请输入插入商品信息");String sql = "insert into commodity values(?,?,?,?)";try { //数据库信息/*cno char(2) primary key,cname varchar2(50) not null,cvalue number(3) not null,cnum number(3) not null*/String gno=scan.next();           String gname=scan.next();        String zno=scan.next();            String ghost=scan.next();ps =  connection.prepareStatement(sql); ps.setString(1,gno);ps.setString(2,gname); ps.setString(3,zno); ps.setString(4,ghost);result = ps.executeUpdate(); System.out.printf(" 插入成功 ");} catch (SQLException e) { e.printStackTrace();}finally { cwd.closeCon(connection); } return result;}public int insertstaff() throws SQLException{ int result = 0; connection =  cwd.getCon(); System.out.printf("请输入插入职工信息");String sql = "insert into staff values(?,?,?,?,?,?)";try { //数据库信息/*sno char(3) primary key,sex char(4) not null check(sex in ('男','女')),sname varchar2(50) not null,category varchar2(50) not null,sphone char(11)not null,swage number(4)not null*/String gno=scan.next();           String gname=scan.next();        String zno=scan.next();            String ghost=scan.next();String gmember=scan.next();String g=scan.next();ps =  connection.prepareStatement(sql); ps.setString(1,gno);ps.setString(2,gname); ps.setString(3,zno); ps.setString(4,ghost);ps.setString(5,gmember);ps.setString(6,g);result = ps.executeUpdate(); System.out.printf(" 插入成功 ");} catch (SQLException e) { e.printStackTrace();}finally { cwd.closeCon(connection); } return result;}public int insertfanzhuo() throws SQLException{ int result = 0; connection =  cwd.getCon(); System.out.printf("请输入插入信息");String sql = "insert into fanzhuo values(?,?,?,?,?)";try { //数据库信息/*rnum number(2) not null,zcon char(4) not null check(zcon in('空','满')),zno char(2) primary key,zlo varchar2(50) not null,esweep char(3) not null,*/String gno=scan.next();           String gname=scan.next();        String zno=scan.next();            String ghost=scan.next();String gmember=scan.next();ps =  connection.prepareStatement(sql); ps.setString(1,gno);ps.setString(2,gname); ps.setString(3,zno); ps.setString(4,ghost);ps.setString(5,gmember);result = ps.executeUpdate(); System.out.printf(" 插入成功 ");} catch (SQLException e) { e.printStackTrace();}finally { cwd.closeCon(connection); } return result;}public int deletecommodity() throws SQLException{int result = 0;connection = cwd.getCon();String sql = "delete from commodity where cno = ?";String sq2 = "select *from commodity";try {Scanner scan = new Scanner(System.in);System.out.println("请输入删除商品的编号:");String  gno = scan.next();ps = connection.prepareStatement(sql);ps.setString(1,gno);result = ps.executeUpdate();System.out.println("删除成功 ");ps = connection.prepareStatement(sq2);rs = ps.executeQuery();System.out.println("删除后的信息 ");while (rs.next()){String gname = rs.getString(1);String cname = rs.getString(2);String os = rs.getString(3);String c = rs.getString(4);System.out.println("商品编号:"+os);System.out.println("商品名:"+cname);System.out.println("商品价格:"+gname);System.out.println("商品总量:"+c);}} catch (SQLException e) {e.printStackTrace();}finally {cwd.closeCon(connection);}return result;}public int deletestaff() throws SQLException{int result = 0;connection = cwd.getCon();String sql = "delete from staff where sno = ?";String sq2 = "select *from staff";try {Scanner scan = new Scanner(System.in);System.out.println("请输入删除职工的编号:");String  gno = scan.next();ps = connection.prepareStatement(sql);ps.setString(1,gno);result = ps.executeUpdate();System.out.println("删除成功 ");ps = connection.prepareStatement(sq2);rs = ps.executeQuery();System.out.println("删除后的信息 ");while (rs.next()){String gname = rs.getString(1);String cname = rs.getString(2);String os = rs.getString(3);String c = rs.getString(4);String b = rs.getString(5);String a = rs.getString(6);System.out.println("职工编号:"+os);System.out.println("职工性别:"+cname);System.out.println("职工姓名:"+gname);System.out.println("职工类别:"+c);System.out.println("职工电话:"+b);System.out.println("工资:"+a);}} catch (SQLException e) {e.printStackTrace();}finally {cwd.closeCon(connection);}return result;}public int deletefanzhuo() throws SQLException{int result = 0;connection = cwd.getCon();String sql = "delete from fanzhuo where zno = ?";String sq2 = "select *from fanzhuo";try {Scanner scan = new Scanner(System.in);System.out.println("请输入删除饭桌的编号:");String  gno = scan.next();ps = connection.prepareStatement(sql);ps.setString(1,gno);result = ps.executeUpdate();System.out.println("删除成功 ");ps = connection.prepareStatement(sq2);rs = ps.executeQuery();System.out.println("删除后的信息 ");while (rs.next()){String gname = rs.getString(1);String cname = rs.getString(2);String os = rs.getString(3);String c = rs.getString(4);String b = rs.getString(5);          System.out.println("顾客人数:"+os);System.out.println("餐桌状态:"+cname);System.out.println("餐桌编号:"+gname);System.out.println("餐桌位置:"+c);System.out.println("职工编号:"+b);}} catch (SQLException e) {e.printStackTrace();}finally {cwd.closeCon(connection);}return result;}
//主函数public static void main(String[] args) throws SQLException{String driver="oracle.jdbc.OracleDriver";String url="jdbc:oracle:thin:@localhost:1521:xe";String name="tianshi";String pwd="123456";//Class.forName(jdbcName);Connection conn=DriverManager.getConnection(url,name,pwd);Scanner input = new Scanner(System.in);//connection = cwd.getCon();System.out.println("管理员登录界面");System.out.println("账号:");System.out.println("密码:");String numb=input.next();String pw=input.next();String sql="select * from manage where numb='"+numb+"'and pw='"+pw+"'";try {Statement st=conn.createStatement();ResultSet rs=st.executeQuery(sql);if(rs.next()) { System.out.println("欢迎你,尊敬的管理员");function oc = new function();Scanner scan = new Scanner(System.in);int sel;System.out.println("1.查询顾客信息");System.out.println("2.更新顾客信息");System.out.println("3.删除顾客对商品满意度评价");System.out.println("4.增加顾客");System.out.println("5.查询顾客对商品满意度");System.out.println("6.查询打扫餐桌的职员");System.out.println("7.查询商品信息");System.out.println("8.查询职工信息");System.out.println("9.查询餐桌信息");System.out.println("10.更新商品信息");System.out.println("11.更新职工信息");System.out.println("12.更新餐桌信息");System.out.println("13.增加商品");System.out.println("14.增加职工");System.out.println("15.增加餐桌");System.out.println("16.删除商品");System.out.println("17.删除职工");System.out.println("18.删除餐桌");System.out.println("19.退出");while(scan.hasNext()){sel = scan.nextInt();int result = 1;switch(sel){case 1: oc.selectcostomer();    break;case 2: oc.updatecostomer();    break;case 3: oc.deletecostomer();         break;case 4: oc.insertcostomer();  break;case 5: oc.selectoc();    break;case 6: oc.selectsweep();    break;case 7: oc.selectcommodity();    break;case 8: oc.selectstaff();    break;case 9: oc.selectfanzhuo();    break;case 10: oc.updatcommodity();    break;case 11: oc.updatstaff();    break;case 12: oc.updatefanzhuo();    break;case 13: oc.insertcommodity();  break;case 14: oc.insertstaff();  break;case 15: oc.insertfanzhuo();  break;case 16: oc.deletecommodity();  break;case 17: oc.deletestaff();  break;case 18: oc.deletefanzhuo();  break;default:System.exit(0);}}}else System.out.println("登录失败");}catch(SQLException e){e.printStackTrace();}}
}

基于数据库的餐厅管理系统相关推荐

  1. android餐厅管理系统,基于Android的餐厅管理系统的设计与实现

    摘要: 在信息技术高速发展的今天,传统餐饮业受到了来自互联网的强烈冲击.传统运营方式的落后导致其工作效率已经跟不上时代的步伐.其中,信息化技术改造成本过高成为阻碍传统餐饮业发展的一个重要因素.本文旨在 ...

  2. Java项目:基于ssm智能餐厅管理系统

    作者主页:夜未央5788 简介:Java领域优质创作者.Java项目.学习资料.技术互助 文末获取源码 项目介绍 本项目主要分为服务员.厨师.收银员.经理四种角色: 主要功能包括: 客户可以根据自己的 ...

  3. (附源码)计算机毕业设计SSM基于的餐厅管理系统

    (附源码)计算机毕业设计SSM基于的餐厅管理系统 项目运行 环境配置: Jdk1.8 + Tomcat7.0 + Mysql + HBuilderX(Webstorm也行)+ Eclispe(Inte ...

  4. 通向架构师的道路(第六天)之漫谈基于数据库的权限系统的设计

    一.权限系统 这一天将讲述一个基本的基于数据库的权限管理系统的设计,在这一天的课程的最后将讲述"左右值无限分类实现算法"如何来优化"系统菜单"的结构而告终.今天 ...

  5. 餐厅管理系统(SpringBoot Mybatis Mysql)

    下载链接:基于SpringBoot的餐厅管理系统_餐饮管理系统springboot-互联网文档类资源-CSDN下载

  6. J2EE开发之(六)之漫谈基于数据库的权限系统的设计

    一,权限系统 这一天将讲述一个基本的基于数据库的权限管理系统的设计,在这一天的课程的最后将讲述"左右值无限分类实现算法"如何来优化"系统菜单"的结构而告终.今天 ...

  7. 基于JAVA建材公司管理系统计算机毕业设计源码+数据库+lw文档+系统+部署

    基于JAVA建材公司管理系统计算机毕业设计源码+数据库+lw文档+系统+部署 基于JAVA建材公司管理系统计算机毕业设计源码+数据库+lw文档+系统+部署 本源码技术栈: 项目架构:B/S架构 开发语 ...

  8. 基于JAVA学生健康管理系统计算机毕业设计源码+系统+数据库+lw文档+部署

    基于JAVA学生健康管理系统计算机毕业设计源码+系统+数据库+lw文档+部署 基于JAVA学生健康管理系统计算机毕业设计源码+系统+数据库+lw文档+部署 本源码技术栈: 项目架构:B/S架构 开发语 ...

  9. 基于JAVA客服管理系统计算机毕业设计源码+数据库+lw文档+系统+部署

    基于JAVA客服管理系统计算机毕业设计源码+数据库+lw文档+系统+部署 基于JAVA客服管理系统计算机毕业设计源码+数据库+lw文档+系统+部署 本源码技术栈: 项目架构:B/S架构 开发语言:Ja ...

最新文章

  1. Python __call__详解
  2. 爬虫基础-request的一些基础属性
  3. ubuntu18.04下编译mysql5.7源码
  4. blender, 创建多边形面片
  5. 如何在ubuntu下安装detectron2_Anaconda中安装Cascade RCNN(Detectron)的若干问题
  6. ZOJ 2562 More Divisors
  7. python fabric上传文件夹_通过python的fabric包完成代码上传部署(简单版)
  8. 甭给《程序员》把脉——你不是主编
  9. CS231N课程笔记学习一——图像分类
  10. 中国元宇宙企业有哪些?
  11. 【webshell分析】PHP大马分析
  12. windows系统升级
  13. iis部署网站java_值得分享的IIS部署网站详细步骤
  14. 视频、图像原理 设配选择 图像出入门概念理解
  15. C#实现触摸屏自定义键盘
  16. CAD绘图时怎么查看所绘制图形两点间的距离?
  17. matlab 输出矩阵 逗号隔开,在MATLAB中自定义矩阵时,矩阵同行元素之间用逗号隔开,而每一行元素之间用分号隔开。...
  18. 基于sklearn的软硬间隔以及各类核函数的SVM实现
  19. iostextarea获取焦点_jquery – 在iOS上的Safari中针对textarea触发的不一致事件
  20. SSL/TLS证书1年有效期新规已至,被“证书过期”支配的恐惧又增加了!

热门文章

  1. 【ffmpeg 给视频添加背景音乐,去掉视频背景音乐原声】
  2. 控制哔哩哔哩群发软件运行的参数
  3. 编程之美中的NIM游戏及异或性质应用
  4. Java中暂停线程的方法sleep()
  5. 柱面投影介绍与python实现(一)
  6. iPhone 6S展示了玫瑰金颜色和3D触摸功能
  7. 戴尔科技全面创新,让数字化梦想照见现实
  8. SQL中如何使用EXISTS替代IN
  9. CentOS离线安装rpm包
  10. 剑指 offer 全记录