⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 restaurant.java

📁 java版虚拟社区,在mysql上运行.
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
    			}
    			else if("false".equals(mm.GetType()))
    			{
    				JOptionPane.showMessageDialog(null,"No record!");
    			}	
    			else
    			{
    				JOptionPane.showMessageDialog(null,"Error!");
    			}
    		}catch(Exception ie)
    		{
    			JOptionPane.showMessageDialog(null,"Network exception,please exit and log!");
    		}
    	}
    	private void Payback()
    	{
    		try{
    			mm.SetType("Payback");
    			mm.SetNum(2);
    			mm.SetMes(id, 0);
    			mm.SetMes(""+bankrecord_jTable.getValueAt(RowNumBank, 2), 1);
    			mes.SendMessage(mm);
    			mes.GetMessage(mm);
    			if("true".equals(mm.GetType()))
    			{
    				JOptionPane.showMessageDialog(null,"Payback success!");
    				bankrecord_jTable.setValueAt("payed",RowNumBank, 0);
    			}
    			else if("notenough".equals(mm.GetType()))
    			{
    				JOptionPane.showMessageDialog(null,"Banance not enough!");
    			}	
    			else
    			{
    				JOptionPane.showMessageDialog(null,"Error!");
    			}
    		}catch(Exception ie)
    		{
    			JOptionPane.showMessageDialog(null,"Network exception,please exit and log!");
    		}
    	}
        public void SendAddMenuImformation()
        {
                if("".equals(FoodNameTextField.getText()))
                {
                    JOptionPane.showMessageDialog(null,"Enter foodname.");
                }
                else if("".equals(PriceTextField.getText()))
                {
                    JOptionPane.showMessageDialog(null,"Enter price.");
                }
                else{
                    try {
                        mm.SetType("RestaurantAddToMenu");
                        mm.SetNum(3);
                        mm.SetMes(id, 0);
                        mm.SetMes(FoodNameTextField.getText(), 1);
                        mm.SetMes(PriceTextField.getText(), 2);
                        mes.SendMessage(mm);
                        mes.GetMessage(mm);
                        if ("true".equals(mm.GetType())) {
                            JOptionPane.showMessageDialog(null, "Add succeed!");
                            FoodNameTextField.setText("");
                            PriceTextField.setText("");
                        } else {
                            JOptionPane.showMessageDialog(null, "Add failed!");
                        }
                    } catch (Exception ie) {
                        JOptionPane.showMessageDialog(null,
                                "Network exception,please exit and log!");
                    }
                }
        }

        public void GetMenuViewImfor()
        {
            try{
                   mm.SetType("RestaurantMenuView");
                   mm.SetNum(1);
                   mm.SetMes(id,0);
                   mes.SendMessage(mm);
                   mes.GetMessage(mm);
                   if("true".equals(mm.GetType()))
                   {
                       MenuViewdatamode = new DefaultTableModel(null,MenuViewColumnname)
                       {
                           public boolean isCellEditable(int row, int column) {
                               return false;
                           }

                       };
                       MenuViewTable.setModel(MenuViewdatamode);
                       MenuViewTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

                       int n = mm.GetNum()/2;
                       for(int i = 0; i < n; i++)
                       {
                                MenuViewdatamode.addRow(new Object[]{mm.GetMes(2*i),mm.GetMes(2*i+1)});
                       }


                   }
                   else if("false".equals(mm.GetType()))
                   {
                           JOptionPane.showMessageDialog(null,"No menu!");
                   }

                   else
                   {
                        JOptionPane.showMessageDialog(null,"Wrong!");
                   }

               }catch(Exception ie){
                   JOptionPane.showMessageDialog(null,"Network exception,please exit and log!");
               }

        }

        public void GetCustomerImfor()
        {
            try{
                   mm.SetType("RestaurantCustomerView");
                   mm.SetNum(1);
                   mm.SetMes(id,0);
                   mes.SendMessage(mm);
                   mes.GetMessage(mm);
                   if("true".equals(mm.GetType()))
                   {
                       CustomerViewdatamode = new DefaultTableModel(null,CustomerViewColumnname)
                       {
                           public boolean isCellEditable(int row, int column) {
                               return false;
                           }

                       };
                       CustomerViewTable.setModel(CustomerViewdatamode);
                       CustomerViewTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

                       int n = mm.GetNum()/5;
                       for(int i = 0; i < n; i++)
                       {
                                CustomerViewdatamode.addRow(new Object[]{mm.GetMes(5*i),mm.GetMes(5*i+1),mm.GetMes(5*i+2),mm.GetMes(5*i+3),mm.GetMes(5*i+4)});
                       }


                   }
                   else if("false".equals(mm.GetType()))
                   {
                           JOptionPane.showMessageDialog(null,"No customer!");
                   }

                   else
                   {
                        JOptionPane.showMessageDialog(null,"Wrong!");
                   }

               }catch(Exception ie){
                   JOptionPane.showMessageDialog(null,"Network exception,please exit and log!");
               }

        }
        public void GetFinanceImfor()
        {
            try{
                   mm.SetType("RestaurantFinanceView");
                   mm.SetNum(1);
                   mm.SetMes(id,0);
                   mes.SendMessage(mm);
                   mes.GetMessage(mm);
                   if("true".equals(mm.GetType()))
                   {
                       FinanceTextField.setText(mm.GetMes(0));
                       FinanceTextField.setEditable(false);
                   }
                   else if("false".equals(mm.GetType()))
                   {
                           JOptionPane.showMessageDialog(null,"No Finance Imfor!");
                   }

                   else
                   {
                        JOptionPane.showMessageDialog(null,"Wrong!");
                   }

               }catch(Exception ie){
                   JOptionPane.showMessageDialog(null,"Network exception,please exit and log!");
               }

        }


    public void AddtoMenuButton_actionPerformed(ActionEvent e) {
        AddMenuPanel.setVisible(true);
        MenuViewPanel.setVisible(false);
        bankPanel.setVisible(false);
        bankenterPanel.setVisible(false);
        regaccountPanel.setVisible(false);
        CustomerViewPanel.setVisible(false);
        FinancePanel.setVisible(false);
        note_jLabel.setText("You are in Adding menu.");
    }

    public void OKButton_actionPerformed(ActionEvent e) {
        SendAddMenuImformation();
    }

    public void CancelButton_actionPerformed(ActionEvent e) {
        FoodNameTextField.setText("");
        PriceTextField.setText("");
    }

    public void MenuViewButton_actionPerformed(ActionEvent e) {
        AddMenuPanel.setVisible(false);
        MenuViewPanel.setVisible(true);
        bankPanel.setVisible(false);
        bankenterPanel.setVisible(false);
        regaccountPanel.setVisible(false);
        CustomerViewPanel.setVisible(false);
        FinancePanel.setVisible(false);
        GetMenuViewImfor();
        note_jLabel.setText("You are in menu imformation.");
    }

    public void CustomerViewButton_actionPerformed(ActionEvent e) {
        AddMenuPanel.setVisible(false);
        MenuViewPanel.setVisible(false);
        bankPanel.setVisible(false);
        bankenterPanel.setVisible(false);
        regaccountPanel.setVisible(false);
        CustomerViewPanel.setVisible(true);
        FinancePanel.setVisible(false);
        GetCustomerImfor();
        note_jLabel.setText("You are in customer imformation.");

    }

    public void FinanceButton_actionPerformed(ActionEvent e) {
        AddMenuPanel.setVisible(false);
        MenuViewPanel.setVisible(false);
        bankPanel.setVisible(false);
        bankenterPanel.setVisible(false);
        regaccountPanel.setVisible(false);
        CustomerViewPanel.setVisible(false);
        FinancePanel.setVisible(true);
        GetFinanceImfor();
        note_jLabel.setText("You are in finance imformation.");

    }

}


class Restaurant_FinanceButton_actionAdapter implements ActionListener {
    private Restaurant adaptee;
    Restaurant_FinanceButton_actionAdapter(Restaurant adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.FinanceButton_actionPerformed(e);
    }
}


class Restaurant_CustomerViewButton_actionAdapter implements ActionListener {
    private Restaurant adaptee;
    Restaurant_CustomerViewButton_actionAdapter(Restaurant adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.CustomerViewButton_actionPerformed(e);
    }
}


class Restaurant_MenuViewButton_actionAdapter implements ActionListener {
    private Restaurant adaptee;
    Restaurant_MenuViewButton_actionAdapter(Restaurant adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.MenuViewButton_actionPerformed(e);
    }
}


class Restaurant_CancelButton_actionAdapter implements ActionListener {
    private Restaurant adaptee;
    Restaurant_CancelButton_actionAdapter(Restaurant adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.CancelButton_actionPerformed(e);
    }
}


class Restaurant_OKButton_actionAdapter implements ActionListener {
    private Restaurant adaptee;
    Restaurant_OKButton_actionAdapter(Restaurant adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.OKButton_actionPerformed(e);
    }
}


class Restaurant_AddtoMenuButton_actionAdapter implements ActionListener {
    private Restaurant adaptee;
    Restaurant_AddtoMenuButton_actionAdapter(Restaurant adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.AddtoMenuButton_actionPerformed(e);
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -