javaSwing宿舍管理系统(三个角色),Java Swing宿舍管理系统(三大角色管理)

马肤

温馨提示:这篇文章已超过413天没有更新,请注意相关的内容是否还可用!

摘要:该宿舍管理系统基于Java Swing框架开发,具备管理员、宿舍长和访客三个角色的功能。系统提供宿舍信息录入、查询、修改和删除等基本管理功能,同时支持宿舍分配、住宿登记和退宿管理。管理员可全面管理宿舍信息,宿舍长可查看并管理本宿舍信息,访客则可进行简单的查询操作。系统界面友好,操作便捷,适用于学校宿舍管理的需求。

一、 简介

宿舍管理系统是一个针对学校宿舍管理的软件系统,旨在方便学生、宿管和管理员进行宿舍信息管理、学生信息管理以及宿舍评比等操作。该系统使用 Java Swing 进行界面设计,分为三个角色:管理员、宿管和学生。

二、 功能模块

2.1 管理员功能

学生信息管理: 管理员可以进行学生信息的添加、刷新、删除和查询操作。

宿舍信息管理: 管理员可以进行宿舍信息的刷新、删除和查询操作,以及添加新的宿舍信息。

宿舍评比: 管理员可以查看宿舍评比结果。

密码重置: 管理员可以重置管理员、宿舍和学生的密码。

2.2 宿管功能

学生信息查看: 宿管可以查看学生信息。

宿舍信息查看: 宿管可以查看宿舍信息。

宿舍评比: 宿管可以对宿舍进行评比,并提交评比结果。

密码修改: 宿管只可以修改自己的密码。

2.3 学生功能

个人信息查看: 学生可以查看自己的个人信息。

宿舍信息查看: 学生可以查看自己所在宿舍的信息。

宿舍评比: 学生可以参与宿舍评比。

密码修改: 学生只可以修改自己的密码。

三、 技术实现

该系统使用 Java Swing 实现界面设计,使用 Java 编程语言实现后端逻辑。数据库可以采用 MySQL 或其他关系型数据库来存储学生、宿舍和评比等信息。使用 JDBC 连接数据库进行数据的增删改查操作。同时,可以使用密码加密算法对密码进行加密存储,增强安全性。

四、数据库分析

1.1 dorm 表:

dorm_id:宿舍号,char(10),主键。

bed_num:床位数,int(2)。

people_num:人数,int(2)。

1.2 grade 表:

grade_id:评分编号,int(10),自增主键。

dorm_id:宿舍号,char(10),外键,关联到 dorm 表的 dorm_id。

discipline:纪律分,int(3)。

checks:考勤分,int(3)。

health:卫生分,int(3)。

grade:总分,int(3)。

dates:评分时间,date。

managers_id:评分人员ID,int(11),外键,关联到 managers 表的 manager_id。

1.3 lived 表:

student_id:学号,int(11),外键,关联到 students 表的 student_id。

dorm_id:宿舍号,char(10),外键,关联到 dorm 表的 dorm_id。

bed_id:床号,int(1)。

livingdate:入住时间,date。

1.4 managers 表:

manager_name:姓名,char(20)。

manager_id:员工号,int(11),主键。

contact:联系方式,char(11),唯一。

1.5 register 表:

identity:身份(0为管理员,1为宿管,2为学生),int(1)。

account:账号,int(15),主键。

password:密码,char(12)。

1.6 students 表:

name:姓名,char(10)。

sex:性别,char(2)。

birthday:出生日期,bigint(15)。

addresss:地址,char(20)。

contact:联系方式,char(11),唯一。

student_id:学号,int(9),主键。

college:学院,char(20)。

major:专业,char(20)。

classes:班级,char(10)。

dorm_id:宿舍号,char(10),外键,关联到 dorm 表的 dorm_id。

bed_id:床号,int(1)。

status:状态,smallint(1)。

五、程序截图

0.登录与接角色

javaSwing宿舍管理系统(三个角色),Java Swing宿舍管理系统(三大角色管理) 第1张

javaSwing宿舍管理系统(三个角色),Java Swing宿舍管理系统(三大角色管理) 第2张

1.管理员

javaSwing宿舍管理系统(三个角色),Java Swing宿舍管理系统(三大角色管理) 第3张

javaSwing宿舍管理系统(三个角色),Java Swing宿舍管理系统(三大角色管理) 第4张

javaSwing宿舍管理系统(三个角色),Java Swing宿舍管理系统(三大角色管理) 第5张

javaSwing宿舍管理系统(三个角色),Java Swing宿舍管理系统(三大角色管理) 第6张

2.宿管

javaSwing宿舍管理系统(三个角色),Java Swing宿舍管理系统(三大角色管理) 第7张

javaSwing宿舍管理系统(三个角色),Java Swing宿舍管理系统(三大角色管理) 第8张

3.学生

javaSwing宿舍管理系统(三个角色),Java Swing宿舍管理系统(三大角色管理) 第9张

javaSwing宿舍管理系统(三个角色),Java Swing宿舍管理系统(三大角色管理) 第10张

六、部分代码

Login.java

package System;
import java.awt.Color;
import java.awt.Font;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.KeyStroke;
import Control.RegisterControl;
import Model.RegisterModel;
import Operation.StudentsOperation;
import TableStudent.PersonInformation;
@SuppressWarnings("serial")
public class Login extends JFrame implements ActionListener {
	Managers managers;
	public static JTextField text1;
	JPasswordField text2 = new JPasswordField();
	private JButton enter = new JButton("登   录");
	Font butfont = new Font("宋体", Font.BOLD, 20);
	private JFrame frame = new JFrame();
	private JPanel jpl = new JPanel();
	JComboBox comboBox;
	@SuppressWarnings("unchecked")
	public Login() {
		JLabel label0 = new JLabel("宿舍管理系统");
		label0.setBounds(80, 25, 150, 50);
		label0.setFont(new Font("华文彩云", Font.BOLD, 23));
		frame.add(label0);
		JLabel lab1 = new JLabel("身份:");
		jpl.add(lab1);
		lab1.setBounds(20, 75, 100, 50);
		lab1.setFont(new Font("隶书", Font.BOLD, 18));
		comboBox = new JComboBox();
		comboBox.setBounds(70, 87, 150, 30);
		comboBox.addItem("管理员");
		comboBox.addItem("宿管");
		comboBox.addItem("学生");
		comboBox.setFont(new Font("华文行楷", Font.PLAIN, 20));
		jpl.add(comboBox);
		// 标签
		JLabel label2 = new JLabel("账号:");
		label2.setBounds(20, 125, 100, 50);
		label2.setFont(new Font("隶书", Font.BOLD, 18));
		frame.add(label2);
		JLabel label3 = new JLabel("密码:");
		label3.setBounds(20, 175, 100, 50);
		label3.setFont(new Font("隶书", Font.BOLD, 18));
		frame.add(label3);
		JLabel label4 = new JLabel();
		label4.setText("忘记密码?");
		label4.setBounds(225, 175, 100, 50);
		label4.setForeground(Color.BLUE);
		label4.setFont(new Font("黑体", Font.BOLD, 13));
		label4.setToolTipText("你是不是傻!!!密码都能忘???");
		label4.addMouseListener(new MouseListener() {
			public void mouseReleased(MouseEvent e) {
			}
			public void mousePressed(MouseEvent e) {
			}
			public void mouseExited(MouseEvent e) {
			}
			public void mouseEntered(MouseEvent e) {
			}
			public void mouseClicked(MouseEvent e) {
				JOptionPane.showMessageDialog(null, "请到管理处重置密码", "友情提示", JOptionPane.INFORMATION_MESSAGE);
			}
		});
		frame.add(label4);
		// 账号
		text1 = new JTextField();
		text1.setBounds(70, 137, 150, 30);
		text1.setFont(new Font("黑体", Font.BOLD, 18));
		frame.add(text1);
		// 密码
		text2.setBounds(70, 185, 150, 30);
		text2.setFont(new Font("", Font.BOLD, 24));
		text2.setEchoChar('*');
		frame.add(text2);
		// 背景
		JLabel label = new JLabel(new ImageIcon("image\\background.jpg"));
		label.setSize(300, 565);
		Image image = this.getToolkit().getImage("image\\icon.png");
		jpl.setLayout(null);
		jpl.add(enter);
		jpl.add(label);
		// 窗体
		frame.add(jpl);
		frame.setIconImage(image);
		frame.setTitle("登录");
		frame.setSize(300, 565);
		frame.setResizable(false);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setLocationRelativeTo(null);
		frame.setVisible(true);
		// 登录
		enter.setBounds(85, 300, 120, 40); // 设置按钮大小
		enter.setBackground(Color.WHITE);
		enter.setVisible(true);
		enter.setLayout(null);
		enter.setFont(butfont);
		enter.addActionListener(new ButtonListener());
		enter.registerKeyboardAction(new ButtonListener(), KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0),
				JComponent.WHEN_IN_FOCUSED_WINDOW);
	}
	public static void main(String[] args) {
		new Login();
	}
	// 登录监听
	class ButtonListener implements ActionListener {
		public void actionPerformed(ActionEvent e) {
			RegisterControl r = new RegisterControl();
			RegisterModel rr = null;
			boolean bb = false;
			if (text1.getText().length() == 0 || text2.getText().length() == 0) {
				JOptionPane.showMessageDialog(null, "账号或密码为空", "系统提示", JOptionPane.ERROR_MESSAGE);
				return;
			} else {
				try {
					rr = r.get(Integer.parseInt(text1.getText()));
				} catch (NumberFormatException e1) {
				} catch (Exception e1) {
					return;
				}
				if (rr != null) {
					bb = rr.getPassword().equals(text2.getText());
					//System.out.println(rr.getPassword() + "数据库中的密码");
				} else {
					JOptionPane.showMessageDialog(null, "账号密码有误", "系统提示", JOptionPane.ERROR_MESSAGE);
					text1.setText(null);
					text2.setText(null);
					return;
				}
				if (bb) {
//					System.out.println(comboBox.getSelectedItem().toString().equals(rr.getIdentity()));
					if (comboBox.getSelectedIndex()==rr.getIdentity()){
						frame.dispose();
						if (comboBox.getSelectedIndex()==2) {
							new Students();
							PersonInformation.jpl.setVisible(true);
						} else if (comboBox.getSelectedIndex()==1) {
							new Managers();
						} else {
							new Administrator();
						}
						return;
					} else {
						JOptionPane.showOptionDialog(managers, "身份有误!!!", "提示", JOptionPane.DEFAULT_OPTION,
								JOptionPane.PLAIN_MESSAGE, null, null, null);
						text2.setText(null);
						return;
					}
				}
			}
			JOptionPane.showMessageDialog(null, "账号密码有误", "系统提示", JOptionPane.ERROR_MESSAGE);
			text1.setText(null);
			text2.setText(null);
		}
	}
	public void actionPerformed(ActionEvent e) {
	}
}

Managers.java

package System;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import ButtonFrame.GradeRefer;
import TableManager.DormTable;
import TableManager.GradeTable;
import TableManager.PartStudentTable;
@SuppressWarnings("serial")
public class Managers extends JFrame {
	private JPanel jpl = null;
	private MoveLabel label = null;
	JButton logout, exit;
	JLabel lab1, lab2, lab3, lab4, lab5;
	public Managers() {
		super("宿舍管理系统");
		jpl = new JPanel();
		label = new MoveLabel(
				"欢迎登录宿舍管理系统      欢迎登录宿舍管理系统      欢迎登录宿舍管理系统");
		label.setOpaque(false); // 透明
		label.setFont(new Font("宋体", Font.BOLD, 20));
		label.setSize(1366, 20);
		label.setBackground(Color.cyan);
		lab1 = new JLabel("学生信息");
		lab1.setFont(new Font("华文楷体", Font.BOLD, 23));
		lab1.setBounds(35, 50, 100, 50);
		lab1.setForeground(Color.BLUE);
		lab1.addMouseListener(new MouseListener() {
			public void mouseClicked(MouseEvent e) {
				//System.out.println("按下");
				PartStudentTable.jp.setVisible(true);
				DormTable.jp.setVisible(false);
				GradeTable.jp.setVisible(false);
				lab1.setForeground(Color.RED);
				lab2.setForeground(Color.BLUE);
				lab3.setForeground(Color.BLUE);
				lab4.setForeground(Color.BLUE);
				lab5.setForeground(Color.BLUE);
			}
			public void mouseEntered(MouseEvent e) {
			}
			public void mouseExited(MouseEvent e) {
			}
			public void mousePressed(MouseEvent e) {
			}
			public void mouseReleased(MouseEvent e) {
			}
		});
		lab2 = new JLabel("宿舍信息");
		lab2.setFont(new Font("华文楷体", Font.BOLD, 23));
		lab2.setBounds(35, 150, 100, 50);
		lab2.setForeground(Color.BLUE);
		lab2.addMouseListener(new MouseListener() {
			public void mouseClicked(MouseEvent e) {
				//System.out.println("按下");
				PartStudentTable.jp.setVisible(false);
				GradeTable.jp.setVisible(false);
				DormTable.jp.setVisible(true);
				lab1.setForeground(Color.BLUE);
				lab2.setForeground(Color.RED);
				lab3.setForeground(Color.BLUE);
				lab4.setForeground(Color.BLUE);
				lab5.setForeground(Color.BLUE);
			}
			public void mouseEntered(MouseEvent e) {
			}
			public void mouseExited(MouseEvent e) {
			}
			public void mousePressed(MouseEvent e) {
			}
			public void mouseReleased(MouseEvent e) {
			}
		});
		lab3 = new JLabel("宿舍评比");
		lab3.setFont(new Font("华文楷体", Font.BOLD, 23));
		lab3.setBounds(35, 250, 100, 50);
		lab3.setForeground(Color.BLUE);
		lab3.addMouseListener(new MouseListener() {
			public void mouseClicked(MouseEvent e) {
				//System.out.println("按下");
				PartStudentTable.jp.setVisible(false);
				DormTable.jp.setVisible(false);
				GradeTable.jp.setVisible(true);
				lab1.setForeground(Color.BLUE);
				lab2.setForeground(Color.BLUE);
				lab3.setForeground(Color.RED);
				lab4.setForeground(Color.BLUE);
				lab5.setForeground(Color.BLUE);
			}
			public void mouseEntered(MouseEvent e) {
			}
			public void mouseExited(MouseEvent e) {
			}
			public void mousePressed(MouseEvent e) {
			}
			public void mouseReleased(MouseEvent e) {
			}
		});
		lab4 = new JLabel("评比提交");
		lab4.setFont(new Font("华文楷体", Font.BOLD, 23));
		lab4.setBounds(35, 350, 100, 50);
		lab4.setForeground(Color.BLUE);
		lab4.addMouseListener(new MouseListener() {
			public void mouseClicked(MouseEvent e) {
				//System.out.println("按下");
				PartStudentTable.jp.setVisible(false);
				DormTable.jp.setVisible(false);
				GradeTable.jp.setVisible(false);
				new GradeRefer();
				lab1.setForeground(Color.BLUE);
				lab2.setForeground(Color.BLUE);
				lab3.setForeground(Color.BLUE);
				lab4.setForeground(Color.RED);
				lab5.setForeground(Color.BLUE);
			}
			public void mouseEntered(MouseEvent e) {
			}
			public void mouseExited(MouseEvent e) {
			}
			public void mousePressed(MouseEvent e) {
			}
			public void mouseReleased(MouseEvent e) {
			}
		});
		lab5 = new JLabel("修改密码");
		lab5.setFont(new Font("华文楷体", Font.BOLD, 23));
		lab5.setBounds(35, 450, 100, 50);
		lab5.setForeground(Color.BLUE);
		lab5.addMouseListener(new MouseListener() {
			public void mouseClicked(MouseEvent e) {
				//System.out.println("按下");
				PartStudentTable.jp.setVisible(false);
				DormTable.jp.setVisible(false);
				GradeTable.jp.setVisible(false);
				new ChangePassword();
				lab1.setForeground(Color.BLUE);
				lab2.setForeground(Color.BLUE);
				lab3.setForeground(Color.BLUE);
				lab4.setForeground(Color.BLUE);
				lab5.setForeground(Color.RED);
			}
			public void mouseEntered(MouseEvent e) {
			}
			public void mouseExited(MouseEvent e) {
			}
			public void mousePressed(MouseEvent e) {
			}
			public void mouseReleased(MouseEvent e) {
			}
		});
		JLabel lab = new JLabel(new ImageIcon("image\\back.jpg"));
		jpl.add(lab);
		ImageIcon ilogout = new ImageIcon("image\\logout.png");
		logout = new JButton(ilogout);
		logout.setBounds(240, 550, 100, 45);
		logout.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if (e.getSource() == logout) {
					String[] options = new String[] { "是", "否" };
					int n = JOptionPane.showOptionDialog(null, "确定注销系统???", "提示", JOptionPane.DEFAULT_OPTION,
							JOptionPane.WARNING_MESSAGE, null, options, options[0]);
					// 点击是的话,注销
					if (n == JOptionPane.YES_OPTION) {
						setVisible(false);
						new Login();
					}
				}
			}
		});
		this.add(logout);
		ImageIcon ic = new ImageIcon("image\\exit.png");
		exit = new JButton(ic);
		exit.setBounds(820, 550, 100, 45);
		exit.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if (e.getSource() == exit) {
					String[] options = new String[] { "是", "否" };
					int n = JOptionPane.showOptionDialog(null, "确定退出系统???", "提示", JOptionPane.DEFAULT_OPTION,
							JOptionPane.WARNING_MESSAGE, null, options, options[0]);
					// 点击是的话,直接退出
					if (n == JOptionPane.YES_OPTION) {
						setVisible(false);
						System.exit(0);
					}
				}
			}
		});
		this.add(exit);
		this.add(new PartStudentTable().getpanel());
		this.add(new DormTable().getpanel());
		this.add(new GradeTable().getpanel());
		this.add(lab1);
		this.add(lab2);
		this.add(lab3);
		this.add(lab4);
		this.add(lab5);
		this.add(label);
		this.add(jpl);
		Image image = this.getToolkit().getImage("image\\icon.png");
		this.setIconImage(image);
		this.setSize(960, 640); // 窗体的大小
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // 关闭窗口
		this.setLocationRelativeTo(null);
		this.setVisible(true);
	}
	/**
	 * 带有滚动效果的Label标签
	 */
	private class MoveLabel extends JLabel implements Runnable {
		private String text = null;
		private Thread thread = null;
		private int x = 0;
		private int w = 0, h = 0;
		public MoveLabel(String text) {
			super(text);
			this.text = text;
			thread = new Thread(this);
			thread.start();
		}
		public String getText() {
			return text;
		}
		public void setText(String text) {
			super.setText(text);
			this.text = text;
		}
		protected void paintComponent(Graphics g) {
			super.paintComponent(g);
			g.setColor(this.getBackground());
			g.fillRect(0, 0, w = this.getWidth(), h = this.getHeight());
			g.setColor(this.getForeground());
			g.setFont(this.getFont());
			g.drawString(text, x, h - 2);
		}
		public void run() {
			while (true) {
				x -= 2;
				if (x  

七、联系与交流

q:969060742 完整代码、sql、文档、程序资源

0
收藏0
文章版权声明:除非注明,否则均为VPS857原创文章,转载或复制请以超链接形式并注明出处。

相关阅读

  • 【研发日记】Matlab/Simulink自动生成代码(二)——五种选择结构实现方法,Matlab/Simulink自动生成代码的五种选择结构实现方法(二),Matlab/Simulink自动生成代码的五种选择结构实现方法详解(二)
  • 超级好用的C++实用库之跨平台实用方法,跨平台实用方法的C++实用库超好用指南,C++跨平台实用库使用指南,超好用实用方法集合,C++跨平台实用库超好用指南,方法与技巧集合
  • 【动态规划】斐波那契数列模型(C++),斐波那契数列模型(C++实现与动态规划解析),斐波那契数列模型解析与C++实现(动态规划)
  • 【C++】,string类底层的模拟实现,C++中string类的模拟底层实现探究
  • uniapp 小程序实现微信授权登录(前端和后端),Uniapp小程序实现微信授权登录全流程(前端后端全攻略),Uniapp小程序微信授权登录全流程攻略,前端后端全指南
  • Vue脚手架的安装(保姆级教程),Vue脚手架保姆级安装教程,Vue脚手架保姆级安装指南,Vue脚手架保姆级安装指南,从零开始教你如何安装Vue脚手架
  • 如何在树莓派 Raspberry Pi中本地部署一个web站点并实现无公网IP远程访问,树莓派上本地部署Web站点及无公网IP远程访问指南,树莓派部署Web站点及无公网IP远程访问指南,本地部署与远程访问实践,树莓派部署Web站点及无公网IP远程访问实践指南,树莓派部署Web站点及无公网IP远程访问实践指南,本地部署与远程访问详解,树莓派部署Web站点及无公网IP远程访问实践详解,本地部署与远程访问指南,树莓派部署Web站点及无公网IP远程访问实践详解,本地部署与远程访问指南。
  • vue2技术栈实现AI问答机器人功能(流式与非流式两种接口方法),Vue2技术栈实现AI问答机器人功能,流式与非流式接口方法探究,Vue2技术栈实现AI问答机器人功能,流式与非流式接口方法详解
  • 发表评论

    快捷回复:表情:
    评论列表 (暂无评论,0人围观)

    还没有评论,来说两句吧...

    目录[+]

    取消
    微信二维码
    微信二维码
    支付宝二维码