Eclipse+Java+Swing+Mysql实现酒店管理系统
Posted 水坚石青
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Eclipse+Java+Swing+Mysql实现酒店管理系统相关的知识,希望对你有一定的参考价值。
目录
一、系统介绍
1.开发环境
开发工具:Eclipse2021
JDK版本:jdk1.8
mysql版本:8.0.13
2.技术选型
Java+Swing+Mysql
3.系统功能
1.登录系统
2.员工管理
3.顾客管理
4.房间查询(房间添加在数据库里面操作)
5.退换房间
二、系统展示
1.登录系统
2.系统主页
3.员工管理
4.顾客信息添加
5.订单详情提交
6.房间查询
7.退换房间
三、部分代码
ClientDao.java
package com.sqc.dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import com.sqc.model.Client;
public class ClientDao
/**
* 客户信息增加
*
* @param con
* @param client
* @return
* @throws Exception
*/
public int add(Connection con, Client client) throws Exception
// TODO Auto-generated method stub
String sql = "insert into tb_client values(?,?,?,?,?)";
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setString(1, client.getCid());
pstmt.setString(2, client.getCname());
pstmt.setString(3, client.getCsex());
pstmt.setInt(4, client.getCage());
pstmt.setString(5, client.getCtel());
return pstmt.executeUpdate();
ExRoomDao.java
package com.sqc.dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import com.sqc.model.ExRoom;
import com.sqc.util.StringUtil;
public class ExRoomDao
/**
* 订单信息查询
*
* @param con
* @param exRoom
* @return
*/
public ResultSet list(Connection con, ExRoom exRoom) throws Exception
// TODO Auto-generated method stub
StringBuffer sb = new StringBuffer("select oid,cid,rid,ocomedate,odays,oleavedate from tb_order");
if (StringUtil.isNotEmpty(exRoom.getCid()))
sb.append(" and tb_order.cid like'%" + exRoom.getCid() + "%'");
if (StringUtil.isNotEmpty(exRoom.getRid()))
sb.append(" and tb_order.rid like'%" + exRoom.getRid() + "%'");
PreparedStatement pstmt = con.prepareStatement(sb.toString().replaceFirst("and", "where"));
return pstmt.executeQuery();
/**
* 订单修改
*
* @param con
* @param exRoom
* @return
*/
public int update(Connection con, ExRoom exRoom) throws Exception
// TODO Auto-generated method stub
String sql = "update tb_order set Cid=?,Rid=?,Ocomedate=?,Odays=?,Oleavedate=?";
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setString(1, exRoom.getCid());
pstmt.setString(2, exRoom.getRid());
pstmt.setString(3, exRoom.getOcomedate());
pstmt.setInt(4, exRoom.getOdays());
pstmt.setString(5, exRoom.getOleavedate());
return pstmt.executeUpdate();
/**
* 退房事件处理
*
* @param con
* @param cid
* @return
*/
public int delete(Connection con, String cid) throws Exception
// TODO Auto-generated method stub
String sql = "delete from tb_order where cid=?";
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setString(1, cid);
return pstmt.executeUpdate();
OrderDao.java
package com.sqc.dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import com.sqc.model.Client;
import com.sqc.model.Order;
public class OrderDao
public int add(Connection con, Order order) throws Exception
// TODO Auto-generated method stub
String sql = "insert into tb_order values(null,?,?,?,?,?)";
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setString(1, order.getCid());
pstmt.setString(2, order.getRid());
pstmt.setString(3, order.getOcomedate());
pstmt.setInt(4, order.getOdays());
pstmt.setString(5, order.getOleavedate());
return pstmt.executeUpdate();
RoomDao.java
package com.sqc.dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import com.sqc.model.Room;
import com.sqc.util.StringUtil;
public class RoomDao
public ResultSet list(Connection con, Room room) throws Exception
// TODO Auto-generated method stub
StringBuffer sb = new StringBuffer("select *from tb_room");
if (StringUtil.isNotEmpty(room.getRid()))
sb.append(" and tb_room.rid like '%" + room.getRid() + "%'");
if (StringUtil.isNotEmpty(room.getRtype()))
sb.append(" and tb_room.rtype like '%" + room.getRtype() + "%'");
PreparedStatement pstmt = con.prepareStatement(sb.toString().replaceFirst("and", "where"));
return pstmt.executeQuery();
StaffDao.java
package com.sqc.dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import com.sqc.model.Staff;
import com.sqc.util.StringUtil;
public class StaffDao
/**
* 员工信息添加
*
* @param con
* @param staff
* @return
* @throws Exception
*/
public int add(Connection con, Staff staff) throws Exception
// TODO Auto-generated method stub
String sql = "insert into tb_staff values(?,?,?,?,?)";
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setString(1, staff.getSid());
pstmt.setString(2, staff.getSname());
pstmt.setString(3, staff.getSsex());
pstmt.setString(4, staff.getStel());
pstmt.setString(5, staff.getSjob());
return pstmt.executeUpdate();
/**
* 员工信息查询
*
* @param con
* @param staff
* @return
*/
public ResultSet list(Connection con, Staff staff) throws Exception
// TODO Auto-generated method stub
StringBuffer sb = new StringBuffer("select * from tb_staff");
if (StringUtil.isNotEmpty(staff.getSid()))
sb.append(" and tb_staff.sid like '%" + staff.getSid() + "%'");
PreparedStatement pstmt = con.prepareStatement(sb.toString().replaceFirst("and", "where"));
return pstmt.executeQuery();
/**
* 员工信息修改
*
* @param con
* @param staff
* @return
* @throws Exception
*/
public int update(Connection con, Staff staff) throws Exception
// TODO Auto-generated method stub
String sql = "update tb_staff set sid=?,sname=?,ssex=?,stel=?,sjob=? where sid=" + staff.getSid();
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setString(1, staff.getSid());
pstmt.setString(2, staff.getSname());
pstmt.setString(3, staff.getSsex());
pstmt.setString(4, staff.getStel());
pstmt.setString(5, staff.getSjob());
return pstmt.executeUpdate();
/**
* 员工信息删除
*
* @param con
* @param sid
* @return
*/
public int delete(Connection con, String sid) throws Exception
// TODO Auto-generated method stub
String sql = "delete from tb_staff where sid=?";
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setString(1, sid);
return pstmt.executeUpdate();
UserDao.java
package com.sqc.dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import com.sqc.model.User;
/**
* 用户Dao类
*
* @author XXX
*
*/
public class UserDao
/**
* 登录验证
*
* @param con
* @param user
* @return
* @throws Exception
*/
public User login(Connection con, User user) throws Exception
User resultUser = null;
String sql = "select * from tb_login where userName = ? and password = ?";
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setString(1, user.getUserName());
pstmt.setString(2, user.getPassword());
ResultSet rs = pstmt.executeQuery();
if (rs.next())
resultUser = new User();
resultUser.setUserName(rs.getString("userName"));
resultUser.setPassword(rs.getString("password"));
return resultUser;
四、其他
1.更多系统
更多JavaSwing系统请关注专栏。
https://blog.csdn.net/helongqiang/category_6229101.htmlhttps://blog.csdn.net/helongqiang/category_6229101.html
更多JavaWeb系统请关注专栏。
2.源码下载
3.运行项目
请点击以下链接,部署你的项目。
4.备注
如有侵权请联系我删除。
5.支持博主
如果您觉得此文对您有帮助,请点赞加关注加收藏。祝您生活愉快!想要获取其他资源可关注左侧微信公众号获取!
以上是关于Eclipse+Java+Swing+Mysql实现酒店管理系统的主要内容,如果未能解决你的问题,请参考以下文章
Eclipse+Java+Swing+Mysql实现超市管理系统
Eclipse+Java+Swing+Mysql实现酒店管理系统
Eclipse+Java+Swing+Mysql实现学生信息管理系统
Eclipse+Java+Swing+Mysql实现进销存管理系统建议收藏