功能概述
管理员功能:
1)宿舍床位管理,包括:宿舍楼编号、房间编号,床位号、在住人等。
2)学生入住,包括学生信息录入,床位分配等。
3)邮件信息录入。
4)夜归学生录入
5)宿舍报修信息管理
6)学生离校,宿舍床位清空,床位调整。
学生功能
1)邮件查询
2)宿舍故障报修
另外根据实际情景,这里也实现了一些较为复杂的功能如下:
1)宿舍管理员在添加夜归生信息后,系统能够在该夜归生登录学生端时立即收到夜归信息警告并显示其姓名和夜归次数,另外系统只会提醒一次。
2)增加了报修处理反馈,学生在提交报修处理后,宿舍管理员会立即收到并做出响应。
3)增加了文件PDF输出功能
4)能够实现宿舍、床位分配或调整时,直接安排空余位置,不能重复。
5)设计了一个较为美观的界面并能够将信息以表单形式展示。
6)提供了验证码注册登录服务
开发环境
Eclipse 2019 jdk1.8
需要导入下面两个jar包(版本可能不一样,与自己版本对应即可,我电脑用的是这两个):
|
文件结构
jar包放在了网盘,下载即可(另外整个工程文件也放在了,由于文件较多,后面只列举了部分功能的实现)链接: https://pan.baidu.com/s/1nwHGOUCaFgIn6PAxvjdsgQ
提取码:qmmq
1.工程名:Students_Beds 。下面有四个包
2.包分别为:
3.每个包对应的Java文件:
Functions:
login:
main:
Connect_SQL
部分运行结果:
数据库表
表3-1学生信息表
student
字段名 类型 NULL 其他 备注
Id int(15) not null PK 学生学号
Name varchar(255) not null 学生姓名
Room int(255) not null 学生房号
Bed int(255) not null 学生床号
Louhao int(255) not null 学生楼号
Grade int(2) not null 年级
表3-2学生注册登录表
enter
字段名 类型 NULL 其他 备注
ID varchar(255) not null PK 学生学号
K varchar(255) not null 登录密码
表3-3管理员信息表
housemaster
字段名 类型 NULL 其他 备注
M_Id varchar(255) not null PK 管理员编号
M_Name varchar(255) not null 管理员姓名
M_Age varchar(255) not null 管理员年龄
M_Sex varchar(255) not null 管理员性别
表3-4管理员注册登录表
enter1
字段名 类型 NULL 其他 备注
ID varchar(255) not null PK 管理员编号
K varchar(255) not null 登录密码
表3-5 夜归生记录表
dark_enter
字段名 类型 NULL 其他 备注
darkback_id varchar(255) not null 夜归生学号
darkback_name varchar(255) not null 夜归生姓名
时间记录 varchar(255) not null 记录时间
表3-6 报修管理表
manage
字段名 类型 NULL 其他 备注
处理时间 varchar(255) not null 处理时间
处理人员 varchar(255) not null 处理人员
报修编号 varchar(255) not null 报修编号
表3-7 邮件管理表
email
字段名 类型 NULL 其他 备注
发送_ID varchar(255) not null 邮件发送端
TO_ID varchar(255) not null 邮件接收端
邮件内容 varchar(255) not null 邮件内容
时间 not null 时间
表3-8 床位管理表
beds
字段名 类型 NULL 其他 备注
楼号 varchar(255) not null 楼号
宿舍号 varchar(255) not null 宿舍号
床号 varchar(255) not null 床号
在住人 varchar(255) not null 在住人
外键定义
1.fk0的定义:
ALTER TABLE students_beds
. manage
DROP FOREIGN KEY fk0
;
ALTER TABLE students_beds
. manage
ADD CONSTRAINT fk0
FOREIGN KEY (报修编号
) REFERENCES students_beds
.mend
(报修编号
)
ON DELETE CASCADE
ON UPDATE CASCADE,
2.fk1的定义:
ALTER TABLE students_beds
.dark_enter
ADD CONSTRAINT fk1
FOREIGN KEY (darkback_id
)
REFERENCES students_beds
.students
(Id
)
ON DELETE CASCADE
ON UPDATE CASCADE;
3.fk3的定义:
ALTER TABLE students_beds
.stu_dark_counts
DROP FOREIGN KEY fk3
;
ALTER TABLE students_beds
.stu_dark_counts
ADD CONSTRAINT fk6
FOREIGN KEY (dark_id
)
REFERENCES students_beds
.students
(Id
)
ON DELETE NO ACTION
ON UPDATE CASCADE
//连接数据库
package Connect_SQL;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class Get_Connect {
public Connection Getconn() {
Connection conn=null;
try {
Class.forName("com.mysql.jdbc.Driver");
conn=DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/students_beds","root","061900");
}catch(ClassNotFoundException e) {
System.err.println(e.toString());
}catch(SQLException ex) {
System.err.println(ex.toString());
}
return conn;
}
}
//只列举了登录和注册的主要逻辑
public void actionPerformed(ActionEvent e)
{
boolean flag=true;
//while(flag) {
//if(jt_code.getText()!="-1") {
if (e.getActionCommand() == "退出") { System.exit(0);}
if (e.getActionCommand() == "学生登录")
{
//对夜归的学生发送窗口警告信息
if (Code.getText().isEmpty()) JOptionPane.showMessageDialog(null, "请输入验证码!", "提示消息", JOptionPane.WARNING_MESSAGE);
else//验证码不为空
{
if (!isValidCodeRight())
{
JOptionPane.showMessageDialog(null, "验证码错误,请重新输入!", "提示消息", JOptionPane.WARNING_MESSAGE);
clear();
}
else//验证码正确
{
Connection con=null;
Statement stmt=null;
ResultSet rs=null;
Connection con1=null;
Statement stmt1=null;
ResultSet rs1=null;
try
{
Class.forName("com.mysql.jdbc.Driver");
}
catch(ClassNotFoundException f)
{
System.out.println("SQLException:"+f.getLocalizedMessage());
}
try
{
con = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/students_beds", "root", "061900");
stmt=con.createStatement();
rs=stmt.executeQuery("SELECT ID FROM enter");
rs.beforeFirst();
//System.out.print(rs.getRow()+" ");
int k=0;String str2="";int count=0;
while (rs.next()) {
String st1 = rs.getString("ID");
if(ID.getText().equals(st1))
{
con1 = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/students_beds", "root", "061900");
stmt1=con1.createStatement();
String sql="select K from enter where ID = '"+ID.getText()+"'";
rs1 =stmt1 .executeQuery(sql);
// rs1=stmt1.executeQuery("SELECT Key FROM enter where ID="+"'"+ID.getText()+"'");
massage = 1;
break;
}}
if(massage ==1) //在数据库中找到了该账号
{
rs1.beforeFirst();
while(rs1.next()) {//必须用.next方法,无法直接找
if(!KEY.getText().equals(rs1.getNString("K")))//密码与账号不对应
{
JOptionPane.showMessageDialog(this, "您输入密码有误,请重新输入!", "系统提示",
JOptionPane.ERROR_MESSAGE);clear();
}
else //登录成功
{
new MainSystem_Student();
//
Connection con0=null;
Statement stmt0=null;
ResultSet rs0=null; String s ="";
try
{
Class.forName("com.mysql.jdbc.Driver");
}
catch(ClassNotFoundException f)
{
System.out.println("SQLException:"+f.getLocalizedMessage());
}
try
{ con0 = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/students_beds", "root", "061900");
stmt0=con0.createStatement();
String sql="select * from dark_enter ";
rs0=stmt0 .executeQuery(sql);
rs0.beforeFirst();
while (rs0.next()) {
if(rs0.getString("darkback_id").equals(ID.getText()))
{
try
{
rs0.beforeFirst();
while(rs0.next()) {
count++;
s =rs0.getString("darkback_name");
}
}
catch(SQLException ex)
{
System.err.println(ex.toString());
}
}}}
catch(SQLException ex)
{
System.err.println(ex.toString());
}
String sql2="select * from stu_dark_counts";
rs1 = stmt1.executeQuery(sql2);
rs1.beforeFirst();
while(rs1.next()) {
if(rs1.getString("dark_id").equals(ID.getText())) break;
}
if(count>Integer.parseInt(rs1.getString("counts"))) {
String s1=Integer.toString(count);
JOptionPane.showMessageDialog(null, s+"同学"+"你已经晚归"+s1+"次了,"+"请准时回到宿舍!", "提示消息", JOptionPane.QUESTION_MESSAGE);
}
Connection con3=null;
Statement stmt3=null;
ResultSet rs3=null;
con3 = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/students_beds", "root", "061900");
stmt3=con3.createStatement();
String updatesql="UPDATE stu_dark_counts SET counts='"+count+"'WHERE dark_id='"+ID.getText()+"'";
stmt3.executeUpdate(updatesql);
this.dispose();
this.setVisible(false);
}}
}
else //在数据库中没有找到该账号
{
JOptionPane.showMessageDialog(this, "您输入的用户名不存在,请注册或者检查用户名是否正确!", "系统提示",
JOptionPane.ERROR_MESSAGE);
clear();
}
}
catch(SQLException ex)
{
System.err.println(ex.toString());
}
}
}
}
if (e.getActionCommand() == "宿管登录")
{
if (Code.getText().isEmpty()) JOptionPane.showMessageDialog(null, "请输入验证码!", "提示消息", JOptionPane.WARNING_MESSAGE);
else//验证码不为空
{
if (!isValidCodeRight())
{
JOptionPane.showMessageDialog(null, "验证码错误,请重新输入!", "提示消息", JOptionPane.WARNING_MESSAGE);
clear();
}
else//验证码正确
{
Connection con=null;
Statement stmt=null;
ResultSet rs=null;
Connection con1=null;
Statement stmt1=null;
ResultSet rs1=null;
try
{
Class.forName("com.mysql.jdbc.Driver");
}
catch(ClassNotFoundException f)
{
System.out.println("SQLException:"+f.getLocalizedMessage());
}
try
{
con = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/students_beds", "root", "061900");
stmt=con.createStatement();
rs=stmt.executeQuery("SELECT ID FROM enter1");
rs.beforeFirst();
//System.out.print(rs.getRow()+" ");
int k=0;String str2="";
while (rs.next()) {
String st1 = rs.getString("ID");
if(ID.getText().equals(st1))
{
con1 = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/students_beds", "root", "061900");
stmt1=con1.createStatement();
String sql="select K from enter1 where ID = '"+ID.getText()+"'";
rs1 =stmt1 .executeQuery(sql);
// rs1=stmt1.executeQuery("SELECT Key FROM enter where ID="+"'"+ID.getText()+"'");
massage = 1;
break;
}}
if(massage ==1) //在数据库中找到了该账号
{
rs1.beforeFirst();
while(rs1.next()) {//必须用.next方法,无法直接找
if(!KEY.getText().equals(rs1.getNString("K")))//密码与账号不对应
{
JOptionPane.showMessageDialog(this, "您输入密码有误,请重新输入!", "系统提示",
JOptionPane.ERROR_MESSAGE);clear();
}
else //登录成功
{
new MainSystem_Master();
Connection con0=null;
Statement stmt0=null;
ResultSet rs0=null; String s ="";
try
{
Class.forName("com.mysql.jdbc.Driver");
}
catch(ClassNotFoundException f)
{
System.out.println("SQLException:"+f.getLocalizedMessage());
}
try
{ con0 = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/students_beds", "root", "061900");
stmt0=con0.createStatement();
String sql="select * from mend ";
rs0=stmt0 .executeQuery(sql);
rs0.beforeFirst();
while (rs0.next()) {
if(rs0.getString("是否已修").equals("否"))
{
JOptionPane.showMessageDialog(null,"有报修未处理,请及时处理", "提示消息", JOptionPane.INFORMATION_MESSAGE);
break;
}}}
catch(SQLException ex)
{
System.err.println(ex.toString());
}
}
break;
}}
else //在数据库中没有找到该账号
{
JOptionPane.showMessageDialog(this, "您输入的用户名不存在,请注册或者检查用户名是否正确!", "系统提示",
JOptionPane.ERROR_MESSAGE);
clear();
}
}
catch(SQLException ex)
{
System.err.println(ex.toString());
}
}
}
}
if (e.getActionCommand() == "学生注册") {
try {
Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://localhost:3306/students_beds";
String user = "root";
String password = "061900";
Connection conn = DriverManager.getConnection(url, user, password);
//String sqlstr="INSERT INTO enter (ID,Key) VALUES(?,?)";
String sqlstr="INSERT INTO enter (ID,K) VALUES (?,?)" ;
PreparedStatement ps1 = conn.prepareStatement(sqlstr);
ps1.setString(1, ID.getText());
ps1.setString(2, KEY.getText());
System.out.print( sqlstr);
int l=ps1.executeUpdate();
JOptionPane.showMessageDialog(null,"注册成功!"); clear();
} catch (ClassNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
if (e.getActionCommand() == "宿管注册") {
try {
Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://localhost:3306/students_beds";
String user = "root";
String password = "061900";
Connection conn = DriverManager.getConnection(url, user, password);
//String sqlstr="INSERT INTO enter (ID,Key) VALUES(?,?)";
String sqlstr="INSERT INTO enter1 (ID,K) VALUES (?,?)" ;
PreparedStatement ps1 = conn.prepareStatement(sqlstr);
ps1.setString(1, ID.getText());
ps1.setString(2, KEY.getText());
System.out.print( sqlstr);
int l=ps1.executeUpdate();
if(l>0) JOptionPane.showMessageDialog(null,"注册成功!"); clear();
} catch (ClassNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
//验证码功能
package Login;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.Random;
import javax.swing.JComponent;
public class Verification_Code extends JComponent implements MouseListener {
public Verification_Code() {
}
private String code;
private int width, height = 40;
private int codeLength = 4;
private Random random = new Random();
public void ValidCode() {
width = this.codeLength * 16 + (this.codeLength - 1) * 10;
setPreferredSize(new Dimension(width, height));
setSize(width, height);
this.addMouseListener(this);
setToolTipText("点击可以更换验证码");
}
public int getCodeLength() {
return codeLength;
}
/*
设置验证码文字的长度
*/
public void setCodeLength(int codeLength) {
if(codeLength < 4) {
this.codeLength = 4;
} else {
this.codeLength = codeLength;
}
}
public String getCode() {
return code;
}
/*
产生随机的颜色
*/
public Color getRandColor(int min, int max) {
if (min > 255)
min = 255;
if (max > 255)
max = 255;
int red = random.nextInt(max - min) + min;
int green = random.nextInt(max - min) + min;
int blue = random.nextInt(max - min) + min;
return new Color(red, green, blue);
}
/*
设置验证码具体的字母是什么
*/
protected String generateCode() {
char[] codes = new char[this.codeLength];
for (int i = 0, len = codes.length; i < len; i++) {
if (random.nextBoolean()) {
codes[i] = (char) (random.nextInt(26) + 65);
} else {
codes[i] = (char) (random.nextInt(26) + 97);
}
}
this.code = new String(codes);
return this.code;
}
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
if(this.code == null || this.code.length() != this.codeLength) {
this.code = generateCode();
}
width = this.codeLength * 16 + (this.codeLength - 1) * 10;
super.setSize(width, height);
super.setPreferredSize(new Dimension(width, height));
Font mFont = new Font("Arial", Font.BOLD | Font.ITALIC, 25);
g.setFont(mFont);
//绘制出验证码的背景的矩形轮廓
Graphics2D g2d = (Graphics2D) g;
g2d.setColor(getRandColor(200, 250));
g2d.fillRect(0, 0, width, height);
g2d.setColor(getRandColor(180, 200));
g2d.drawRect(0, 0, width - 1, height - 1);
//绘制出验证码背景的线
int i = 0, len = 150;
for (; i < len; i++) {
int x = random.nextInt(width - 1);
int y = random.nextInt(height - 1);
int x1 = random.nextInt(width - 10) + 10;
int y1 = random.nextInt(height - 4) + 4;
g2d.setColor(getRandColor(180, 200));
g2d.drawLine(x, y, x1, y1);
}
//绘制出验证码的具体字母
i = 0; len = this.codeLength;
FontMetrics fm = g2d.getFontMetrics();
int base = (height - fm.getHeight())/2 + fm.getAscent();
for(;i<len;i++) {
int b = random.nextBoolean() ? 1 : -1;
g2d.rotate(random.nextInt(10)*0.01*b);
g2d.setColor(getRandColor(20, 130));
g2d.drawString(code.charAt(i)+"", 16 * i + 10, base);
}
}
public void nextCode() {
generateCode();
repaint();
}
//发生单击事件时被触发
public void mouseClicked(MouseEvent e) {
nextCode();
}
//鼠标按键被按下时被触发
public void mousePressed(MouseEvent e) {
// TODO Auto-generated method stub
}
//鼠标按键被释放时被触发
public void mouseReleased(MouseEvent e) {
// TODO Auto-generated method stub
}
//光标移入组件时被触发
public void mouseEntered(MouseEvent e) {
// TODO Auto-generated method stub
}
//光标移入组件时被触发
public void mouseExited(MouseEvent e) {
// TODO Auto-generated method stub
}
}
//修改的主要逻辑(只需要输入要修改的,不修改的不用管)
public void setText() {
textField.setText("");
textField_1.setText("");
textField_2.setText("");
textField_3.setText("");
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==jb1)
{
setText();
}
if(e.getSource()==jb2)
if( !textField_3.getText().isEmpty()) {
try{
Connection con;
Statement stmt;
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/students_beds", "root", "061900");
stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select * from students");
int message=0;
while(rs.next()) {//message=1;System.out.print(rs.getString("M_Id"));
if(textField_3.getText().contentEquals(rs.getString("Id"))) {
message=1;
if(textField_1.getText().isEmpty()) s1=rs.getString("Name");
if(textField_2.getText().isEmpty()) s2=rs.getString("Bed");
if(textField.getText().isEmpty()) s3=rs.getString("Room");
if(textField_4.getText().isEmpty()) s4=rs.getString("Louhao");
if(textField_5.getText().isEmpty()) s5=rs.getString("Grade");
if(!textField_1.getText().isEmpty()) s1=textField_1.getText();
if(!textField_2.getText().isEmpty()) s2=textField_2.getText();
if(!textField.getText().isEmpty()) s3=textField.getText();
if(!textField_4.getText().isEmpty()) s4=textField_4.getText();
if(!textField_5.getText().isEmpty()) s5=textField_5.getText();
String updatesql="UPDATE students SET Name='"+s1+"',Room='"+s3+"',Bed='"+s2+"',Louhao='"+s4+"',Grade='"+s5+"'WHERE Id='"+textField_3.getText()+"'";
stmt.executeUpdate(updatesql);
JOptionPane.showMessageDialog(this, "修改成功 !新信息已录入数据库!","系统提示", JOptionPane.INFORMATION_MESSAGE);
setText();
break;
}
}
if(message==0)
JOptionPane.showMessageDialog(this, "对不起!此用户不存在!请重新输入!","系统提示", JOptionPane.INFORMATION_MESSAGE);
setText();
stmt.close();
con.close();
}catch(SQLException ex){
ex.printStackTrace();
}catch(ClassNotFoundException ex){
ex.printStackTrace();
}}
else {JOptionPane.showMessageDialog(this, "请输入编号!","系统提示", JOptionPane.INFORMATION_MESSAGE);setText();}
}
//宿舍管理员主界面
package Main;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;
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 javax.swing.JTabbedPane;
import javax.swing.JTextField;
import com.sun.awt.AWTUtilities;
import Functions.Add_Beds;
import Functions.Add_Emails;
import Functions.Add_Housemasters;
import Functions.Add_Students;
import Functions.Change_Emails;
import Functions.Change_Masters;
import Functions.Change_Students;
import Functions.Check_Beds;
import Functions.Check_Housemaster_Students;
import Functions.Check_Students;
import Functions.Creat_Man;
import Functions.Delete_Emails;
import Functions.Delete_Roommaster;
import Functions.Delete_Students;
import Functions.Roublshooting_M_V;
import Functions.Roublshooting_M_C;
import Functions.View_Students;
import Login.LoginJF;
public class MainSystem_Master extends JFrame implements ActionListener
{
private JPanel p1,p2,p3,p4,p5,p6,p7,p8,p9,p2_1,p3_1,p4_1,p5_1,p6_1,p7_1,p8_1,p9_1,p10,p10_1;
//各种按钮
private JButton Add_S,Chenck_S,View_S,Delete_S,Chenge_S,Add_M,Check_M,Change_M,Delete_M,Add_Dark,Delete_Dark,View_Dark,Chnage_Dark,
Change_R,View_R,Add_bed,Check_beds,Change_bed,Clear_beds,Add_Email,Delete_Email,Change_Email,perD;
private JLabel mz1,sj,sj1,zh1,mz,zh;
private JTabbedPane jtab =new JTabbedPane(JTabbedPane.TOP);
private JTabbedPane jtab1=new JTabbedPane(JTabbedPane.TOP);
private JTabbedPane jtab2=new JTabbedPane(JTabbedPane.TOP);
private JTabbedPane jtab3=new JTabbedPane(JTabbedPane.TOP);
private JTabbedPane jtab4=new JTabbedPane(JTabbedPane.TOP);
private JTabbedPane jtab5=new JTabbedPane(JTabbedPane.TOP);
private JTabbedPane jtab6=new JTabbedPane(JTabbedPane.TOP);
private JTabbedPane jtab7=new JTabbedPane(JTabbedPane.TOP);
private JPanel panel1,panel2,panel3,pane14,pane15,pane16,panel7,panel8,panel_5,panel_6,panel_7,panel_8,panel9,panel10;
JFrame app;
public MainSystem_Master()
{
app=new JFrame("宿舍管理系统:宿舍管理员");
Container c=app.getContentPane();
c.setLayout(null);
c.setBackground(Color.PINK);
JPanel p1=new JPanel();
p1.setLayout(new FlowLayout(FlowLayout.LEFT));
p1.setBounds(1, 1, 593, 37);
p1.setBackground(Color.PINK);
Container c1=app.getContentPane();
c1.setLayout(null);
c1.setBackground(Color.PINK);
JPanel p2=new JPanel();
p2.setLayout(new FlowLayout(FlowLayout.LEFT));
p2.setBounds(130, 170, 800, 400);
p2.setBackground(Color.PINK);
app.add(p2);
Container c2=app.getContentPane();
c1.setLayout(null);
c1.setBackground(Color.PINK);
JPanel p3=new JPanel();
p3.setLayout(new FlowLayout(FlowLayout.LEFT));
p3.setBounds(620, 0, 300, 121);
p3.setBackground(Color.pink);
//app.add(p3);
JPanel panels1;
JLabel labels1;
ImageIcon tt1;
tt1= new ImageIcon( "F:\\E_workplace1\\Students_Beds\\3.png");
labels1= new JLabel(tt1);
panels1= new JPanel();
panels1.add(labels1);
panels1.setSize(100, 60);
p3.add(panels1);
JPanel panels;
JLabel labels;
ImageIcon tt;
tt = new ImageIcon( "F:\\E_workplace1\\Students_Beds\\3.png");
labels= new JLabel(tt);
panels= new JPanel();
panels.add(labels);
p2.add(panels);
p2.setSize(670, 515);//图片大小
p2.setLocation(180, 178);
panels.setBounds(150, 0, 500, 500);
JButton LogOU=new JButton("注销用户");
p1.add(LogOU);
LogOU.setBounds(200, 0,100, 40);
LogOU.setBackground(Color.PINK);
Font f1=new Font("楷体",Font.BOLD,18);
Font f2=new Font("楷体",Font.BOLD,15);
LogOU.setFont(f1);
LogOU.addActionListener(this);
JButton ExitS=new JButton("退出系统");
ExitS.setFont(f1);
ExitS.setBackground(Color.PINK);
p1.add(ExitS);
ExitS.addActionListener(this);
JButton Help=new JButton("客服帮助");
Help.setFont(f1);
Help.setBackground(Color.PINK);
Help.addActionListener(this);
p1.add(Help);
c.add(p1);
zh=new JLabel("学号:");
zh.setBounds(0, 50, 50, 30);
c.add(zh);
zh.setFont(f2);
zh1=new JLabel("");
zh1.setBackground(Color.BLACK);
zh1.setBounds(40, 50, 100, 30);
c.add(zh1);
zh1.setFont(f2);
zh1.setBackground(Color.WHITE);
mz=new JLabel("姓名:");
mz.setBounds(150,50, 50, 30);
c.add(mz);
mz.setFont(f2);
mz1=new JLabel("廖林");
mz1.setBackground(Color.WHITE);
mz1.setBounds(186, 50, 100, 30);
c.add(mz1);
mz1.setFont(f2);
mz1.setBackground(Color.WHITE);
perD=new JButton("开发者");
perD.setFont(f1);
perD.setBackground(Color.PINK);
perD.setBounds(353, 5,99, 33);
c.add(perD);
p1.add(perD);
perD.setVisible(true);
perD.addActionListener(this);
p6=new JPanel();
p6.setSize(380, 500);
p6.setLayout(null);
sj=new JLabel("时间:");
sj.setBounds(250, 50, 50, 30);
c.add(sj);
sj.setFont(f2);
sj1=new JLabel();
sj1.setBounds(290, 50, 300, 30);
c.add(sj1);
sj1.setFont(f2);
sj1.setBackground(Color.WHITE);
//时间1.setFont(f2);
jtab1=new JTabbedPane();
jtab2=new JTabbedPane();
jtab3=new JTabbedPane();
jtab4=new JTabbedPane();
jtab5=new JTabbedPane();
jtab6=new JTabbedPane();
jtab7=new JTabbedPane();
p2=new JPanel();
p3=new JPanel();
p4=new JPanel();
p5=new JPanel();
p6_1=new JPanel();
p7=new JPanel();
p8=new JPanel();
p9=new JPanel();
p10=new JPanel();
p2.setLayout(null);
p3.setLayout(null);
p4.setLayout(null);
p5.setLayout(null);
p6_1.setLayout(null);
p7.setLayout(null);
p8.setLayout(null);
p9.setLayout(null);
p10.setLayout(null);
jtab1.addTab("学生管理模块", null,p2,null);
jtab2.addTab("宿管管理模块", null,p3,null);
jtab3.addTab("邮件管理模块", null,p4,null);
jtab4.addTab("床位管理模块", null,p5,null);
jtab5.addTab("夜归生管理面板", null,p6_1,null);
jtab6.addTab("报修管理面板", null,p7,null);
jtab7.addTab("文件打印面板", null,p8,null);
jtab1.setFont(f1);
jtab2.setFont(f1);
jtab3.setFont(f1);
jtab4.setFont(f1);
jtab4.setFont(f1);
jtab5.setFont(f1);
jtab6.setFont(f1);
jtab7.setFont(f1);
jtab=new JTabbedPane();
panel1=new JPanel();
panel2=new JPanel();
panel3=new JPanel();
pane14=new JPanel();
pane15=new JPanel();
pane16=new JPanel();
panel10=new JPanel();
panel_5=new JPanel();
panel_6=new JPanel();
panel_7=new JPanel();
panel_8=new JPanel();
jtab.setBackground(Color.PINK);
jtab.addTab("学生信息管理模块",null,jtab1,"First panel");
//jtab1.setBackground();
jtab.addTab("宿管管理模块",null,jtab2,"Second panel");
jtab.addTab("邮件管理模块",null,jtab3,"Third panel");
jtab.addTab("床号管理模块",null,jtab4,"Forth panel");
jtab.addTab("夜归生管理模块",null,jtab5,"Five panel");
jtab.addTab("报修管理模块",null,jtab6,"Six panel");
jtab.addTab("文件打印模块",null,jtab7,"Seven panel");
jtab.setFont(f1);
jtab.setBackground(Color.pink);
p2.setLayout(null);
p2_1=new JPanel();
p2_1.setBounds(125,0,800,800);
p2.add(p2_1);
p2_1.setLayout(new BorderLayout());
p3.setLayout(null);
p3_1=new JPanel();
p3_1.setBounds(125, 0, 650, 500);
p3.add(p3_1);
p3_1.setLayout(new BorderLayout());
p4.setLayout(null);
p4_1=new JPanel();
p4_1.setBounds(125, 0, 650, 500);
p4.add(p4_1);
p4_1.setLayout(new BorderLayout());
p5.setLayout(null);
p5_1=new JPanel();
p5_1.setBounds(125, 0, 650, 500);
p5.add(p5_1);
p5_1.setLayout(new BorderLayout());
p6_1.setLayout(null);
p10_1=new JPanel();
p10_1.setBounds(125,0,650,500);
p6_1.add(p10_1);
p10_1.setLayout(new BorderLayout());
p7.setLayout(null);
p7_1=new JPanel();
p7_1.setBounds(125,0,650,500);
p7.add(p7_1);
p7_1.setLayout(new BorderLayout());
p8.setLayout(null);
p8_1=new JPanel();
p8_1.setBounds(125, 0, 650, 500);
p8.add(p8_1);
p8_1.setLayout(new BorderLayout());
panel7=new JPanel();
panel8=new JPanel();
panel9=new JPanel();
p2.add(pane15);
p3.add(pane16);
p4.add(panel7);
p5.add(panel8);
p6_1.add(panel9);
p7.add(panel_6);
p8.add(panel_7);
pane16.setBackground(Color.pink);
pane15.setBackground(Color.pink);
panel_6.setBackground(Color.pink);
panel_7.setBackground(Color.pink);
pane15.setBounds(0,0,125,700);
pane16.setBounds(0,0,125,700);
panel_6.setBounds(0,0,125,700);
panel_7.setBounds(0,0,125,700);
panel7.setBackground(Color.pink);
panel8.setBackground(Color.pink);
panel9.setBackground(Color.pink);
panel10.setBackground(Color.pink);
panel7.setBounds(0, 0, 125, 700);
panel8.setBounds(0, 0, 125, 700);
panel9.setBounds(0, 0, 125, 700);
panel10.setBounds(0, 0, 125, 700);
pane15.setLayout(null);
pane16.setLayout(null);
panel_6.setLayout(null);
panel_7.setLayout(null);
panel7.setLayout(null);
panel8.setLayout(null);
panel9.setLayout(null);
panel9.setLayout(null);
//---------------------------------------学生管理-----------------------------------------------------------
Add_S=new JButton("添加学生");
Chenck_S=new JButton("查询信息");
View_S=new JButton("浏览信息");
Add_S.setBounds(10,30,115,30);
Chenck_S.setBounds(8,95,115,30);
View_S.setBounds(10,170,115,30);
Add_S.addActionListener(this);
Chenck_S.addActionListener(this);
View_S.addActionListener(this);
pane15.add(Add_S);
pane15.add(Chenck_S);
pane15.add(View_S);
Delete_S = new JButton("删除学生");
Delete_S.setBounds(10,240,115,30);
Delete_S.addActionListener(this);
pane15.add(Delete_S);
Delete_S.setBackground(Color.gray);
Delete_S.setFont(f1);
Chenge_S = new JButton("修改学生");
Chenge_S.setBounds(10,300,115,30);
Chenge_S.addActionListener(this);
pane15.add(Chenge_S);
Chenge_S.setBackground(Color.gray);
Chenge_S.setFont(f1);
Add_S.setBackground(Color.gray);
Add_S.setFont(f1);
Chenck_S.setBackground(Color.gray);
Chenck_S.setFont(f1);
View_S.setBackground(Color.gray);
View_S.setFont(f1);
//-----------------------------------------宿管管理---------------------------------------------------------
Add_M=new JButton("添加宿管");
Check_M=new JButton("宿管查询");
Change_M=new JButton("宿管修改");
Delete_M=new JButton("删除宿管");
Add_M.setBounds(10,30,115,50);
Check_M.setBounds(8,90,115,50);
Change_M.setBounds(10,170,115,50);
Delete_M.setBounds(10,240,115,50);
Add_M.addActionListener(this);
Check_M.addActionListener(this);
Change_M.addActionListener(this);
Delete_M.addActionListener(this);
pane16.add(Add_M);
pane16.add(Check_M);
pane16.add(Change_M);
pane16.add(Delete_M);
Add_M.setBackground(Color.gray);
Add_M.setFont(f1);
Check_M.setBackground(Color.gray);
Check_M.setFont(f1);
Change_M.setBackground(Color.gray);
Change_M.setFont(f1);
Delete_M.setBackground(Color.gray);
Delete_M.setFont(f1);
//-------------------------------------------邮件管理---------------------------------------------------------
Add_Email=new JButton("邮件录入");
Delete_Email=new JButton("邮件删除");
Change_Email=new JButton("邮件修改");
Add_Email.setBounds(10, 30, 115, 50);
Delete_Email.setBounds(10, 100, 115, 50);
Change_Email.setBounds(10, 170, 115, 50);
Add_Email.addActionListener(this);
Delete_Email.addActionListener(this);
Change_Email.addActionListener(this);
Add_Email.setBackground(Color.gray);
Add_Email.setFont(f1);
Delete_Email.setBackground(Color.gray);
Delete_Email.setFont(f1);
Change_Email.setBackground(Color.gray);
Change_Email.setFont(f1);
panel7.add(Add_Email);
panel7.add(Delete_Email);
panel7.add( Change_Email);
//--------------------------------------------床位管理-----------------------------------------------------------
Add_bed = new JButton("添加床位");
Check_beds = new JButton("查询处理");
Change_bed = new JButton("调整床位");
Clear_beds = new JButton("清空处理");
Add_bed.setBounds(10, 30, 115, 30);
Check_beds.setBounds(10, 80, 115 ,30);
Change_bed.setBounds(10, 130, 115, 30);
Clear_beds.setBounds(10, 180, 115 ,30);
Check_beds.addActionListener(this);
Add_bed.addActionListener(this);
Change_bed.addActionListener(this);
Clear_beds.addActionListener(this);
Add_bed.setBackground(Color.gray);
Add_bed.setFont(f1);
Check_beds.setBackground(Color.gray);
Check_beds.setFont(f1);
panel8.add(Add_bed);
panel8.add(Check_beds);
Clear_beds.setBackground(Color.gray);
Clear_beds.setFont(f1);
Change_bed.setBackground(Color.gray);
Change_bed.setFont(f1);
panel8.add(Change_bed);
panel8.add(Clear_beds);
//------------------------------------------------夜归生管理----------------------------------------------------
Add_Dark=new JButton("添加夜归");
Delete_Dark=new JButton("删除夜归");
View_Dark=new JButton("查阅夜归");
Chnage_Dark=new JButton("查询夜归");
Add_Dark.setBounds(5, 30, 120, 30);
Delete_Dark.setBounds(5, 80, 120, 30);
View_Dark.setBounds(5, 130, 120, 30);
Chnage_Dark.setBounds(5, 180, 120, 30);
Add_Dark.addActionListener(this);
Delete_Dark.addActionListener(this);
View_Dark.addActionListener(this);
Chnage_Dark.addActionListener(this);
panel9.add(Add_Dark);
panel9.add(Delete_Dark);
panel9.add(View_Dark);
panel9.add(Chnage_Dark);
Add_Dark.setBackground(Color.gray);
Add_Dark.setFont(f1);
Delete_Dark.setBackground(Color.gray);
Delete_Dark.setFont(f1);
View_Dark.setBackground(Color.gray);
View_Dark.setFont(f1);
Chnage_Dark.setBackground(Color.gray);
Chnage_Dark.setFont(f1);
//---------------------------------------------------报修管理--------------------------------------------------
Change_R=new JButton("更新报修");
View_R=new JButton("查阅报修");
Change_R.setBounds(10, 30, 120, 30);
View_R.setBounds(10, 80, 120, 30);
Change_R.setBackground(Color.gray);
Change_R.setFont(f1);
View_R.setBackground(Color.gray);
View_R.setFont(f1);
Change_R.addActionListener(this);
View_R.addActionListener(this);
panel_6.add(Change_R);
panel_6.add(View_R);
TimerTask task=new TimerTask()
{
public void run()
{
String sdate;
sdate=(new SimpleDateFormat("yyyy-MM-dd EEEE hh:mm:ss")).format(new Date());
sj1.setText(sdate);
}
};
Timer t=new Timer();
t.scheduleAtFixedRate(task, new Date(),1000);
c.add(jtab);
p2=new JPanel();
p2.setLayout(new BorderLayout());
p2.setBounds(50,100,800 ,600);
p2.add(jtab);
c.add(p2);
app.setVisible(true);
app.setSize(900, 800);
app.setLocation(500 , 160);
app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
//------------------------------------------------注销,退出窗口---------------------------------------------
public void actionPerformed(ActionEvent e)
{
if(e.getActionCommand()=="注销用户") {
int n=JOptionPane.showConfirmDialog(null,"你要注销该用户吗","注销用户",JOptionPane.YES_NO_OPTION);
if(n==JOptionPane.YES_OPTION)
{
System.exit(0);
}
}
if(e.getActionCommand()=="退出系统") {
JLabel l1=new JLabel("你要退出此系统,是否确定?");
l1.setFont(new Font("楷体", Font.PLAIN, 13));
int n=JOptionPane.showConfirmDialog(null,l1,"退出系统",JOptionPane.YES_NO_OPTION);
if(n==JOptionPane.YES_OPTION) {
//调用dispose()方法,实现当前窗口的关闭
app.dispose();
new LoginJF();
}
}
//-------------------------------------------------学生------------------------------------------------------
if(e.getSource()==Add_S)
{
//不要更好,但下面的必须有
//p2_1.setVisible(false);
//p2_1.removeAll();
//p2_1.add(new Add_Students());
//p2_1.setVisible(true);
//显示虚化界面
this.setUndecorated(true);
this.add(new Add_Students());
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
//this.setSize(new Dimension(800,600));
this.setBounds(730, 400, 500, 500);
AWTUtilities.setWindowOpaque(this, false);
this.setVisible(true);
}
if(e.getSource()==Chenck_S)
{
p2_1.setVisible(false);
p2_1.removeAll();
p2_1.add(new Check_Students());
p2_1.setVisible(true);
}
if(e.getSource()==View_S)
{
p2_1.setVisible(false);
p2_1.removeAll();
p2_1.add(new View_Students());
p2_1.setVisible(true);
}
if(e.getSource()==Delete_S)
{
p2_1.setVisible(false);
p2_1.removeAll();
p2_1.add(new Delete_Students());
p2_1.setVisible(true);
}
if(e.getSource()==Chenge_S)
{
p2_1.setVisible(false);
p2_1.removeAll();
p2_1.add(new Change_Students());
p2_1.setVisible(true);
}
//-------------------------------------------------宿管-----------------------------------------------
if(e.getSource()==Add_M)
{
p3_1.setVisible(false);
p3_1.removeAll();
p3_1.add(new Add_Housemasters());
p3_1.setVisible(true);
}
if(e.getSource()==Check_M)
{
p3_1.setVisible(false);
p3_1.removeAll();
p3_1.add(new Check_Housemaster_Students());
p3_1.setVisible(true);
}
if(e.getSource()==Change_M)
{
p3_1.setVisible(false);
p3_1.removeAll();
p3_1.add(new Change_Masters());
p3_1.setVisible(true);
}
if(e.getSource()==Delete_M)
{
p3_1.setVisible(false);
p3_1.removeAll();
p3_1.add(new Delete_Roommaster());
p3_1.setVisible(true);
}
//-----------------------------------------------床位----------------------------------------------------
if(e.getSource()==Add_bed)
{
p5_1.setVisible(false);
p5_1.removeAll();
p5_1.add(new Add_Beds());
p5_1.setVisible(true);
}
if(e.getSource()==Check_beds)
{
p5_1.setVisible(false);
p5_1.removeAll();
p5_1.add(new Check_Beds());
p5_1.setVisible(true);
}
if(e.getSource()==Change_bed)
{
p5_1.setVisible(false);
p5_1.removeAll();
p5_1.add(new Add_Beds());
p5_1.setVisible(true);
}
if(e.getSource()==Clear_beds)
{
p5_1.setVisible(false);
p5_1.removeAll();
p5_1.add(new Check_Beds());
p5_1.setVisible(true);
}
//----------------------------------------------邮件------------------------------------------------------
if(e.getSource()==Add_Email)
{
p4_1.setVisible(false);
p4_1.removeAll();
p4_1.add(new Add_Emails());
p4_1.setVisible(true);
}
if(e.getSource()==Delete_Email)
{
p4_1.setVisible(false);
p4_1.removeAll();
p4_1.add(new Delete_Emails());
p4_1.setVisible(true);
}
if(e.getSource()==Change_Email)
{
p4_1.setVisible(false);
p4_1.removeAll();
p4_1.add(new Change_Emails());
p4_1.setVisible(true);
}
//-----------------------------------------------夜归生----------------------------------------------------
/* if(e.getSource()==Add_Dark)
{
p10_1.setVisible(false);
p10_1.removeAll();
p10_1.add(new currentAM());
p10_1.setVisible(true);
}
if(e.getSource()==Delete_Dark)
{
p10_1.setVisible(false);
p10_1.removeAll();
p10_1.add(new currentAA());
p10_1.setVisible(true);
}
if(e.getSource()==View_Dark)
{
p10_1.setVisible(false);
p10_1.removeAll();
p10_1.add(new currentAD());
p10_1.setVisible(true);
}
if(e.getSource()== Chnage_Dark)
{
p10_1.setVisible(false);
p10_1.removeAll();
p10_1.add(new currentAMod());
p10_1.setVisible(true);
}*/
//-------------------------------------------------文件打印----------------------------------------------------
//----------------------------------------------------报修------------------------------------------------------
if(e.getSource()==Change_R)
{
p7_1.setVisible(false);
p7_1.removeAll();
p7_1.add(new Roublshooting_M_C());
p7_1.setVisible(true);
}
if(e.getSource()==View_R)
{
p7_1.setVisible(false);
p7_1.removeAll();
p7_1.add(new Roublshooting_M_V());
p7_1.setVisible(true);
}
}
public static void main(String[]args) {
new MainSystem_Master();
}}