基于mysql和Java Swing的简单课程设计

摘要

现代化的酒店组织庞大、服务项目多、信息量大、要想提高效率、降低成本、提高服务质量和管理水平,进而促进经济效益,必须利用电脑网络技术处理宾馆酒店经营数据,实现酒店现代化的信息管理。本次课程设计运用了mysql,javaswing技术,分三层对象模型,sql操作方法,swing界面设计了一个简单酒店管理系统数据库的WEB应用。

 

 第一章  设计概述

1.1 课题背景

   随着社会的进步、服务行业的不断发展,宾馆、酒店的服务行业的信息量和工作量的日益变大,传统的人工管理方式已经远远不能满足现代宾馆酒店的管理需求,经分析传统的方式有如下缺陷:

  1. 记录查询不方便;
  2. 数据维护效率低下;
  3. 数据不易保管,容易丢失和出错;
  4. 管理酒店的资源信息不方便;
  5. 酒店业务拓展不方便;
  6. 管理复杂;
  7. 对各种信息反应缓慢,容易丧失商机。

为了弥补以上缺陷和考虑到旅游度假和商务旅行已经成为人们的一种生活需求,利用电脑网络技术处理宾馆酒店经营数据,已经成为提高企业管理效率,改善服务的关键。采用先进的计算机网络通信技术改变传统的酒店业务模式,实现酒店业务管理的自动化已经成为一种必然。

1.2设计任务

本课程设计设计出的酒店数据管理系统主要是为了解决传统的酒店业务模式,实现现代化信息管理。

本课程设计的主要任务和要求是:

  1. 用户登录。通过身份验证后,进入系统首页。未通过验证,给出登录错误信息。
  2. 用户为客人办理入住登记。
  3. 用户可以为客户进行退房操作。
  4. 用户可以查询住店客人的各种相关的详细信息。
  5. 用户可以对酒店的客房类型进行操作。包括对新客房类型的添加和对原客房类型的修改。
  6. 可以对酒店的房间进行操作。对新房间的增、删、改。
  7. 可以对酒店客房状态进行修改操作。
  8. 可为客人进行房间的预定操作。
  9. 可设定条件对酒店客房信息进行查询,如客房房态、客房预订情况等。
  10. 用户可修改登录密码。

1.3基本理论依据

       酒店信息化管理,就是将原先用纸质材料保存的数据通过数据库进行存储。利用数据库进行数据管理有如下优点:

  1. 实现数据共享;
  2. 减少数据冗余度;
  3. 数据独立性;
  4. 数据实现集中控制;
  5. 数据一致性和可维护性,以确保数据的安全性和可靠性;
  6. 故障恢复。

1.4 课题的目的和意义

       在市场经济的激烈的竞争情况下,对酒店整个来说,多经营状况起决定作用的是酒店的服务管理水平。如何利用先进的管理手段来提高酒店的管理水平成为酒店业务发展的当务之急。面对信息时代的机遇和挑战,利用科技手段提高酒店的管理无疑是一条行之有效的途径。虽然计算机管理并不是酒店走向成功的关键元素,但它可以最大限度的发挥准确、快捷、高效等作用,对酒店的业务管理提供强有力的支持。总结归纳:计算机有三大优势:

  1. 节省大量资源,提高效率;
  2. 加快信息传递,保障信息安全;
  3. 节省劳力,方便管理。

从而给酒店行业带来在线信息查询,在线需要预定、在线业务处理等等遍历,实现流畅的工作流衔接,帮助酒店有效的进行业务管理,释放最大价值。

第二章  设计简介

2.1 总体设计

ER图:                                                                 用例图:

   基于mysql和Java Swing的简单课程设计_第1张图片          基于mysql和Java Swing的简单课程设计_第2张图片

 

表设计:

基于mysql和Java Swing的简单课程设计_第3张图片

数据字典:

基于mysql和Java Swing的简单课程设计_第4张图片

基于mysql和Java Swing的简单课程设计_第5张图片

基于mysql和Java Swing的简单课程设计_第6张图片

基于mysql和Java Swing的简单课程设计_第7张图片

基于mysql和Java Swing的简单课程设计_第8张图片

 

 

 

 

2.2 数据库物理结构设计

  1. 创建数据库
  2. 旅客信息表
  3. 房间信息表
  4. 房间类型表

根据实际需求需要创建视图

第三章:设计结果及介绍

  1. 注册、登陆及修改密码界面

基于mysql和Java Swing的简单课程设计_第9张图片

基于mysql和Java Swing的简单课程设计_第10张图片

基于mysql和Java Swing的简单课程设计_第11张图片

 

 

 

  1. 欢迎界面(用户登陆之后进入)

 

基于mysql和Java Swing的简单课程设计_第12张图片

  1. 酒店房间一览

 

基于mysql和Java Swing的简单课程设计_第13张图片

  1. 订单界面

 

基于mysql和Java Swing的简单课程设计_第14张图片

  1. 个人信息界面

 

基于mysql和Java Swing的简单课程设计_第15张图片

6.欢迎界面(管理员进入时界面)

 

基于mysql和Java Swing的简单课程设计_第16张图片

7.房间详情页面

 

基于mysql和Java Swing的简单课程设计_第17张图片

8.订单管理页面

 

基于mysql和Java Swing的简单课程设计_第18张图片

9.顾客管理页面

 

基于mysql和Java Swing的简单课程设计_第19张图片

10.酒店管理页面

基于mysql和Java Swing的简单课程设计_第20张图片

第四章 学习路径

运用mysql,javaswing技术 分三层对象模型,sql操作方法,swing界面

学习路径1.sql:慕课网  与myaql零距离接触  https://www.imooc.com/learn/122

             2、数据库设计:慕课网  数据库设计那些事  https://www.imooc.com/learn/117

            3、jdbc连接:慕课网  jdbc之对岸的女孩看过来  https://www.imooc.com/learn/157

            4、java swing   小网站比较粗糙主要看的Java书籍 http://www.java1234.com/a/yuanchuang/swing/

            5、个人源代码,仅供参考 https://download.csdn.net/download/qq_38723677/10419994

第五章源代码

1、获取数据库连接,需jdbc包

