📄 roombookingbean1.java
字号:
package Wearnes;
import java.sql.*;
import java.util.*;
import javax.faces.component.UIParameter;
import javax.faces.event.*;
import javax.faces.context.*;
public class RoomBookingBean1
{
private String roomNo;
private String date;
ArrayList bookingRecords;
public RoomBookingBean1()
{
bookingRecords=new ArrayList();
getAll(null,null);
}
public RoomBookingBean1(String r,String d)
{
bookingRecords=new ArrayList();
roomNo=r;
date=d;
getAll(r,d);
}
public ArrayList getBookingRecords()
{
return bookingRecords;
}
public void getAll(String r,String d)
{
String strDate="", strDate2="";
if(r!=null&&d!=null)
{
strDate=date.substring(6,10)+date.substring(3,5)+date.substring(0,2)+"000000";
int tmp=1+Integer.parseInt(date.substring(0,2));
String tmpDate2="";
if(tmp<10)
tmpDate2="0"+new Integer(tmp).toString();
else
tmpDate2=new Integer(tmp).toString();
strDate2=date.substring(6,10)+date.substring(3,5)+tmpDate2+"000000";
//String r=(String)getRoomNo().getValue();
}
java.util.Date currdate=new java.util.Date();
String dd="",mm="";
if(new Integer(1+currdate.getMonth()).toString().length()==1)
mm="0"+new Integer(1+currdate.getMonth()).toString();
else
mm=new Integer(1+currdate.getMonth()).toString();
if(new Integer(currdate.getDate()).toString().length()==1)
dd="0"+new Integer(currdate.getDate()).toString();
else
dd=new Integer(currdate.getDate()).toString();
String strDate0=new Integer(1900+currdate.getYear()).toString()+mm+dd+"000000";
ResultSet rs=null;
WearnesDB db=new WearnesDB();
String sql="";
if(r!=null&&d!=null)
sql="select roomNo,requestor,fromTime,toTime,status,substring(fromint,1,8) ff from roombooking where roomNo='"+r.trim()+"' and status='reserved' and fromint>='"+strDate.trim()+"' and fromint<'"+strDate2.trim()+"' order by bookid desc";
else
sql="select roomNo,requestor,fromTime,toTime,status from roombooking where status='reserved' and fromint>='"+strDate0.trim()+"' order by bookid desc";
try{
rs =db.select(sql);
while(rs.next())
{
RoomBookingEntity entity=new RoomBookingEntity(rs.getString("roomNo"),rs.getString("requestor"),rs.getString("fromTime"),rs.getString("toTime"),rs.getString("status"));
bookingRecords.add(entity);
}
}catch(SQLException e)
{
System.out.println(" Database Err");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -