更新面板类,数据源修改为MySQL

taojinfeng_branch
zaczq 6 months ago
parent ee899af090
commit dedc1f4660

@ -7,7 +7,11 @@ import java.awt.*;
import java.util.ArrayList;
/**
* Title : Check_in_idNum_Panel.java
* Description : This class is used to build an interface for logging in with an id number.
* Description : 使
*
*
* (Main_Frame.flag = false)
* (Main_Frame.flag = true)
*/
public class Check_in_idNum_Panel extends JPanel {

@ -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);
}

@ -1,9 +1,13 @@
package frame.UserPanel;
import model.flight;
import model_new.Order;
import model_new.Passenger;
import service.OrderService;
import service.PassengerService;
import javax.swing.*;
import java.awt.*;
import java.util.Optional;
/**
* This page is for displaying print payment GUI.
@ -19,11 +23,24 @@ public class Pay_Panel extends JPanel {
private float foodPrice;
private float seatPrice;
private OrderService orderService;
private PassengerService passengerService;
public Pay_Panel(){
//according to arguments,choose to displayed different label
if (flight.IS_VIP(Flights_Panel.flight_order)==1){
orderService = new OrderService();
passengerService = new PassengerService();
Optional<Order> optionalOrder = orderService.getOrderById(Flights_Panel.flight_order); // 获取订单容器
Order order = optionalOrder.get(); // 获取订单对象
Optional<Passenger> optionalPassenger = passengerService.getPassengerById(order.getPassenger_id()); // 获取乘客容器
Passenger passenger = optionalPassenger.get(); // 获取乘客对象
// 判断某订单是否是VIP订单
if (passenger.Get_is_vip()){
// 是VIP
if(Foods_Panel.food.equals("standard")){
this.food = "STANDARD";
this.foodPrice = 0.0F;

@ -3,9 +3,9 @@ package frame.UserPanel;
//import com.sun.tools.javac.Main;
import constant.Constant;
import frame.Main_Frame;
import model.passenger_order;
import model_new.Flight;
import service.FlightService;
import service.PassengerService;
import utils.BackGroundImagePanle;
import javax.swing.*;
@ -23,6 +23,7 @@ public class Print_Panel extends JPanel {
public Print_Panel(){
FlightService flightService = new FlightService();
PassengerService passengerService = new PassengerService();
//Set background color
setBackground(new Color(72,46,115));
//Set initial panel
@ -76,7 +77,7 @@ public class Print_Panel extends JPanel {
JLabel label14 = new JLabel("SEAT");
JLabel label15 = new JLabel("GATE");
JLabel label16 = new JLabel("BOARDING TIME");
JLabel label17 = new JLabel(passenger_order.findName(Main_Frame.IDNum));
JLabel label17 = new JLabel(passengerService.getPassengerById(Main_Frame.IDNum).get().getName());
Optional<Flight> optionalFlight = flightService.findFlightById(Main_Frame.flightNum);
Flight flight = optionalFlight.orElse(new Flight()); // 获取航班对象

Loading…
Cancel
Save