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

📄 booking_fr.java

📁 java开发
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
        contentPane.add(table7, new XYConstraints(357, 122, 105, 55));
        contentPane.add(table6, new XYConstraints(194, 122, 105, 55));
        contentPane.add(table5, new XYConstraints(45, 122, 105, 55));
        contentPane.add(table9, new XYConstraints(45, 220, 105, 55));
        contentPane.add(table13, new XYConstraints(45, 319, 105, 55));
        contentPane.add(table14, new XYConstraints(194, 319, 105, 55));
        contentPane.add(table11, new XYConstraints(357, 220, 105, 55));
        contentPane.add(table15, new XYConstraints(357, 319, 105, 55));
        contentPane.add(table16, new XYConstraints(500, 319, 105, 55));
        contentPane.add(table12, new XYConstraints(500, 220, 105, 55));
        contentPane.add(jButton7, new XYConstraints(2, 29, 638, 3));
        contentPane.add(jButton5, new XYConstraints(323, 29, 3, 358));
        contentPane.add(date1, new XYConstraints(5, 1, -1, 24));
        contentPane.add(jButton8, new XYConstraints(100, 1, 64, 28));
        setJMenuBar(jMenuBar1);
    }

    /**
     * File | Exit action performed.
     *
     * @param actionEvent ActionEvent
     */
    void jMenuFileExit_actionPerformed(ActionEvent actionEvent) {
        System.exit(0);
    }
    /////////////////////获取当前日期前一天/////////////////////////////////////
  /////////////////////////////////////////////////////////////////////////
  public Date currentDateSubOne()
  {
      Date   currentDay   =   new   Date();
      Calendar   cal   =  Calendar.getInstance();
      cal.setTime(currentDay) ;
      cal.add(cal.DAY_OF_MONTH ,-1);
      Date   daySubOne   =   cal.getTime() ;
      return daySubOne;
  }
  //////////////////////////////日期合法性判断/////////////////////////////
  ///////////////////////////////////////////////////////////////////////
  public boolean dateJudge(Date date)
  {
      if(this.getCalendarDate().before(date))
     {
         JOptionPane.showConfirmDialog(null,"您选择了一个过去的日期,操作失败!","选择",-1);
         return false;
     }
     else
         return true;
  }
  ////////////////////////根据桌号得到对应JLabel对象//////////////////////////
   /////////////////////////////////////////////////////////////////////////
   public JLabel getTableObjByTno(int tno)
   {
       return (JLabel)(vector.get(tno-1));
   }
   //////////////////////根据桌子Text信息得到桌号//////////////////////////////
   ////////////////////////////////////////////////////////////////////////
   public int getTableTnoByText(String tableText)
   {
       int i = 0;
       for( i=0;i<vector.size();i++)
       {
           if(((JLabel)vector.get(i)).getText().trim()==tableText)
           {
               break;
           }
       }
       return i+1;
   }
 ///////////////////////////////响应右键第一个菜单项////////////////////////
    /////////////////////////////////////////////////////////////////////////
    void menuItem1_actionPerformed(ActionEvent e)
    {
        if(dateJudge(this.currentDateSubOne())==false)
       {
           return;
       }

        AddReservation dlg = new AddReservation() ;
        dlg.setLocation(400,300) ;
        dlg.SetControlDate(getStrCalendarDate());
        if(tip==1)
        {
            dlg.SetControlTno(tempTno);
            dlg.enableControlTno(false);
            if((this.getTableObjByTno(tempTno)).getBackground()==Color.green )
         {
             JOptionPane.showConfirmDialog(null,"您所选择的时间当前选择餐桌已经预约,不能执行预约!","预约失败!",-1);
             return;
         }
         if((this.getTableObjByTno(tempTno)).getBackground()==Color.red )
         {
             JOptionPane.showConfirmDialog(null,"您所选择的时间当前餐桌已经有人就餐,不能执行预约!","预约失败!",-1);
             return;
         }

            tip = 0;
        }
        dlg.show();
        if(dlg.isConfirm == false)
        {
            return;
        }
        else
        {
            this.makeReservation(this.getCalendarDate(),dlg.getTno(),dlg.getStrName(),dlg.GetTel()) ;
            return;
        }


    }
    ////////////////////////////////响应右键第二个菜单项////////////////////////
    /////////////////////////////////////////////////////////////////////////
    void menuItem2_actionPerformed(ActionEvent e)
    {
        if(dateJudge(this.currentDateSubOne())==false)
       {
           return;
       }

        RecordArrival dlg = new RecordArrival() ;
        dlg.setLocation(400,300);
        dlg.SetControlDate(getStrCalendarDate());
        if(tip==1)
        {
            dlg.SetControlTno(tempTno);
            dlg.enableControlTno(false);
            if((this.getTableObjByTno(tempTno)).getBackground()==Color.yellow  )
       {
           JOptionPane.showConfirmDialog(null,"您所选择的时间当前选择餐桌还没有预约,不可能预约到达!","预约到达执行失败!",-1);
           return;
       }
       if((this.getTableObjByTno(tempTno)).getBackground()==Color.red )
       {
           JOptionPane.showConfirmDialog(null,"您所选择的时间当前餐桌已经有人就餐,预约不可能到达!","预约到达执行失败!",-1);
           return;
       }

            tip = 0;
        }
        dlg.show();
        if(dlg.isConfirm == false)
        {
            return;
        }
        else
        {
              recoreArrival(this.getCalendarDate(),tempTno);
            return;
        }
    }
    ////////////////////////////////响应右键第三个菜单项////////////////////////
    /////////////////////////////////////////////////////////////////////////
    void menuItem3_actionPerformed(ActionEvent e)
    {
        if(dateJudge(this.currentDateSubOne())==false)
       {
           return;
       }
        Cancel dlg = new Cancel() ;
        dlg.setLocation(400,300);
        dlg.SetControlDate(getStrCalendarDate());
        if(tip==1)
       {
           dlg.SetControlTno(tempTno);
           dlg.enableControlTno(false);
           if((this.getTableObjByTno(tempTno)).getBackground()==Color.red)
          {
              JOptionPane.showConfirmDialog(null,"您选择时间的餐桌正在用餐!","取消预约失败!",-1);
              return;
          }
          if((this.getTableObjByTno(tempTno)).getBackground()== Color.yellow )
          {
              JOptionPane.showConfirmDialog(null,"您选择时间的当前餐桌还没有被预约!","取消预约失败!",-1);
              return;
          }
          tip = 0;
     }
     dlg.show();
     if(dlg.isConfirm == false)
     {
         return;
      }
     else
     {

         this.Cancel(this.getCalendarDate(),dlg.getTno());
         return;
      }
  }


    ////////////////////////////////响应右键第四个菜单项////////////////////////
    /////////////////////////////////////////////////////////////////////////
    void menuItem4_actionPerformed(ActionEvent e)
    {
        if(dateJudge(this.currentDateSubOne())==false)
        {
            return;
        }
        TableChange dlg = new TableChange();
        dlg.setLocation(400,300);
        dlg.SetControlDate(getStrCalendarDate());
        if(tip==1)
       {
          dlg.SetControlTno(tempTno);
          dlg.enableControlTno(false);
          if((this.getTableObjByTno(tempTno)).getBackground()==Color.yellow  )
         {
             //JOptionPane.showConfirmDialog(null,"您所指定的餐桌还没有预约,不能执行餐桌调换!","餐桌调换失败!",-1);
             return;
         }
         if((this.getTableObjByTno(tempTno)).getBackground()==Color.red )
         {
             //JOptionPane.showConfirmDialog(null,"您所指定的餐桌已经有人就餐,不能执行餐桌调换!","餐桌调换失败!",-1);
             return;
         }
          tip = 0;
      }
      dlg.show();
      if(dlg.isConfirm == false)
      {
          return;
      }
      else
      {
          transferTable(this.getCalendarDate(),dlg.getTno(),dlg.getTnoChange());
          return;
      }
  }
    //////////////////////////响应右键第五个菜单///////////////////////////////
    //////////////////////////////////////////////////////////////////////////////
    void menuItem5_actionPerformed(ActionEvent e)
    {
        if(dateJudge(this.currentDateSubOne())==false)
      {
          return;
      }

        MakeWalkIn dlg = new MakeWalkIn();
        dlg.setLocation(400,300);
        dlg.SetControlDate(getStrCalendarDate());
        if(tip==1)
       {
           dlg.SetControlTno(tempTno);
           dlg.enableControlTno(false);
           if((this.getTableObjByTno(tempTno)).getBackground()==Color.green )
         {
             JOptionPane.showConfirmDialog(null,"您所选择时间的选择餐桌已经被预约,不能执行未约就餐!","未约就餐失败!",-1);
             return;
         }
         if((this.getTableObjByTno(tempTno)).getBackground()==Color.red )
         {
             JOptionPane.showConfirmDialog(null,"您所选择时间的选择餐桌已经有人就餐,不能未约就餐!","未约就餐失败!",-1);
             return;
         }
           tip = 0;
       }

        dlg.show();
        if(dlg.isConfirm == false)
        {
            return;
        }
        else
        {
            this.walkIn(5,this.getCalendarDate(),dlg.getTno());
            return;
        }
    }

    public void update(Observable arg0, Object arg1)
  {
      Vector vector1 = this.getstate();
      for(int i=0;i<=15;i++)
      {
          ((JLabel)vector.get(i)).setBackground(((Color)vector1.get(i)));
      }




  }
  /////////////////////////////////初始显示预约函数////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////
  public void displayBooking(Date d)
  {
      bookingSystem.Display(d);
      //////////////////////////调用底层函数//////////////////////////////////////
  }
  ////////////////////////////////增加预约函数  ///////////////////////////////
    /////////////////////////////////////////////////////////////////////////
  public void makeReservation(Date d, int tno, String name, String phone)
  {
      bookingSystem.makeReservation(d,tno,name,phone);
      //////////////////调用下层///////////////////////
  }
  ////////////////////////////////取消预约函数////////////////////////////////
  //////////////////////////////////////////////////////////////////////////
  public void Cancel(Date date,int tno)
  {
      bookingSystem.cancel(date,tno);
       ///////////////////////调用下层/////////////////////////////////////
  }
  //////////////////////////////////预约到达函数////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////
  public void recoreArrival(Date date,int tno)
  {
      bookingSystem.recordArrival(date,tno);
      //////////////////////////调用下层函数/////////////////////////////////////
  }
  //////////////////////////////////更换餐桌函数/////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////
  public void transferTable(Date date,int originTable,int destTable)
  {
      bookingSystem.Transfer(date,originTable,destTable);
      //////////////////////////////调用下层函数//////////////////////////////////
  }
  ///////////////////////////////////用户未预约直接到达//////////////////////////////
  //////////////////////////////////////////////////////////////////////////////
  public void walkIn(int guestNo,Date date,int tno)
  {
      bookingSystem.makeWalkln(guestNo,date,tno);
      ///////////////////////////////调用下层函数//////////////////////////////
  }
