package adminPackage;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.table.DefaultTableModel;
import serialized.Client_DeleteList;
import serialized.Client_ModelApply;
import serialized.Client_Request;
import serialized.Client_Student;
import serialized.Client_Toolman;
import serialized.Client_ToolmanSelectOdds;
import serialized.Client_Toolman_finishi;
import serialized.MASSAGE_TYPE;
import serialized.MASSAGE_TYPE.MASSAGE_type;
import serialized.Server_Model;
import serialized.Server_Student;
import serialized.Server_Toolman;
import serialized.Server_ToolmanAllModel;
import serialized.Server_Toolman_OnesModel;
import serialized.Student;
import serialized.Toolman;
import sql.DriverMysql;
import studentPackage.studentsignin;
public class Server extends JFrame {
JLabel id = new JLabel("AdminID:");
JLabel password = new JLabel("密码:");
JTextField idtextfield = new JTextField(11);
JPasswordField passwordfield = new JPasswordField();
JButton signin = new JButton("开启服务器");
JButton signout = new JButton("关闭服务器");
ServerSocket serverSocket=null;
boolean connet =false;
ExecutorService threadPool = Executors.newFixedThreadPool(10);
public Server() {
// TODO Auto-generated constructor stub
//窗口先初始化S
this.setTitle("后台管理人员登录");
this.setBounds(400, 300, 375, 325);
this.setLayout(null);
this.setVisible(true);
//组件添加进去
this.add(id);
this.add(password);
this.add(signin);
this.add(idtextfield);
this.add(passwordfield);
this.add(signout);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
//设置组件位置大小
id.setBounds(25, 60, 70, 35);
password.setBounds(20, 130, 70, 35);
idtextfield.setBounds(100, 60, 170, 30);
passwordfield.setBounds(100, 130, 170, 30);
signin.setBounds(70, 230, 200, 40);
signout.setBounds(70, 230, 200, 40);
signout.setVisible(false);
signin.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
String number = idtextfield.getText();
String password = new String(passwordfield.getPassword());
DriverMysql driverMysql = new DriverMysql();
String sqlString = "SELECT `admin_password` FROM `school`.`admin_signin`WHERE`admin_number`='"+number+"'"+";";
String passwordString = driverMysql.login(sqlString);
if (password.equals(passwordString)) {
idtextfield.setEnabled(false);
passwordfield.setEnabled(false);
signin.setVisible(false);
signout.setVisible(true);
connet = true;
JOptionPane.showMessageDialog(null, "欢迎admin:"+number);
}else {
JOptionPane.showMessageDialog(null, "请重新输入账号密码");
idtextfield.setText("");
passwordfield.setText("");
connet = false;
}
}
});
signout.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
idtextfield.setEnabled(true);
passwordfield.setEnabled(true);
signin.setVisible(true);
signout.setVisible(false);
idtextfield.setText("");
passwordfield.setText("");
System.exit(0);
JOptionPane.showMessageDialog(null, "您已关闭服务器");
}
});
go();
disserver();
}
private void go() {
// TODO Auto-generated method stub
while (!connet) {
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
}
}
try {
serverSocket = new ServerSocket(5754);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
while(connet) {
try {
System.out.println("等待客户端连接.....");
Socket socket = serverSocket.accept();
System.out.println("客户端连接了!!!!!");
ThreadServer threadServer = new ThreadServer(socket);
threadPool.execute(threadServer);
socket = null;
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
}
//得到数据库中的tablemodel,然后传输model.
private void disserver() {
// TODO Auto-generated method stub
if (serverSocket!=null) {
try {
serverSocket.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
serverSocket=null;
}
}
public static void main(String[] args) {
new Server();
}
}
class ThreadServer implements Runnable{
Socket socket = null;
private ObjectOutputStream oos = null;
public ThreadServer(Socket socket) {
// TODO Auto-generated constructor stub
this.socket = socket;
}
@Override
public void run() {
// TODO Auto-generated method stub
run_doing();
closeserver();
}
//传入服务器收到的客户端套接字
private void run_doing() {
// TODO Auto-generated method stub
OutputStream os = null;
InputStream is = null;
ObjectInputStream ois = null;
try {
// 创建对象数据流
os = socket.getOutputStream();
is = socket.getInputStream();
oos = new ObjectOutputStream(os);
ois = new ObjectInputStream(is);
} catch (IOException e) {
System.out.println(e.getMessage());
return;
}
while (true) {
MASSAGE_TYPE receive_massage = null;
try {
receive_massage = (MASSAGE_TYPE) ois.readObject();
System.out.println(receive_massage);
} catch (ClassNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
continue;
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return;
}
switch (receive_massage.Default_type) {
case client_student:
Studentlogin(receive_massage, oos);
break;
case client_toolman:
Toolmanlogin(receive_massage, oos);
break;
case client_student_table:
ShowOnesModel(receive_massage, oos);
break;
case client_deleteodds:
DeleteOdds(receive_massage);
break;
case clirnt_toolman_table:
ShowtoolmanModel(oos);
break;
case client_toolman_selectodds:
SelectOdds(receive_massage);
break;
case client_toolman_onestable:
ShowToolmanOnesModel(oos);
break;
case client_toolman_finish:
FinishOdd(receive_massage);
break;
case client_repairtable:
break;
}
}
}
private void Studentlogin(MASSAGE_TYPE receive_massage,ObjectOutputStream oos) {
// TODO Auto-generated method stub
Client_Student client_Student = (Client_Student) receive_massage;
client_Student.getStudent().getPasswordString();
DriverMysql mysql = new DriverMysql();
String sqlString = "SELECT * FROM `school`.`student_signin` WHERE `student_number` = '"+client_Student.getStudent().getNumberString()+"
没有合适的资源?快使用搜索试试~ 我知道了~
通过Java,MySQL实现的基于C/S模式的校园报修管理系统
共72个文件
class:41个
java:26个
jar:1个
需积分: 11 0 下载量 21 浏览量
2022-11-03
13:04:09
上传
评论
收藏 1.01MB ZIP 举报
温馨提示
通过Java,MySQL实现的基于C/S模式的校园报修管理系统
资源推荐
资源详情
资源评论
收起资源包目录
CampusRepairSystem.zip (72个子文件)
CampusRepairSystem
CampusRepairSystem
bin
studentPackage
showTable$1.class 3KB
applyORcheak$1.class 786B
showTable$3.class 2KB
applyORcheak.class 1KB
RepairRequest$1.class 2KB
studentsignin.class 5KB
showTable.class 5KB
RepairRequest.class 4KB
applyORcheak$2.class 865B
showTable$2.class 851B
UI
ui.class 2KB
serialized
Server_Toolman.class 809B
Server_Model.class 854B
Client_Toolman_OnesModelApply.class 586B
Server_Toolman_OnesModel.class 716B
Client_Request.class 1KB
Server_ToolmanAllModel.class 923B
Client_ModelApply.class 846B
Client_ToolmanSelectOdds.class 1KB
Client_ToolmanModelApply.class 567B
Client_Toolman.class 809B
Student.class 1KB
Client_DeleteList.class 1KB
Toolman.class 866B
MASSAGE_TYPE.class 577B
Client_Toolman_finishi.class 1KB
Server_Student.class 1KB
Client_Student.class 809B
MASSAGE_TYPE$MASSAGE_type.class 2KB
toolManPackage
toolmansignin$1.class 2KB
selectTable$3.class 2KB
toolmansignin.class 4KB
selectTable$4.class 2KB
selectTable$2.class 2KB
selectTable$1.class 2KB
selectTable.class 5KB
sql
DriverMysql.class 5KB
adminPackage
ThreadServer.class 11KB
Server$1.class 2KB
Server.class 3KB
Server$2.class 1KB
.settings
org.eclipse.jdt.core.prefs 598B
src
studentPackage
showTable.java 7KB
RepairRequest.java 4KB
studentsignin.java 4KB
applyORcheak.java 1KB
UI
ui.java 1KB
serialized
Server_ToolmanAllModel.java 619B
Client_Toolman_finishi.java 501B
Client_ToolmanSelectOdds.java 532B
Toolman.java 641B
Student.java 816B
Server_Student.java 694B
Client_DeleteList.java 515B
Client_ModelApply.java 460B
Server_Toolman_OnesModel.java 567B
Client_Student.java 409B
Client_ToolmanModelApply.java 274B
Client_Request.java 481B
MASSAGE_TYPE.java 633B
Server_Toolman.java 407B
Client_Toolman.java 407B
Server_Model.java 477B
Client_Toolman_OnesModelApply.java 288B
toolManPackage
toolmansignin.java 4KB
selectTable.java 8KB
sql
DriverMysql.java 5KB
adminPackage
Server.java 15KB
.project 394B
hs_err_pid18152.log 279KB
.classpath 479B
lib
mysql-connector-java-5.1.39-bin (2).jar 966KB
共 72 条
- 1
资源评论
217y_418
- 粉丝: 5
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功