在好例子网,分享、交流、成长!
您当前所在位置:首页Java 开发实例Java语言基础 → java酒店管理系统(源码+数据库脚本)

java酒店管理系统(源码+数据库脚本)

Java语言基础

下载此实例
  • 开发语言:Java
  • 实例大小:2.29M
  • 下载次数:310
  • 浏览次数:6031
  • 发布时间:2019-06-24
  • 实例类别:Java语言基础
  • 发 布 人:不爱敲代码的喵
  • 文件格式:.zip
  • 所需积分:2

实例介绍

【实例简介】一个很基础的Java实例,实现最基础的增删改查
【实例截图】

账号:01101  密码:1234


from clipboard

from clipboard

from clipboard


from clipboard


from clipboard


from clipboard

【核心代码】

package com.sqc.view;

import java.awt.BorderLayout;
import java.awt.EventQueue;

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

import com.sqc.dao.UserDao;
import com.sqc.model.User;
import com.sqc.util.DbUtil;
import com.sqc.util.StringUtil;

import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.BoxLayout;
import java.awt.FlowLayout;
import javax.swing.JLabel;
import javax.swing.JOptionPane;

import java.awt.Font;
import javax.swing.ImageIcon;
import javax.swing.JTextField;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.awt.event.ActionEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

public class LoginFra extends JFrame {

	private JPanel contentPane;
	private JTextField userName_text;
	private JPasswordField password_text;
	
	private DbUtil dbUtil=new DbUtil();
	private UserDao userDao=new UserDao();
	

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					LoginFra frame = new LoginFra();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public LoginFra() {
		setTitle("\u6854\u5B50\u9152\u5E97\u7BA1\u7406\u7CFB\u7EDF");
		setResizable(false);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 557, 444);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		
		JLabel password = new JLabel("\u5458\u5DE5\u53F7\uFF1A");
		password.setFont(new Font("华文行楷", Font.PLAIN, 18));
		password.setIcon(new ImageIcon(LoginFra.class.getResource("/image/head.png")));
		
		JLabel label = new JLabel("\u5BC6  \u7801\uFF1A");
		label.setFont(new Font("华文行楷", Font.PLAIN, 18));
		label.setIcon(new ImageIcon(LoginFra.class.getResource("/image/password.png")));
		
		userName_text = new JTextField();
		userName_text.setColumns(10);
		
		JButton btn_login = new JButton("\u767B      \u5F55");
		btn_login.setIcon(new ImageIcon(LoginFra.class.getResource("/image/accept.png")));
		btn_login.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				loginActionPerformed(e);
			}
		});
		btn_login.setFont(new Font("微软雅黑", Font.PLAIN, 18));
		
		JButton btn_cancel = new JButton("\u6E05      \u9664");
		btn_cancel.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				btn_cancelActionPerformed(e);
			}

		});
		btn_cancel.setIcon(new ImageIcon(LoginFra.class.getResource("/image/refersh.png")));
		btn_cancel.setFont(new Font("微软雅黑", Font.PLAIN, 18));
		
		password_text = new JPasswordField();
		
		JButton btnNewButton = new JButton("");
		btnNewButton.setIcon(new ImageIcon(LoginFra.class.getResource("/image/theme.jpg")));
		GroupLayout gl_contentPane = new GroupLayout(contentPane);
		gl_contentPane.setHorizontalGroup(
			gl_contentPane.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_contentPane.createSequentialGroup()
					.addGap(69)
					.addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
						.addComponent(label)
						.addComponent(password))
					.addGap(39)
					.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING, false)
						.addComponent(btnNewButton, GroupLayout.PREFERRED_SIZE, 148, GroupLayout.PREFERRED_SIZE)
						.addComponent(userName_text, GroupLayout.DEFAULT_SIZE, 202, Short.MAX_VALUE)
						.addComponent(password_text))
					.addContainerGap(127, Short.MAX_VALUE))
				.addGroup(gl_contentPane.createSequentialGroup()
					.addGap(93)
					.addComponent(btn_login)
					.addPreferredGap(ComponentPlacement.RELATED, 79, Short.MAX_VALUE)
					.addComponent(btn_cancel, GroupLayout.PREFERRED_SIZE, 151, GroupLayout.PREFERRED_SIZE)
					.addGap(67))
		);
		gl_contentPane.setVerticalGroup(
			gl_contentPane.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_contentPane.createSequentialGroup()
					.addGap(33)
					.addComponent(btnNewButton, GroupLayout.PREFERRED_SIZE, 134, GroupLayout.PREFERRED_SIZE)
					.addGap(27)
					.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
						.addComponent(password)
						.addComponent(userName_text, GroupLayout.PREFERRED_SIZE, 37, GroupLayout.PREFERRED_SIZE))
					.addGap(40)
					.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
						.addComponent(label)
						.addComponent(password_text, GroupLayout.PREFERRED_SIZE, 37, GroupLayout.PREFERRED_SIZE))
					.addPreferredGap(ComponentPlacement.RELATED, 21, Short.MAX_VALUE)
					.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
						.addComponent(btn_login)
						.addComponent(btn_cancel, GroupLayout.PREFERRED_SIZE, 54, GroupLayout.PREFERRED_SIZE))
					.addGap(37))
		);
		contentPane.setLayout(gl_contentPane);
	}
	/**
	 * 登录事件处理
	 * @param e
	 */
	private void loginActionPerformed(ActionEvent evt) {
		String userName=this.userName_text.getText();
		String password=new String(this.password_text.getPassword());
		if(StringUtil.isEmpty(userName)){
			JOptionPane.showMessageDialog(null, "用户名不能为空!");
			return;
		}
		if(StringUtil.isEmpty(password)){
			JOptionPane.showMessageDialog(null, "密码不能为空!");
			return;
		}
		User user=new User(userName,password);
		Connection con=null;
		try {
			con=dbUtil.getCon();
			User currentUser=userDao.login(con, user);
			if(currentUser!=null){
				dispose();
				new MainFra().setVisible(true);
			}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();
			}
		}
	}

	/**
	 * 重置事件处理
	 * @param e
	 */
	private void btn_cancelActionPerformed(ActionEvent e) {
		// TODO Auto-generated method stub
		this.userName_text.setText("");
		this.password_text.setText("");
	}
}


实例下载地址

java酒店管理系统(源码+数据库脚本)

不能下载?内容有错? 点击这里报错 + 投诉 + 提问

好例子网口号:伸出你的我的手 — 分享

网友评论

第 1 楼 飞飞飞飞飞飞飞飞 发表于: 2019-09-12 01:40 25
根本用不了数据库

支持(0) 盖楼(回复)

第 2 楼 yonghu12345678 发表于: 2020-04-25 09:33 55
数据库怎么连接呢?

支持(0) 盖楼(回复)

第 3 楼 yonghu12345678 发表于: 2020-04-25 09:33 58
数据库怎么连接呢?

支持(0) 盖楼(回复)

第 4 楼 yonghu12345678 发表于: 2020-04-25 09:33 59
数据库怎么连接呢?

支持(0) 盖楼(回复)

第 5 楼 yonghu12345678 发表于: 2020-04-25 09:34 00
数据库怎么连接呢?

支持(0) 盖楼(回复)

第 6 楼 yonghu12345678 发表于: 2020-04-25 09:34 00
数据库怎么连接呢?

支持(0) 盖楼(回复)

第 7 楼 yonghu12345678 发表于: 2020-04-25 09:34 01
数据库怎么连接呢?

支持(0) 盖楼(回复)

第 8 楼 yonghu12345678 发表于: 2020-04-25 09:34 01
数据库怎么连接呢?

支持(0) 盖楼(回复)

第 9 楼 不爱敲代码的喵 发表于: 2020-04-25 09:38 02
数据库怎么连接呢?

yonghu12345678 2020-04-25 09:34 01

把sql文件导入到Navicat中,然后修改java中连接数据库的配置。但是这个系统还是有点问题的!

支持(0) 盖楼(回复)

第 10 楼 yonghu12345678 发表于: 2020-04-25 09:43 19
数据库怎么连接呢?

yonghu12345678 2020-04-25 09:34 01

把sql文件导入到Navicat中,然后修改java中连接数据库的配置。但是这个系统还是有点问题的!

不爱敲代码的喵 2020-04-25 09:38 02

有啥问题?

支持(0) 盖楼(回复)

第 11 楼 yonghu12345678 发表于: 2020-04-25 16:17 07
能加QQ或者微信吗?有问题想请教

支持(0) 盖楼(回复)

第 12 楼 K364965044 发表于: 2020-04-26 17:24 38
这个 怎么进入 页面呢

支持(0) 盖楼(回复)

第 13 楼 javsbdjdj 发表于: 2020-07-05 18:15 47
这能联系到博主嘛或者有其他的朋友,有一些问题我解决不了。可怜!

支持(0) 盖楼(回复)

第 14 楼 javsbdjdj 发表于: 2020-07-05 21:37 23
那个订单添加不了,不知带是不是我创建的表的问题;然后还有房间查询是查询不了的,求助!!

支持(0) 盖楼(回复)

第 15 楼 刘宇3 发表于: 2020-07-06 00:09 40
为什么添加信息的时候显示的是????

支持(0) 盖楼(回复)

第 16 楼 刘宇3 发表于: 2020-07-06 00:09 42
为什么添加信息的时候显示的是????

支持(0) 盖楼(回复)

第 17 楼 fat12138 发表于: 2021-04-06 18:31 58
idea怎么加载数据库啊

支持(0) 盖楼(回复)

发表评论

(您的评论需要经过审核才能显示)

查看所有17条评论>>

小贴士

感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。

  • 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
  • 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
  • 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
  • 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。

关于好例子网

本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明

;
报警