///////////////////桌子响应鼠标点击事件/////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////
    public void mouseClicked(MouseEvent e)
    {
        ////////////////可用函数替换///////////////////////////////////////////////////////
        dragFlag = 0;
        String strTable = ((JLabel)e.getSource()).getText().trim();
        tempTno=getTableTnoByText(strTable);
        int mods=e.getModifiers();
       //鼠标右键
       if((mods&InputEvent.BUTTON3_MASK)!=0)
       {
            tip = 1;//弹出菜单
            popupMenu1.show(this,e.getX()+220,e.getY()+140);
            tempTabelText = strTable;
       }
       int a  = e.getClickCount() ;
       if(e.getClickCount()==2)
    {
        //////////////////////////当前餐桌为未预约状态,不可能出现记录到达////////////////////////
        if(((JLabel)vector.get(tempTno-1)).getBackground()==Color.yellow  )
        {
              //JOptionPane.showConfirmDialog(null,"该餐桌还没有被预约,顾客不可能到达!","操作错误",-1);
              return;
        }
        //////////////////////////当前餐桌已经有人用餐,不可能记录到达//////////////////////////////
        if(((JLabel)vector.get(tempTno-1)).getBackground()==Color.red)
        {
              //JOptionPane.showConfirmDialog(null,"该餐桌客户正在用餐,顾客不可能到达!","操作错误",-1);
            return;
        }
        String message = Integer.toString(tempTno);
        message+="号餐桌客人来到?确定吗?";
        if(JOptionPane.showConfirmDialog(null,message,"选择",0)==0)
        {
            recoreArrival(this.getCalendarDate(),tempTno);
        }
        else
            return;
    }

    }
    ///////////////////整个区域响应鼠标点击事件/////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////
    public void frame_mouseClicked(MouseEvent e)
    {
        dragFlag = 0;
        tip = 0;
        int mods=e.getModifiers();
        //鼠标右键
        if((mods&InputEvent.BUTTON3_MASK)!=0)
        {
            //弹出菜单
             popupMenu1.show(this,e.getX(),e.getY());
        }
    }
    /////////////////////// 得到日期控件的日期Date形式//////////////////////////
    ////////////////////////////////////////////////////////////////////////////
    public Date getCalendarDate()
    {
        try {
            return date1.getSelectedDate();
        } catch (ParseException ex) {
            return null;
        }
    }
    //////////////////////////得到日期控件的String形式////////////////////////////
    ////////////////////////////////////////////////////////////////////////
    public String getStrCalendarDate()
    {
        Date newDate = null;
        try {
            newDate = date1.getSelectedDate();
        } catch (ParseException ex) {
        }
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");

⌨️ 快捷键说明

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