Added Cannot delte if the flight path only has 2 points

main
YaFedImYaEatIm 9 years ago
parent fdce7e2f2f
commit 8f5bd3e192

Binary file not shown.

@ -2,6 +2,7 @@ package seng202.group9.Controller;
import javafx.scene.chart.PieChart; import javafx.scene.chart.PieChart;
import javafx.scene.control.Alert;
import seng202.group9.Core.*; import seng202.group9.Core.*;
import java.sql.Connection; import java.sql.Connection;
@ -1160,7 +1161,7 @@ public class Dataset {
flightPathDictionary.put(pathID, newPath); flightPathDictionary.put(pathID, newPath);
flightPaths.add(newPath); flightPaths.add(newPath);
FlightPoint sourcePoint = new FlightPoint(sourceAirport, pathID); FlightPoint sourcePoint = new FlightPoint(sourceAirport, pathID);
FlightPoint destinationPoint = new FlightPoint(sourceAirport, pathID); FlightPoint destinationPoint = new FlightPoint(destAirport, pathID);
try{ try{
addFlightPointToPath(sourcePoint); addFlightPointToPath(sourcePoint);
addFlightPointToPath(destinationPoint); addFlightPointToPath(destinationPoint);
@ -1591,6 +1592,7 @@ public class Dataset {
* @param flightPoint * @param flightPoint
*/ */
public void deleteFlightPoint(FlightPoint flightPoint, FlightPath flightPath){ public void deleteFlightPoint(FlightPoint flightPoint, FlightPath flightPath){
if (flightPath.getFlightPoints().size() > 2){
//drop the tables //drop the tables
Connection c = null; Connection c = null;
Statement stmt = null; Statement stmt = null;
@ -1618,6 +1620,13 @@ public class Dataset {
flightPointDictionary.remove(flightPoint); flightPointDictionary.remove(flightPoint);
updateFlightPointInfo(flightPath); updateFlightPointInfo(flightPath);
updateFlightPath(flightPath); updateFlightPath(flightPath);
}else{
Alert cannotDelete = new Alert(Alert.AlertType.ERROR);
cannotDelete.setTitle("Flight Path Error");
cannotDelete.setHeaderText("Cannot Delete Flight Point.");
cannotDelete.setContentText("You cannot have less than 2 Points in a Flight Path.");
cannotDelete.showAndWait();
}
} }
/** /**

Loading…
Cancel
Save