package com.jdgl.service;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.junit.Test;
import com.jdbc.DButil.DButil;
import com.jdgl.Util;
import com.jdgl.entity.Room;
import com.jdgl.entity.VipCard;
public class JdService {
public List<Room> showList(int roomNum)
{
Connection conn=null;
PreparedStatement ps=null;
ResultSet rs=null;
Room r=null;
List<Room> roomList=new LinkedList<Room>();
String sql="select * from room where 1=1";
try {
conn=DButil.getConn();
if(roomNum!=0)
{
sql+=" and room_num="+roomNum;
}
ps=conn.prepareStatement(sql);
rs=ps.executeQuery();
while(rs.next())
{
r=new Room(rs.getInt("room_num"),rs.getInt("room_stat"),rs.getInt("room_price"),rs.getString("custom"));
roomList.add(r);
}
}catch(Exception e) {
e.printStackTrace();
}finally {
try {
DButil.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return roomList;
}
// public void moveIn(String room_num)
// {
// int price=0;
// String room_num=request.getParameter("room_num");
// System.out.println(room_num);
// String id=request.getParameter("sfz");
// System.out.println(id);
// String vipId=request.getParameter("vipid");
// String sql="Update room set room_stat=1 where room_num=?";
// String sql5="Update room set custom=? where room_num=?";
// String sql1="select * from room where room_num="+room_num;
// Connection conn=null;
// PreparedStatement ps=null;
// ResultSet rs=null;
// try{
// conn=DButil.getConn();
// ps=conn.prepareStatement(sql);
// ps.setString(1, room_num);
// ps.executeUpdate();
// ps=conn.prepareStatement(sql1);
// rs=ps.executeQuery();
// ps=conn.prepareStatement(sql5);
// ps.setString(1, id);
// ps.setString(2, room_num);
// ps.executeUpdate();
// if(rs.next()){
// System.out.print(rs.getString("room_price"));
// price=rs.getInt("room_price");
// }
// }
@Test
public void vipLog(VipCard vc)
{
String sql = "insert into vip (idCard,name,phone,sex) values (?,?,?,?)";
Object[] obj = {vc.getIdCard(),vc.getName(),vc.getPhone(),vc.getSex()};
try {
DButil.update(sql, obj);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public int returnId()
{
int id = 0;
String sql = "select * from vip order by id desc limit 0,1";
try {
ResultSet rs = DButil.select(sql);
rs.next();
id = rs.getInt("id");
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return id;
}
public long calPrice(String roomNum,long divDay)
{
int roomPrice = 0;
long price = 0;
String sql = "select room_price from room where room_num = "+roomNum;
try {
ResultSet rs = DButil.select(sql);
rs.next();
roomPrice = rs.getInt("room_price");
System.out.println(roomPrice);
System.out.println(divDay);
price = roomPrice * divDay;
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return price;
}
public long calPrice(String roomNum,Date nowDay,Date toDay)
{
int roomPrice = 0;
long price = 0;
long nd = 1000*24*60*60;
long diff = toDay.getTime()-nowDay.getTime();
long divDay = diff/nd;
String sql = "select room_price from room where room_num = "+roomNum;
try {
ResultSet rs = DButil.select(sql);
rs.next();
roomPrice = rs.getInt("room_price");
// System.out.println(roomPrice);
// System.out.println(divDay);
price = roomPrice * divDay;
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return price;
}
public void moveIn(String idCard,String name,double money,String phone,String sex,String roomNum,String type,Date nowDay,Date toDay)
{
String searchSql = "select * from custom where id = "+idCard;
String customSql = "insert into custom values (?,?,?,?,?,?)";
String roomSql = "update room set room_stat=?, custom=?, movein_date=? , moveout_date=? where room_num=?";
Object[] obj1 = {idCard,money,type,phone,sex,name};
Object[] obj2 = {1,idCard,nowDay,toDay,roomNum};
ResultSet rs = null;
try {
rs = DButil.select(searchSql);
if(rs.next())
{
DButil.update(roomSql, obj2);
}else {
DButil.update(customSql, obj1);
DButil.update(roomSql, obj2);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void vipMoveIn(String vipCard,double money,String roomNum,String type,Date nowDay,Date toDay,HttpServletRequest request,HttpServletResponse response)
{
String sql = "select * from vip where id = "+vipCard;
String customSql = "insert into custom values (?,?,?,?,?,?)";
String roomSql = "update room set room_stat=?, custom=?, movein_date=? , moveout_date=? where room_num=?";
ResultSet rs = null;
try {
rs = DButil.select(sql);
if(rs.next())
{
String name = rs.getString("name");
String phone = rs.getString("phone");
int sex = rs.getInt("sex");
String idCard = rs.getString("idCard");
Object[] obj1 = {idCard,money,type,phone,sex,name};
Object[] obj2 = {1,idCard,nowDay,toDay,roomNum};
DButil.update(customSql, obj1);
DButil.update(roomSql, obj2);
}else {
request.setAttribute("errorMsg", "会员卡号不存在");
request.getRequestDispatcher("success/ErrorVip.jsp").forward(request, response);
}
}catch(Exception e)
{
e.printStackTrace();
}
}
public int preMoveOut(String roomNum)
{
String sql = "select * from room,custom where custom.id = room.custom and room_num = "+roomNum;
ResultSet rs = null;
int money = 0;
try {
rs = DButil.select(sql);
rs.next();
money = rs.getInt("costMoney");
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return money;
}
public String getCustom(String roomNum)
{
String sql = "select * from room where room_num = "+roomNum;
ResultSet rs = null;
String custom = null;
try {
rs = DButil.select(sql);
rs.next();
custom = rs.getString("custom");
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return custom;
}
public void MoveOut(String roomNum,String doPerson,String[] ulCosts)
{
Date date1 = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String date = sdf.format(date1);
// System.out.println(date);
String updateSql = "update room set room_stat =2,custom = null,movein_date=null,moveout_date=null where room_num = "+roomNum;
String insertSql = "insert into jdorder (customer_id,room,money,order_data,costThing,do_person) values (?,?,?,?,?,?)";
// System.out.println("-----"+roomNum);
String selectSql = "select * from room,custom where room.custom = custom.id and room_num = "+roomNum;
String deleteSql = "delete from custom where id =?";
String ulCost = Util.doStringArray(ulCosts);
ResultSet rs = null;
try {
rs = DButil.select(selectSql);
rs.next();
String idCard = rs.getString("id");
int money = rs.getInt("costMoney");
Object[] obj1 = {idCard};
Object[] obj = {idCard,roomNum,money,date,ulCost,doPerson};
DButil.update0(updateSql);
DButil.update(deleteSql, obj1);
DButil.update(insertSql, obj);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void cle
没有合适的资源?快使用搜索试试~ 我知道了~
基于jsp+servlet设计酒店管理系统.zip
![preview](https://csdnimg.cn/release/downloadcmsfe/public/img/white-bg.ca8570fa.png)
共447个文件
png:180个
js:80个
css:35个
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 184 浏览量
2023-10-29
19:24:05
上传
评论
收藏 10.31MB ZIP 举报
温馨提示
1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用! 2、本项目适合计算机相关专业(如计科、人工智能、通信工程、自动化、电子信息等)的在校学生、老师或者企业员工下载学习,也适合小白学习进阶,当然也可作为毕设项目、课程设计、作业、项目初期立项演示等。 3、如果基础还行,也可在此代码基础上进行修改,以实现其他功能,也可用于毕设、课设、作业等。 -------- 下载后请首先打开README.md文件(如有),仅供学习参考, 切勿用于商业用途。
资源推荐
资源详情
资源评论
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JAR.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JAR.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JAR.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JAR.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JAR.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JAR.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JAR.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JAR.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JAR.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JAR.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JAR.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JAR.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JAR.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JAR.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JAR.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
共 447 条
- 1
- 2
- 3
- 4
- 5
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/e416cf33407c4440aec4cb2cdd82a4e2_a1137588003.jpg!1)
程皮
- 粉丝: 265
- 资源: 2567
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)