package hotel;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class DBUtil {

	private static final String URL = "jdbc:mysql://127.0.0.1:3306/hotel";
	private static final String USER = "root";
	private static final String PASSWORD = "110110110";
	
	private static Connection conn=null ;
	
	static {
		try {
			// 1.加载驱动程序
			Class.forName("com.mysql.jdbc.Driver");
			// 2.获得数据库的连接
			conn = DriverManager.getConnection(URL, USER, PASSWORD);
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
	
	
	public static Connection getConnertion() {
		return conn;
	}
}

2、对象模型

package model;

public class Costmer {
	private int id;
	private String name;
	private String password;
	private String mycall;
	private String ordernamber;

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getmyCall() {
		return mycall;
	}

	public void setmyCall(String mycall) {
		this.mycall = mycall;
	}

	public String getOrdernamber() {
		return ordernamber;
	}

	public void setOrdernamber(String ordernamber) {
		this.ordernamber = ordernamber;
	}

	@Override
	public String toString() {
		return "Costmer [id=" + id + ", name=" + name + ", password=" + password + ", mycall=" + mycall
				+ ", ordernamber=" + ordernamber + "]";
	}
}
package model;

public class Costmer {
	private int id;
	private String name;
	private String password;
	private String mycall;
	private String ordernamber;

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getmyCall() {
		return mycall;
	}

	public void setmyCall(String mycall) {
		this.mycall = mycall;
	}

	public String getOrdernamber() {
		return ordernamber;
	}

	public void setOrdernamber(String ordernamber) {
		this.ordernamber = ordernamber;
	}

	@Override
	public String toString() {
		return "Costmer [id=" + id + ", name=" + name + ", password=" + password + ", mycall=" + mycall
				+ ", ordernamber=" + ordernamber + "]";
	}
}

 

package model;

import java.util.Date;

public class Order {
	String ordernumber;
	int id;
	String home;
	String istate;
	Date firsttime;
	public String getOrdernumber() {
		return ordernumber;
	}
	public void setOrdernumber(String ordernumber) {
		this.ordernumber = ordernumber;
	}
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	@Override
	public String toString() {
		return "Order [ordernumber=" + ordernumber + ", id=" + id + ", home=" + home + ", istate=" + istate
				+ ", firsttime=" + firsttime + "]";
	}
	public String getHome() {
		return home;
	}
	public void setHome(String home) {
		this.home = home;
	}
	public String getIstate() {
		return istate;
	}
	public void setIstate(String istate) {
		this.istate = istate;
	}
	public Date getFirsttime() {
		return firsttime;
	}
	public void setFirsttime(Date firsttime) {
		this.firsttime = firsttime;
	}
}

 

package model;

public class Hotel {
	String hotelname;
	String ilocation;
	String hotelcall;
	public String getHotelname() {
		return hotelname;
	}
	public void setHotelname(String hotelname) {
		this.hotelname = hotelname;
	}
	public String getmyLocation() {
		return ilocation;
	}
	public void setmyLocation(String mylocation) {
		this.ilocation = mylocation;
	}
	public String getHotelcall() {
		return hotelcall;
	}
	public void setHotelcall(String hotelcall) {
		this.hotelcall = hotelcall;
	}
	@Override
	public String toString() {
		return "Hotel [hotelname=" + hotelname + ", mylocation=" + ilocation + ", hotelcall=" + hotelcall + "]";
	}
}
package model;

public class SumHome {
	String homenumber;
	String home;
	int money;
	int state;
	public String getHomenumber() {
		return homenumber;
	}
	public void setHomenumber(String homenumber) {
		this.homenumber = homenumber;
	}
	public String getHome() {
		return home;
	}
	public void setHome(String home) {
		this.home = home;
	}
	public int getMoney() {
		return money;
	}
	public void setMoney(int money) {
		this.money = money;
	}
	public int getState() {
		return state;
	}
	public void setState(int state) {
		this.state = state;
	}
	@Override
	public String toString() {
		return "SumHome [homenumber=" + homenumber + ", home=" + home + ", money=" + money + ", state=" + state + "]";
	}
}

3、操作数据库方法

package method;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

import hotel.DBUtil;
import model.Costmer;

public class CostmerMethod {
	//插入条信息
	public void addcostmer(Costmer g) throws Exception {
		Connection conn=DBUtil.getConnertion();
		String SQL=""+"insert into costmer(name,password,mycall,ordernumber)"
					+" values(?,?,?,?)";
		PreparedStatement ptmt=conn.prepareStatement(SQL);
		ptmt.setString(1, g.getName());
		ptmt.setString(2, g.getPassword());
		ptmt.setString(3, g.getmyCall());
		ptmt.setString(4, g.getOrdernamber());
		ptmt.execute();
	}
	//
	public void updatacostmer2(Costmer gg) throws Exception {
		Connection conn=DBUtil.getConnertion();
		String SQL=""+" update costmer set name=?,password=?,mycall=?,ordernumber=?"+" where id=?";
		PreparedStatement ptmt=conn.prepareStatement(SQL);
		ptmt.setString(1, gg.getName());
		ptmt.setString(2, gg.getPassword());
		ptmt.setString(3, gg.getmyCall());
		ptmt.setString(4, gg.getOrdernamber());
		ptmt.setInt(5, gg.getId());
		ptmt.execute();
	}
	//刷新一条信息
	public void updatacostmer(Costmer g) throws Exception {
		Connection conn=DBUtil.getConnertion();
		String SQL=""+" update costmer set name=?,password=?,mycall=?,ordernumber=?"
					+" where name=?";
		PreparedStatement ptmt=conn.prepareStatement(SQL);
		ptmt.setString(1, g.getName());
		ptmt.setString(2, g.getPassword());
		ptmt.setString(3, g.getmyCall());
		ptmt.setString(4, g.getOrdernamber());
		ptmt.setString(5, g.getName());
		ptmt.execute();
	}
	//删除一条信息
	public void deletecostmer(int id1) throws SQLException {
		Connection conn=DBUtil.getConnertion();
		String SQL=" delete from costmer "
					+"  where id=?";
		PreparedStatement ptmt=conn.prepareStatement(SQL);
		ptmt.setInt(1, id1);
		ptmt.execute();
	}
	//返回表中所有信息到一个集合中
	public List query() throws Exception{
		Connection conn=DBUtil.getConnertion();
		Statement stmt = conn.createStatement();
		ResultSet rs = stmt.executeQuery("select * from costmer");
		List  gs=new ArrayList();
		Costmer g=null;
		while (rs.next()) {
			g=new Costmer();
			g.setId(rs.getInt("id"));
			g.setName(rs.getString("name"));
			g.setPassword(rs.getString("password"));
			g.setmyCall(rs.getString("mycall"));
			g.setOrdernamber(rs.getString("ordernumber"));
			gs.add(g);
		}
		return gs;
	}
	//查找所有姓名为name的信息
	public List namequery(String name) throws Exception{
		List  gs=new ArrayList();
		
		Connection conn=DBUtil.getConnertion();
		StringBuilder sb=new StringBuilder();
		sb.append("select * from costmer where name=?");
		PreparedStatement ptmt=conn.prepareStatement(sb.toString());
		
		ptmt.setString(1, name);
		ResultSet rs = ptmt.executeQuery();
		Costmer g=null;
		while (rs.next()) {
			g=new Costmer();
			g.setId(rs.getInt("id"));
			g.setName(rs.getString("name"));
			g.setPassword(rs.getString("password"));
			g.setmyCall(rs.getString("mycall"));
			g.setOrdernamber(rs.getString("ordernumber"));
			gs.add(g);
		}
		return gs;
	}
	//得到id的信息
	public Costmer get(int id) throws Exception {
		Connection conn=DBUtil.getConnertion();
		String SQL=""+"select id,name,password,mycall,ordernumber from costmer"
					+" where id=?";
		PreparedStatement ptmt=conn.prepareStatement(SQL);
		ptmt.setInt(1, id);
		ResultSet rs=ptmt.executeQuery();
		Costmer g=null;
		while(rs.next()) {
			g=new Costmer();
			g.setId(rs.getInt("id"));
			g.setName(rs.getString("name"));
			g.setPassword(rs.getString("password"));
			g.setmyCall(rs.getString("mycall"));
			g.setOrdernamber(rs.getString("ordernumber"));
		}
		return g;
	}
}

 

package method;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

import hotel.DBUtil;
import model.SumHome;

public class HomeMethod {
	public void addcostmer(SumHome g) throws Exception {
		Connection conn=DBUtil.getConnertion();
		String SQL=""+"insert into sumhome(homenumber,home,money,state)"
					+" values(?,?,?,?)";
		PreparedStatement ptmt=conn.prepareStatement(SQL);
		ptmt.setString(1, g.getHomenumber());
		ptmt.setString(2, g.getHome());
		ptmt.setInt(3, g.getMoney());
		ptmt.setInt(4, g.getState());
		ptmt.execute();
	}
	public void updatacostmer(String homenumber) throws Exception {
		Connection conn=DBUtil.getConnertion();
		String SQL=""+" update sumhome set state=0"
					+" where homenumber=?";
		PreparedStatement ptmt=conn.prepareStatement(SQL);
		ptmt.setString(1, homenumber);
		ptmt.execute();
	}
	public void updatacostmer(SumHome g) throws Exception {
		Connection conn=DBUtil.getConnertion();
		String SQL=""+" update sumhome set homenumber=?,home=?,money=?,state=?"
					+" where homenumber=?";
		PreparedStatement ptmt=conn.prepareStatement(SQL);
		ptmt.setString(1, g.getHomenumber());
		ptmt.setString(2, g.getHome());
		ptmt.setInt(3, g.getMoney());
		ptmt.setInt(4, g.getState());
		ptmt.setString(5, g.getHomenumber());
		ptmt.execute();
	}
	public void deletecostmer(String homenumber) throws SQLException {
		Connection conn=DBUtil.getConnertion();
		String SQL=" delete from sumhome "
					+"  where homenumber=?";
		PreparedStatement ptmt=conn.prepareStatement(SQL);
		ptmt.setString(1, homenumber);
		ptmt.execute();
	}
	public List query() throws Exception{
		Connection conn=DBUtil.getConnertion();
		Statement stmt = conn.createStatement();
		ResultSet rs = stmt.executeQuery("select homenumber,home,money,state from sumhome");
		List  gs=new ArrayList();
		SumHome g=null;
		while (rs.next()) {
			g=new SumHome();
			g.setHomenumber(rs.getString("homenumber"));
			g.setHome(rs.getString("home"));
			g.setMoney(rs.getInt("money"));
			g.setState(rs.getInt("state"));
			gs.add(g);
		}
		return gs;
	}
	//按照房间类型查询
	public List namequery(String home) throws Exception{
		List  gs=new ArrayList();
		
		Connection conn=DBUtil.getConnertion();
		StringBuilder sb=new StringBuilder();
		sb.append("select * from sumhome where home=?");
		PreparedStatement ptmt=conn.prepareStatement(sb.toString());
		
		ptmt.setString(1, home);
		ResultSet rs = ptmt.executeQuery();
		SumHome g=null;
		while (rs.next()) {
			g=new SumHome();
			g.setHomenumber(rs.getString("homenumber"));
			g.setHome(rs.getString("home"));
			g.setMoney(rs.getInt("money"));
			g.setState(rs.getInt("state"));
			gs.add(g);
		}
		return gs;
	}
	public SumHome get(String homenumber) throws Exception {
		Connection conn=DBUtil.getConnertion();
		String SQL=""+"select homenumber,home,money,state from sumhome"
					+" where homenumber=?";
		PreparedStatement ptmt=conn.prepareStatement(SQL);
		ptmt.setString(1, homenumber);
		ResultSet rs=ptmt.executeQuery();
		SumHome g=null;
		while(rs.next()) {
			g=new SumHome();
			g.setHomenumber(rs.getString("homenumber"));
			g.setHome(rs.getString("home"));
			g.setMoney(rs.getInt("money"));
			g.setState(rs.getInt("state"));
		}
		return g;
	}
}

 

package method;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

import hotel.DBUtil;
import model.Hotel;

public class HotelMethod {
	// 刷新一条信息
	public void updatacostmer(Hotel g) throws Exception {
		Connection conn = DBUtil.getConnertion();
		String SQL = "" + " update myhotel set hotelname=?,ilocation=?,hotelcall=?";
		PreparedStatement ptmt = conn.prepareStatement(SQL);
		ptmt.setString(1, g.getHotelname());
		ptmt.setString(2, g.getmyLocation());
		ptmt.setString(3, g.getHotelcall());
		ptmt.execute();
	}

	// 返回表中所有信息到一个集合中
	public List query() throws Exception {
		Connection conn = DBUtil.getConnertion();
		Statement stmt = conn.createStatement();
		ResultSet rs = stmt.executeQuery("select * from myhotel");
		List gs = new ArrayList();
		Hotel g = null;
		while (rs.next()) {
			g = new Hotel();
			g.setHotelname(rs.getString("hotelname"));
			g.setmyLocation(rs.getString("ilocation"));
			g.setHotelcall(rs.getString("hotelcall"));
			gs.add(g);
		}
		return gs;
	}
}

 

package method;

import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

import hotel.DBUtil;
import model.Order;

public class OrderMethod {
	// 插入条信息
	public void addcostmer(Order g) throws Exception {
		Connection conn = DBUtil.getConnertion();
		String SQL = "" + "insert into iorder(ordernumber,id,home,istate,firsttime) " + " values(?,?,?,?,?);";
		PreparedStatement ptmt = conn.prepareStatement(SQL);
		ptmt.setString(1, g.getOrdernumber());
		ptmt.setInt(2, g.getId());
		ptmt.setString(3, g.getHome());
		ptmt.setString(4, g.getIstate());
		ptmt.setDate(5, new Date(g.getFirsttime().getTime()));
		ptmt.execute();
	}

	// 刷新一条信息
	public void updatacostmer(Order g) throws Exception {
		Connection conn = DBUtil.getConnertion();
		String SQL = "" + " update iorder set ordernumber=?,id=?,home=?,istate=?,firsttime=?" + " where ordernumber=?";
		PreparedStatement ptmt = conn.prepareStatement(SQL);
		ptmt.setString(1, g.getOrdernumber());
		ptmt.setInt(2, g.getId());
		ptmt.setString(3, g.getHome());
		ptmt.setString(4, g.getIstate());
		ptmt.setDate(5, new Date(g.getFirsttime().getTime()));
		ptmt.setString(6, g.getOrdernumber());
		ptmt.execute();
	}

	// 删除一条信息
	public void deletecostmer(String ordernumber) throws SQLException {
		Connection conn = DBUtil.getConnertion();
		String SQL = " delete from iorder " + "  where ordernumber=?";
		PreparedStatement ptmt = conn.prepareStatement(SQL);
		ptmt.setString(1, ordernumber);
		ptmt.execute();
	}

	// 返回表中所有信息到一个集合中
	public List query() throws Exception {
		Connection conn = DBUtil.getConnertion();
		Statement stmt = conn.createStatement();
		ResultSet rs = stmt.executeQuery("select * from iorder");
		List gs = new ArrayList();
		Order g = null;
		while (rs.next()) {
			g = new Order();
			g.setOrdernumber(rs.getString("ordernumber"));
			g.setId(rs.getInt("id"));
			g.setHome(rs.getString("home"));
			g.setIstate(rs.getString("istate"));
			g.setFirsttime(rs.getDate("firsttime"));
			gs.add(g);
		}
		return gs;
	}

	// 得到ordernumber的信息
	public Order getid(String ordernumber) throws Exception {
		Connection conn = DBUtil.getConnertion();
		String SQL = "" + "select ordernumber,id,home,istate,firsttime from iorder" + " where ordernumber=?";
		PreparedStatement ptmt = conn.prepareStatement(SQL);
		ptmt.setString(1, ordernumber);
		ResultSet rs = ptmt.executeQuery();
		Order g = null;
		while (rs.next()) {
			g = new Order();
			g.setOrdernumber(rs.getString("ordernumber"));
			g.setId(rs.getInt("id"));
			g.setHome(rs.getString("home"));
			g.setIstate(rs.getString("istate"));
			g.setFirsttime(rs.getDate("firsttime"));
		}
		return g;
	}

	// 得到id的信息
	public Order get(int id) throws Exception {
		Connection conn = DBUtil.getConnertion();
		String SQL = "" + "select ordernumber,id,home,istate,firsttime from iorder" + " where id=?";
		PreparedStatement ptmt = conn.prepareStatement(SQL);
		ptmt.setInt(1, id);
		ResultSet rs = ptmt.executeQuery();
		Order g = null;
		while (rs.next()) {
			g = new Order();
			g.setOrdernumber(rs.getString("ordernumber"));
			g.setId(rs.getInt("id"));
			g.setHome(rs.getString("home"));
			g.setIstate(rs.getString("istate"));
			g.setFirsttime(rs.getDate("firsttime"));
		}
		return g;
	}
}

 

package method;

import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

import hotel.DBUtil;
import model.Contact;

public class ContactMethod {
	// 插入条信息
	public void addcostmer(Contact g) throws Exception {
		Connection conn = DBUtil.getConnertion();
		String SQL = "" + "insert into contact(ordernumber,homenumber,oldtime)" + " values(?,?,?)";
		PreparedStatement ptmt = conn.prepareStatement(SQL);
		ptmt.setString(1, g.getOrdernumber());
		ptmt.setString(2, g.getHomenumber());
		ptmt.setDate(3, new Date(g.getOldtime().getTime()));
		ptmt.execute();
	}

	// 刷新一条信息
	public void updatacostmer(Contact g) throws Exception {
		Connection conn = DBUtil.getConnertion();
		String SQL = "" + " update contact set ordernumber=?,homenumber=?,oldtime=?" + " where ordernumber=? and homenumber=?";
		PreparedStatement ptmt = conn.prepareStatement(SQL);
		ptmt.setString(1, g.getOrdernumber());
		ptmt.setString(2, g.getHomenumber());
		ptmt.setDate(3, new Date(g.getOldtime().getTime()));
		ptmt.setString(4, g.getOrdernumber());
		ptmt.setString(5, g.getHomenumber());
		ptmt.execute();
	}

	// 删除一条信息
	public void deletecostmer(String ordernumber) throws SQLException {
		Connection conn = DBUtil.getConnertion();
		String SQL = " delete from contact " + " where ordernumber=? ";
		PreparedStatement ptmt = conn.prepareStatement(SQL);
		ptmt.setString(1, ordernumber);
		ptmt.execute();
	}

	// 返回表中所有信息到一个集合中
	public List query() throws Exception {
		Connection conn = DBUtil.getConnertion();
		Statement stmt = conn.createStatement();
		ResultSet rs = stmt.executeQuery("select * from contact");
		List gs = new ArrayList();
		Contact g = null;
		while (rs.next()) {
			g = new Contact();
			g.setOrdernumber(rs.getString("ordernumber"));
			g.setHomenumber(rs.getString("homenumber"));
			g.setOldtime(rs.getDate("oldtime"));
			gs.add(g);
		}
		return gs;
	}

	// 查找ordernumber的信息
	public Contact getorder(String ordernumber) throws Exception {
		Connection conn = DBUtil.getConnertion();
		String SQL = "" + "select ordernumber,homenumber,oldtime from contact" + " where ordernumber=?";
		PreparedStatement ptmt = conn.prepareStatement(SQL);
		ptmt.setString(1, ordernumber);
		ResultSet rs = ptmt.executeQuery();
		Contact g = null;
		while (rs.next()) {
			g = new Contact();
			g.setOrdernumber(rs.getString("ordernumber"));
			g.setHomenumber(rs.getString("homenumber"));
			g.setOldtime(rs.getDate("oldtime"));
		}
		return g;
	}

	// 得到homenumber的信息
	public Contact gethome(String homenumber) throws Exception {
		Connection conn = DBUtil.getConnertion();
		String SQL = "" + "select ordernumber,homenumber,oldtime from contact" + " where homenumber=?";
		PreparedStatement ptmt = conn.prepareStatement(SQL);
		ptmt.setString(1, homenumber);
		ResultSet rs = ptmt.executeQuery();
		Contact g = null;
		while (rs.next()) {
			g = new Contact();
			g.setOrdernumber(rs.getString("ordernumber"));
			g.setHomenumber(rs.getString("homenumber"));
			g.setOldtime(rs.getDate("oldtime"));
		}
		return g;
	}
}

4、swing界面

package windowlogin;


import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

import method.CostmerMethod;
import model.Costmer;

import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.util.List;
import java.awt.event.ActionEvent;
import java.awt.Font;
import javax.swing.ImageIcon;

@SuppressWarnings("serial")
public class Modify extends JFrame {

	/**
	 * 
	 */
	private JPanel contentPane;
	private JTextField Modifytext1;
	private JTextField Modifytext2;
	private JTextField Modifytext;

	/**
	 * Launch the application.
	 */
	/**
	 * Create the frame.
	 * @throws Exception 
	 */
	public Modify() throws Exception {
		setFont(new Font("宋体", Font.PLAIN, 12));
		setResizable(false);
		CostmerMethod gg=new CostmerMethod();
		List m=gg.query();
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		this.setLocationRelativeTo(null); 		//设置居中显示
		
		JLabel label = new JLabel("\u65E7\u5BC6\u7801\uFF1A");
		label.setIcon(new ImageIcon("H:\\zjavaStudy\\EnglishEclipaseJob\\hotel\\src\\icon\\\u5BC6\u7801.png"));
		label.setBounds(44, 109, 91, 21);
		contentPane.add(label);
		
		JLabel label_1 = new JLabel("\u65B0\u5BC6\u7801\uFF1A");
		label_1.setIcon(new ImageIcon("H:\\zjavaStudy\\EnglishEclipaseJob\\hotel\\src\\icon\\\u5BC6\u7801.png"));
		label_1.setBounds(44, 140, 80, 21);
		contentPane.add(label_1);
		
		Modifytext1 = new JTextField();
		Modifytext1.setBounds(134, 109, 215, 21);
		contentPane.add(Modifytext1);
		Modifytext1.setColumns(10);
		
		Modifytext2 = new JTextField();
		Modifytext2.setColumns(10);
		Modifytext2.setBounds(134, 140, 215, 21);
		contentPane.add(Modifytext2);
		
		JButton button_1 = new JButton("\u786E          \u8BA4    ");
		button_1.setIcon(new ImageIcon("H:\\zjavaStudy\\EnglishEclipaseJob\\hotel\\src\\icon\\\u786E\u8BA4.png"));
		button_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				String iname=Modifytext.getText();
				String oldpassword=Modifytext1.getText();
				String newpassword=Modifytext2.getText();
				if("".equals(oldpassword)||oldpassword==null) {
					JOptionPane.showMessageDialog(null, "旧密码不能为空");
					return;
				}
				if("".equals(newpassword)||newpassword==null) {
					JOptionPane.showMessageDialog(null, "新密码不能为空");
					return;
				}
				for (Costmer costmer : m) {
					if(costmer.getName().equals(iname)){
						if(costmer.getPassword().equals(oldpassword)) {
							try {
								costmer.setPassword(newpassword);
								gg.updatacostmer(costmer);
								JOptionPane.showMessageDialog(null, "密码修改成功");
								return;
							} catch (Exception e1) {
								// TODO Auto-generated catch block
								e1.printStackTrace();
							}
						}else {
							JOptionPane.showMessageDialog(null, "旧密码输入错误,请联系管理员");
							return;
						}
					}
				}
				JOptionPane.showMessageDialog(null, "不存在该账号");
				return;
			}
		});
		button_1.setBounds(148, 171, 185, 31);
		contentPane.add(button_1);
		
		JLabel label_2 = new JLabel("\u8D26 \u53F7\uFF1A");
		label_2.setIcon(new ImageIcon("H:\\zjavaStudy\\EnglishEclipaseJob\\hotel\\src\\icon\\\u8D26\u53F7.png"));
		label_2.setBounds(44, 78, 91, 21);
		contentPane.add(label_2);
		
		Modifytext = new JTextField();
		Modifytext.setColumns(10);
		Modifytext.setBounds(134, 78, 215, 21);
		contentPane.add(Modifytext);
		
		JLabel label_3 = new JLabel("\u4FEE  \u6539  \u5BC6  \u7801");
		label_3.setIcon(new ImageIcon("H:\\zjavaStudy\\EnglishEclipaseJob\\hotel\\src\\icon\\\u4E3B\u98982.png"));
		label_3.setFont(new Font("宋体", Font.BOLD | Font.ITALIC, 14));
		label_3.setBounds(148, 32, 185, 31);
		contentPane.add(label_3);
		
		JLabel label_4 = new JLabel("");
		label_4.setIcon(new ImageIcon("H:\\zjavaStudy\\EnglishEclipaseJob\\hotel\\src\\icon\\u=3006991615,3365362070&fm=27&gp=0.jpg"));
		label_4.setBounds(0, 0, 444, 271);
		contentPane.add(label_4);
	}

}

 

