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

📄 restaurant.java

📁 这个一个餐厅预定系统,可实现查询目前餐厅预订情况,实现餐桌预订以及就餐时为顾客调节餐桌的情况.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
           ConnectionDB.close(rs2);
           ConnectionDB.close(st2);
           ConnectionDB.close(rs3);
           ConnectionDB.close(st3);
           ConnectionDB.close(cn);



       }
       else if (isDateBefore(stdTime3,nowTime)&&isDateBefore(nowTime,stdTime4))
       {
           try{
           String arrvialtime = "18:00-20:00";

           String sqlget1 = "select TALNO from RESERVATION where ARRIVALDATE= '" + nowDate+ "' and ARRIVALTIME ='"+arrvialtime+"' and ISARRIVAL="+isarrival_false+" and ISPAYBILL = "+ispaybill_false;
           st1 =cn.createStatement();
           rs1 = st1.executeQuery(sqlget1);
           while (rs1.next())
           {
               String temptalno = rs1.getString("talno");
               String sqlupdate = "update T_TABLE set STATE=? where TALNO=?";
               try {
                   PreparedStatement ps = cn.prepareStatement(sqlupdate);
                   ps.setString(1,"reservation");
                   ps.setString(2,temptalno);
                   ps.executeUpdate();
           } catch (SQLException e) {
                   e.printStackTrace();
           }


           }
           String sqlget2 = "select TALNO from RESERVATION where ARRIVALDATE= '" + nowDate+ "' and ARRIVALTIME ='"+arrvialtime+"' and ISARRIVAL="+isarrival_true+" and ISPAYBILL = "+ispaybill_false;
           st2 = cn.createStatement();
           rs2 = st2.executeQuery(sqlget2);
           while (rs2.next())
           {
               String temptalno = rs2.getString("talno");
               String sqlupdate = "update T_TABLE set STATE=? where TALNO=?";
               try {
                   PreparedStatement ps = cn.prepareStatement(sqlupdate);
                   ps.setString(1,"dining");
                   ps.setString(2,temptalno);
                   ps.executeUpdate();
           } catch (SQLException e) {
                   e.printStackTrace();
           }


           }
         String sqlget3 = "select TALNO from RESERVATION where ARRIVALDATE= '" + nowDate+ "' and ARRIVALTIME ='"+arrvialtime+"' and ISARRIVAL="+isarrival_true+" and ISPAYBILL = "+ispaybill_true;
          st3 = cn.createStatement();
          rs3 = st3.executeQuery(sqlget3);
          while (rs3.next())
          {
              String temptalno = rs3.getString("talno");
              String sqlupdate = "update T_TABLE set STATE=? where TALNO=?";
              try {
                  PreparedStatement ps = cn.prepareStatement(sqlupdate);
                  ps.setString(1,"free");
                  ps.setString(2,temptalno);
                  ps.executeUpdate();
          } catch (SQLException e) {
                  e.printStackTrace();
          }


          }

           }catch(SQLException e)
           {
               e.printStackTrace();
           }
           ConnectionDB.close(rs1);
           ConnectionDB.close(st1);
           ConnectionDB.close(rs2);
           ConnectionDB.close(st2);
           ConnectionDB.close(rs3);
           ConnectionDB.close(st3);
           ConnectionDB.close(cn);


       }
       else if (isDateBefore(stdTime5,nowTime)&&isDateBefore(nowTime,stdTime6))
       {
           try{
           String arrvialtime = "20:00-22:00";

           String sqlget1 = "select TALNO from RESERVATION where ARRIVALDATE= '" + nowDate+ "' and ARRIVALTIME ='"+arrvialtime+"' and ISARRIVAL="+isarrival_false+" and ISPAYBILL = "+ispaybill_false;
           st1 =cn.createStatement();
           rs1 = st1.executeQuery(sqlget1);
           while (rs1.next())
           {
               String temptalno = rs1.getString("talno");
               String sqlupdate = "update T_TABLE set STATE=? where TALNO=?";
               try {
                   PreparedStatement ps = cn.prepareStatement(sqlupdate);
                   ps.setString(1,"reservation");
                   ps.setString(2,temptalno);
                   ps.executeUpdate();
           } catch (SQLException e) {
                   e.printStackTrace();
           }


           }
           String sqlget2 = "select TALNO from RESERVATION where ARRIVALDATE= '" + nowDate+ "' and ARRIVALTIME ='"+arrvialtime+"' and ISARRIVAL="+isarrival_true+" and ISPAYBILL = "+ispaybill_false;
           st2 = cn.createStatement();
           rs2 = st2.executeQuery(sqlget2);
           while (rs2.next())
           {
               String temptalno = rs2.getString("talno");
               String sqlupdate = "update T_TABLE set STATE=? where TALNO=?";
               try {
                   PreparedStatement ps = cn.prepareStatement(sqlupdate);
                   ps.setString(1,"dining");
                   ps.setString(2,temptalno);
                   ps.executeUpdate();
           } catch (SQLException e) {
                   e.printStackTrace();
           }


           }
         String sqlget3 = "select TALNO from RESERVATION where ARRIVALDATE= '" + nowDate+ "' and ARRIVALTIME ='"+arrvialtime+"' and ISARRIVAL="+isarrival_true+" and ISPAYBILL = "+ispaybill_true;
          st3 = cn.createStatement();
          rs3 = st3.executeQuery(sqlget3);
          while (rs3.next())
          {
              String temptalno = rs3.getString("talno");
              String sqlupdate = "update T_TABLE set STATE=? where TALNO=?";
              try {
                  PreparedStatement ps = cn.prepareStatement(sqlupdate);
                  ps.setString(1,"free");
                  ps.setString(2,temptalno);
                  ps.executeUpdate();
          } catch (SQLException e) {
                  e.printStackTrace();
          }


          }

           }catch(SQLException e)
           {
               e.printStackTrace();
           }
           ConnectionDB.close(rs1);
           ConnectionDB.close(st1);
           ConnectionDB.close(rs2);
           ConnectionDB.close(st2);
           ConnectionDB.close(rs3);
           ConnectionDB.close(st3);
           ConnectionDB.close(cn);

       }







   }
   /**
    * 这个函数判断时间的先后返回BOOLEAN类型
    * @param date1 String
    * @param date2 String
    * @return boolean
    */
   public static boolean isDateBefore(String date1,String date2){
     try{
          DateFormat   df   =   new   SimpleDateFormat("yyyy-MM-dd HH:mm",Locale.SIMPLIFIED_CHINESE);
          boolean i = df.parse(date1).before(df.parse(date2));
          System.out.println(i);
          return df.parse(date1).before(df.parse(date2));

     }catch(ParseException e){
       System.out.print("[SYS] " + e.getMessage());
        return false;
    }

   }





   public Vector getAllTables() throws SQLException {
       Vector allTable = new Vector();
       Statement st;
       ResultSet rs;

       String sql = "SELECT * FROM T_TABLE";
       st = cn.createStatement();
       rs = st.executeQuery(sql);
       while(rs.next())
       {
           allTable.add(new Table(rs.getString("TALNO")));
       }
       return allTable;

   }

   public Vector getAllCustomer() throws SQLException {
       Vector allCustomer = new Vector();
       Statement st;
       ResultSet rs;

      String sql = "SELECT * FROM CUSTOMER";
      st = cn.createStatement();
      rs = st.executeQuery(sql);
      while(rs.next())
      {
          allCustomer.add(new Customer(rs.getInt("CNO")));
      }
      cn.close();
      return allCustomer;

   }



}

⌨️ 快捷键说明

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