📄 customer.java
字号:
/*
* @(#)Customer.java 1.0 05/10/10
*
* Copyright 2005 HUST Hotel, Inc. All rights reserved.
*/
package net.husthotel.beans;
import java.sql.SQLException;
import java.util.ResourceBundle;
import javax.faces.model.SelectItem;
import net.husthotel.datebase.NoRoomAvailableException;
import net.husthotel.datebase.OrderDAO;
/**
* 代表客户对象;可以提交订单.
* @author icerain
* @version 1.0
*/
public class Customer extends AbstractOrder {
//加载国际化和本地化绑定资源
private static ResourceBundle roomTypeBundle = ResourceBundle.getBundle("property.roomType");
//设置JSF中的选项
private SelectItem[] roomTypeListItems = new SelectItem[] {
new SelectItem("standard",roomTypeBundle.getString("standard")),
new SelectItem("deluxe",roomTypeBundle.getString("deluxe")),
new SelectItem("presidentialSuit",roomTypeBundle.getString("presidentialSuit"))
};
public Customer() {
}
public SelectItem[] getRoomTypeListItems() {
return roomTypeListItems;
}
public void setRoomTypeListItems(SelectItem[] roomTypeList) {
this.roomTypeListItems = roomTypeList;
}
/**
* 将输入信息提交给OrderDAO.create(Customer)。
* 如果返回信息为ORDER_SUCCESS(int1)提示客户创建Order成功,
* 如果返回信息为NO_AVAILABLE_ROOM(int -1)提示客户所订的房间类型已经没有了,
* 提示客户更改房间类型;如果返回信息为ORDER_EXIST(int 0)提示客户已经预定了房间.
* 根据以上信息分别返回"reservationSuc","noAvailableRoom","reservationFail"
* @return a string is "reservationSuc" or "noAvailableRoom" or "reservationFail"
*/
public String submitOrderAction() {
//-----------------------------
System.out.println("submit order action.");
try {
if (null != new OrderDAO().create(this))
return "reservationSuc";
} catch (NoRoomAvailableException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return "noAvailableRoom";
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return "reservationFail";
}
return "reservationSuc";
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -