package com.codergeshu.train.ticketing.system.view;
import java.awt.*;
import java.awt.event.*;
import java.util.ArrayList;
import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import com.codergeshu.train.ticketing.system.dao.*;
import com.codergeshu.train.ticketing.system.entity.*;
/**
* @Project: StationTicketingSystem
* @Date: 2020/2/23 18:45
* @author: Eric
* @Description: TODO 管理员界面类
*/
public class AdminWindow extends JFrame implements ActionListener {
//菜单项目
private JMenuItem menuitem_manageRoute, menuitem_setTicketPrice;
private JMenuItem menuitem_usersInfo, menuitem_exit;
//列车车次表格,用户信息表格
private JTable trainTable, userTable;
//单个车次信息面板,单个用户信息面板
private JPanel jp_singleRouteInfo, jp_singleUserInfo, jp_main;
//用到的下拉框
private JComboBox<String> com_trainType, com_gender, com_userType;
//列车实体数组列表
private ArrayList<Trains> trains = new ArrayList<>();
//对实体的dao属性
private TrainsDao trainsDao = new TrainsDao();
private UsersDao usersDao = new UsersDao();
//列车信息表头
private Object[] cols_train = {"车次", "类型", "起点", "终点", "出发时间", "到达时间", "用时"};
private Object[][] rows_train;
//单个列车信息显示框及功能按钮
private JTextField txt_trainNo, txt_startPlace, txt_midPlace, txt_endPlace;
private JTextField txt_startTime, txt_endTime, txt_runtime;
private JButton btn_search, btn_confirmSearch, btn_return, btn_input;
private JButton btn_add, btn_modify, btn_delete;
private JPanel jp_functionBtn;
//用户信息表头
private Object[] cols_user = {"手机号", "密码", "姓名", "性别", "类型", "ID"};
private Object[][] rows_user;
//单个用户信息显示框及功能按钮
private JTextField txt_tel, txt_password, txt_name, txt_id;
private JButton btn_confirm, btn_deleteUser;
//票价设置
private JButton btn_ordinaryTrain, btn_highSpeedTrain, btn_bulletTrain;
private JLabel lbl_businessSeat, lbl_firstSeat, lbl_secondSeat;
private JTextField txt_businessSeat, txt_firstSeat, txt_secondSeat;
private JButton btn_modifyPrice;
private JPanel jp_seatPrice;
private int trainTypeNo;
public AdminWindow(String s) {
//设置界面题头和符号
setTitle(s);
ImageIcon icon = new ImageIcon("picture/logo1.jpg");
setIconImage(icon.getImage());
//设置系统界面菜单条
this.setMenuBar();
//初始化列车信息表格
trainTable = new JTable(rows_train, cols_train);
//为列车信息添加监视器
trainTable.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
showSelectedRouteInfo();//选中某行会出现在信息显示模块
}
});
//初始化显示单个车次信息的模块
initSingleRouteInfoModule();
//初始化票价管理模块
initPriceModule();
//初始化所有用户信息表格
userTable = new JTable(rows_user, cols_user);
//为用户信息表格添加监视器
userTable.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
showSelectedUserInfo();
}
});
//初始化显示单个用户信息的模块
initSingleUserInfoModule();
//主面板
jp_main = new JPanel();
jp_main.setLayout(new BorderLayout());
this.add(jp_main);
this.validate();
this.setVisible(true);
this.setSize(1000, 500);
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
//实现监视器中的方法
public void actionPerformed(ActionEvent e) {
//路线管理事件,获得所有列车信息数组列表并生成表格,更新主面板
if (e.getSource() == menuitem_manageRoute) {
trains = trainsDao.trainQueryAll();
this.updateTrainTable();
jp_main.removeAll();
jp_main.setLayout(new BorderLayout());
jp_main.add(new JScrollPane(trainTable), BorderLayout.CENTER);
jp_main.add(jp_singleRouteInfo, BorderLayout.SOUTH);
jp_main.updateUI();
return;
}
//查询按钮事件
if (e.getSource() == btn_search) {
this.clearText(); //清除文本框内容
txt_startTime.setEditable(false);
txt_endTime.setEditable(false);
txt_runtime.setEditable(false);
txt_midPlace.setEditable(false);
jp_functionBtn.removeAll();
jp_functionBtn.add(btn_confirmSearch);
jp_functionBtn.add(btn_return);
jp_functionBtn.updateUI();
return;
}
//确认查询路线
if (e.getSource() == btn_confirmSearch) {
String startPlace = txt_startPlace.getText().trim();
String endPlace = txt_endPlace.getText().trim();
int trainTypeNo = com_trainType.getSelectedIndex();
trains = this.searchTrain(startPlace, endPlace, trainTypeNo);
this.updateTrainTable();
return;
}
//查询后的返回按钮
if (e.getSource() == btn_return) {
txt_startTime.setEditable(true);
txt_endTime.setEditable(true);
txt_runtime.setEditable(true);
txt_midPlace.setEditable(true);
jp_functionBtn.removeAll();
jp_functionBtn.add(btn_search);
jp_functionBtn.add(btn_input);
jp_functionBtn.add(btn_modify);
jp_functionBtn.add(btn_delete);
jp_functionBtn.updateUI();
//更新车次信息表
trains = trainsDao.trainQueryAll();
this.updateTrainTable();
this.clearText();
return;
}
//录入路线按钮
if (e.getSource() == btn_input) {
this.clearText();
txt_trainNo.setEditable(true);
jp_functionBtn.removeAll();
jp_functionBtn.add(btn_add);
jp_functionBtn.updateUI();
return;
}
//确认增加路线按钮
if (e.getSource() == btn_add) {
this.addTrain();
txt_trainNo.setEditable(false);
jp_functionBtn.removeAll();
jp_functionBtn.add(btn_search);
jp_functionBtn.add(btn_input);
jp_functionBtn.add(btn_modify);
jp_functionBtn.add(btn_delete);
jp_functionBtn.updateUI();
//更新车次信息
trains = trainsDao.trainQueryAll();
this.updateTrainTable();
return;
}
//修改路线
if (e.getSource() == btn_modify) {
String trainNo = txt_trainNo.getText().trim();
if (trainNo.equals("")) {
JOptionPane.showMessageDialog(this, "请先选择要修改的路线!", "提醒", JOptionPane.WARNING_MESSAGE);
return;
}
int k = JOptionPane.showConfirmDialog(this, "确定修改此路线吗?", "提醒", JOptionPane.OK_CANCEL_OPTION);
if (k == 0) {
this.updateTrain();
}
//更新车次信息
trains = trainsDao.trainQueryAll();
this.updateTrainTable();
return;
}
//删除路线
if (e.getSource() == btn_delete) {
String trainNo = txt_trainNo.getText().trim();
if (trainNo.equals("")) {
JOptionPane.showMessageDialog(this, "请先选择要删除的路线!", "提醒", JOptionPane.WARNING_MESSAGE);
return;
}
int k = JOptionPane.showConfirmDialog(this, "确定删�
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
Java+Swing+Mysql实现铁路售票管理系统 该系统有两个角色分别是管理员和乘客,具体功能如下: 1、管理员 登录,线路管理,价格管理,用户服务,退出系统。 2、乘客 登录注册、车票业务、购票、订单查询、可以查看吗出发地、到达地,出发日期,乘车查询,联系人等功能 源码+数据库,系统经多次测试,运行无误,请大家放心下载
资源推荐
资源详情
资源评论
收起资源包目录
Java Swing铁路售票管理系统.zip (70个子文件)
图
车次查询.jpg 36KB
订单信息.jpg 38KB
线路管理.jpg 58KB
价格管理.jpg 21KB
登录.jpg 40KB
用户信息管理.jpg 40KB
sql
create.sql 9KB
ͼ
train-ticketing-system-main
.classpath 310B
picture
hexiehao3.jpg 65KB
success.jpg 3KB
rail5.jpg 53KB
failed.jpg 3KB
logo1.jpg 37KB
src
com
codergeshu
train
ticketing
system
utils
Background.java 792B
SQLHelper.java 3KB
dao
UsersDao.java 5KB
ContactsDao.java 3KB
TrainsDao.java 5KB
SeatPriceDao.java 2KB
OrderSheetsDao.java 4KB
AppStarter.java 295B
view
RegisterWindow.java 8KB
PassengerWindow.java 21KB
AdminWindow.java 30KB
LoginWindow.java 7KB
SearchResultWindow.java 7KB
OrderSheetWindow.java 10KB
entity
OrderSheets.java 2KB
BoxSeatQuantity.java 628B
Trains.java 1KB
Seats.java 1KB
Contacts.java 1KB
Users.java 1KB
SeatPrice.java 987B
libs
mysql-connector-java-5.1.7-bin.jar 693KB
mysql-connector-java-8.0.15.jar 2.04MB
.idea
libraries
mysql_connector_java_5_1_7_bin.xml 259B
workspace.xml 24KB
misc.xml 262B
inspectionProfiles
modules.xml 294B
encodings.xml 200B
bin
com
codergeshu
train
ticketing
system
utils
Background.class 1KB
SQLHelper.class 3KB
dao
OrderSheetsDao.class 5KB
TrainsDao.class 5KB
ContactsDao.class 3KB
SeatPriceDao.class 2KB
UsersDao.class 6KB
AppStarter.class 587B
view
RegisterWindow$1.class 1KB
AdminWindow$1.class 853B
AdminWindow$2.class 853B
RegisterWindow.class 7KB
AdminWindow.class 19KB
PassengerWindow.class 12KB
OrderSheetWindow.class 10KB
LoginWindow.class 6KB
SearchResultWindow.class 8KB
OrderSheetWindow$1.class 901B
SearchResultWindow$1.class 2KB
entity
Trains.class 2KB
Users.class 2KB
Contacts.class 1KB
BoxSeatQuantity.class 837B
SeatPrice.class 1KB
OrderSheets.class 3KB
Seats.class 1KB
.project 403B
.gitignore 107B
train-ticketing-system-main.iml 1KB
共 70 条
- 1
资源评论
一季春秋
- 粉丝: 9340
- 资源: 44
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功