您好,欢迎访问三七文档
当前位置:首页 > 行业资料 > 酒店餐饮 > java点菜系统代码
酒店点菜系统importjava.sql.*;importjavax.swing.*;importjava.awt.*;importjava.awt.event.*;importjavax.swing.border.*;publicclassJiudianimplementsActionListener,ItemListener{staticJFramef=null;//因为要在main静态方法中被引用,所以必须设为static类型ButtonGroupbg;//按钮组,可组合若干单选按钮JRadioButtonr1,r2,r3,r4,r5;//单选按钮JRadioButtonc1,c2,c3,c4;//单选按钮intop=0;staticinti=0;publicJiudian(){//Dialog=newJDialog(f,选择您想要的桌号和您喜欢的菜,true);f=newJFrame(选择您想要的桌号和您喜欢的菜);ContainerdialogPane=f.getContentPane();dialogPane.setLayout(newGridLayout(3,1));JPanelp1=newJPanel();//新建一个Panelp1.setLayout(newGridLayout(1,5));//设置边框p1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.green,4),选择桌号,TitledBorder.CENTER,TitledBorder.TOP));//单选按钮r1=newJRadioButton(one);r2=newJRadioButton(two);r3=newJRadioButton(three);r4=newJRadioButton(four);r5=newJRadioButton(five);p1.add(r1);p1.add(r2);p1.add(r3);p1.add(r4);p1.add(r5);bg=newButtonGroup();//按钮组,组合5个单选按钮,使一次只能选择一个bg.add(r1);bg.add(r2);bg.add(r3);bg.add(r4);bg.add(r5);r1.addItemListener(this);//为单选按钮增加ItemListener事件监听器r2.addItemListener(this);r3.addItemListener(this);r4.addItemListener(this);r5.addItemListener(this);JPanelp2=newJPanel();//新建一个Pane1p2.setLayout(newGridLayout(4,1));//设置边框p2.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorde(Color.green,4),选择您喜欢的菜,TitledBorder.CENTER,TitledBorder.TOP));//单选钮c1=newJRadioButton(小鸡炖蘑菇,价格为:25元/份);c2=newJRadioButton(青椒炒肉,价格为:18元/份);c3=newJRadioButton(东北火锅,价格为:36元/份);c4=newJRadioButton(豆腐炖鱼头,价格为:36元/份);p2.add(c1);p2.add(c2);p2.add(c3);p2.add(c4);c1.addItemListener(this);//为单选按钮增加ItemListener事件监听器c2.addItemListener(this);c3.addItemListener(this);c4.addItemListener(this);JPanelp3=newJPanel();//创建一个新的Panelp3.setLayout(newGridLayout(1,2));JButtonbutton1=newJButton(确定);JButtonbutton2=newJButton(结帐);p3.add(button1);p3.add(button2);button1.addActionListener(this);button2.addActionListener(this);//将三个Panel加在内容面板上dialogPane.add(p1,BorderLayout.NORTH);dialogPane.add(p2,BorderLayout.CENTER);dialogPane.add(p3,BorderLayout.SOUTH);f.getRootPane().setDefaultButton(button1);//设置窗体回车对应按钮f.pack();//排版f.setBounds(250,250,400,400);f.addWindowListener(newWindowAdapter(){publicvoidwindowClosing(WindowEventevt){System.exit(0);}});}publicvoiditemStateChanged(ItemEvente)//单选钮被点击时触发{if(e.getSource()==r1)op=1;if(e.getSource()==r2)op=2;if(e.getSource()==r3)op=3;if(e.getSource()==r4)op=4;if(e.getSource()==r5)op=5;if(e.getSource()==c1)i=1;if(e.getSource()==c2)i=2;if(e.getSource()==c3)i=3;if(e.getSource()==c4)i=4;}publicvoidactionPerformed(ActionEvente)//单选按钮被点击时触发{Stringcmd=e.getActionCommand();if(cmd.equals(确定)){try{Class.forName(sun.jdbc.odbc.JdbcOdbcDriver);Connectioncon=DriverManager.getConnection(jdbc:odbc:jiudian,test,1234);Statementstmt=con.createStatement();intm=0,val=0;Stringstr=null;StringSQLOrder;switch(op){case1:{switch(i){case1:m=1;val=25;str=小鸡炖蘑菇;SQLOrder=InsertIntojiudianValues(+m+,'+str+',+val+);stmt.executeUpdate(SQLOrder);case2:m=1;val=18;str=青椒炒肉;SQLOrder=InsertIntojiudianValues(+m+,'+str+',+val+);stmt.executeUpdate(SQLOrder);case3:m=1;val=36;str=东北火锅;SQLOrder=InsertIntojiudianValues(+m+,'+str+',+val+);stmt.executeUpdate(SQLOrder);case4:m=1;val=36;str=豆腐炖鱼头;SQLOrder=InsertIntojiudianValues(+m+,'+str+',+val+);stmt.executeUpdate(SQLOrder);}break;}case2:switch(i){case1:m=2;val=25;str=小鸡炖蘑菇;SQLOrder=InsertIntojiudianValues(+m+,'+str+',+val+);stmt.executeUpdate(SQLOrder);case2:m=2;val=18;str=青椒炒肉;SQLOrder=InsertIntojiudianValues(+m+,'+str+',+val+);stmt.executeUpdate(SQLOrder);case3:m=2;val=36;str=东北火锅;SQLOrder=InsertIntojiudianValues(+m+,'+str+',+val+);stmt.executeUpdate(SQLOrder);case4:m=2;val=36;str=豆腐炖鱼头;SQLOrder=InsertIntojiudianValues(+m+,'+str+',+val+);stmt.executeUpdate(SQLOrder);}case3:switch(i){case1:m=3;val=25;str=小鸡炖蘑菇;SQLOrder=InsertIntojiudianValues(+m+,'+str+',+val+);stmt.executeUpdate(SQLOrder);case2:m=3;val=18;str=青椒炒肉;SQLOrder=InsertIntojiudianValues(+m+,'+str+',+val+);stmt.executeUpdate(SQLOrder);case3:m=3;val=36;str=东北火锅;SQLOrder=InsertIntojiudianValues(+m+,'+str+',+val+);stmt.executeUpdate(SQLOrder);case4:m=3;val=36;str=豆腐炖鱼头;SQLOrder=InsertIntojiudianValues(+m+,'+str+',+val+);stmt.executeUpdate(SQLOrder);}break;case4:switch(i){case1:m=4;val=25;str=小鸡炖蘑菇;SQLOrder=InsertIntojiudianValues(+m+,'+str+',+val+);stmt.executeUpdate(SQLOrder);case2:m=4;val=18;str=青椒炒肉;SQLOrder=InsertIntojiudianValues(+m+,'+str+',+val+);stmt.executeUpdate(SQLOrder);case3:m=4;val=36;str=东北火锅;SQLOrder=InsertIntojiudianValues(+m+,'+str+',+val+);stmt.executeUpdate(SQLOrder);case4:m=4;val=36;str=豆腐炖鱼头;SQLOrder=InsertIntojiudianValues(+m+,'+str+',+val+);stmt.executeUpdate(SQLOrder);}break;case5:switch(i){case1:m=5;val=25;str=小鸡炖蘑菇;SQLOrder=InsertIntojiudianValues(+m+,'+str+',+val+);stmt.executeUpdate(SQLOrder);case2:m=5;val=18;str=青椒炒肉;SQLOrder=InsertIntojiudianValues(+m+,'+str+',+val+);stmt.executeUpdate(SQLOrder);case3:m=5;val=36;str=东北火锅;SQLOrder=InsertIntojiudianValues(+m+,'+str+',+val+);stmt.executeUpdate(SQLOrder);case4:m=5;val=36;str=豆腐炖鱼头;SQLOrder=InsertInto
本文标题:java点菜系统代码
链接地址:https://www.777doc.com/doc-1881799 .html