📄 manage.java
字号:
}
/**
* 设置酒店信息。
* @param p_hotel 酒店信息。
*/
public void setHotel(Hotel p_hotel)
{
this.m_hotel=p_hotel;
}
/**
* 读取酒店信息。
* @param hotelid 酒店标识。
* @return 酒店信息。
*/
public Hotel getHotel(int hotelid)
{
Connection cn = null;
Statement stm = null;
ResultSet rst = null;
try
{
cn=db.getMySQL(mysql_usr,mysql_psw);
stm=cn.createStatement();
String sql="select * from tt_hotel where hotelid="+Integer.toString(hotelid);
rst=stm.executeQuery(sql);
while(rst.next())
{
m_hotel.setAccountstyle(rst.getString("accountstyle"));
m_hotel.setAddbed(rst.getString("addbed"));//
m_hotel.setAddress(rst.getString("address"));;
m_hotel.setCbreakfast(rst.getString("cbreakfast"));//
m_hotel.setCity(rst.getString("city"));
m_hotel.setCname(rst.getString("cname"));
m_hotel.setDaccount(rst.getString("daccount"));
m_hotel.setDbank(rst.getString("dbank"));
m_hotel.setEmail(rst.getString("email"));
m_hotel.setEname(rst.getString("ename"));
m_hotel.setExchangerate(rst.getString("exchangerate"));
m_hotel.setFax(rst.getString("fax"));
m_hotel.setGuidebed(rst.getString("guidebed"));//
m_hotel.setHomepage(rst.getString("homepage"));
m_hotel.setIntr(rst.getString("intr"));
m_hotel.setLevel(rst.getString("level"));
m_hotel.setLinkman(rst.getString("linkman"));
m_hotel.setPaystyle(rst.getString("paystyle"));
m_hotel.setPicid(rst.getInt("picid"));
m_hotel.setRaccount(rst.getString("raccount"));
m_hotel.setRbank(rst.getString("rbank"));
m_hotel.setTel(rst.getString("tel"));
m_hotel.setWbreakfast(rst.getString("wbreakfast"));//
m_hotel.setZip(rst.getString("zip"));
}
}
catch(Exception e)
{
Error(e);
}
finally
{
db.CloseConnection(cn);
db.CloseStatement(stm);
}
return m_hotel;
}
//-------------------------【 用于后台管理 】-------------------------
/**
* 添加房价信息。
*/
public void insertPrice()
{
String sql = new String();
sql="insert into tt_price (";
sql+="hotelid, roomstyle, breakfast, gprice, price, groupprice, startdate, ";
sql+="enddate, tprice, memo) values (";
sql+="'"+m_price.getHotelid()+"','"+m_price.getRoomstyle()+"','"+Integer.toString(m_price.getBreakfast())+"','";
sql+=m_price.getGprice()+"','";
sql+=m_price.getPrice()+"','"+m_price.getGroupprice()+"','"+m_price.getStartdate()+"','";
sql+=m_price.getEnddate()+"','";
sql+=m_price.getTprice()+"','"+m_price.getMemo()+"'";
sql+=")";
insertData(sql);
}
//-------------------------【 用于后台管理 】-------------------------
/**
* 删除房价信息。
* @param roomid 房价标识。
*/
public void deletePrice(int roomid)
{
String sql = new String();
sql="delete from tt_price where roomid="+Integer.toString(roomid);
deleteData(sql);
}
//-------------------------【 用于后台管理 】-------------------------
/**
* 更新房价信息。
* @param roomid 房价标识。
*/
public void updatePrice(int roomid)
{
String sql = new String();
sql+="update tt_price set ";
sql+="hotelid='"+m_price.getHotelid()+"', roomstyle='"+m_price.getRoomstyle()+"', breakfast='"+m_price.getBreakfast()+"', ";
sql+="gprice='"+m_price.getGprice()+"', ";
sql+="price='"+m_price.getPrice()+"', groupprice='"+m_price.getGroupprice()+"', startdate='"+m_price.getStartdate()+"', ";
sql+="enddate='"+m_price.getEnddate()+"', ";
sql+="tprice='"+m_price.getTprice()+"', memo='"+m_price.getMemo()+"'";
sql+="where roomid="+Integer.toString(roomid);
updateData(sql);
}
/**
* 设置房价信息。
* @param p_price 房价信息。
*/
public void setPrice(Price p_price)
{
this.m_price=p_price;
}
/**
* 读取价格信息。
* @param roomid 房型标识。
* @return 返回房价信息。
*/
public Price getPrice(int roomid)
{
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 hotelid, roomstyle, breakfast, gprice, price, ";
sql+="groupprice, startdate, enddate, tprice, memo from tt_price ";
sql+="where roomid="+Integer.toString(roomid);
rst=stm.executeQuery(sql);
if(rst.next())
{
m_price.setHotelid(rst.getInt("hotelid"));
m_price.setBreakfast(rst.getString("breakfast"));
m_price.setEnddate(rst.getString("enddate"));
m_price.setGprice(rst.getString("gprice"));
m_price.setPrice(rst.getString("price"));
m_price.setGroupprice(rst.getString("groupprice"));
m_price.setRoomstyle(rst.getString("roomstyle"));
m_price.setStartdate(rst.getString("startdate"));
m_price.setTprice(rst.getString("tprice"));
m_price.setMemo(rst.getString("memo"));
}
rst.close();
}
catch(Exception e)
{
Error(e);
}
finally
{
db.CloseConnection(cn);
db.CloseStatement(stm);
}
return m_price;
}
/**
* 返回酒店中文名列表。
* @param selected 一个整型值。代表酒店标识,用来设置列表的缺省项。
* @return 返回一个字符串。生成HTML列表代码。
*/
public String getHotelNames(int selected)
{
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 hotelid, cname from tt_hotel where cname>\'\'";
rst=stm.executeQuery(sql);
while(rst.next())
{
retnStr+="<option value="+rst.getString("hotelid")+(rst.getInt("hotelid")==selected?" selected":"")+">"+rst.getString("cname")+"</option>\n";
}
rst.close();
}
catch(Exception e)
{
Error(e);
}
finally
{
db.CloseConnection(cn);
db.CloseStatement(stm);
}
return retnStr;
}
//========================= 〖※ 用于前台 ※〗 =========================
/**
* 返回酒店价目表 (用于返回查询后信息)。
* 只返回:房型、早餐、门市价、前台现付、网上支付(=前台现付)、转账价、预订(是个连接)
* @param hotelid 一个整型值。酒店标识。
* @param condition 字符串。查询条件。
* @return 返回一个字符串。生成HTML表格。
*/
public String getPriceTable(int hotelid,String condition)
{
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 roomid, roomstyle, breakfast, gprice, price, tprice from tt_price where hotelid="+Integer.toString(hotelid)+condition;
rst=stm.executeQuery(sql);
while(rst.next())
{
retnStr+="<tr>\n";
retnStr+="<td>"+rst.getString("roomstyle")+"</td>\n";
retnStr+="<td align=center>"+((rst.getInt("breakfast")==1)?"含":"不含")+"</td>\n";
retnStr+="<td align=center>¥"+rst.getString("gprice")+"</td>\n";
retnStr+="<td align=center>¥"+rst.getString("price")+"</td>\n";
retnStr+="<td align=center>¥<strike>"+rst.getString("price")+"</strike></td>\n";
retnStr+="<td align=center>¥<strike>"+rst.getString("tprice")+"</strike></td>\n";
retnStr+="<td align=center><a href=\"checkorder.jsp?hId="+Integer.toString(hotelid)+"\">预订</a></td>\n";
retnStr+="</tr>\n";
}
rst.close();
}
catch(Exception e)
{
Error(e);
}
finally
{
db.CloseConnection(cn);
db.CloseStatement(stm);
}
return retnStr;
}
//========================= 〖※ 用于前台 ※〗 =========================
/**
* 返回酒店价目表 (用于返回查询后信息)。
* @param hotelid 酒店标识。
* @return 返回一个字符串。生成HTML表格。
*/
public String getPriceTable(int hotelid)
{
return getPriceTable(hotelid,"");
}
//========================= 〖※ 用于前台 ※〗 =========================
/**
* 将得到的提交酒店查询条件转换为 SQL 语句的条件串。
* @param p_submitData 表单提交数据。
* @return 返回一个字符串。生成SQL查询条间。
*/
public String getHotelSearchConditionString(SubmitData p_submitData)
{
String retnStr = new String();
String str1,str2,str3;
str1=p_submitData.getSearchCity();
str2=p_submitData.getSearchLevel();
str3=p_submitData.getSearchPrice();
retnStr=str1;
retnStr+=str2.equals("")?"":retnStr.equals("")?str2:" and "+str2;
retnStr+=str3.equals("")?"":retnStr.equals("")?str3:" and "+str3;
return retnStr;
}
//========================= 〖※ 用于前台 ※〗 =========================
/**
* 返回酒店查询结果。
* @param p_submitData 表单提交数据。
* @return 返回一个字符串。生成HTML表格。
*/
public String getHotelSearchResult(SubmitData p_submitData)
{
String retnStr = new String();
Connection cn = null;
Statement stm = null;
ResultSet rst = null;
int recordCount = 0;
try
{
String str5 = getHotelSearchConditionString(p_submitData); //查询条件
cn=db.getMySQL(mysql_usr,mysql_psw);
stm=cn.createStatement();
String sql = new String();
sql="select count(*) from tt_hotel, tt_price where tt_hotel.hotelid=tt_price.hotelid "+(str5.equals("")?"":" and "+str5) + " group by tt_hotel.hotelid";
rst=stm.executeQuery(sql);
while(rst.next())
recordCount+=1;
sql="select distinct tt_hotel.hotelid, cname, level from tt_hotel, tt_price where tt_hotel.hotelid=tt_price.hotelid "+(str5.equals("")?"":" and "+str5);
sql+=" limit "+Integer.toString((m_curPage-1)*m_pageSize)+","+Integer.toString((m_curPage*m_pageSize>recordCount)?recordCount-(m_curPage-1)*m_pageSize:m_pageSize);
rst=stm.executeQuery(sql);
while(rst.next()) //返回结果表格,以后这一段可能会修改页面版式
{
retnStr+="\t\t<tr>\n";
retnStr+="\t\t\t<td align=\"center\" style=\"border-bottom: 1px inset rgb(0,0,0)\">\n";
retnStr+="\t\t\t\t<div align=\"left\"><font color=\"#000066\"><a href=\"hotel.jsp?hId="+rst.getString("hotelid")+"\" target=\"_blank\">"+rst.getString("cname")+"</a> <font color=\"#FF0000\">"+Hotel.getLevel(rst.getInt("level"),"★")+"</font></font></div>\n";
retnStr+="\t\t\t</td>\n";
retnStr+="\t\t</tr>\n";
retnStr+="\t\t<tr>\n\t\t\t<td>\n";
retnStr+="<table width=\"586\" border=\"0\" cellspacing=\"2\" cellpadding=\"2\">\n";
retnStr+="\t<tr bgcolor=\"#EBEBEB\">\n";
retnStr+="\t\t<td width=125>\n";
retnStr+="\t\t\t<div align=center><font color=\"#003366\">房 型</font></div>\n";
retnStr+="\t\t</td>\n";
retnStr+="\t\t<td width=60>\n";
retnStr+="\t\t\t<div align=center><font color=\"#003366\">早 餐</font></div>\n";
retnStr+="\t\t</td>\n";
retnStr+="\t\t<td width=90 bgcolor=\"#EBEBEB\">\n";
retnStr+="\t\t\t<div align=center><font color=\"#003366\">门市价</font></div>\n";
retnStr+="\t\t</td>\n";
retnStr+="\t\t<td width=90>\n";
retnStr+="\t\t\t<div align=center><font color=\"#003366\">前台现付</font></div>\n";
retnStr+="\t\t</td>\n";
retnStr+="\t\t<td width=90>\n";
retnStr+="\t\t\t<div align=center><font color=\"#003366\">网上支付</font></div>\n";
retnStr+="\t\t</td>\n";
retnStr+="\t\t<td width=90>\n";
retnStr+="\t\t\t<div align=center><font color=\"#003366\">转账支付</font></div>\n";
retnStr+="\t\t</td>\n";
retnStr+="\t\t<td width=41>\n";
retnStr+="\t\t\t<div align=center><font color=\"#003366\">预订</font></div>\n";
retnStr+="\t\t</td>\n";
retnStr+="\t</tr>\n";
retnStr+=getPriceTable(rst.getInt("hotelid"),(p_submitData.getSearchPrice().equals("")?"":" and "+p_submitData.getSearchPrice()));
retnStr+="</table>\n";
retnStr+="\t\t\t</td>\n\t\t</tr>\n";
}
rst.close();
}
catch(Exception e)
{
Error(e);
}
finally
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -