📄 manage.java
字号:
db.CloseConnection(cn);
db.CloseStatement(stm);
}
String str2="<tr><td><br></td></tr>\n<tr align=center><td>"+splitPage(recordCount,m_pageSize,m_curPage)+"</td></tr>\n";
return (retnStr.equals("")?"<tr><td align=center>很遗憾,没有满足条件的酒店。<input type=button value=\"返回\"onClick=\"history.back()\"></td></tr>":retnStr+str2);
}
/**
* 返回指定酒店的中文名。
* @param hotelid 酒店标识。
* @return 返回一个字符串。代表酒店中文名。
*/
public String getHotelName(int hotelid)
{
String retnStr = new String();
Connection cn = null;
Statement stm = null;
ResultSet rst = null;
try
{
cn=db.getMySQL(mysql_usr,mysql_psw);
stm=cn.createStatement();
rst=stm.executeQuery("select cname from tt_hotel where hotelid="+Integer.toString(hotelid));
if(rst.next())
retnStr=rst.getString("cname");
rst.close();
}
catch(Exception e)
{
Error(e);
}
finally
{
db.CloseConnection(cn);
db.CloseStatement(stm);
}
return retnStr;
}
/**
* 返回指定酒店的英文名。
* @param hotelid 酒店标识。
* @return 返回一个字符串。表示酒店英文名。
*/
public String getHotelEName(int hotelid)
{
String retnStr = new String();
Connection cn = null;
Statement stm = null;
ResultSet rst = null;
try
{
cn=db.getMySQL(mysql_usr,mysql_psw);
stm=cn.createStatement();
rst=stm.executeQuery("select ename from tt_hotel where hotelid="+Integer.toString(hotelid));
if(rst.next())
retnStr=rst.getString("ename");
rst.close();
}
catch(Exception e)
{
Error(e);
}
finally
{
db.CloseConnection(cn);
db.CloseStatement(stm);
}
return retnStr;
}
/**
* 得到指定酒店的付款方式。
* @param hotelid 酒店标识。
* @return 返回一个字符串。酒店的以具体文字描述的付款方式。
*/
public String getPayStyle(int hotelid)
{
String retnStr = new String();
Connection cn = null;
Statement stm = null;
ResultSet rst = null;
try
{
cn=db.getMySQL(mysql_usr,mysql_psw);
stm=cn.createStatement();
rst=stm.executeQuery("select paystyle from tt_hotel where hotelid="+Integer.toString(hotelid));
if(rst.next())
retnStr=rst.getString("paystyle");
rst.close();
}
catch(Exception e)
{
Error(e);
}
finally
{
db.CloseConnection(cn);
db.CloseStatement(stm);
}
return Hotel.getPaystyle(retnStr,0);
}
/**
* 返回酒店坐落城市列表。
* @return 返回一个字符串。生成HTML列表。
*/
public String getCities()
{
String retnStr = new String();
Connection cn = null;
Statement stm = null;
ResultSet rst = null;
try
{
cn=db.getMySQL(mysql_usr,mysql_psw);
stm=cn.createStatement();
String sql=new String();
sql="select distinct city from tt_hotel";
rst=stm.executeQuery(sql);
while(rst.next())
{
retnStr+="<option value="+rst.getString("city")+">"+rst.getString("city")+"</option>\n";
}
rst.close();
}
catch(Exception e)
{
Error(e);
}
finally
{
db.CloseConnection(cn);
db.CloseStatement(stm);
}
return retnStr;
}
/**
* 得到房型。
* @param roomid 房型标识。
* @return 返回一个字符串。酒店的房型。
*/
public String getRoomStyle(int roomid)
{
String retnStr = new String();
Connection cn = null;
Statement stm = null;
ResultSet rst = null;
try
{
cn=db.getMySQL(mysql_usr,mysql_psw);
stm=cn.createStatement();
rst=stm.executeQuery("select roomstyle from tt_price where roomid="+roomid);
if(rst.next())
retnStr=rst.getString("roomstyle");
rst.close();
}
catch(Exception e)
{
Error(e);
}
finally
{
db.CloseConnection(cn);
db.CloseStatement(stm);
}
return retnStr;
}
/**
* 得到房型列表。
* @param hotelid 酒店标识。
* @return
*/
public String getRoomStyleList(int hotelid)
{
String retnStr = new String();
Connection cn = null;
Statement stm = null;
ResultSet rst = null;
try
{
cn=db.getMySQL(mysql_usr,mysql_psw);
stm=cn.createStatement();
rst=stm.executeQuery("select roomid, roomstyle from tt_price where hotelid=" + Integer.toString(hotelid));
int i = 0;
while(rst.next())
{
retnStr+="<input type=\"checkbox\"name=\"roomid\"value=\""+rst.getString("roomid")+"\"id=\"_room"+Integer.toString(i)+"\"><label for=\"_room"+Integer.toString(i++)+"\">"+rst.getString("roomstyle")+"</label><br>\n";
}
rst.close();
}
catch(Exception e)
{
Error(e);
}
finally
{
db.CloseConnection(cn);
db.CloseStatement(stm);
}
return retnStr;
}
/**
* 返回指定酒店的订单部分的房型选择列表。
* @param hotelid 酒店标识。
* @return 返回一个字符串。生成HTML表格。
*/
public String getRoomTable(int hotelid)
{
String retnStr = new String();
Connection cn = null;
Statement stm = null;
ResultSet rst = null;
try
{
cn=db.getMySQL(mysql_usr,mysql_psw);
stm=cn.createStatement();
rst=stm.executeQuery("select roomid, roomstyle,price from tt_price where hotelid=" + Integer.toString(hotelid));
int i = 0;
while(rst.next())
{
retnStr+="<tr>\n";
retnStr+="<td><input type=\"checkbox\"name=\"roomids\"value=\""+rst.getString("roomid")+"\"id=\"_room"+Integer.toString(i)+"\"><label for=\"_room"+Integer.toString(i++)+"\">"+rst.getString("roomstyle")+"</label> ¥"+rst.getString("price")+"<br></td>\n";
retnStr+="<td align=center><input type=\"text\"name=\"rooms_"+rst.getString("roomid")+"\"size=3> 间</td>\n";
retnStr+="<td align=center><select name=\"breakfasts_"+rst.getString("roomid")+"\"><option selected value=0>不含早餐</option><option value=1>中式早餐</option><option value=2>西式早餐</option></select></td>\n";
retnStr+="</tr>\n";
}
rst.close();
}
catch(Exception e)
{
Error(e);
}
finally
{
db.CloseConnection(cn);
db.CloseStatement(stm);
}
return retnStr;
}
/**
* 返回指定酒店的订单部分的房型选择列表,且只包括订单中选择的房型。
* @param orderid 订单标识。
* @return 返回一个字符串。生成HTML表格。
*/
public String getRoomTableOrder(int orderid)
{
String retnStr = new String();
Connection cn = null;
Statement stm = null;
ResultSet rst = null;
try
{
cn = db.getMySQL(mysql_usr,mysql_psw);
stm = cn.createStatement();
rst = stm.executeQuery("select tt_price.roomstyle, rooms, tt_roomlist.breakfast from tt_price, tt_roomlist where tt_roomlist.orderid="+
Integer.toString(orderid)+" and tt_price.roomid=tt_roomlist.roomid");
int curRow = 0;
while(rst.next())
{
retnStr+="<tr>\n";
retnStr+="<td>"+rst.getString("roomstyle")+"</td>\n";
retnStr+="<td align=center>"+rst.getString("rooms")+"</td>\n";
retnStr+="<td align=center>"+transBreakfast(rst.getInt("breakfast"))+"</td>\n";
retnStr+="</tr>\n";
}
rst.close();
}
catch(Exception e)
{
Error(e);
}
finally
{
db.CloseConnection(cn);
db.CloseStatement(stm);
}
return retnStr;
}
/**
* 设置订单信息。
* @param p_order 订单信息。
*/
public void setOrder(Order p_order)
{
m_order = p_order;
}
/**
* 读取订单信息。
* @param orderid 订单信息。
* @return 返回订单信息。
*/
public Order getOrder(int orderid)
{
Connection cn = null;
Statement stm = null;
ResultSet rst = null;
try
{
cn = db.getMySQL(mysql_usr,mysql_psw);
stm = cn.createStatement();
rst = stm.executeQuery("select * from tt_order where orderid="+Integer.toString(orderid));
if(rst.next())
{
m_order.setBooker(rst.getString("booker"));
m_order.setCertificatecode(rst.getString("certificatecode"));
m_order.setCertificate(rst.getString("certificate"));
m_order.setCompany(rst.getString("company"));
m_order.setEarliestarrive(rst.getString("earliestarrive"));
m_order.setFax(rst.getString("fax"));
m_order.setHandset(rst.getString("handset"));
m_order.setHotelid(rst.getInt("hotelid"));
m_order.setHowby(rst.getString("howby"));
m_order.setIndate(rst.getString("indate"));
m_order.setLatestarrive(rst.getString("latestarrive"));
m_order.setLinkman(rst.getString("linkman"));
m_order.setMemo(rst.getString("memo"));
m_order.setNumber(rst.getString("number"));
m_order.setOrderid(rst.getInt("orderid"));
m_order.setOutdate(rst.getString("outdate"));
m_order.setReceive(rst.getString("receive"));
m_order.setTel(rst.getString("tel"));
}
rst.close();
}
catch(Exception e)
{
Error(e);
}
finally
{
db.CloseConnection(cn);
db.CloseStatement(stm);
}
return m_order;
}
/**
* 删除订单信息。
* @param orderid 订单标识。
*/
public void deleteOrder(int orderid)
{
String sql = new String();
sql="delete from tt_order where orderid="+Integer.toString(orderid);
deleteData(sql);
sql="delete from tt_roomlist where orderid="+Integer.toString(orderid);
deleteData(sql);
}
/**
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -