javaSwing酒店管理

一、介绍

在这篇博客中,我们将介绍一个基于MySQL数据库、Java编程语言和Swing图形用户界面的简单酒店管理系统。该系统包括了查询房客信息、查询房客状态、修改房客信息、添加房间信息、添加住户、退房管理、预定管理、退订管理、入账管理、出账管理、修改资料等多个功能。

二、数据库介绍

1.t_book(预订信息表):

表示酒店客房的预订信息,每条记录对应一个预订订单。
字段解释:
id: 预订编号,主键。
name: 预订人姓名。
phone: 预订人电话。
checkTime: 预订入住时间。
creditTime: 订单创建时间。
state: 预订状态(已退订等)。
t_cashier(收支信息表):

记录酒店的收入和支出情况,用于财务管理。
字段解释:
id: 记录编号,主键。
type: 类型(收入/支出)。
money: 金额。
remarks: 备注。
time: 创建时间。

2.t_guestroom(客房信息表):

存储酒店客房的基本信息,包括房间号、状态和类型。
字段解释:
id: 客房编号,主键。
num: 房间号。
state: 房间状态(0表示空闲,1表示已入住)。
type: 客房类型。

3.t_household(住户信息表):

记录入住和退房的住户信息,包括姓名、身份证号、入住时间、房间号等。
字段解释:
id: 住户编号,主键。
name: 住户姓名。
idNum: 身份证号码。
checkTime: 入住时间。
roomNum: 入住房号。
money: 收费金额。
state: 入住状态。
outTime: 退房时间。

4.t_user(用户信息表):

存储系统用户的登录名和密码。
字段解释:
id: 用户编号,主键。
userName: 登录名。
password: 登录密码。

三、程序截图

1.查询房客信息

在这里插入图片描述

2.查询房客状态

在这里插入图片描述

3.修改客房信息

在这里插入图片描述

4.添加房间信息

在这里插入图片描述

5.添加住户

在这里插入图片描述

6.退房管理

在这里插入图片描述

7.预定管理

在这里插入图片描述

8.退订管理

在这里插入图片描述

9.入账管理

在这里插入图片描述

10.出账管理

在这里插入图片描述

11.修改资料

在这里插入图片描述

四、代码

1.addGuestRoom

/*
 * addGuestRoom.java
 *
 * Created on __DATE__, __TIME__
 */

package hotel.view;

import java.awt.event.ActionEvent;
import java.sql.Connection;

import hotel.dao.KeFangDao;
import hotel.model.KeFang;
import hotel.util.DbUtil;

import javax.swing.JOptionPane;

/**
 *
 * @author  __USER__
 */
public class addGuestRoom extends javax.swing.JInternalFrame {
	
	DbUtil dbUtil = new DbUtil();
	KeFangDao guestRoomDao = new KeFangDao();

	/** Creates new form addGuestRoom */
	public addGuestRoom() {
		initComponents();
	}

//GEN-BEGIN:initComponents
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

jLabel1 = new javax.swing.JLabel();
num = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
type = new javax.swing.JTextField();
save = new javax.swing.JButton();
reset = new javax.swing.JButton();

setClosable(true);
setTitle("添加房间信息");

jLabel1.setText("房间号");

num.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
numActionPerformed(evt);
}
});

jLabel2.setText("类型");

save.setText("保存");
save.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
saveActionPerformed(evt);
}
});

reset.setText("重置");
reset.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
resetActionPerformed(evt);
}
});

org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(45, 45, 45)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(jLabel1)
.add(jLabel2))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
.add(type)
.add(num, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE)))
.add(layout.createSequentialGroup()
.add(84, 84, 84)
.add(save)
.add(18, 18, 18)
.add(reset)))
.addContainerGap(88, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(38, 38, 38)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel1)
.add(num, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel2)
.add(type, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 17, Short.MAX_VALUE)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(reset)
.add(save))
.addContainerGap())
);

pack();
}	
	/**
	 * 重置按钮时间
	 * @param evt
	 */
	private void resetActionPerformed(ActionEvent evt) {
		reset();
	}


	private void saveActionPerformed(java.awt.event.ActionEvent evt) {
		String num = this.num.getText();
		String type = this.type.getText();
		if(num == null || "".equals(num)){
			JOptionPane.showMessageDialog(null, "请输入房间号");
			return;
		}
		if(type == null && "".equals(type)){
			JOptionPane.showMessageDialog(null, "请输入类型");
			return;
		}
		Connection con = null;
		try {
			con = dbUtil.getCon();
			KeFang g = guestRoomDao.findByRoomNum(con, Integer.parseInt(num));
			//判断房间号是否存在
			if(g != null){
				JOptionPane.showMessageDialog(null, "该房间已存在");
				return;
			}
			
			//封装对象
			KeFang guestRoom = new KeFang();
			guestRoom.setNum(Integer.parseInt(num));
			guestRoom.setState(0);
			guestRoom.setType(type);
			
			//保存数据
			int result = guestRoomDao.addGusteRoom(con, guestRoom);
			if(result != 0){
				JOptionPane.showMessageDialog(null, "添加成功");
			}else{
				JOptionPane.showMessageDialog(null, "添加失败");
			}
		} catch (Exception e) {
			JOptionPane.showMessageDialog(null, "添加失败");
			e.printStackTrace();
		}finally{
			try {
				dbUtil.closeCon(con);//关闭数据库连接
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		
		
	}
	/**
	 * 清空输入框的值
	 */
	private void reset(){
		this.num.setText("");
		this.type.setText("");
	}

	void numActionPerformed(java.awt.event.ActionEvent evt) {
		// TODO add your handling code here:
	}

//GEN-BEGIN:variables
// Variables declaration - do not modify
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JTextField num;
private javax.swing.JButton reset;
private javax.swing.JButton save;
private javax.swing.JTextField type;
// End of variables declaration//GEN-END:variables

}

2.addHousehold

/*
 * addHousehold.java
 *
 * Created on __DATE__, __TIME__
 */

package hotel.view;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;

import hotel.dao.ShouYinDao;
import hotel.dao.KeFangDao;
import hotel.dao.RuZhuDao;
import hotel.model.ShouYin;
import hotel.model.KeFang;
import hotel.model.ZhuHu;
import hotel.util.DbUtil;

import javax.swing.JButton;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;

import org.jdesktop.layout.GroupLayout;
import org.jdesktop.layout.LayoutStyle;


/**
 *
 * 添加住户窗口
 */
public class addHousehold extends JInternalFrame {
	
	//实例化对象
	DbUtil dbUtil = new DbUtil();
	RuZhuDao householdDao = new RuZhuDao();
	KeFangDao guestRoomDao = new KeFangDao();
	ShouYinDao cashierDao = new ShouYinDao();

	//创建窗口
	public addHousehold() {
		initComponents();
		this.setLocation(200, 50);
	}

	//控件
	private void initComponents() {

		jLabel1 = new JLabel();
		jLabel2 = new JLabel();
		jLabel3 = new JLabel();
		jLabel4 = new JLabel();
		name = new JTextField();
		idNum = new JTextField();
		money = new JTextField();
		roomNum = new JTextField();
		jButton1 = new JButton();
		jButton2 = new JButton();

		setClosable(true);
		setIconifiable(true);
		setMaximizable(true);
		setTitle("添加住户");

		jLabel1.setText("姓名");

		jLabel2.setText("身份证");

		jLabel3.setText("房间号");

		jLabel4.setText("收费");

		jButton1.setText("添加");
		jButton1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent evt) {
				jButton1ActionPerformed(evt);
			}
		});

		jButton2.setText("重置");
		/**
		 * layout布局
		 */
		GroupLayout layout = new GroupLayout(getContentPane());
		getContentPane().setLayout(layout);
		layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.LEADING)
						.add(layout.createSequentialGroup()
						.addContainerGap(56, Short.MAX_VALUE)
						.add(layout.createParallelGroup(GroupLayout.LEADING)
						.add(GroupLayout.TRAILING,layout.createSequentialGroup()
						.add(jButton1)
						.add(51,51,51)
						.add(jButton2)
						.add(119,119,119))
						.add(GroupLayout.TRAILING,layout.createSequentialGroup()
						.add(layout.createParallelGroup(GroupLayout.TRAILING)
						.add(jLabel3)
						.add(jLabel4)
						.add(jLabel2)
						.add(jLabel1))
						.add(50,50,50)
						.add(layout.createParallelGroup(GroupLayout.LEADING)
						.add(layout.createParallelGroup(GroupLayout.TRAILING,false)
						.add(GroupLayout.LEADING,idNum)
						.add(GroupLayout.LEADING,name,GroupLayout.DEFAULT_SIZE,195,Short.MAX_VALUE))
						.add(layout.createParallelGroup(GroupLayout.TRAILING,false)
						.add(GroupLayout.LEADING,money)
						.add(GroupLayout.LEADING,roomNum,GroupLayout.DEFAULT_SIZE,193,Short.MAX_VALUE)))
						.add(89,89,89)))));
						layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.LEADING)
						.add(layout.createSequentialGroup()
						.add(39, 39, 39)
						.add(layout.createParallelGroup(GroupLayout.BASELINE)
						.add(jLabel1)
						.add(name,GroupLayout.PREFERRED_SIZE,GroupLayout.DEFAULT_SIZE,GroupLayout.PREFERRED_SIZE))
						.addPreferredGap(LayoutStyle.RELATED)
						.add(layout.createParallelGroup(GroupLayout.BASELINE)
						.add(jLabel2)
						.add(idNum,GroupLayout.PREFERRED_SIZE,GroupLayout.DEFAULT_SIZE,GroupLayout.PREFERRED_SIZE))
						.addPreferredGap(LayoutStyle.RELATED)
						.add(layout.createParallelGroup(GroupLayout.BASELINE)
						.add(jLabel3)
						.add(roomNum,GroupLayout.PREFERRED_SIZE,GroupLayout.DEFAULT_SIZE,GroupLayout.PREFERRED_SIZE))
						.add(4, 4, 4)
						.add(layout.createParallelGroup(GroupLayout.BASELINE)
						.add(jLabel4)
						.add(money,GroupLayout.PREFERRED_SIZE,GroupLayout.DEFAULT_SIZE,GroupLayout.PREFERRED_SIZE))
						.add(18, 18, 18)
						.add(layout.createParallelGroup(GroupLayout.BASELINE)
						.add(jButton1)
						.add(jButton2))
						.addContainerGap()));

		pack();
	}// </editor-fold>
	//GEN-END:initComponents

	private void jButton1ActionPerformed(ActionEvent evt) {
		//获取输入框的值
		String name = this.name.getText();//姓名
		String idNum = this.idNum.getText();//身份证号
		
		String roomNum = this.roomNum.getText();//房间号
		String money = this.money.getText();//费用
		
		//验证值是否为空
		if("".equals(name) || name == null){
			JOptionPane.showMessageDialog(null, "请输入姓名");
			return;
		}
		if("".equals(idNum) || idNum == null){
			JOptionPane.showMessageDialog(null, "请输入身份证号码");
			return;
		}
		if("".equals(roomNum) || roomNum == null){
			JOptionPane.showMessageDialog(null, "请输入房间号");
			return;
		}
		if("".equals(money) || money == null){
			JOptionPane.showMessageDialog(null, "请输入入住费用");
		}
		//封装对象
		ZhuHu household = new ZhuHu();
		household.setName(name);
		household.setIdNum(idNum);
		household.setRoomNum(Integer.parseInt(roomNum));
		household.setMoney(Integer.parseInt(money));
		household.setState("入住中");
		Connection con = null;
		try {
			con = dbUtil.getCon();
			KeFang gr = new KeFang();
			
			//判断房间是否存在或者是否已有人入住
			gr = guestRoomDao.findByRoomNum(con, Integer.parseInt(roomNum));
			if(gr == null){
				JOptionPane.showMessageDialog(null, "未查询到客房信息");
				return;
			}
			if(gr.getState() == 1){
				JOptionPane.showMessageDialog(null, "房间占用,请重新选择房间");
				return;
			}
			int result = householdDao.addHousehold(con, household);
			if(result != 0){
				JOptionPane.showMessageDialog(null, "添加成功");
				reset();
				//更新房间状态未已入住
				KeFang guestRoom = new KeFang();
				guestRoom.setNum(Integer.parseInt(roomNum));
				guestRoom.setState(1);
				guestRoomDao.updateState(con, guestRoom);
				//添加收银信息
				ShouYin cashier = new ShouYin();
				cashier.setType("收入");
				cashier.setMoney(money);
				cashier.setRemarks("用户"+name+"入住收入金额"+money);
				cashierDao.addCashier(con, cashier);
				
			}else{
				JOptionPane.showMessageDialog(null, "添加失败");
			}
		} catch (Exception e) {
			JOptionPane.showMessageDialog(null, "添加失败");
			e.printStackTrace();
		}finally{
			try {
				dbUtil.closeCon(con);//关闭数据库连接
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}
	//清空输入框的值
	public void reset(){
		this.name.setText("");
		this.idNum.setText("");
		this.roomNum.setText("");
		this.money.setText("");
	}

	//窗口控件
	private JTextField idNum;
	private	JButton jButton1;
	private JButton jButton2;
	private JLabel jLabel1;
	private JLabel jLabel2;
	private JLabel jLabel3;
	private JLabel jLabel4;
	private JTextField money;
	private JTextField name;
	private JTextField roomNum;
	

}

3.BookManger

/*
 * BookManger.java
 *
 * Created on __DATE__, __TIME__
 */

package hotel.view;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;

import hotel.dao.YuDingDao;
import hotel.model.YuDing;
import hotel.util.DbUtil;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;

import org.jdesktop.layout.GroupLayout;
import org.jdesktop.layout.LayoutStyle;
/**
 *添加预订信息
 * @author Administrator
 *
 */
public class BookManger extends javax.swing.JInternalFrame {
	//实例化对象
	DbUtil dbUtil = new DbUtil();
	YuDingDao bookDao = new YuDingDao();

	/** 创建窗口 */
	public BookManger() {
		initComponents();
		this.setLocation(200, 50);//设置窗口位置
	}

	//初始化控件
	private void initComponents() {

		jLabel1 = new JLabel();
		name = new JTextField();
		jLabel2 = new JLabel();
		phone = new JTextField();
		jLabel3 = new JLabel();
		checkTime = new JTextField();
		save = new JButton();
		jButton2 = new JButton();

		setClosable(true);
		setIconifiable(true);
		setTitle("预订管理");

		jLabel1.setText("姓名");

		jLabel2.setText("联系电话");

		jLabel3.setText("入住时间");

		save.setText("保存");
		save.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent evt) {
				saveActionPerformed(evt);
			}
		});

		jButton2.setText("重置");
		/**
		 * layout布局
		 */
		GroupLayout layout = new GroupLayout(getContentPane());
		getContentPane().setLayout(layout);
		layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.LEADING)
		.add(layout.createSequentialGroup()
		.add(layout.createParallelGroup(GroupLayout.LEADING)
		.add(layout.createSequentialGroup()
		.add(32,32,32)
		.add(layout.createParallelGroup(GroupLayout.LEADING)
		.add(jLabel3)
		.add(jLabel2)
		.add(jLabel1))
		.addPreferredGap(LayoutStyle.RELATED)
		.add(layout.createParallelGroup(GroupLayout.LEADING,false)
		.add(GroupLayout.TRAILING,phone,GroupLayout.DEFAULT_SIZE,153,Short.MAX_VALUE)
		.add(save)
		.add(checkTime)
		.add(GroupLayout.TRAILING,name)))
		.add(layout.createSequentialGroup()
		.add(186,186,186)
		.add(jButton2))).addContainerGap(89, Short.MAX_VALUE)));
		layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.LEADING)
		.add(layout.createSequentialGroup()
		.add(30, 30, 30)
		.add(layout.createParallelGroup(GroupLayout.BASELINE)
		.add(jLabel1)
		.add(name,GroupLayout.PREFERRED_SIZE,GroupLayout.DEFAULT_SIZE,GroupLayout.PREFERRED_SIZE))
		.addPreferredGap(LayoutStyle.RELATED)
		.add(layout.createParallelGroup(GroupLayout.BASELINE)
		.add(jLabel2)
		.add(phone,GroupLayout.PREFERRED_SIZE,GroupLayout.DEFAULT_SIZE,GroupLayout.PREFERRED_SIZE))
		.addPreferredGap(LayoutStyle.RELATED)
		.add(layout.createParallelGroup(GroupLayout.BASELINE)
		.add(jLabel3)
		.add(checkTime,GroupLayout.PREFERRED_SIZE,GroupLayout.DEFAULT_SIZE,GroupLayout.PREFERRED_SIZE))
		.addPreferredGap(LayoutStyle.RELATED,28, Short.MAX_VALUE)
		.add(layout.createParallelGroup(GroupLayout.BASELINE)
		.add(jButton2)
		.add(save))
		.addContainerGap()));

		pack();
	}
	/**
	 * 保存按钮事件
	 * @param evt
	 */
	private void saveActionPerformed(java.awt.event.ActionEvent evt) {
		String name = this.name.getText();//姓名
		String phone = this.phone.getText();//联系电话
		String checkTime = this.checkTime.getText();//预订入住时间
		
		//验证数据是否为空
		if (name == null || "".equals(name)) {
			JOptionPane.showMessageDialog(null, "请输入入住人姓名");
		}
		if (phone == null || "".equals(phone)) {
			JOptionPane.showMessageDialog(null, "请输入联系电话");
		}
		if (checkTime == null || "".equals(checkTime)) {
			JOptionPane.showMessageDialog(null, "请输入入住时间");
		}
		//封装数据对象
		YuDing book = new YuDing();
		book.setName(name);
		book.setPhone(phone);
		book.setCheckTime(checkTime);
		book.setState("已预订");
		Connection con = null;
		//保存数据
		try {
			con = dbUtil.getCon();
			int result = bookDao.addBook(con, book);
			if (result != 0) {
				JOptionPane.showMessageDialog(null, "保存成功");
				reset();
			} else {
				JOptionPane.showMessageDialog(null, "保存失败");
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			JOptionPane.showMessageDialog(null, "保存失败");
		}finally{
			try {
				dbUtil.closeCon(con);//关闭数据库连接
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
	//清空输入框的值
	private void reset() {
		this.name.setText("");
		this.phone.setText("");
		this.checkTime.setText("");
	}

	/** 控件 */
	private JTextField checkTime;
	private JButton jButton2;
	private JLabel jLabel1;
	private JLabel jLabel2;
	private JLabel jLabel3;
	private JTextField name;
	private JTextField phone;
	private JButton save;
	

}

4.editAdmin

 * editAdmin.java
 *
 * Created on __DATE__, __TIME__
 */

package hotel.view;

import hotel.dao.BianJiDao;
import hotel.util.DbUtil;

import java.sql.Connection;

import javax.swing.JOptionPane;

/**
 *
 * @author  __USER__
 */
public class editAdmin extends javax.swing.JInternalFrame {
	DbUtil dbUtil = new DbUtil();
	BianJiDao editModulDao = new BianJiDao();

	/** Creates new form editAdmin */
	public editAdmin() {
		initComponents();
	}

	/** This method is called from within the constructor to
	 * initialize the form.
	 * WARNING: Do NOT modify this code. The content of this method is
	 * always regenerated by the Form Editor.
	 */
	//GEN-BEGIN:initComponents
	// <editor-fold defaultstate="collapsed" desc="Generated Code">
	private void initComponents() {

		jLabel1 = new javax.swing.JLabel();
		jTextField1 = new javax.swing.JTextField();
		jLabel2 = new javax.swing.JLabel();
		password = new javax.swing.JPasswordField();
		jLabel3 = new javax.swing.JLabel();
		repassword = new javax.swing.JPasswordField();
		jButton1 = new javax.swing.JButton();
		jLabel4 = new javax.swing.JLabel();
		oldpassword = new javax.swing.JPasswordField();

		setClosable(true);
		setResizable(true);

		jLabel1.setText("\u7528\u6237\u540d");

		jTextField1.setText("admin");
		jTextField1.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jTextField1ActionPerformed(evt);
			}
		});

		jLabel2.setText("\u65b0\u5bc6\u7801");

		password.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				passwordActionPerformed(evt);
			}
		});

		jLabel3.setText("\u786e\u8ba4\u5bc6\u7801");

		jButton1.setText("\u4fee\u6539");
		jButton1.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jButton1ActionPerformed(evt);
			}
		});

		jLabel4.setText("\u65e7\u5bc6\u7801");

		org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(
				getContentPane());
		getContentPane().setLayout(layout);
		layout.setHorizontalGroup(layout
				.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
				.add(layout
						.createSequentialGroup()
						.add(layout
								.createParallelGroup(
										org.jdesktop.layout.GroupLayout.LEADING)
								.add(layout
										.createSequentialGroup()
										.add(26, 26, 26)
										.add(layout
												.createParallelGroup(
														org.jdesktop.layout.GroupLayout.TRAILING)
												.add(jLabel3)
												.add(jLabel2)
												.add(layout
														.createParallelGroup(
																org.jdesktop.layout.GroupLayout.LEADING)
														.add(jLabel4)
														.add(jLabel1)))
										.addPreferredGap(
												org.jdesktop.layout.LayoutStyle.RELATED)
										.add(layout
												.createParallelGroup(
														org.jdesktop.layout.GroupLayout.LEADING,
														false)
												.add(oldpassword, 0, 0,
														Short.MAX_VALUE)
												.add(jTextField1,
														org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
														181, Short.MAX_VALUE)
												.add(repassword, 0, 0,
														Short.MAX_VALUE)
												.add(password, 0, 0,
														Short.MAX_VALUE)))
								.add(layout.createSequentialGroup()
										.add(134, 134, 134).add(jButton1)))
						.addContainerGap(82, Short.MAX_VALUE)));
		layout.setVerticalGroup(layout
				.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
				.add(layout
						.createSequentialGroup()
						.add(26, 26, 26)
						.add(layout
								.createParallelGroup(
										org.jdesktop.layout.GroupLayout.BASELINE)
								.add(jTextField1,
										org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
										org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
										org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
								.add(jLabel1))
						.add(18, 18, 18)
						.add(layout
								.createParallelGroup(
										org.jdesktop.layout.GroupLayout.BASELINE)
								.add(jLabel4)
								.add(oldpassword,
										org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
										org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
										org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
						.add(12, 12, 12)
						.add(layout
								.createParallelGroup(
										org.jdesktop.layout.GroupLayout.BASELINE)
								.add(password,
										org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
										org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
										org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
								.add(jLabel2))
						.addPreferredGap(
								org.jdesktop.layout.LayoutStyle.UNRELATED)
						.add(layout
								.createParallelGroup(
										org.jdesktop.layout.GroupLayout.BASELINE)
								.add(repassword,
										org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
										org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
										org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
								.add(jLabel3))
						.addPreferredGap(
								org.jdesktop.layout.LayoutStyle.RELATED, 23,
								Short.MAX_VALUE).add(jButton1).add(28, 28, 28)));

		pack();
	}// </editor-fold>
	//GEN-END:initComponents

	private void passwordActionPerformed(java.awt.event.ActionEvent evt) {
		// TODO add your handling code here:
	}

	private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
		Connection con = null;
		String password = new String(this.password.getPassword());
		String repassword = new String(this.repassword.getPassword());
		String oldpassword = new String(this.oldpassword.getPassword());
		try {
			con = dbUtil.getCon();
			String oldpwd = editModulDao.oldPassword(con);
			if(!oldpassword.equals(oldpwd)){
				JOptionPane.showMessageDialog(null, "旧密码不符");
				return;
			}
		} catch (Exception e1) {
			e1.printStackTrace();
		}
		if (password == null || "".equals(password)) {
			JOptionPane.showMessageDialog(null, "请输入密码");
			return;
		}
		if (!password.equals(repassword)) {
			JOptionPane.showMessageDialog(null, "两次输入密码不一致");
			return;
		}
		//修改数据库操作
		try {
			con = dbUtil.getCon();
			int result = editModulDao.updateAdmin(con, password);
			if (result != 0) {
				JOptionPane.showMessageDialog(null, "修改成功");
				this.password.setText("");
			} else {
				JOptionPane.showMessageDialog(null, "修改失败");
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			try {
				dbUtil.closeCon(con);//关闭数据库连接
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}

	private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {
		// TODO add your handling code here:
	}

	//GEN-BEGIN:variables
	// Variables declaration - do not modify
	private javax.swing.JButton jButton1;
	private javax.swing.JLabel jLabel1;
	private javax.swing.JLabel jLabel2;
	private javax.swing.JLabel jLabel3;
	private javax.swing.JLabel jLabel4;
	private javax.swing.JTextField jTextField1;
	private javax.swing.JPasswordField oldpassword;
	private javax.swing.JPasswordField password;
	private javax.swing.JPasswordField repassword;
	// End of variables declaration//GEN-END:variables

}```


## 5.editData
```java
/*
 * editData.java
 *
 * Created on __DATE__, __TIME__
 */

package hotel.view;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPasswordField;
import javax.swing.JTextField;

import org.jdesktop.layout.GroupLayout;
import org.jdesktop.layout.LayoutStyle;

import hotel.dao.BianJiDao;
import hotel.util.DbUtil;

/**
 * 修改管理员资料
 * @author Administrator
 *
 */
public class editData extends javax.swing.JInternalFrame {

	DbUtil dbUtil = new DbUtil();
	BianJiDao editModulDao = new BianJiDao();

	/** Creates new form editData */
	public editData() {
		initComponents();
		this.setLocation(300, 100);//设置窗口位置
	}
	/** 控件 */
	private void initComponents() {

		jLabel1 = new JLabel();
		jTextField1 = new JTextField();
		jLabel2 = new JLabel();
		password = new JPasswordField();
		password2 = new JPasswordField();
		jButton1 = new JButton();
		reset = new JButton();

		setClosable(true);
		setTitle("修改资料");

		jLabel1.setText("账号");

		jTextField1.setEditable(false);
		jTextField1.setText("admin");

		jLabel2.setText("密码");

		jButton1.setText("修改");
		jButton1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent evt) {
				jButton1ActionPerformed(evt);
			}
		});

		reset.setText("重置");
		reset.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent evt) {
				resetActionPerformed(evt);
			}
		});
		/**
		 * layout布局
		 */
		GroupLayout layout = new GroupLayout(getContentPane());
		getContentPane().setLayout(layout);
		layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.LEADING)
		.add(layout.createSequentialGroup()
		.add(29, 29, 29)
		.add(layout.createParallelGroup(GroupLayout.LEADING,false)
		.add(layout.createSequentialGroup()
		.add(jLabel1)
		.add(18,18,18)
		.add(jTextField1,GroupLayout.PREFERRED_SIZE,172,GroupLayout.PREFERRED_SIZE))
		.add(layout.createSequentialGroup()
		.add(jLabel2)
		.add(18,18,18)
		.add(layout.createParallelGroup(GroupLayout.LEADING)
		.add(password,0,0,Short.MAX_VALUE)
		.add(layout.createSequentialGroup()
		.add(jButton1).addPreferredGap(LayoutStyle.RELATED,35,Short.MAX_VALUE)
		.add(reset)
		.add(23,23,23)))))
		.addContainerGap(52, Short.MAX_VALUE)));
		layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.LEADING)
		.add(layout.createSequentialGroup()
		.add(31, 31, 31)
		.add(layout.createParallelGroup(GroupLayout.BASELINE)
		.add(jLabel1)
		.add(jTextField1,GroupLayout.PREFERRED_SIZE,GroupLayout.DEFAULT_SIZE,GroupLayout.PREFERRED_SIZE))
		.add(18, 18, 18)
		.add(layout.createParallelGroup(GroupLayout.BASELINE)
		.add(jLabel2)
		.add(password,GroupLayout.PREFERRED_SIZE,GroupLayout.DEFAULT_SIZE,GroupLayout.PREFERRED_SIZE))
		.add(18, 18, 18)
		.add(layout.createParallelGroup(GroupLayout.BASELINE)
		.add(jButton1).add(reset))
		.addContainerGap(35, Short.MAX_VALUE)));

		pack();
	}

	/**
	 * 修改管理员资料
	 */
	//修改按钮事件
	private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
		String password = new String(this.password.getPassword());
		String repassword = new String(this.password2.getPassword());
		if (password == null || "".equals(password)) {
			JOptionPane.showMessageDialog(null, "请输入密码");
			return;
		}
		if(!password.equals(repassword)){
			JOptionPane.showMessageDialog(null, "两次输入密码不一致");
			return;
		}
		Connection con = null;
		//修改数据库操作
		try {
			con = dbUtil.getCon();
			int result = editModulDao.updateAdmin(con, password);
			if (result != 0) {
				JOptionPane.showMessageDialog(null, "修改成功");
				this.password.setText("");
			} else {
				JOptionPane.showMessageDialog(null, "修改失败");
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			try {
				dbUtil.closeCon(con);//关闭数据库连接
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
	//重置输入框的值
	private void resetActionPerformed(ActionEvent evt) {
		this.password.setText("");
	}

	//页面控件
	private JButton jButton1;
	private JLabel jLabel1;
	private JLabel jLabel2;
	private JTextField jTextField1;
	private JPasswordField password;
	private JPasswordField password2;
	private JButton reset;
	

}

5.inAccountManger

/*
 * inAccountManger.java
 *
 * Created on __DATE__, __TIME__
 */

package hotel.view;

import hotel.dao.YuDingDao;
import hotel.dao.ShouYinDao;
import hotel.model.ShouYin;
import hotel.util.DbUtil;

import java.sql.Connection;
import java.sql.ResultSet;
import java.util.Vector;

import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;

import com.sun.org.apache.bcel.internal.generic.NEW;

/**
 *
 * @author  __USER__
 */
public class inAccountManger extends javax.swing.JInternalFrame {

	DbUtil dbUtil = new DbUtil();
	ShouYinDao cashierDao = new ShouYinDao();

	/** Creates new form inAccountManger */
	public inAccountManger() {
		initComponents();
		this.fillTable();
		this.setLocation(200, 50);//设置窗口位置
	}

	/**
	 * 填充表格数据
	 * @param name
	 */
	public void fillTable() {
		DefaultTableModel dtm = (DefaultTableModel) inAccountTable.getModel();
		dtm.setRowCount(0);
		Connection con = null;
		try {
			con = dbUtil.getCon();
			ResultSet re = cashierDao.cashier(con);
			while (re.next()) {
				Vector v = new Vector();
				//添加每一行的数据
				v.add(re.getString("id"));
				v.add(re.getString("type"));
				v.add(re.getString("money"));
				v.add(re.getString("remarks"));
				v.add(re.getString("time"));
				dtm.addRow(v);
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			try {
				dbUtil.closeCon(con);
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}

	/** This method is called from within the constructor to
	 * initialize the form.
	 * WARNING: Do NOT modify this code. The content of this method is
	 * always regenerated by the Form Editor.
	 */
	//GEN-BEGIN:initComponents
	// <editor-fold defaultstate="collapsed" desc="Generated Code">
	private void initComponents() {

		jScrollPane1 = new javax.swing.JScrollPane();
		inAccountTable = new javax.swing.JTable();
		jPanel1 = new javax.swing.JPanel();
		jLabel1 = new javax.swing.JLabel();
		money = new javax.swing.JTextField();
		jLabel2 = new javax.swing.JLabel();
		remarks = new javax.swing.JTextField();
		add = new javax.swing.JButton();
		jLabel3 = new javax.swing.JLabel();
		type = new javax.swing.JTextField();

		setClosable(true);
		setIconifiable(true);
		setTitle("\u5165\u8d26\u7ba1\u7406");

		inAccountTable.setModel(new javax.swing.table.DefaultTableModel(
				new Object[][] { { null, null, null, null, null },
						{ null, null, null, null, null },
						{ null, null, null, null, null },
						{ null, null, null, null, null } }, new String[] {
						"编号", "状态", "金额", "备注", "时间" }) {
			boolean[] canEdit = new boolean[] { false, false, false, false,
					false };

			public boolean isCellEditable(int rowIndex, int columnIndex) {
				return canEdit[columnIndex];
			}
		});
		jScrollPane1.setViewportView(inAccountTable);

		jLabel1.setText("\u91d1\u989d");

		jLabel2.setText("\u5907\u6ce8");

		add.setText("\u6dfb\u52a0");
		add.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				addActionPerformed(evt);
			}
		});

		jLabel3.setText("\u7c7b\u578b");

		type.setEditable(false);
		type.setText("\u6536\u5165");
		type.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jTextField1ActionPerformed(evt);
			}
		});

		org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(
				jPanel1);
		jPanel1.setLayout(jPanel1Layout);
		jPanel1Layout
				.setHorizontalGroup(jPanel1Layout
						.createParallelGroup(
								org.jdesktop.layout.GroupLayout.LEADING)
						.add(
								jPanel1Layout
										.createSequentialGroup()
										.addContainerGap()
										.add(
												jPanel1Layout
														.createParallelGroup(
																org.jdesktop.layout.GroupLayout.TRAILING)
														.add(add)
														.add(
																jPanel1Layout
																		.createSequentialGroup()
																		.add(
																				jPanel1Layout
																						.createParallelGroup(
																								org.jdesktop.layout.GroupLayout.TRAILING,
																								false)
																						.add(
																								org.jdesktop.layout.GroupLayout.LEADING,
																								jPanel1Layout
																										.createSequentialGroup()
																										.add(
																												jLabel3)
																										.addPreferredGap(
																												org.jdesktop.layout.LayoutStyle.RELATED)
																										.add(
																												type))
																						.add(
																								jPanel1Layout
																										.createSequentialGroup()
																										.add(
																												jLabel1)
																										.addPreferredGap(
																												org.jdesktop.layout.LayoutStyle.RELATED)
																										.add(
																												money,
																												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
																												176,
																												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
																		.add(
																				18,
																				18,
																				18)
																		.add(
																				jLabel2)
																		.add(
																				18,
																				18,
																				18)
																		.add(
																				remarks,
																				org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
																				181,
																				org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
										.addContainerGap(439, Short.MAX_VALUE)));
		jPanel1Layout
				.setVerticalGroup(jPanel1Layout
						.createParallelGroup(
								org.jdesktop.layout.GroupLayout.LEADING)
						.add(
								jPanel1Layout
										.createSequentialGroup()
										.addContainerGap()
										.add(
												jPanel1Layout
														.createParallelGroup(
																org.jdesktop.layout.GroupLayout.BASELINE)
														.add(jLabel1)
														.add(
																money,
																org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
																org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
																org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
														.add(jLabel2)
														.add(
																remarks,
																org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
																org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
																org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
										.add(18, 18, 18)
										.add(
												jPanel1Layout
														.createParallelGroup(
																org.jdesktop.layout.GroupLayout.BASELINE)
														.add(jLabel3)
														.add(
																type,
																org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
																org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
																org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
										.addPreferredGap(
												org.jdesktop.layout.LayoutStyle.RELATED,
												org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
												Short.MAX_VALUE).add(add)));

		org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(
				getContentPane());
		getContentPane().setLayout(layout);
		layout.setHorizontalGroup(layout.createParallelGroup(
				org.jdesktop.layout.GroupLayout.LEADING).add(
				org.jdesktop.layout.GroupLayout.TRAILING,
				layout.createSequentialGroup().addContainerGap().add(
						layout.createParallelGroup(
								org.jdesktop.layout.GroupLayout.TRAILING).add(
								org.jdesktop.layout.GroupLayout.LEADING,
								jPanel1,
								org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
								org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
								Short.MAX_VALUE).add(
								org.jdesktop.layout.GroupLayout.LEADING,
								jScrollPane1,
								org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
								897, Short.MAX_VALUE)).addContainerGap()));
		layout.setVerticalGroup(layout.createParallelGroup(
				org.jdesktop.layout.GroupLayout.LEADING).add(
				layout.createSequentialGroup().addContainerGap().add(
						jScrollPane1,
						org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 131,
						org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
						.addPreferredGap(
								org.jdesktop.layout.LayoutStyle.UNRELATED).add(
								jPanel1,
								org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
								org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
								org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
						.addContainerGap(30, Short.MAX_VALUE)));

		pack();
	}// </editor-fold>
	//GEN-END:initComponents

	private void addActionPerformed(java.awt.event.ActionEvent evt) {
		String money = this.money.getText();
		String remarks = this.remarks.getText();
		String type = this.type.getText();
		if("".equals(money) || money == null){
			JOptionPane.showMessageDialog(null, "请输入金额");
			return;
		}
		if("".equals(remarks) || remarks == null){
			JOptionPane.showMessageDialog(null, "请输入备注");
			return;
		}
		ShouYin cashier = new ShouYin();
		cashier.setMoney(money);
		cashier.setRemarks(remarks);
		cashier.setType(type);
		Connection con  = null;	
		try {
			con = dbUtil.getCon();
			int result = cashierDao.addCashier(con, cashier);
			if(result != 0){
				JOptionPane.showMessageDialog(null, "添加成功!");
				this.fillTable();
				this.money.setText("");
				this.remarks.setText("");
			}
		} catch (Exception e) {
			JOptionPane.showMessageDialog(null, "添加失败!");
			e.printStackTrace();
		}
	}

	private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {
		// TODO add your handling code here:
	}

	//GEN-BEGIN:variables
	// Variables declaration - do not modify
	private javax.swing.JButton add;
	private javax.swing.JTable inAccountTable;
	private javax.swing.JLabel jLabel1;
	private javax.swing.JLabel jLabel2;
	private javax.swing.JLabel jLabel3;
	private javax.swing.JPanel jPanel1;
	private javax.swing.JScrollPane jScrollPane1;
	private javax.swing.JTextField type;
	private javax.swing.JTextField money;
	private javax.swing.JTextField remarks;
	// End of variables declaration//GEN-END:variables

}

6.login

/*
 * login.java
 *
 * Created on __DATE__, __TIME__
 */

package hotel.view;

import hotel.dao.UserDao;
import hotel.model.User;
import hotel.util.DbUtil;

import java.awt.Font;
import java.sql.Connection;

import javax.swing.JOptionPane;
import javax.swing.UIManager;


/**
 *
 * @author  __USER__
 */
public class login extends javax.swing.JFrame {
	
	DbUtil dbUtil = new DbUtil();
	UserDao userDao = new UserDao();

	/** Creates new form login */
	public login() {
		//改变系统默认字体
		Font font = new Font("Dialog", Font.PLAIN, 12);
		java.util.Enumeration keys = UIManager.getDefaults().keys();
		while (keys.hasMoreElements()) {
			Object key = keys.nextElement();
			Object value = UIManager.get(key);
			if (value instanceof javax.swing.plaf.FontUIResource) {
				UIManager.put(key, font);
			}
		}
		initComponents();
		// 设置Frame居中显示
		this.setLocationRelativeTo(null);
	}

	/** This method is called from within the constructor to
	 * initialize the form.
	 * WARNING: Do NOT modify this code. The content of this method is
	 * always regenerated by the Form Editor.
	 */
	//GEN-BEGIN:initComponents
	// <editor-fold defaultstate="collapsed" desc="Generated Code">
	private void initComponents() {

		jLabel1 = new javax.swing.JLabel();
		jLabel2 = new javax.swing.JLabel();
		userName = new javax.swing.JTextField();
		password = new javax.swing.JPasswordField();
		login = new javax.swing.JButton();
		reset = new javax.swing.JButton();

		setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
		setTitle("\u7ba1\u7406\u5458\u767b\u9646");

		jLabel1.setText("\u767b\u5f55\u540d");

		jLabel2.setText("\u5bc6\u7801");

		login.setText("\u767b\u9646");
		login.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				loginActionPerformed(evt);
			}
		});

		reset.setText("\u91cd\u7f6e");

		org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(
				getContentPane());
		getContentPane().setLayout(layout);
		layout
				.setHorizontalGroup(layout
						.createParallelGroup(
								org.jdesktop.layout.GroupLayout.LEADING)
						.add(
								layout
										.createSequentialGroup()
										.add(
												layout
														.createParallelGroup(
																org.jdesktop.layout.GroupLayout.LEADING)
														.add(
																layout
																		.createSequentialGroup()
																		.add(
																				39,
																				39,
																				39)
																		.add(
																				layout
																						.createParallelGroup(
																								org.jdesktop.layout.GroupLayout.LEADING)
																						.add(
																								jLabel1)
																						.add(
																								jLabel2))
																		.addPreferredGap(
																				org.jdesktop.layout.LayoutStyle.RELATED)
																		.add(
																				layout
																						.createParallelGroup(
																								org.jdesktop.layout.GroupLayout.LEADING,
																								false)
																						.add(
																								password,
																								0,
																								0,
																								Short.MAX_VALUE)
																						.add(
																								userName,
																								org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
																								154,
																								Short.MAX_VALUE)))
														.add(
																layout
																		.createSequentialGroup()
																		.add(
																				81,
																				81,
																				81)
																		.add(
																				login)
																		.add(
																				18,
																				18,
																				18)
																		.add(
																				reset)))
										.addContainerGap(55, Short.MAX_VALUE)));
		layout
				.setVerticalGroup(layout
						.createParallelGroup(
								org.jdesktop.layout.GroupLayout.LEADING)
						.add(
								layout
										.createSequentialGroup()
										.add(32, 32, 32)
										.add(
												layout
														.createParallelGroup(
																org.jdesktop.layout.GroupLayout.BASELINE)
														.add(jLabel1)
														.add(
																userName,
																org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
																org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
																org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
										.add(18, 18, 18)
										.add(
												layout
														.createParallelGroup(
																org.jdesktop.layout.GroupLayout.BASELINE)
														.add(jLabel2)
														.add(
																password,
																org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
																org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
																org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
										.addPreferredGap(
												org.jdesktop.layout.LayoutStyle.RELATED,
												18, Short.MAX_VALUE)
										.add(
												layout
														.createParallelGroup(
																org.jdesktop.layout.GroupLayout.BASELINE)
														.add(reset).add(login))
										.addContainerGap()));

		pack();
	}// </editor-fold>
	//GEN-END:initComponents

	private void loginActionPerformed(java.awt.event.ActionEvent evt) {
		String userName = this.userName.getText();
		String password = new String(this.password.getPassword());
		if("".equals(userName) || userName == null){
			JOptionPane.showMessageDialog(null, "用户名不能为空");
			return;
		}
		if("".equals(password) || password == null){
			JOptionPane.showMessageDialog(null, "密码不能为空");
			return;
		}
		User user = new User();
		user.setUserName(userName);
		user.setPassword(password);
		Connection conn = null;
		try {
			conn = dbUtil.getCon();
			User us = userDao.login(conn, user);
			if(us == null){
				JOptionPane.showMessageDialog(null, "用户名或密码错误");
			}else{
				this.dispose();
				new main().setVisible(true);
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			try {
				dbUtil.closeCon(conn);
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}

	/**
	 * @param args the command line arguments
	 */
	public static void main(String args[]) {
		java.awt.EventQueue.invokeLater(new Runnable() {
			public void run() {
				new login().setVisible(true);
			}
		});
	}

	//GEN-BEGIN:variables
	// Variables declaration - do not modify
	private javax.swing.JLabel jLabel1;
	private javax.swing.JLabel jLabel2;
	private javax.swing.JButton login;
	private javax.swing.JPasswordField password;
	private javax.swing.JButton reset;
	private javax.swing.JTextField userName;
	// End of variables declaration//GEN-END:variables

}

五、联系与交流

扣:969060742 完整程序资源、sql、代码

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/234913.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

微信小程序制作-背单词的小程序制作

微信小程序–背单词的 好久没有发过文章了&#xff0c;但是不代表着我不去学习了喽&#xff0c;以下是我最近做的东西&#xff0c;前端的UI由朋友设计的&#xff0c;目前这个是前端使用的是微信小程序后端是Python的一个轻量型框架&#xff0c;FastApi&#xff0c;嗯&#xff…

fv悬浮球自定义任务正在编辑的文件操作失误丢失找回方法_fv悬浮球自定义任务推荐

场景&#xff1a;自定义任务时不小心点击了取消按钮或者删除按钮导致重要丢失 原因&#xff1a;因为fv悬浮球自定义任务没有撤回按钮 解决方案&#xff1a;使用系统的应用设置把悬浮球强制停止运行&#xff0c;默认&#xff08;开启全部权限&#xff09;然后它会自动重启&…

IBM Qiskit量子机器学习速成(六)

量子卷积神经网络 卷积和池化&#xff1a;卷积神经网络的必备成分 卷积神经网络被广泛应用于图像和音频的识别当中&#xff0c;关键在于“卷积”操作赋予神经网络统筹学习数据的能力。 执行卷积操作需要输入数据与卷积核&#xff0c;卷积核首先与输入数据左上角对齐&#xf…

【Scala】Scala中的一些基本数据类型的特性 列表、元组、构造器、单例对象、伴生类、伴生对象、抽象类与特质

列表 使用List(“”,“”,“”)去声明 sliding 和 groued表示迭代器 val iter List("Hadoop", "Spark", "Scala") sliding 2// sliding 和 groued 是有区别的while (iter.hasNext){println(iter.next())}for (elem <- iter){println(elem)}…

高项备考葵花宝典-项目进度管理核心概念加强记忆

项目进度管理的核心目标是使项目按时完成。 目录 一、待办事项列表 二、看板方法 三、在制品 四、进度计划模型 五、活动清单 六、里程碑清单 七、前导图法 八、资源日历 九、活动历时估算方法 一、待办事项列表 如上图所示&#xff0c;实际工作中需求往往不是一次性全…

【SpringBoot教程】SpringBoot 创建定时任务(配合数据库动态执行)

作者简介&#xff1a;大家好&#xff0c;我是撸代码的羊驼&#xff0c;前阿里巴巴架构师&#xff0c;现某互联网公司CTO 联系v&#xff1a;sulny_ann&#xff08;17362204968&#xff09;&#xff0c;加我进群&#xff0c;大家一起学习&#xff0c;一起进步&#xff0c;一起对抗…

Leetcode1466. 重新规划路线

Every day a Leetcode 题目来源&#xff1a;1466. 重新规划路线 解法1&#xff1a;深度优先搜索 n 座城市&#xff0c;从 0 到 n-1 编号&#xff0c;其间共有 n-1 条路线。 因此&#xff0c;要想在两座不同城市之间旅行只有唯一一条路线可供选择&#xff08;路线网形成一颗…

计算机毕业设计 SpringBoot的乐乐农产品销售系统 Javaweb项目 Java实战项目 前后端分离 文档报告 代码讲解 安装调试

&#x1f34a;作者&#xff1a;计算机编程-吉哥 &#x1f34a;简介&#xff1a;专业从事JavaWeb程序开发&#xff0c;微信小程序开发&#xff0c;定制化项目、 源码、代码讲解、文档撰写、ppt制作。做自己喜欢的事&#xff0c;生活就是快乐的。 &#x1f34a;心愿&#xff1a;点…

OSPF路由协议

随着Internet技术在全球范围的飞速发展&#xff0c;OSPF已成为目前应用最广泛的路由协议之一。OSPF&#xff08;Open Shortest Path First&#xff09;路由协议是由IETF&#xff08;Internet Engineering Task Force&#xff09;IGP工作组提出的&#xff0c;是一种基于SPF算法的…

通过生成模拟释放无限数据以实现机器人自动化学习

该工作推出RoboGen&#xff0c;这是一种生成机器人代理&#xff0c;可以通过生成模拟自动大规模学习各种机器人技能。 RoboGen 利用基础模型和生成模型的最新进展。该工作不直接使用或调整这些模型来产生策略或低级动作&#xff0c;而是提倡一种生成方案&#xff0c;该方案使用…

利用Microsoft Visual Studio Installer Projects打包安装包

利用Microsoft Visual Studio Installer Projects打包安装包 具体步骤步骤1&#xff1a;安装扩展步骤2&#xff1a;创建 Setup 项目步骤3&#xff1a;设置属性步骤4&#xff1a;添加输出步骤5&#xff1a;添加文件步骤6&#xff1a;添加桌面快捷方式步骤7&#xff1a;添加菜单快…

初识人工智能,一文读懂人工智能概论(1)

&#x1f3c6;作者简介&#xff0c;普修罗双战士&#xff0c;一直追求不断学习和成长&#xff0c;在技术的道路上持续探索和实践。 &#x1f3c6;多年互联网行业从业经验&#xff0c;历任核心研发工程师&#xff0c;项目技术负责人。 &#x1f389;欢迎 &#x1f44d;点赞✍评论…

C语言——从键盘输入两个字串,判断它们是否相同。

代码实现&#xff1a; #include <stdio.h> #include <string.h>int main() {char str1[100], str2[100];printf("请输入第一个字串&#xff1a;");scanf("%s", str1);printf("请输入第二个字串&#xff1a;");scanf("%s"…

uc_16_UDP协议_HTTP协议

1 UDP协议 适合游戏、视频等情景&#xff0c;安全性要求不高&#xff0c;效率要求高。 1&#xff09;UDP不提供客户机与服务器的链接&#xff1a; UDP的客户机与服务器不必存在长期关系。一个UDP的客户机在通过一个套接字向一个UDP服务器发送了一个数据报之后&#xff0c;马上…

C语言----文件操作(一)

一&#xff1a;C语言中文件的概念 对于文件想必大家都很熟悉&#xff0c;无论在windows上还是Linux中&#xff0c;我们用文件去存储资料&#xff0c;记录笔记&#xff0c;常见的如txt文件&#xff0c;word文档&#xff0c;log文件等。那么&#xff0c;在C语言中文件是什么样的存…

unity 2d 入门 飞翔小鸟 死亡闪烁特效(十三)

一、c#脚本 using System.Collections; using System.Collections.Generic; using UnityEngine;public class Bling : MonoBehaviour {public Texture img;public float speed;public static bool changeWhite false;private float alpha0f;// Start is called before the fi…

极速学习SSM之SpringMVC笔记

文章目录 一、SpringMVC简介1、什么是MVC2、什么是SpringMVC3、SpringMVC的特点 二、HelloWorld1、开发环境2、创建maven工程a>添加web模块b>打包方式&#xff1a;warc>引入依赖 3、配置web.xmla>默认配置方式b>扩展配置方式 4、创建请求控制器5、创建springMVC…

kafka中消息key作用与分区规则关系

在 kafka 2.0.0 的 java sdk 中 <dependency><groupId>org.apache.kafka</groupId><artifactId>kafka_2.12</artifactId><version>2.0.0</version> </dependency> ProducerRecord 中类注释如下 A key/value pair to be sen…

TypeScript 之 console的使用

语言&#xff1a; TypeScript 在线工具&#xff1a; PlayGround console console 对象是一个非常强大的控制台日志显示工具&#xff0c; 可以帮助我们在浏览器中调试代码。 注&#xff1a; console不属于TypeScript的语法&#xff0c;而是由JavaScript封装的内置对象。 简单的…

[AutoSar]一种ECU间CAN通信的优化方法

目录 关键词平台说明一、背景二、问题现象三、原因四、解决办法五、实现5.1 配置5.2 code 关键词 嵌入式、C语言、autosar 平台说明 项目ValueOSautosar OSautosar厂商EB芯片厂商英飞凌 TC397编程语言C&#xff0c;C编译器TASKING 一、背景 在一个项目中&#xff0c;会从多个…