|
|
|
|
@ -2,18 +2,20 @@ package frame.UserPanel;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import frame.Main_Frame;
|
|
|
|
|
import model.*;
|
|
|
|
|
import model_new.Flight;
|
|
|
|
|
import model_new.Order;
|
|
|
|
|
import service.FlightService;
|
|
|
|
|
import service.OrderService;
|
|
|
|
|
|
|
|
|
|
import java.awt.*;
|
|
|
|
|
import java.awt.event.ActionEvent;
|
|
|
|
|
import java.awt.event.ActionListener;
|
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Optional;
|
|
|
|
|
import javax.swing.*;
|
|
|
|
|
/**
|
|
|
|
|
* <p>This page is mainly for the passengers to choose which flight to check in and see the detail information of the flights. </p>
|
|
|
|
|
* <p>此页面主要供乘客选择办理哪个航班的登机手续,并查看航班的详细信息。 </p>
|
|
|
|
|
*
|
|
|
|
|
* @author Jiayi Yu
|
|
|
|
|
* @version 3.1
|
|
|
|
|
@ -23,18 +25,18 @@ public class Flights_Panel extends JPanel {
|
|
|
|
|
|
|
|
|
|
public static String idNum=""; // ID number initialization
|
|
|
|
|
|
|
|
|
|
passenger_order po = new passenger_order(); // Initialization of passenger's order
|
|
|
|
|
flight flight_object1 = new flight(); // Initialization of the "flight" object
|
|
|
|
|
|
|
|
|
|
// 这里的变量更新没有问题
|
|
|
|
|
public static String flight_num = ""; // Initialization of the flight number
|
|
|
|
|
public static String flight_order=""; // Initialization of the flight order
|
|
|
|
|
public static int page = 1 ; // set the number of page in this panel
|
|
|
|
|
public int num ; // Initialization of an integer number which stands for the number of flights which the current passenger is able to check in
|
|
|
|
|
public int num ; // 初始化一个整数,表示当前乘客可以办理登机手续的航班数量
|
|
|
|
|
|
|
|
|
|
String flight1_order ;
|
|
|
|
|
String flight2_order ;
|
|
|
|
|
String flight3_order ;
|
|
|
|
|
String flight4_order ;
|
|
|
|
|
// Initialization of the orders of these four flights
|
|
|
|
|
// 这四个航班的订单初始化
|
|
|
|
|
|
|
|
|
|
String flight1 ;
|
|
|
|
|
String flight2 ;
|
|
|
|
|
@ -46,6 +48,11 @@ public class Flights_Panel extends JPanel {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
idNum= Main_Frame.temp;
|
|
|
|
|
OrderService orderService = new OrderService(); // 定义订单服务接口
|
|
|
|
|
|
|
|
|
|
// 乘客ID为空
|
|
|
|
|
List<Order> orderList = orderService.getOrdersByPassenger(idNum); // 获取乘客的所有订单
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setBackground(new Color(72,46,115)); //Set background color
|
|
|
|
|
@ -102,7 +109,8 @@ public class Flights_Panel extends JPanel {
|
|
|
|
|
//String id_num = "360124200102040017"; which is just for software testing
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
num =po.orderNum(idNum); // get the number of flights which the current passenger is able to check in.
|
|
|
|
|
|
|
|
|
|
num = orderList.size(); // 获取当前乘客能够办理登机手续的航班数量。
|
|
|
|
|
|
|
|
|
|
if(num>2) {
|
|
|
|
|
jButtonNext.setVisible(true);
|
|
|
|
|
@ -113,9 +121,20 @@ public class Flights_Panel extends JPanel {
|
|
|
|
|
jButtonLast.setVisible(false);
|
|
|
|
|
// "Next" button and "Last" button will be visible only if the number of flights which the current passenger is able to check in is bigger than 2
|
|
|
|
|
|
|
|
|
|
//===================================================源代码========================================
|
|
|
|
|
// flight1_order = po.findOrder(idNum,1);
|
|
|
|
|
//
|
|
|
|
|
// flight1 = flight_object1.findFlight(flight1_order);
|
|
|
|
|
//===================================================源代码========================================
|
|
|
|
|
|
|
|
|
|
//===================================================修改版========================================
|
|
|
|
|
|
|
|
|
|
Order order = orderList.get(0); // 返回列表的第一个元素
|
|
|
|
|
flight1_order = order.getOrder_id(); // 获取订单号
|
|
|
|
|
flight1 = order.getFlight_id(); // 获取航班号
|
|
|
|
|
|
|
|
|
|
//===================================================修改版========================================
|
|
|
|
|
|
|
|
|
|
flight1_order = po.findOrder(idNum,1);
|
|
|
|
|
flight1 = flight_object1.findFlight(flight1_order); // Get the detail information of the first flight of current passenger
|
|
|
|
|
|
|
|
|
|
JPanel panel1 = new JPanel(); // Create a new middle-size panel for the first flight to show all important information
|
|
|
|
|
panel1.setBounds(150,120,900,220); // Set the size of this panel
|
|
|
|
|
@ -375,9 +394,12 @@ public class Flights_Panel extends JPanel {
|
|
|
|
|
To make codes clean and clear, less important and repetitive annotations won't be shown here.
|
|
|
|
|
Any questions please reference to the annotations in the part of flight.
|
|
|
|
|
*/
|
|
|
|
|
flight flight_object2 = new flight();
|
|
|
|
|
flight2_order = po.findOrder(idNum,2);
|
|
|
|
|
flight2 = flight_object2.findFlight(flight2_order);
|
|
|
|
|
|
|
|
|
|
//===================================================修改版========================================
|
|
|
|
|
order = orderList.get(1);
|
|
|
|
|
flight2_order = order.getOrder_id(); // 获取订单号
|
|
|
|
|
flight2 = order.getFlight_id(); // 获取航班号
|
|
|
|
|
//===================================================修改版========================================
|
|
|
|
|
|
|
|
|
|
GridBagLayout gbl2 = new GridBagLayout();
|
|
|
|
|
GridBagConstraints gbc2 = new GridBagConstraints();
|
|
|
|
|
@ -622,9 +644,20 @@ public class Flights_Panel extends JPanel {
|
|
|
|
|
To make codes clean and clear, less important and repetitive annotations won't be shown here.
|
|
|
|
|
Any questions please reference to the annotations in the part of flight.
|
|
|
|
|
*/
|
|
|
|
|
flight flight_object3 = new flight();
|
|
|
|
|
flight3_order = po.findOrder(idNum,3);
|
|
|
|
|
flight3 = flight_object3.findFlight(flight3_order);
|
|
|
|
|
|
|
|
|
|
// =============================================源代码===============================================
|
|
|
|
|
// flight flight_object3 = new flight();
|
|
|
|
|
// flight3_order = po.findOrder(idNum,3);
|
|
|
|
|
// flight3 = flight_object3.findFlight(flight3_order);
|
|
|
|
|
|
|
|
|
|
// =============================================源代码===============================================
|
|
|
|
|
|
|
|
|
|
// =============================================修改版===============================================
|
|
|
|
|
order = orderList.get(2); // 获取第二个元素
|
|
|
|
|
flight3_order = order.getOrder_id();
|
|
|
|
|
flight3 = order.getFlight_id();
|
|
|
|
|
|
|
|
|
|
// =============================================修改版===============================================
|
|
|
|
|
|
|
|
|
|
panel3.setBounds(150,120,900,220);
|
|
|
|
|
panel3.setBackground(new Color(72,46,20));
|
|
|
|
|
@ -856,10 +889,19 @@ public class Flights_Panel extends JPanel {
|
|
|
|
|
panel4.setBackground(new Color(20, 100, 115));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ========================================源代码===========================================
|
|
|
|
|
// flight flight_object4 = new flight();
|
|
|
|
|
// flight4_order = po.findOrder(idNum,4);
|
|
|
|
|
// flight4 = flight_object4.findFlight(flight4_order);
|
|
|
|
|
// ========================================源代码===========================================
|
|
|
|
|
|
|
|
|
|
// ========================================源代码===========================================
|
|
|
|
|
|
|
|
|
|
order = orderList.get(3);
|
|
|
|
|
flight4_order = order.getOrder_id();
|
|
|
|
|
flight4 = order.getFlight_id();
|
|
|
|
|
|
|
|
|
|
flight flight_object4 = new flight();
|
|
|
|
|
flight4_order = po.findOrder(idNum,4);
|
|
|
|
|
flight4 = flight_object4.findFlight(flight4_order);
|
|
|
|
|
// ========================================源代码===========================================
|
|
|
|
|
|
|
|
|
|
GridBagLayout gbl4 = new GridBagLayout();
|
|
|
|
|
GridBagConstraints gbc4 = new GridBagConstraints();
|
|
|
|
|
@ -1138,6 +1180,9 @@ public class Flights_Panel extends JPanel {
|
|
|
|
|
|
|
|
|
|
flight_num=flight1;// Set flight number as flight 1's number
|
|
|
|
|
flight_order=flight1_order;// Set flight order as flight 1's order
|
|
|
|
|
|
|
|
|
|
System.out.println("=====第一个航班被点击=====");
|
|
|
|
|
System.out.println(flight_num + " " + flight_order);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1154,6 +1199,9 @@ public class Flights_Panel extends JPanel {
|
|
|
|
|
button4.setBackground(new Color(96 ,84, 146));
|
|
|
|
|
flight_num=flight2;// Set flight number as flight 2's number
|
|
|
|
|
flight_order=flight2_order;// Set flight order as flight 2's order
|
|
|
|
|
|
|
|
|
|
System.out.println("=====第二个航班被点击=====");
|
|
|
|
|
System.out.println(flight_num + " " + flight_order);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1170,6 +1218,9 @@ public class Flights_Panel extends JPanel {
|
|
|
|
|
button4.setBackground(new Color(96 ,84, 146));
|
|
|
|
|
flight_num=flight3;// Set flight number as flight 3's number
|
|
|
|
|
flight_order=flight3_order;// Set flight order as flight 3's order
|
|
|
|
|
|
|
|
|
|
System.out.println("=====第三个航班被点击=====");
|
|
|
|
|
System.out.println(flight_num + " " + flight_order);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1186,6 +1237,9 @@ public class Flights_Panel extends JPanel {
|
|
|
|
|
button3.setBackground(new Color(96 ,84, 146));
|
|
|
|
|
flight_num=flight4; // Set flight number as flight 4's number
|
|
|
|
|
flight_order=flight4_order;// Set flight order as flight 4's order
|
|
|
|
|
|
|
|
|
|
System.out.println("=====第四个航班被点击=====");
|
|
|
|
|
System.out.println(flight_num + " " + flight_order);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|