package windowlogin;


import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

import method.CostmerMethod;
import model.Costmer;

import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.util.List;
import java.awt.event.ActionEvent;
import java.awt.Font;
import javax.swing.ImageIcon;

@SuppressWarnings("serial")
public class Register extends JFrame {

	private JPanel contentPane;
	private JTextField Registertext1;
	private JTextField Registertext2;
	private JTextField Registertext3;

	/**
	 * Launch the application.
	 */
	/**
	 * Create the frame.
	 * @throws Exception 
	 */
	public Register() throws Exception {
		setResizable(false);
		CostmerMethod gg=new CostmerMethod();//获取顾客表的操作方法
		
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		this.setLocationRelativeTo(null); 		//设置居中显示
		
		JLabel label = new JLabel("\u8D26\u53F7\uFF1A");
		label.setIcon(new ImageIcon("H:\\zjavaStudy\\EnglishEclipaseJob\\hotel\\src\\icon\\\u8D26\u53F7.png"));
		label.setBounds(43, 70, 81, 21);
		contentPane.add(label);
		
		JLabel label_1 = new JLabel("\u5BC6\u7801\uFF1A");
		label_1.setIcon(new ImageIcon("H:\\zjavaStudy\\EnglishEclipaseJob\\hotel\\src\\icon\\\u5BC6\u7801.png"));
		label_1.setBounds(43, 98, 81, 21);
		contentPane.add(label_1);
		
		Registertext1 = new JTextField();
		Registertext1.setBounds(134, 67, 200, 21);
		contentPane.add(Registertext1);
		Registertext1.setColumns(10);
		
		Registertext2 = new JTextField();
		Registertext2.setColumns(10);
		Registertext2.setBounds(134, 95, 200, 21);
		contentPane.add(Registertext2);
		
		JButton button = new JButton("\u6CE8\u518C");
		button.setIcon(new ImageIcon("H:\\zjavaStudy\\EnglishEclipaseJob\\hotel\\src\\icon\\\u786E\u8BA4.png"));
		button.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				List m = null;
				try {
					m = gg.query();
				} catch (Exception e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}//返回顾客信息到List中
				String name=Registertext1.getText();
				String password=Registertext2.getText();
				String call=Registertext3.getText();
				if("".equals(name)||name==null) {
					JOptionPane.showMessageDialog(null, "账号不能为空");
					return;
				}
				if("".equals(password)||password==null) {
					JOptionPane.showMessageDialog(null, "密码不能为空");
					return;
				}
				if("".equals(call)||call==null) {
					JOptionPane.showMessageDialog(null, "电话不能为空");
					return;
				}
				if(name.length()>2&&name.length()<12&&password.length()>5&&password.length()<12&&call.length()==11) {
					for (Costmer costmer : m) {
						if(costmer.getName().equals(name)) {
							JOptionPane.showMessageDialog(null, "账号已被人注册");
							return;
						}
					}
					Costmer cost=new Costmer();
					cost.setName(name);
					cost.setPassword(password);
					cost.setmyCall(call);
					cost.setOrdernamber("");
					try {
						gg.addcostmer(cost);
						m=gg.query();//返回顾客信息到List中
						JOptionPane.showMessageDialog(null, "注册成功");
					} catch (Exception e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
				}else {
					JOptionPane.showMessageDialog(null, "账号3~12位之间密码5~12位之间,手机号11位");
				}
			}
		});
		button.setBounds(134, 151, 200, 23);
		contentPane.add(button);
		
		JLabel label_2 = new JLabel("\u8D26  \u53F7  \u6CE8  \u518C");
		label_2.setIcon(new ImageIcon("H:\\zjavaStudy\\EnglishEclipaseJob\\hotel\\src\\icon\\\u4E3B\u98982.png"));
		label_2.setFont(new Font("宋体", Font.BOLD | Font.ITALIC, 14));
		label_2.setBounds(151, 21, 165, 36);
		contentPane.add(label_2);
		
		JLabel label_3 = new JLabel("\u7535\u8BDD\uFF1A");
		label_3.setIcon(new ImageIcon("H:\\zjavaStudy\\EnglishEclipaseJob\\hotel\\src\\icon\\\u7535\u8BDD.png"));
		label_3.setBounds(43, 123, 81, 21);
		contentPane.add(label_3);
		
		Registertext3 = new JTextField();
		Registertext3.setColumns(10);
		Registertext3.setBounds(134, 120, 200, 21);
		contentPane.add(Registertext3);
		
		JLabel label_4 = new JLabel("");
		label_4.setIcon(new ImageIcon("H:\\zjavaStudy\\EnglishEclipaseJob\\hotel\\src\\icon\\u=3006991615,3365362070&fm=27&gp=0.jpg"));
		label_4.setBounds(0, 0, 444, 271);
		contentPane.add(label_4);
	}

}

 

package windowlogin;

import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.ImageIcon;
import java.awt.Color;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

@SuppressWarnings("serial")
public class UserMain extends JFrame {

	private JPanel contentPane;

	/**
	 * Launch the application.
	 */
	/**
	 * Create the frame.
	 */
	public UserMain(int iid) {
		setResizable(false);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 540, 330);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		this.setLocationRelativeTo(null); 		//设置居中显示
		
		JMenuBar menuBar = new JMenuBar();
		menuBar.setForeground(Color.WHITE);
		menuBar.setBounds(0, 0, 533, 21);
		contentPane.add(menuBar);
		
		JMenuItem menuItem = new JMenuItem("   \u6B22\u8FCE\u754C\u9762");
		menuItem.setForeground(Color.RED);
		menuBar.add(menuItem);
		
		JMenuItem menuItem_1 = new JMenuItem("\u4F4F\u5BBF\u67E5\u8BE2");
		menuItem_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				EventQueue.invokeLater(new Runnable() {
					public void run() {
						try {
							User1 frame = new User1(iid);
							frame.setVisible(true);
						} catch (Exception e) {
							e.printStackTrace();
						}
					}
				});
			}
		});
		menuBar.add(menuItem_1);
		
		JMenuItem menuItem_2 = new JMenuItem("\u6211\u7684\u8BA2\u5355");
		menuItem_2.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				EventQueue.invokeLater(new Runnable() {
					public void run() {
						try {
							User2 frame = new User2(iid);
							frame.setVisible(true);
						} catch (Exception e) {
							e.printStackTrace();
						}
					}
				});
			}
		});
		menuBar.add(menuItem_2);
		
		JMenuItem menuItem_3 = new JMenuItem("\u4E2A\u4EBA\u4E2D\u5FC3");
		menuItem_3.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				EventQueue.invokeLater(new Runnable() {
					public void run() {
						try {
							User3 frame = new User3(iid);
							frame.setVisible(true);
						} catch (Exception e) {
							e.printStackTrace();
						}
					}
				});
			}
		});
		menuBar.add(menuItem_3);
		
		JLabel lblWelcomeToQilu = new JLabel("       Welcome to qilu International hotel\r\n");
		lblWelcomeToQilu.setIcon(new ImageIcon("H:\\zjavaStudy\\EnglishEclipaseJob\\hotel\\src\\icon\\\u4E3B\u9898.png"));
		lblWelcomeToQilu.setFont(new Font("Vivaldi", Font.BOLD, 18));
		lblWelcomeToQilu.setBounds(10, 25, 424, 30);
		contentPane.add(lblWelcomeToQilu);
		
		JLabel lblToTheWorld = new JLabel("To the world you may be one person ");
		lblToTheWorld.setFont(new Font("宋体", Font.ITALIC, 15));
		lblToTheWorld.setBounds(10, 88, 288, 21);
		contentPane.add(lblToTheWorld);
		
		JLabel lblNewLabel_1 = new JLabel("but to us you  may be the word");
		lblNewLabel_1.setFont(new Font("宋体", Font.ITALIC, 15));
		lblNewLabel_1.setBounds(54, 150, 244, 21);
		contentPane.add(lblNewLabel_1);
		
		JLabel label_1 = new JLabel("\u5BF9\u4E8E\u4E16\u754C\u800C\u8A00\uFF0C\u4F60\u662F\u4E00\u4E2A\u4EBA\uFF1B");
		label_1.setFont(new Font("宋体", Font.ITALIC, 15));
		label_1.setBounds(39, 119, 204, 21);
		contentPane.add(label_1);
		
		JLabel lblNewLabel_2 = new JLabel("\u4F46\u662F\u5BF9\u4E8E\u6211\u4EEC\uFF0C\u4F60\u662F\u6211\u4EEC\u7684\u6574\u4E2A\u4E16\u754C\u3002");
		lblNewLabel_2.setFont(new Font("宋体", Font.ITALIC, 15));
		lblNewLabel_2.setBounds(104, 181, 255, 21);
		contentPane.add(lblNewLabel_2);
		
		JLabel lblNewLabel = new JLabel(" ");
		lblNewLabel.setForeground(Color.WHITE);
		lblNewLabel.setIcon(new ImageIcon("H:\\zjavaStudy\\EnglishEclipaseJob\\hotel\\src\\icon\\13.jpg"));
		lblNewLabel.setBounds(0, 0, 533, 300);
		contentPane.add(lblNewLabel);
		
		
	}
}

 

package windowlogin;

import java.util.Calendar;
import java.util.Date;
import java.util.List;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

import method.ContactMethod;
import method.HomeMethod;
import method.OrderMethod;
import model.Contact;
import model.Order;
import model.SumHome;

import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import java.awt.Color;
import java.awt.event.ActionListener;
import java.text.SimpleDateFormat;
import java.awt.event.ActionEvent;
import javax.swing.JComboBox;
import java.awt.Font;

@SuppressWarnings("serial")
public class User1 extends JFrame {

	private JPanel contentPane;

	/**
	 * Launch the application.
	 */
	/**
	 * Create the frame.
	 * @throws Exception 
	 */
	public User1(int iid) throws Exception {
		setResizable(false);
		HomeMethod gg=new HomeMethod();//获取顾客表的操作方法
		List m=gg.query();//返回顾客信息到List中
		OrderMethod gg2=new OrderMethod();//获取订单表的操作方法
		ContactMethod ggg=new ContactMethod();
		
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		this.setLocationRelativeTo(null); 		//设置居中显示
		
		JLabel label = new JLabel("\u672C\u9152\u5E97\u7A7A\u623F\u95F4");
		label.setFont(new Font("华文隶书", Font.PLAIN, 18));
		label.setIcon(new ImageIcon("H:\\zjavaStudy\\EnglishEclipaseJob\\hotel\\src\\icon\\\u4E3B\u98982.png"));
		label.setBounds(144, 0, 151, 40);
		contentPane.add(label);
		
		JLabel label_1 = new JLabel("\u623F\u95F4\u7C7B\u578B");
		label_1.setBounds(70, 45, 54, 15);
		contentPane.add(label_1);
		
		JLabel label_2 = new JLabel("\u623F\u95F4\u4EF7\u683C");
		label_2.setBounds(144, 45, 54, 15);
		contentPane.add(label_2);
		
		JLabel label_3 = new JLabel("\u623F\u95F4\u4F59\u91CF");
		label_3.setBounds(208, 45, 54, 15);
		contentPane.add(label_3);
		
		JLabel lblNewLabel = new JLabel("\u5355\u4EBA\u95F4");
		lblNewLabel.setBounds(70, 70, 54, 21);
		contentPane.add(lblNewLabel);
		
		JLabel label_4 = new JLabel("\u53CC\u4EBA\u95F4");
		label_4.setBounds(70, 101, 54, 21);
		contentPane.add(label_4);
		
		JLabel label_5 = new JLabel("\u8C6A\u534E\u5957\u623F");
		label_5.setBounds(70, 132, 54, 21);
		contentPane.add(label_5);
		
		JComboBox comboBox = new JComboBox();
		comboBox.setBounds(275, 70, 54, 21);
		comboBox.addItem(1);
		comboBox.addItem(2);
		comboBox.addItem(3);
		comboBox.addItem(4);
		comboBox.addItem(5);
		comboBox.addItem(6);
		comboBox.addItem(7);
		comboBox.addItem(8);
		comboBox.addItem(9);
		comboBox.addItem(10);
		contentPane.add(comboBox);
		
		JComboBox comboBox_1 = new JComboBox();
		comboBox_1.setBounds(275, 101, 54, 21);
		comboBox_1.addItem(1);
		comboBox_1.addItem(2);
		comboBox_1.addItem(3);
		comboBox_1.addItem(4);
		comboBox_1.addItem(5);
		comboBox_1.addItem(6);
		comboBox_1.addItem(7);
		comboBox_1.addItem(8);
		comboBox_1.addItem(9);
		comboBox_1.addItem(10);
		contentPane.add(comboBox_1);
		
		JComboBox comboBox_2 = new JComboBox();
		comboBox_2.setBounds(275, 132, 54, 21);
		comboBox_2.addItem(1);
		comboBox_2.addItem(2);
		comboBox_2.addItem(3);
		comboBox_2.addItem(4);
		comboBox_2.addItem(5);
		comboBox_2.addItem(6);
		comboBox_2.addItem(7);
		comboBox_2.addItem(8);
		comboBox_2.addItem(9);
		comboBox_2.addItem(10);
		contentPane.add(comboBox_2);
		
		JLabel label_6 = new JLabel("");
		label_6.setBounds(144, 73, 54, 15);
		contentPane.add(label_6);
		
		JLabel label_7 = new JLabel("");
		label_7.setBounds(144, 104, 54, 15);
		contentPane.add(label_7);
		
		JLabel label_8 = new JLabel("");
		label_8.setBounds(144, 135, 54, 15);
		contentPane.add(label_8);
		
		JLabel label1 = new JLabel("");
		label1.setBounds(227, 76, 54, 15);
		contentPane.add(label1);
		
		JLabel label2 = new JLabel("");
		label2.setBounds(227, 104, 54, 15);
		contentPane.add(label2);
		
		JLabel label3 = new JLabel("");
		label3.setBounds(227, 135, 54, 15);
		contentPane.add(label3);
		
		JButton button = new JButton("\u4E0B\u5355");
		button.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				//刷新房间数量
				int aa=0;
				for (SumHome sumhome : m) {
					if(sumhome.getState()==0) {
						if(sumhome.getHome().equals("单人间")) aa++;
					}				
				}
				label1.setText(""+aa);
				if(aa==0) {
					JOptionPane.showMessageDialog(null, "没有空房间了,抱歉");
					return;
				}
				
				
				Order Or=new Order();
				Or.setIstate("1");
				Or.setId(iid);
				Date da=new Date();
				Or.setFirsttime(da);//new获取当前时间
				SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");//设置日期格式
				String Str=df.format(new Date());
				Or.setOrdernumber(Str);//以字符串形式输出系统时间精确到毫秒
				Or.setHome("单人间");
				try {
					gg2.addcostmer(Or);
				} catch (Exception e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
				Contact cont=new Contact();
				cont.setOrdernumber(Str);
				int day=comboBox.getSelectedIndex();
				/*添加天数*/
				Calendar c=Calendar.getInstance();
				c.setTime(new Date());
				c.add(Calendar.DAY_OF_MONTH, day+1);
				cont.setOldtime(c.getTime());
				for (SumHome costmer : m) {
					if(costmer.getState()==0&&costmer.getHome().equals(Or.getHome())) {
						cont.setHomenumber(costmer.getHomenumber());
						try {
							ggg.addcostmer(cont);
						} catch (Exception e2) {
							// TODO Auto-generated catch block
							e2.printStackTrace();
						}
						costmer.setState(1);
						try {
							gg.updatacostmer(costmer);
						} catch (Exception e1) {
							// TODO Auto-generated catch block
							e1.printStackTrace();
						}
						//刷新房间数量
						aa=0;
						for (SumHome sumhome : m) {
							if(sumhome.getState()==0) {
								if(sumhome.getHome().equals("单人间")) aa++;
							}				
						}
						label1.setText(""+aa);
						JOptionPane.showMessageDialog(null, "下单成功:房间为"+costmer.getHomenumber()+"请准时入住");
						return;
					}
				}
			}
		});
		button.setForeground(new Color(255, 0, 0));
		button.setBounds(343, 69, 81, 23);
		contentPane.add(button);
		
		JButton button_1 = new JButton("\u4E0B\u5355");
		button_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				//刷新房间数量
				int bb=0;
				for (SumHome sumhome : m) {
					if(sumhome.getState()==0) {
						if(sumhome.getHome().equals("双人间")) bb++;
					}				
				}
				label2.setText(""+bb);
				if(bb==0) {
					JOptionPane.showMessageDialog(null, "没有空房间了,抱歉");
					return;
				}
				
				
				Order Or=new Order();
				Or.setIstate("1");
				Or.setId(iid);
				Date da=new Date();
				Or.setFirsttime(da);//new获取当前时间
				SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");//设置日期格式
				String Str=df.format(new Date());
				Or.setOrdernumber(Str);//以字符串形式输出系统时间精确到毫秒
				Or.setHome("双人间");
				try {
					gg2.addcostmer(Or);
				} catch (Exception e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
				Contact cont=new Contact();
				cont.setOrdernumber(Str);
				int day=comboBox.getSelectedIndex();
				/*添加天数*/
				Calendar c=Calendar.getInstance();
				c.setTime(new Date());
				c.add(Calendar.DAY_OF_MONTH, day+1);
				cont.setOldtime(c.getTime());
				for (SumHome costmer : m) {
					if(costmer.getState()==0&&costmer.getHome().equals(Or.getHome())) {
						cont.setHomenumber(costmer.getHomenumber());
						try {
							ggg.addcostmer(cont);
						} catch (Exception e2) {
							// TODO Auto-generated catch block
							e2.printStackTrace();
						}
						costmer.setState(1);
						try {
							gg.updatacostmer(costmer);
						} catch (Exception e1) {
							// TODO Auto-generated catch block
							e1.printStackTrace();
						}
						//刷新房间数量
						bb=0;
						for (SumHome sumhome : m) {
							if(sumhome.getState()==0) {
								if(sumhome.getHome().equals("双人间")) bb++;
							}				
						}
						label2.setText(""+bb);
						JOptionPane.showMessageDialog(null, "下单成功:房间为"+costmer.getHomenumber()+"请准时入住");
						return;
					}
				}
			}
		});
		button_1.setForeground(new Color(255, 0, 0));
		button_1.setBounds(343, 100, 81, 23);
		contentPane.add(button_1);
		
		JButton button_2 = new JButton("\u4E0B\u5355");
		button_2.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				//刷新房间数量
				int cc=0;
				for (SumHome sumhome : m) {
					if(sumhome.getState()==0) {
						if(sumhome.getHome().equals("豪华套房")) cc++;
					}				
				}
				label3.setText(""+cc);
				if(cc==0) {
					JOptionPane.showMessageDialog(null, "没有空房间了,抱歉");
					return;
				}
				
				
				Order Or=new Order();
				Or.setIstate("1");
				Or.setId(iid);
				Date da=new Date();
				Or.setFirsttime(da);//new获取当前时间
				SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");//设置日期格式
				String Str=df.format(new Date());
				Or.setOrdernumber(Str);//以字符串形式输出系统时间精确到毫秒
				Or.setHome("豪华套房");
				try {
					gg2.addcostmer(Or);
				} catch (Exception e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
				Contact cont=new Contact();
				cont.setOrdernumber(Str);
				int day=comboBox.getSelectedIndex();
				/*添加天数*/
				Calendar c=Calendar.getInstance();
				c.setTime(new Date());
				c.add(Calendar.DAY_OF_MONTH, day+1);
				cont.setOldtime(c.getTime());
				for (SumHome costmer : m) {
					if(costmer.getState()==0&&costmer.getHome().equals(Or.getHome())) {
						cont.setHomenumber(costmer.getHomenumber());
						try {
							ggg.addcostmer(cont);
						} catch (Exception e2) {
							// TODO Auto-generated catch block
							e2.printStackTrace();
						}
						costmer.setState(1);
						try {
							gg.updatacostmer(costmer);
						} catch (Exception e1) {
							// TODO Auto-generated catch block
							e1.printStackTrace();
						}
						//刷新房间数量
						cc=0;
						for (SumHome sumhome : m) {
							if(sumhome.getState()==0) {
								if(sumhome.getHome().equals("豪华套房")) cc++;
							}				
						}
						label3.setText(""+cc);
						JOptionPane.showMessageDialog(null, "下单成功:房间为"+costmer.getHomenumber()+"请准时入住");
						return;
					}
				}
			}
		});
		button_2.setForeground(new Color(255, 0, 0));
		button_2.setBounds(343, 131, 81, 23);
		contentPane.add(button_2);
		
		JLabel label_9 = new JLabel("\u65F6\u95F4");
		label_9.setBounds(275, 45, 54, 15);
		contentPane.add(label_9);
		
		//刷新房间数量
		int aa=0,bb=0,cc=0;
		for (SumHome sumhome : m) {
			if(sumhome.getState()==0) {
				if(sumhome.getHome().equals("单人间")) aa++;
				if(sumhome.getHome().equals("双人间")) bb++;
				if(sumhome.getHome().equals("豪华套房")) cc++;
			}				
		}
		if(aa==0&&bb==0&&cc==0) {
			JOptionPane.showMessageDialog(null, "没有空房间了,抱歉");
		}
		label1.setText(""+aa);
		label2.setText(""+bb);
		label3.setText(""+cc);
		
		JLabel lblNewLabel_1 = new JLabel("New label");
		lblNewLabel_1.setIcon(new ImageIcon("H:\\zjavaStudy\\EnglishEclipaseJob\\hotel\\src\\icon\\u=3006991615,3365362070&fm=27&gp=0.jpg"));
		lblNewLabel_1.setBounds(0, 0, 444, 271);
		contentPane.add(lblNewLabel_1);
		
		for (SumHome costmer : m) {
			if(costmer.getHome().equals("单人间")) {
				label_6.setText(""+costmer.getMoney());
			}
			if(costmer.getHome().equals("双人间")) {
				label_7.setText(""+costmer.getMoney());
			}
			if(costmer.getHome().equals("豪华套房")) {
				label_8.setText(""+costmer.getMoney());
			}
		}
	}
}

 

package windowlogin;

import java.util.List;
import java.util.Vector;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;

import method.ContactMethod;
import method.OrderMethod;
import model.Contact;
import model.Order;

import javax.swing.JScrollPane;
import javax.swing.ImageIcon;
import java.awt.Font;
import java.awt.Color;

@SuppressWarnings("serial")
public class User2 extends JFrame {

	private JPanel contentPane;
	private JTable table;

	/**
	 * Launch the application.
	 */
	
	/**
	 * Create the frame.
	 * @throws Exception 
	 */
	public User2(int iid) throws Exception {
		setResizable(false);
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		setBounds(100, 100, 450, 292);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		this.setLocationRelativeTo(null); 		//设置居中显示
		OrderMethod gg=new OrderMethod();//获取顾客表的操作方法
		List m=gg.query();//返回顾客信息到List中
		ContactMethod ggg=new ContactMethod();//获取顾客表的操作方法
		
		JLabel label = new JLabel("\u6211\u7684\u8BA2\u5355");
		label.setIcon(new ImageIcon("H:\\zjavaStudy\\EnglishEclipaseJob\\hotel\\src\\icon\\\u4E3B\u98982.png"));
		label.setForeground(Color.DARK_GRAY);
		label.setFont(new Font("华文隶书", Font.BOLD, 18));
		label.setBounds(157, 10, 110, 27);
		contentPane.add(label);
		
		JScrollPane scrollPane = new JScrollPane();
		scrollPane.setToolTipText("");
		scrollPane.setBounds(10, 37, 414, 216);
		contentPane.add(scrollPane);
		
		table = new JTable();
		table.setModel(new DefaultTableModel(
			new Object[][] {
			},
			new String[] {
				"\u8BA2\u5355\u53F7", "id", "\u623F\u95F4\u53F7", "\u623F\u95F4\u7C7B\u578B", "\u5F00\u59CB\u65F6\u95F4", "\u7ED3\u675F\u65F6\u95F4"
			}
		));
		scrollPane.setViewportView(table);
		
		JLabel lblNewLabel = new JLabel("");
		lblNewLabel.setIcon(new ImageIcon("H:\\zjavaStudy\\EnglishEclipaseJob\\hotel\\src\\icon\\u=3006991615,3365362070&fm=27&gp=0.jpg"));
		lblNewLabel.setBounds(0, 0, 444, 263);
		contentPane.add(lblNewLabel);
		
		//表格显示信息
		DefaultTableModel dtm=(DefaultTableModel) table.getModel();
		for (Order order : m) {
			if(order.getId()==iid) {
				Contact Con=new Contact();
				Con=ggg.getorder(order.getOrdernumber());
				Vector v=new Vector();
				v.add(order.getOrdernumber());
				v.add(order.getId());
				v.add(Con.getHomenumber());
				v.add(order.getHome());
				v.add(order.getFirsttime());
				v.add(Con.getOldtime());
				dtm.addRow(v);
			}
		}
		
	}
}
 
  

 

package windowlogin;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

import method.CostmerMethod;
import model.Costmer;

import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.util.List;
import java.awt.event.ActionEvent;
import javax.swing.ImageIcon;
import java.awt.Font;

@SuppressWarnings("serial")
public class User3 extends JFrame {

	private JPanel contentPane;
	private JTextField textField;
	private JTextField textField_1;
	private JTextField textField_2;

	/**
	 * Launch the application.
	 */
	/**
	 * Create the frame.
	 * @throws Exception 
	 */
	public User3(int iid) throws Exception {
		setResizable(false);
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		this.setLocationRelativeTo(null); 		//设置居中显示
		CostmerMethod gg=new CostmerMethod();//获取顾客表的操作方法
		List m=gg.query();//返回顾客信息到List中
		
		JLabel label = new JLabel("\u4E2A\u4EBA\u4FE1\u606F");
		label.setIcon(new ImageIcon("H:\\zjavaStudy\\EnglishEclipaseJob\\hotel\\src\\icon\\\u4E3B\u98982.png"));
		label.setFont(new Font("华文隶书", Font.PLAIN, 18));
		label.setBounds(154, 0, 119, 31);
		contentPane.add(label);
		
		JLabel label_1 = new JLabel("\u8D26\u53F7\uFF1A");
		label_1.setBounds(43, 41, 54, 15);
		contentPane.add(label_1);
		
		JLabel label_2 = new JLabel("\u5BC6\u7801\uFF1A");
		label_2.setBounds(43, 78, 54, 15);
		contentPane.add(label_2);
		
		JLabel label_3 = new JLabel("\u7535\u8BDD\uFF1A");
		label_3.setBounds(43, 115, 54, 15);
		contentPane.add(label_3);
		
		JLabel label_4 = new JLabel("");
		label_4.setBounds(107, 41, 98, 15);
		contentPane.add(label_4);
		
		JLabel label_5 = new JLabel("");
		label_5.setBounds(107, 78, 98, 15);
		contentPane.add(label_5);
		
		JLabel label_6 = new JLabel("");
		label_6.setBounds(107, 115, 98, 15);
		contentPane.add(label_6);
		
		Costmer cos=new Costmer();
		cos=gg.get(iid);
		label_4.setText(cos.getName());
		label_5.setText(cos.getPassword());
		label_6.setText(cos.getmyCall());
		
		textField = new JTextField();
		textField.setBounds(215, 38, 98, 21);
		contentPane.add(textField);
		textField.setColumns(10);
		
		textField_1 = new JTextField();
		textField_1.setBounds(215, 75, 98, 21);
		contentPane.add(textField_1);
		textField_1.setColumns(10);
		
		textField_2 = new JTextField();
		textField_2.setBounds(215, 112, 98, 21);
		contentPane.add(textField_2);
		textField_2.setColumns(10);
		
		JButton btnNewButton = new JButton("\u4FEE\u6539");
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				String Str=textField.getText();
				for (Costmer costmer : m) {
					if(costmer.getName().equals(Str)) {
						JOptionPane.showMessageDialog(null, "昵称被占用");
						return;
					}
				}
				if(Str.length()<3) {
					JOptionPane.showMessageDialog(null, "昵称太短");
					return;
				}
				if(Str.length()>20) {
					JOptionPane.showMessageDialog(null, "昵称太长");
					return;
				}
				Costmer cos1=new Costmer();
				try {
					cos1=gg.get(iid);
				} catch (Exception e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				cos1.setName(Str);
				label_4.setText(cos1.getName());
				try {
					gg.updatacostmer2(cos1);
				} catch (Exception e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				JOptionPane.showMessageDialog(null, "修改成功");
			}
		});
		btnNewButton.setBounds(313, 37, 66, 23);
		contentPane.add(btnNewButton);
		
		JButton button = new JButton("\u4FEE\u6539");
		button.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				String Str=textField_1.getText();
				if(Str.length()<5) {
					JOptionPane.showMessageDialog(null, "密码太短");
					return;
				}
				if(Str.length()>20) {
					JOptionPane.showMessageDialog(null, "密码太长");
					return;
				}
				Costmer cos1=new Costmer();
				try {
					cos1=gg.get(iid);
				} catch (Exception e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				cos1.setPassword(Str);
				label_5.setText(cos1.getPassword());
				try {
					gg.updatacostmer2(cos1);
				} catch (Exception e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				JOptionPane.showMessageDialog(null, "修改成功");
			}
		});
		button.setBounds(313, 74, 66, 23);
		contentPane.add(button);
		
		JButton button_1 = new JButton("\u4FEE\u6539");
		button_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				String Str=textField_2.getText();
				if(Str.length()!=11) {
					JOptionPane.showMessageDialog(null, "请输入正确手机号");
					return;
				}
				Costmer cos1=new Costmer();
				try {
					cos1=gg.get(iid);
				} catch (Exception e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
				cos1.setmyCall(Str);
				label_6.setText(cos1.getmyCall());
				try {
					gg.updatacostmer2(cos1);
				} catch (Exception e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
				JOptionPane.showMessageDialog(null, "修改成功");
			}
		});
		button_1.setBounds(313, 111, 66, 23);
		contentPane.add(button_1);
		
		JLabel label_7 = new JLabel("");
		label_7.setIcon(new ImageIcon("H:\\zjavaStudy\\EnglishEclipaseJob\\hotel\\src\\icon\\u=3006991615,3365362070&fm=27&gp=0.jpg"));
		label_7.setBounds(0, 0, 444, 271);
		contentPane.add(label_7);
		
		
	}
}

 

package windowlogin;


import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JLabel;

import java.awt.EventQueue;
import java.awt.Font;
import javax.swing.ImageIcon;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JMenuItem;

@SuppressWarnings("serial")
public class Rootwindow extends JFrame {

	private JPanel contentPane;

	/**
	 * Launch the application.
	 */
	/**
	 * Create the frame.
	 */
	public Rootwindow() {
		setResizable(false);
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		this.setLocationRelativeTo(null); 		//设置居中显示
		
		JMenuBar menuBar = new JMenuBar();
		menuBar.setBounds(0, 0, 444, 21);
		contentPane.add(menuBar);
		
		JMenu menu_3 = new JMenu("\u4E3B\u9875");
		menuBar.add(menu_3);
		
		JMenuItem menuItem = new JMenuItem("\u623F\u95F4\u67E5\u8BE2");
		menuItem.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				EventQueue.invokeLater(new Runnable() {
					public void run() {
						try {
							Root1 frame = new Root1();
							frame.setVisible(true);
						} catch (Exception e) {
							e.printStackTrace();
						}
					}
				});
			}
		});
		menuBar.add(menuItem);
		
		JMenuItem menuItem_1 = new JMenuItem("\u8BA2\u5355\u67E5\u8BE2");
		menuItem_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				EventQueue.invokeLater(new Runnable() {
					public void run() {
						try {
							Root2 frame = new Root2();
							frame.setVisible(true);
						} catch (Exception e) {
							e.printStackTrace();
						}
					}
				});
			}
		});
		menuBar.add(menuItem_1);
		
		JMenuItem menuItem_2 = new JMenuItem("\u987E\u5BA2\u7BA1\u7406");
		menuItem_2.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				EventQueue.invokeLater(new Runnable() {
					public void run() {
						try {
							Root3 frame = new Root3();
							frame.setVisible(true);
						} catch (Exception e) {
							e.printStackTrace();
						}
					}
				});
			}
		});
		menuBar.add(menuItem_2);
		
		JMenuItem menuItem_3 = new JMenuItem("\u9152\u5E97\u7BA1\u7406");
		menuItem_3.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				EventQueue.invokeLater(new Runnable() {
					public void run() {
						try {
							Root4 frame = new Root4();
							frame.setVisible(true);
						} catch (Exception e) {
							e.printStackTrace();
						}
					}
				});
			}
		});
		menuBar.add(menuItem_3);
		
		JLabel label = new JLabel("       Welcome to qilu International hotel\r\n");
		label.setIcon(new ImageIcon("H:\\zjavaStudy\\EnglishEclipaseJob\\hotel\\src\\icon\\\u4E3B\u9898.png"));
		label.setFont(new Font("Vivaldi", Font.BOLD, 18));
		label.setBounds(10, 27, 424, 30);
		contentPane.add(label);
		
		JLabel label_1 = new JLabel("\u4E3A\u4F60\u6240\u60F3 \u4E3A\u4F60\u6240\u4E50 \u4E3A\u6211\u4EBA\u751F \u521B\u9020\u8F89\u714C\u3002");
		label_1.setBounds(186, 67, 248, 50);
		contentPane.add(label_1);
		
		JLabel label_2 = new JLabel("");
		label_2.setIcon(new ImageIcon("H:\\zjavaStudy\\EnglishEclipaseJob\\hotel\\src\\icon\\4.jpg"));
		label_2.setBounds(0, 0, 444, 271);
		contentPane.add(label_2);
	}
}

 

package windowlogin;


import java.util.List;
import java.util.Vector;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JScrollPane;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;

import method.HomeMethod;
import model.SumHome;

import javax.swing.JComboBox;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.ImageIcon;

@SuppressWarnings("serial")
public class Root1 extends JFrame {

	private JPanel contentPane;
	private JTable table;
	private JTextField textField;
	private JTextField textField_1;
	private JTextField textField_3;
	private JTextField textField_4;

	/**
	 * Launch the application.
	 */
	
	/**
	 * Create the frame.
	 * @throws Exception 
	 */
	public Root1() throws Exception {
		setResizable(false);
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		HomeMethod g=new HomeMethod();
		List m=g.query();
		this.setLocationRelativeTo(null); 		//设置居中显示
		
		JScrollPane scrollPane = new JScrollPane();
		scrollPane.setBounds(10, 35, 414, 113);
		contentPane.add(scrollPane);
		
		table = new JTable();
		table.setModel(new DefaultTableModel(
			new Object[][] {
			},
			new String[] {
				"\u623F\u95F4\u53F7", "\u7C7B\u578B", "\u4EF7\u683C", "\u72B6\u6001"
			}
		));
		scrollPane.setViewportView(table);
		
		JLabel label = new JLabel("\u623F\u95F4\u8BE6\u60C5");
		label.setBounds(184, 10, 54, 15);
		contentPane.add(label);
		
		JLabel label_1 = new JLabel("\u623F\u95F4\u7C7B\u578B\uFF1A");
		label_1.setBounds(10, 161, 79, 15);
		contentPane.add(label_1);
		
		JComboBox comboBox = new JComboBox();
		comboBox.addItem("单人间");
		comboBox.addItem("双人间");
		comboBox.addItem("豪华套房");
		comboBox.setBounds(73, 158, 66, 21);
		contentPane.add(comboBox);
		
		JLabel label_2 = new JLabel("\u4FEE\u6539\u4EF7\u683C\uFF1A");
		label_2.setBounds(149, 161, 65, 15);
		contentPane.add(label_2);
		
		textField = new JTextField();
		textField.setBounds(226, 158, 66, 21);
		contentPane.add(textField);
		textField.setColumns(10);
		
		JButton button = new JButton("\u786E\u5B9A");
		button.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				String Str=(String) comboBox.getSelectedItem();
				String Str2=textField.getText();
				int iid2=0;
				for(int i=0;i0){
					dtm.removeRow(dtm.getRowCount()-1);
				}
				for (SumHome sumhome : m) {
					Vector v=new Vector();
					v.add(sumhome.getHomenumber());
					v.add(sumhome.getHome());
					v.add(sumhome.getMoney());
					v.add(sumhome.getState());
					dtm.addRow(v);
			}
			}
		});
		button.setBounds(311, 157, 93, 23);
		contentPane.add(button);
		
		JLabel label_3 = new JLabel("\u623F\u95F4\u53F7\uFF1A");
		label_3.setBounds(10, 186, 54, 15);
		contentPane.add(label_3);
		
		textField_1 = new JTextField();
		textField_1.setBounds(73, 183, 66, 21);
		contentPane.add(textField_1);
		textField_1.setColumns(10);
		
		JLabel label_4 = new JLabel("\u623F\u95F4\u7C7B\u578B\uFF1A");
		label_4.setBounds(149, 186, 65, 15);
		contentPane.add(label_4);
		
		JLabel label_5 = new JLabel("\u4EF7\u683C\uFF1A");
		label_5.setBounds(10, 211, 54, 15);
		contentPane.add(label_5);
		
		textField_3 = new JTextField();
		textField_3.setBounds(73, 208, 66, 21);
		contentPane.add(textField_3);
		textField_3.setColumns(10);
		
		JLabel label_6 = new JLabel("\u72B6\u6001\uFF081/0\uFF09\uFF1A");
		label_6.setBounds(149, 211, 79, 15);
		contentPane.add(label_6);
		
		textField_4 = new JTextField();
		textField_4.setBounds(226, 208, 66, 21);
		contentPane.add(textField_4);
		textField_4.setColumns(10);
		
		JComboBox comboBox_1 = new JComboBox();
		comboBox_1.addItem("单人间");
		comboBox_1.addItem("双人间");
		comboBox_1.addItem("豪华套房");
		comboBox_1.setBounds(226, 183, 66, 21);
		contentPane.add(comboBox_1);
		
		JButton button_1 = new JButton("\u6DFB\u52A0");
		button_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				String Str=textField_1.getText();
				for (SumHome sumhome : m) {
					if(sumhome.getHomenumber().equals(Str)) {
						JOptionPane.showMessageDialog(null, "房间号已存在");
						return;
					}
				}
				SumHome sumhome1=new SumHome();
				sumhome1.setHomenumber(Str);
				String Str2=(String) comboBox_1.getSelectedItem();
				sumhome1.setHome(Str2);
				String Str3=textField_3.getText();
				int iid3=0;
				for(int i=0;i0){
					dtm.removeRow(dtm.getRowCount()-1);
				}
				List m = null;
				try {
					m = g.query();
				} catch (Exception e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
				for (SumHome sumhome : m) {
					Vector v=new Vector();
					v.add(sumhome.getHomenumber());
					v.add(sumhome.getHome());
					v.add(sumhome.getMoney());
					v.add(sumhome.getState());
					dtm.addRow(v);
			}
			}
		});
		button_1.setBounds(311, 190, 93, 36);
		contentPane.add(button_1);
		
		JLabel label_7 = new JLabel("");
		label_7.setIcon(new ImageIcon("H:\\zjavaStudy\\EnglishEclipaseJob\\hotel\\src\\icon\\u=3006991615,3365362070&fm=27&gp=0.jpg"));
		label_7.setBounds(0, 0, 444, 271);
		contentPane.add(label_7);
		
		DefaultTableModel dtm=(DefaultTableModel) table.getModel();
		for (SumHome sumhome : m) {
				Vector v=new Vector();
				v.add(sumhome.getHomenumber());
				v.add(sumhome.getHome());
				v.add(sumhome.getMoney());
				v.add(sumhome.getState());
				dtm.addRow(v);
		}
	}
}
 
  

 

