?? restaurant.java~40~
字號:
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);
System.out.print(df.parse(date1).before(df.parse(date2)));
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")));
}
return allCustomer;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -