package tool;
import config.GCON;
import display.ExtensionOrderView;
import display.OrderView;
import display.InComeView;
import entity.*;
import java.sql.*;
import java.util.ArrayList;
import java.util.HashMap;
//数据库查询功能
public class Query {
//房间指定型号对应的空和非空房间数量
public static ArrayList<Integer> getNumofRoom(String roomType){
Connection connection = null;
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;
ArrayList<Integer>list =new ArrayList<Integer>() ;
try{
connection = DataBase.getConnection();
preparedStatement = connection.prepareStatement(
"select * from (select roomType,roomStatus ,count(*) from room group by roomType,roomStatus) c where c.roomStatus='空' and c.roomType='"+roomType+"'");
//获取结果数据集
resultSet = preparedStatement.executeQuery();
while (resultSet.next()) {
list.add( resultSet.getInt("count(*)")) ;
}
preparedStatement = connection.prepareStatement(
"select * from (select roomType,roomStatus ,count(*) from room group by roomType,roomStatus) c where c.roomStatus='非空' and c.roomType='"+roomType+"'");
//获取结果数据集
resultSet = preparedStatement.executeQuery();
while (resultSet.next()) {
list.add( resultSet.getInt("count(*)")) ;
}
return list ;
}catch(Exception exception) {
exception.printStackTrace();
}
return null ;
}
//获得已入住的orderview
public static OrderView getFullOrderViews(String roomid) {
ArrayList<OrderView> fullOrderViews = new ArrayList<OrderView>();
Connection connection = null;
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;
try {
connection = DataBase.getConnection();
preparedStatement = connection.prepareStatement("select * from orderviews where roomNumber='"+roomid+"' and orderStatus='已入住'");
//获取结果数据集
resultSet = preparedStatement.executeQuery();
while (resultSet.next()) {
OrderView orderView = new OrderView();
orderView.setOrderNumder(resultSet.getString("orderNumber"));
orderView.setCustomer(resultSet.getString("customerName"));
orderView.setRoomNumber(resultSet.getString("roomNumber"));
orderView.setRoomType(resultSet.getString("roomType"));
orderView.setOrderTime(resultSet.getDate("orderTime"));
orderView.setCheckInTime(resultSet.getDate("checkInTime"));
orderView.setCheckOutTime(resultSet.getDate("checkOutTime"));
int days = (int)((orderView.getCheckOutTime().getTime() - orderView.getCheckInTime().getTime())/1000/60/60/24/1);
orderView.setDays(days);
orderView.setCustomerPhoneNumber(resultSet.getString("customerPhoneNumber"));
orderView.setPrice(resultSet.getInt("totalMoney"));
orderView.setOrderStatus(resultSet.getString("orderStatus"));
return orderView;
}
} catch(Exception exception) {
exception.printStackTrace();
}
return null;
}
//删除waiter
public static void deleteWaiter(Waiter waiter) {
Connection connection = null;
Statement statement = null;
try {
connection = DataBase.getConnection();
statement = connection.createStatement();
statement.execute("DELETE FROM waiter where waiterID='" + waiter.getWaiterID() + "'");
} catch(Exception exception) {
exception.printStackTrace();
}
}
//更新waiter
public static void editWaiter(Waiter waiter) {
Connection connection = null;
Statement statement = null;
try {
connection = DataBase.getConnection();
statement = connection.createStatement();
statement.execute("UPDATE waiter SET waiterIDCard='" + waiter.getWaiterIDCard() + "' where waiterID ='"+waiter.getWaiterID() +"'");
statement.execute("UPDATE waiter SET waiterName='" + waiter.getWaiterName() + "' where waiterID ='"+waiter .getWaiterID() +"'");
statement.execute("UPDATE waiter SET waiterBirthday='" + waiter.getWaiterBirthday() + "' where waiterID ='"+waiter.getWaiterID() +"'");
statement.execute("UPDATE waiter SET waiterPassword='" + waiter.getWaiterPassword() + "' where waiterID ='"+waiter.getWaiterID() +"'");
statement.execute("UPDATE waiter SET waiterJoinDate='" + waiter.getWaiterJoinDate() + "' where waiterID ='"+waiter.getWaiterID() +"'");
statement.execute("UPDATE waiter SET waiterPhoneNumber='" + waiter.getWaiterPhoneNumber() + "'where waiterID ='"+waiter.getWaiterID() +"'");
statement.execute("UPDATE waiter SET remarks='" + waiter.getRemarks() + "'where waiterID ='"+waiter.getWaiterID() +"'");
} catch(Exception exception) {
exception.printStackTrace();
}
}
//使用incomeView
public static ArrayList<InComeView> getInComeView(){
Connection connection = null;
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;
Waiter waiter =null;
ArrayList<InComeView>inComeViews =new ArrayList<InComeView>();
try {
connection = DataBase.getConnection();
String sql = "select * from incomeView";
preparedStatement = connection.prepareStatement(sql);
resultSet = preparedStatement.executeQuery();
while (resultSet.next()) {
inComeViews.add(
new InComeView(resultSet.getDate("co").toString() ,resultSet.getInt("tot"),
resultSet.getInt("num"))
);
}
} catch(Exception exception) {
exception.printStackTrace();
}
return inComeViews;
}
//根据waiterid 来返回waiter
public static Waiter getWaiter(String waiterID){
Connection connection = null;
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;
Waiter waiter =null ;
try {
connection = DataBase.getConnection();
String sql ="select * from waiter where waiterID='"+waiterID+"'" ;
preparedStatement = connection.prepareStatement(sql);
resultSet = preparedStatement.executeQuery();
while (resultSet.next()) {
waiter =new Waiter(resultSet.getString("waiterID")
,resultSet.getString("waiterName")
,resultSet.getDate("waiterBirthday")
,resultSet.getString("waiterIDCard")
,resultSet.getString("waiterPassword")
,resultSet.getDate("waiterJoinDate")
,resultSet.getString("waiterPhoneNumber")
,resultSet.getString("remarks")) ;
return waiter ;
}
} catch(Exception exception) {
exception.printStackTrace();
}
return null ;
}
//根据房间的型号查询房间的相关信息
public static HashMap<String,RoomTypeAndPrice> getRoomTypeMap(){
Connection connection = null;
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;
HashMap<String,RoomTypeAndPrice> map =new HashMap<String, RoomTypeAndPrice>() ;
try {
connection = DataBase.getConnection();
String sql ="select * from roomtypeandprice " ;
preparedStatement = connection.prepareStatement(sql);
resultSet = preparedStatement.executeQuery();
while (result
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
javaweb期末作业-基于MySQL和Tomcat+IDEA+JSP和Servlet宾馆管理系统+文档说明(高分项目),含有代码注释,满分大作业资源,新手也可看懂,期末大作业、课程设计、高分必看,下载下来,简单部署,就可以使用。该项目可以作为课程设计期末大作业使用,该系统功能完善、界面美观、操作简单、功能齐全、管理便捷,具有很高的实际应用价值。 javaweb期末作业-基于MySQL和Tomcat+IDEA+JSP和Servlet宾馆管理系统+文档说明(高分项目)javaweb期末作业-基于MySQL和Tomcat+IDEA+JSP和Servlet宾馆管理系统+文档说明(高分项目)javaweb期末作业-基于MySQL和Tomcat+IDEA+JSP和Servlet宾馆管理系统+文档说明(高分项目)javaweb期末作业-基于MySQL和Tomcat+IDEA+JSP和Servlet宾馆管理系统+文档说明(高分项目)javaweb期末作业-基于MySQL和Tomcat+IDEA+JSP和Servlet宾馆管理系统+文档说明(高分项目)javaweb期末作业-基于MySQL和Tomc
资源推荐
资源详情
资源评论
收起资源包目录
javaweb期末作业-基于MySQL和Tomcat+IDEA+JSP和Servlet宾馆管理系统+文档说明(高分项目) (1370个子文件)
Query.class 22KB
Query.class 22KB
ServiceManage.class 6KB
ServiceManage.class 6KB
TraverseDate.class 4KB
TraverseDate.class 4KB
LoginServlet.class 4KB
LoginServlet.class 4KB
OrderView.class 3KB
OrderView.class 3KB
Order.class 3KB
Order.class 3KB
AdministrationManage.class 3KB
AdministrationManage.class 3KB
Customer.class 2KB
Customer.class 2KB
ExtensionOrderView.class 2KB
ExtensionOrderView.class 2KB
Waiter.class 2KB
Waiter.class 2KB
OrderManage.class 2KB
OrderManage.class 2KB
DataBase.class 2KB
DataBase.class 2KB
RoomManage.class 2KB
RoomManage.class 2KB
OrderTracking.class 2KB
OrderTracking.class 2KB
TimeExtension.class 2KB
TimeExtension.class 2KB
Room.class 1KB
Room.class 1KB
RoomTypeAndPrice.class 1KB
RoomTypeAndPrice.class 1KB
VIPLevel.class 1KB
VIPLevel.class 1KB
GCON.class 1KB
GCON.class 1KB
SystemAdministrator.class 1KB
SystemAdministrator.class 1KB
HelloServlet.class 1KB
HelloServlet.class 1KB
InComeView.class 1KB
InComeView.class 1KB
RoomCountView.class 742B
RoomCountView.class 742B
RoomCountValue.class 735B
RoomCountValue.class 735B
theme.config 2KB
theme.config 2KB
semantic.css 767KB
semantic.css 767KB
semantic.min.css 580KB
semantic.min.css 580KB
button.css 105KB
button.css 105KB
button.min.css 84KB
button.min.css 84KB
grid.css 69KB
grid.css 69KB
grid.min.css 56KB
grid.min.css 56KB
icon.css 54KB
icon.css 54KB
transition.css 44KB
transition.css 44KB
icon.min.css 43KB
icon.min.css 43KB
menu.css 42KB
menu.css 42KB
dropdown.css 36KB
dropdown.css 36KB
transition.min.css 32KB
transition.min.css 32KB
menu.min.css 31KB
menu.min.css 31KB
form.css 27KB
form.css 27KB
dropdown.min.css 27KB
dropdown.min.css 27KB
label.css 26KB
label.css 26KB
card.css 24KB
card.css 24KB
table.css 24KB
table.css 24KB
step.css 22KB
step.css 22KB
form.min.css 21KB
form.min.css 21KB
list.css 21KB
list.css 21KB
flag.css 21KB
flag.css 21KB
rating.css 20KB
rating.css 20KB
label.min.css 20KB
label.min.css 20KB
step.min.css 19KB
step.min.css 19KB
共 1370 条
- 1
- 2
- 3
- 4
- 5
- 6
- 14
资源评论
yava_free
- 粉丝: 3693
- 资源: 1471
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功