package windowlogin;

import java.util.List;
import java.util.Vector;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;

import method.ContactMethod;
import method.HomeMethod;
import method.OrderMethod;
import model.Contact;
import model.Order;

import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.sql.SQLException;
import java.awt.event.ActionEvent;
import javax.swing.ImageIcon;

@SuppressWarnings("serial")
public class Root2 extends JFrame {

	private JPanel contentPane;
	private JTable table;
	private JTextField textField;
	private JTextField textField_1;

	/**
	 * Launch the application.
	 */
	
	/**
	 * Create the frame.
	 * @throws Exception 
	 */
	public Root2() throws Exception {
		setResizable(false);
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		setBounds(100, 100, 500, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		this.setLocationRelativeTo(null); 		//设置居中显示
		OrderMethod gg=new OrderMethod();//获取顾客表的操作方法
		List m=gg.query();//返回顾客信息到List中
		ContactMethod ggg=new ContactMethod();//获取顾客表的操作方法
		HomeMethod gggg=new HomeMethod();
		
		JScrollPane scrollPane = new JScrollPane();
		scrollPane.setBounds(10, 35, 464, 117);
		contentPane.add(scrollPane);
		
		table = new JTable();
		table.setModel(new DefaultTableModel(
			new Object[][] {
			},
			new String[] {
				"\u8BA2\u5355\u53F7", "\u623F\u95F4\u53F7", "id", "\u623F\u95F4\u7C7B\u578B", "\u5F00\u59CB\u65F6\u95F4", "\u7ED3\u675F\u65F6\u95F4"
			}
		));
		scrollPane.setViewportView(table);
		
		table.getColumnModel().getColumn(0).setPreferredWidth(130);
	    
		
		JLabel label = new JLabel("\u8BA2\u5355\u7BA1\u7406");
		label.setBounds(201, 10, 54, 15);
		contentPane.add(label);
		
		JLabel label_1 = new JLabel("\u8BA2\u5355\u53F7\uFF1A");
		label_1.setBounds(10, 166, 54, 15);
		contentPane.add(label_1);
		
		textField = new JTextField();
		textField.setBounds(61, 163, 66, 21);
		contentPane.add(textField);
		textField.setColumns(10);
		
		JButton button = new JButton("\u5220\u9664");
		button.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				String Str=textField.getText();
				for (Order order : m) {
					if(order.getOrdernumber().equals(Str)) {
						try {
							gggg.updatacostmer(ggg.getorder(order.getOrdernumber()).getHomenumber());
						} catch (Exception e3) {
							// TODO Auto-generated catch block
							e3.printStackTrace();
						}
						try {
							gg.deletecostmer(Str);
						} catch (SQLException e1) {
							// TODO Auto-generated catch block
							e1.printStackTrace();
						}
						try {
							ggg.deletecostmer(Str);
						} catch (SQLException e1) {
							// TODO Auto-generated catch block
							e1.printStackTrace();
						}
						//表格显示信息
						DefaultTableModel dtm=(DefaultTableModel) table.getModel();
						//清空
						while(dtm.getRowCount()>0){
							dtm.removeRow(dtm.getRowCount()-1);
						}
						List m = null;
						try {
							m = gg.query();
						} catch (Exception e2) {
							// TODO Auto-generated catch block
							e2.printStackTrace();
						}
						for (Order order1 : m) {
							Contact Con=new Contact();
							try {
								Con=ggg.getorder(order1.getOrdernumber());
							} catch (Exception e1) {
								// TODO Auto-generated catch block
								e1.printStackTrace();
							}
							Vector v=new Vector();
							v.add(order1.getOrdernumber());
							v.add(Con.getHomenumber());
							v.add(order1.getId());
							v.add(order1.getHome());
							v.add(order1.getFirsttime());
							v.add(Con.getOldtime());
							dtm.addRow(v);
						}
						return;
					}
				}
				JOptionPane.showMessageDialog(null, "请输入正确订单号");
			}
		});
		button.setBounds(201, 162, 93, 23);
		contentPane.add(button);
		
		JButton button_1 = new JButton("\u67E5\u8BE2");
		button_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				String Str=textField.getText();
				//表格显示信息
				DefaultTableModel dtm=(DefaultTableModel) table.getModel();
				//清空
				while(dtm.getRowCount()>0){
					dtm.removeRow(dtm.getRowCount()-1);
				}
				for (Order order : m) {
					if(order.getOrdernumber().equals(Str)) {
						Contact Con=new Contact();
						try {
							Con=ggg.getorder(order.getOrdernumber());
						} catch (Exception e1) {
							// TODO Auto-generated catch block
							e1.printStackTrace();
						}
						Vector v=new Vector();
						v.add(order.getOrdernumber());
						v.add(Con.getHomenumber());
						v.add(order.getId());
						v.add(order.getHome());
						v.add(order.getFirsttime());
						v.add(Con.getOldtime());
						dtm.addRow(v);
					}
				}
			}
		});
		button_1.setBounds(381, 162, 93, 23);
		contentPane.add(button_1);
		
		JLabel lblId = new JLabel("id:");
		lblId.setBounds(10, 201, 54, 15);
		contentPane.add(lblId);
		
		textField_1 = new JTextField();
		textField_1.setBounds(61, 198, 66, 21);
		contentPane.add(textField_1);
		textField_1.setColumns(10);
		
		JButton button_2 = new JButton("\u67E5\u8BE2");
		button_2.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				String Str=textField_1.getText();
				int iid=0;
				for(int i=0;i0){
					dtm.removeRow(dtm.getRowCount()-1);
				}
				for (Order order : m) {
					if(order.getId()==iid) {
						Contact Con=new Contact();
						try {
							Con=ggg.getorder(order.getOrdernumber());
						} catch (Exception e1) {
							// TODO Auto-generated catch block
							e1.printStackTrace();
						}
						Vector v=new Vector();
						v.add(order.getOrdernumber());
						v.add(Con.getHomenumber());
						v.add(order.getId());
						v.add(order.getHome());
						v.add(order.getFirsttime());
						v.add(Con.getOldtime());
						dtm.addRow(v);
					}
				}
			}
		});
		button_2.setBounds(381, 197, 93, 23);
		contentPane.add(button_2);
		
		JLabel label_2 = new JLabel("");
		label_2.setIcon(new ImageIcon("H:\\zjavaStudy\\EnglishEclipaseJob\\hotel\\src\\icon\\u=3006991615,3365362070&fm=27&gp=0.jpg"));
		label_2.setBounds(0, 0, 494, 271);
		contentPane.add(label_2);
		
		//表格显示信息
		DefaultTableModel dtm=(DefaultTableModel) table.getModel();
		for (Order order : m) {
				Contact Con=new Contact();
				Con=ggg.getorder(order.getOrdernumber());
				Vector v=new Vector();
				v.add(order.getOrdernumber());
				v.add(Con.getHomenumber());
				v.add(order.getId());
				v.add(order.getHome());
				v.add(order.getFirsttime());
				v.add(Con.getOldtime());
				dtm.addRow(v);
		}
	}

}
 
  

 

package windowlogin;


import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;

import method.CostmerMethod;
import model.Costmer;

import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.JComboBox;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.util.List;
import java.util.Vector;
import java.awt.event.ActionEvent;
import javax.swing.ImageIcon;

@SuppressWarnings("serial")
public class Root3 extends JFrame {

	private JPanel contentPane;
	private JTable table;
	private JTextField textField;
	private JTextField textField_1;

	/**
	 * Launch the application.
	 */
	/**
	 * Create the frame.
	 * @throws Exception 
	 */
	public Root3() throws Exception {
		setResizable(false);
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		CostmerMethod g=new CostmerMethod();
		List m=g.query();
		this.setLocationRelativeTo(null); 		//设置居中显示
				
		JScrollPane scrollPane = new JScrollPane();
		scrollPane.setBounds(10, 48, 414, 130);
		contentPane.add(scrollPane);
		
		table = new JTable();
		table.setModel(new DefaultTableModel(
			new Object[][] {
			},
			new String[] {
				"id", "\u59D3\u540D", "\u5BC6\u7801", "\u7535\u8BDD"
			}
		));
		scrollPane.setViewportView(table);
		
		JLabel label = new JLabel("\u987E\u5BA2\u7BA1\u7406");
		label.setBounds(179, 10, 54, 15);
		contentPane.add(label);
		
		JLabel lblNewLabel = new JLabel("id\uFF1A");
		lblNewLabel.setBounds(10, 188, 35, 15);
		contentPane.add(lblNewLabel);
		
		textField = new JTextField();
		textField.setBounds(53, 185, 54, 21);
		contentPane.add(textField);
		textField.setColumns(10);
		
		JLabel label_1 = new JLabel("\u4FEE\u6539");
		label_1.setBounds(117, 188, 54, 15);
		contentPane.add(label_1);
		
		JComboBox comboBox = new JComboBox();
		comboBox.addItem("账号");
		comboBox.addItem("密码");
		comboBox.addItem("电话");
		comboBox.setBounds(167, 185, 66, 21);
		contentPane.add(comboBox);
		
		textField_1 = new JTextField();
		textField_1.setBounds(236, 185, 66, 21);
		contentPane.add(textField_1);
		textField_1.setColumns(10);
		
		JButton btnNewButton = new JButton("\u786E\u8BA4");
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				String Str=textField.getText();
				String Str3=textField_1.getText();
				int iid2=0;
				for(int i=0;i m = null;
						try {
							m = g.query();
						} catch (Exception e1) {
							// TODO Auto-generated catch block
							e1.printStackTrace();
						}
						//获取表格对象
						DefaultTableModel dtm=(DefaultTableModel) table.getModel();
						//清空
						while(dtm.getRowCount()>0){
							dtm.removeRow(dtm.getRowCount()-1);
						}
						//写入
						for (Costmer costmer2 : m) {
								Vector v=new Vector();
								v.add(costmer2.getId());
								v.add(costmer2.getName());
								v.add(costmer2.getPassword());
								v.add(costmer2.getmyCall());
								dtm.addRow(v);
						}
						return;
					}
				}
				JOptionPane.showMessageDialog(null, "id错误");
			}
		});
		btnNewButton.setBounds(307, 184, 83, 23);
		contentPane.add(btnNewButton);
		
		JLabel label_2 = new JLabel("");
		label_2.setIcon(new ImageIcon("H:\\zjavaStudy\\EnglishEclipaseJob\\hotel\\src\\icon\\u=3006991615,3365362070&fm=27&gp=0.jpg"));
		label_2.setBounds(0, 0, 444, 271);
		contentPane.add(label_2);
		
		//添加数据到表格
		DefaultTableModel dtm=(DefaultTableModel) table.getModel();
		for (Costmer costmer : m) {
				Vector v=new Vector();
				v.add(costmer.getId());
				v.add(costmer.getName());
				v.add(costmer.getPassword());
				v.add(costmer.getmyCall());
				dtm.addRow(v);
		}
	}
}
 
  

 

package windowlogin;


import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

import method.HotelMethod;
import model.Hotel;

import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.util.List;
import java.awt.event.ActionEvent;
import javax.swing.ImageIcon;

@SuppressWarnings("serial")
public class Root4 extends JFrame {

	private JPanel contentPane;
	private JTextField textField;
	private JTextField textField_1;
	private JTextField textField_2;

	/**
	 * Launch the application.
	 */
	/**
	 * Create the frame.
	 * @throws Exception 
	 */
	public Root4() throws Exception {
		setResizable(false);
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		HotelMethod gg=new HotelMethod();
		List m=gg.query();
		this.setLocationRelativeTo(null); 		//设置居中显示
		
		JLabel label = new JLabel("\u9152\u5E97\u7BA1\u7406");
		label.setBounds(176, 10, 54, 15);
		contentPane.add(label);
		
		JLabel label_1 = new JLabel("\u540D\u79F0\uFF1A");
		label_1.setBounds(29, 63, 54, 15);
		contentPane.add(label_1);
		
		JLabel label_2 = new JLabel("\u7535\u8BDD\uFF1A");
		label_2.setBounds(29, 107, 54, 15);
		contentPane.add(label_2);
		
		JLabel label_3 = new JLabel("\u5730\u5740\uFF1A");
		label_3.setBounds(29, 149, 54, 15);
		contentPane.add(label_3);
		
		JLabel label_4 = new JLabel("");
		label_4.setBounds(73, 63, 115, 15);
		contentPane.add(label_4);
		
		JLabel label_5 = new JLabel("");
		label_5.setBounds(73, 107, 115, 15);
		contentPane.add(label_5);
		
		JLabel label_6 = new JLabel("");
		label_6.setBounds(73, 149, 115, 15);
		contentPane.add(label_6);
		
		textField = new JTextField();
		textField.setBounds(198, 60, 93, 21);
		contentPane.add(textField);
		textField.setColumns(10);
		
		textField_1 = new JTextField();
		textField_1.setBounds(198, 104, 93, 21);
		contentPane.add(textField_1);
		textField_1.setColumns(10);
		
		textField_2 = new JTextField();
		textField_2.setBounds(198, 146, 93, 21);
		contentPane.add(textField_2);
		textField_2.setColumns(10);
		
		JButton button = new JButton("\u4FEE\u6539");
		button.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				String Str=textField.getText();
				if(Str.length()<3) {
					JOptionPane.showMessageDialog(null, "名称过短");
					return;
				}
				Hotel hotel =m.get(0);
				hotel.setHotelname(Str);
				try {
					gg.updatacostmer(hotel);
					JOptionPane.showMessageDialog(null, "修改成功");
					label_4.setText(hotel.getHotelname());
					} catch (Exception e1) {
						// TODO Auto-generated catch block
						e1.printStackTrace();
					}
			}
		});
		button.setBounds(290, 59, 93, 23);
		contentPane.add(button);
		
		JButton button_1 = new JButton("\u4FEE\u6539");
		button_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				String Str=textField_1.getText();
				if(Str.length()!=11) {
					JOptionPane.showMessageDialog(null, "请输入正确的手机号");
					return;
				}
				Hotel hotel =m.get(0);
				hotel.setHotelcall(Str);
				try {
					gg.updatacostmer(hotel);
					JOptionPane.showMessageDialog(null, "修改成功");
					label_5.setText(hotel.getHotelcall());
				} catch (Exception e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		});
		button_1.setBounds(290, 103, 93, 23);
		contentPane.add(button_1);
		
		JButton button_2 = new JButton("\u4FEE\u6539");
		button_2.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				String Str=textField_2.getText();
				if(Str.length()<5) {
					JOptionPane.showMessageDialog(null, "地址过短");
					return;
				}
				Hotel hotel =m.get(0);
				hotel.setmyLocation(Str);
				try {
					gg.updatacostmer(hotel);
					JOptionPane.showMessageDialog(null, "修改成功");
					label_6.setText(hotel.getmyLocation());
				} catch (Exception e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
			}
		});
		button_2.setBounds(290, 145, 93, 23);
		contentPane.add(button_2);
		
		JLabel label_7 = new JLabel("");
		label_7.setIcon(new ImageIcon("H:\\zjavaStudy\\EnglishEclipaseJob\\hotel\\src\\icon\\u=3006991615,3365362070&fm=27&gp=0.jpg"));
		label_7.setBounds(0, 0, 444, 271);
		contentPane.add(label_7);
		
		for (Hotel hotel : m) {
			label_4.setText(hotel.getHotelname());
			label_5.setText(hotel.getHotelcall());
			label_6.setText(hotel.getmyLocation());
		}
		
	}
}

 

package windowlogin;

import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

import method.CostmerMethod;
import model.Costmer;

import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.util.List;
import java.awt.event.ActionEvent;
import java.awt.Font;
import javax.swing.ImageIcon;
import javax.swing.JPasswordField;

@SuppressWarnings("serial")
public class Login extends JFrame {

	private JPanel contentPane;
	private JTextField textField;
	static Login frame;
	private JPasswordField textField_1;
	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					frame = new Login();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 * @throws Exception 
	 */
	public Login() throws Exception {
		CostmerMethod gg=new CostmerMethod();//获取顾客表的操作方法
		
		setResizable(false);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		this.setLocationRelativeTo(null); 		//设置居中显示
		
		JLabel label = new JLabel("\u8D26\u53F7\uFF1A");
		label.setIcon(new ImageIcon("H:\\zjavaStudy\\EnglishEclipaseJob\\hotel\\src\\icon\\\u8D26\u53F7.png"));
		label.setBounds(31, 70, 93, 21);
		contentPane.add(label);
		
		JLabel label_1 = new JLabel("\u5BC6\u7801\uFF1A");
		label_1.setIcon(new ImageIcon("H:\\zjavaStudy\\EnglishEclipaseJob\\hotel\\src\\icon\\\u5BC6\u7801.png"));
		label_1.setBounds(31, 98, 93, 21);
		contentPane.add(label_1);
		
		textField = new JTextField();
		textField.setBounds(122, 70, 211, 21);
		contentPane.add(textField);
		textField.setColumns(10);
		
		JButton button = new JButton("\u767B\u5F55");
		button.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				List m = null;
				try {
					m = gg.query();
				} catch (Exception e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}//返回顾客信息到List中
				String name=textField.getText();
				char[] password1=textField_1.getPassword();
				StringBuffer sb = new StringBuffer();
				for(int i = 0; i < password1.length; i++){
				 sb. append(password1[i]);
				}
				String password = sb.toString();
				if("".equals(name)||name==null) {
					JOptionPane.showMessageDialog(null, "账号不能为空");
					return;
				}
				if("".equals(password)||password==null) {
					JOptionPane.showMessageDialog(null, "密码不能为空");
					return;
				}
				for (Costmer costmer : m) {
					if(costmer.getName().equals(name)) {
						if(costmer.getPassword().equals(password)) {
							frame.dispose();
							EventQueue.invokeLater(new Runnable() {
								public void run() {
									try {
										final int iid=costmer.getId();
										UserMain frame = new UserMain(iid);
										frame.setVisible(true);
									} catch (Exception e) {
										e.printStackTrace();
									}
								}
							});
						}
					}
				}
			}
		});
		
		textField_1 = new JPasswordField();
		textField_1.setBounds(122, 98, 211, 21);
		contentPane.add(textField_1);
		button.setIcon(new ImageIcon("H:\\zjavaStudy\\EnglishEclipaseJob\\hotel\\src\\icon\\\u767B\u5F55.png"));
		button.setBounds(122, 126, 93, 23);
		contentPane.add(button);
		
		JButton button_1 = new JButton("\u7BA1\u7406\u5458\u767B\u5F55");
		button_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				String name=textField.getText();
				char[] password1=textField_1.getPassword();
				StringBuffer sb = new StringBuffer();
				for(int i = 0; i < password1.length; i++){
				 sb. append(password1[i]);
				}
				String password = sb.toString();
				if("".equals(name)||name==null) {
					JOptionPane.showMessageDialog(null, "账号不能为空");
					return;
				}
				if("".equals(password)||password==null) {
					JOptionPane.showMessageDialog(null, "密码不能为空");
					return;
				}
				Costmer coste=new Costmer();
				try {
					coste=gg.get(1001);
				} catch (Exception e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
				if(coste.getName().equals(name)&&coste.getPassword().equals(password)) {
					frame.dispose();
					EventQueue.invokeLater(new Runnable() {
						public void run() {
							try {
								Rootwindow frame = new Rootwindow();
								frame.setVisible(true);
							} catch (Exception e) {
								e.printStackTrace();
							}
						}
					});
				}else {
					JOptionPane.showMessageDialog(null, "账号或密码错误");
					frame.dispose();
				}
				
			}
		});
		button_1.setIcon(new ImageIcon("H:\\zjavaStudy\\EnglishEclipaseJob\\hotel\\src\\icon\\\u7BA1\u7406\u767B\u5F55.png"));
		button_1.setBounds(120, 159, 213, 23);
		contentPane.add(button_1);
		
		JButton button_2 = new JButton("\u6CE8\u518C");
		button_2.setIcon(new ImageIcon("H:\\zjavaStudy\\EnglishEclipaseJob\\hotel\\src\\icon\\\u7533\u8BF7\u8D26\u53F7.png"));
		button_2.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				EventQueue.invokeLater(new Runnable() {
					public void run() {
						try {
							Register frame = new Register();
							frame.setVisible(true);
						} catch (Exception e) {
							e.printStackTrace();
						}
					}
				});
			}
		});
		button_2.setBounds(240, 126, 93, 23);
		contentPane.add(button_2);
		
		JButton button_3 = new JButton("\u4FEE\u6539\u5BC6\u7801");
		button_3.setIcon(new ImageIcon("H:\\zjavaStudy\\EnglishEclipaseJob\\hotel\\src\\icon\\\u5BC6\u7801.png"));
		button_3.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				EventQueue.invokeLater(new Runnable() {
					public void run() {
						try {
							Modify frame = new Modify();
							frame.setVisible(true);
						} catch (Exception e) {
							e.printStackTrace();
						}
					}
				});
			}
		});
		button_3.setBounds(122, 192, 213, 23);
		contentPane.add(button_3);
		
		JLabel label_2 = new JLabel("515  \u56FD  \u9645  \u9152  \u5E97");
		label_2.setIcon(new ImageIcon("H:\\zjavaStudy\\EnglishEclipaseJob\\hotel\\src\\icon\\\u4E3B\u9898.png"));
		label_2.setFont(new Font("宋体", Font.BOLD | Font.ITALIC, 14));
		label_2.setBounds(122, 10, 211, 30);
		contentPane.add(label_2);
		
		JLabel label_3 = new JLabel("");
		label_3.setIcon(new ImageIcon("H:\\zjavaStudy\\EnglishEclipaseJob\\hotel\\src\\icon\\1.jpg"));
		label_3.setBounds(0, 0, 444, 271);
		contentPane.add(label_3);
	}
}



 

你可能感兴趣的:(『Ⅲ』项目)