0% found this document useful (0 votes)
17 views31 pages

Airplane Management System

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views31 pages

Airplane Management System

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 31

AIRPLANE MANAGEMENT SYSTEM

SAKTHI R(3122235002105)
MITHUN KARTHICK S(3122235002071)
AIM:
The aim of designing this airport database is to organize and manage
all the essential data related to airplanes, technicians, and testing
activities at an airport. The database will provide a structured way to
store and retrieve information to support maintenance, operations,
and management activities at the airport. The main objectives
include:Airplane Management:Maintain a record of all airplanes,
including their registration numbers and associated model
information.Keep track of the different models of airplanes, with
attributes such as model number, capacity, and weight.Technician
Information:Store detailed information about each technician.

RELATIONAL SCHEMA:
CODE SNIPPETS:
CREATE TABLE Model (
model_number VARCHAR2(20) PRIMARY KEY,
capacity NUMBER NOT NULL,
weight FLOAT NOT NULL
);
-- Airplane table with a foreign key to Model
CREATE TABLE Airplane (
registration_number VARCHAR2(20) PRIMARY KEY,
model_number VARCHAR2(20) NOT NULL,
FOREIGN KEY (model_number) REFERENCES
Model(model_number)
);

-- Technician table
CREATE TABLE Technician (
ssn CHAR(9) PRIMARY KEY,
name VARCHAR2(50) NOT NULL,
address VARCHAR2(100),
phone_number VARCHAR2(15),
salary NUMBER(10, 2)
);

-- Test table
CREATE TABLE Test (
test_number NUMBER PRIMARY KEY,
name VARCHAR2(50) NOT NULL,
max_score NUMBER NOT NULL
);
-- TechnicianExpertise table (linking Technician and Model for
expertise)
CREATE TABLE TechnicianExpertise (
technician_ssn CHAR(9),
model_number VARCHAR2(20),
PRIMARY KEY (technician_ssn, model_number),
FOREIGN KEY (technician_ssn) REFERENCES Technician(ssn),
FOREIGN KEY (model_number) REFERENCES
Model(model_number)
);

-- Creating a sequence for TestingEvent's event_id (Oracle does not


support AUTO_INCREMENT)
CREATE SEQUENCE event_id_seq START WITH 1 INCREMENT BY 1;

-- TestingEvent table to record tests conducted on airplanes by


technicians
CREATE TABLE TestingEvent (
event_id NUMBER PRIMARY KEY,
airplane_reg_number VARCHAR2(20),
test_number NUMBER,
technician_ssn CHAR(9),
"date" DATE NOT NULL, -- "date" is now enclosed in quotes to
avoid the reserved word conflict
hours_spent FLOAT,
score NUMBER,
FOREIGN KEY (airplane_reg_number) REFERENCES
Airplane(registration_number),
FOREIGN KEY (test_number) REFERENCES Test(test_number),
FOREIGN KEY (technician_ssn) REFERENCES Technician(ssn)
);

-- Trigger to auto-increment event_id using the sequence


CREATE OR REPLACE TRIGGER trg_event_id
BEFORE INSERT ON TestingEvent
FOR EACH ROW
BEGIN
SELECT event_id_seq.NEXTVAL INTO :NEW.event_id FROM dual;
END;

CODE IMPLEMENTATIONS:
import tkinter as tk
from tkinter import messagebox, ttk
from PIL import Image, ImageTk
import sqlite3

# Database connection and setup


def connect_db():
conn = sqlite3.connect('airport.db')
cursor = conn.cursor()
# Create tables and insert predefined records
cursor.execute('''
CREATE TABLE IF NOT EXISTS Models (
model_number TEXT PRIMARY KEY,
capacity INTEGER,
weight REAL
)
''')
# Create a trigger to prevent inserts or updates with a weight
greater than 100

cursor.execute('''
CREATE TABLE IF NOT EXISTS Airplanes (
reg_number TEXT PRIMARY KEY,
model_number TEXT,
airline TEXT,
FOREIGN KEY (model_number) REFERENCES Models
(model_number)
)
''')
cursor.execute("INSERT OR IGNORE INTO Airplanes VALUES
('N12345', 'A320', 'AirwaysX')")
cursor.execute("INSERT OR IGNORE INTO Airplanes VALUES
('N67890', 'B737', 'AirwaysY')")
cursor.execute("INSERT OR IGNORE INTO Models VALUES ('A320',
180, 73500)")
cursor.execute("INSERT OR IGNORE INTO Models VALUES ('B737',
189, 79015)")
cursor.execute("INSERT OR IGNORE INTO Models VALUES ('A380',
853, 1235000)")

# Similarly, create and insert data for other tables as needed...

conn.commit()
conn.close()

# Initialize database
connect_db()

# Main application class


class AirportApp:
def __init__(self, root):
self.root = root
self.root.title("Airport Database Management")
self.root.geometry("800x600")
# Load images for navigation buttons (ensure paths are correct)
self.splash_img =
ImageTk.PhotoImage(Image.open("splash.png"))
self.model_img =
ImageTk.PhotoImage(Image.open("model.jpg"))
self.airplane_img =
ImageTk.PhotoImage(Image.open("airplane.jpeg"))
self.technician_img =
ImageTk.PhotoImage(Image.open("tech.webp"))
self.test_img = ImageTk.PhotoImage(Image.open("test.jpeg"))

# Start with the splash screen


self.show_splash_screen()

def show_splash_screen(self):
"""Display the splash screen with a Start button."""
self.clear_window()

splash_label = tk.Label(self.root, image=self.splash_img)


splash_label.pack()

start_button = tk.Button(self.root, text="Start", font=("Arial",


18), command=self.show_main_menu)
start_button.pack(pady=20)
def show_main_menu(self):
"""Display the main menu with navigation buttons evenly spaced
in a 2x2 grid."""
self.clear_window()

# Title label at the top


title_label = tk.Label(self.root, text="Airport Database
Management", font=("Arial", 24))
title_label.pack(pady=20)

# Window dimensions
window_width = 800
window_height = 600

# Calculate button positions


button_width = 150
button_height = 150
button_spacing_x = (window_width - 2 * button_width) // 3
button_spacing_y = (window_height -
title_label.winfo_reqheight() - 2 * button_height) // 3

# Set starting positions for buttons


x_start = button_spacing_x
y_start = title_label.winfo_reqheight() + button_spacing_y + 20
# Model button
model_button = tk.Button(self.root, image=self.model_img,
command=self.show_model_window)
model_button.place(x=x_start, y=y_start, width=button_width,
height=button_height)

# Airplane button
airplane_button = tk.Button(self.root, image=self.airplane_img,
command=self.show_airplane_window)
airplane_button.place(x=x_start + button_width +
button_spacing_x, y=y_start, width=button_width,
height=button_height)

# Technician button
technician_button = tk.Button(self.root,
image=self.technician_img,
command=self.show_technician_window)
technician_button.place(x=x_start, y=y_start + button_height +
button_spacing_y, width=button_width, height=button_height)

# Test button
test_button = tk.Button(self.root, image=self.test_img,
command=self.show_test_window)
test_button.place(x=x_start + button_width + button_spacing_x,
y=y_start + button_height + button_spacing_y, width=button_width,
height=button_height)
def show_model_window(self):
"""Display the Models section with CRUD functionality."""
self.clear_window()
tk.Label(self.root, text="Models", font=("Arial",
24)).pack(pady=10)

# Frame for the Treeview and Scrollbar


frame = tk.Frame(self.root)
frame.pack(pady=10)

# Treeview for displaying model records


self.model_tree = ttk.Treeview(frame,
columns=("model_number", "capacity", "weight"), show="headings")
self.model_tree.heading("model_number", text="Model
Number")
self.model_tree.heading("capacity", text="Capacity")
self.model_tree.heading("weight", text="Weight")
self.model_tree.pack(side="left")

# Scrollbar for the Treeview


scrollbar = ttk.Scrollbar(frame, orient="vertical",
command=self.model_tree.yview)
self.model_tree.configure(yscroll=scrollbar.set)
scrollbar.pack(side="right", fill="y")
# Load existing models into the Treeview
self.load_models()

# Entry fields for model details


form_frame = tk.Frame(self.root)
form_frame.pack(pady=10)

tk.Label(form_frame, text="Model Number:").grid(row=0,


column=0, padx=5, pady=5)
self.model_number_entry = tk.Entry(form_frame)
self.model_number_entry.grid(row=0, column=1, padx=5,
pady=5)

tk.Label(form_frame, text="Capacity:").grid(row=1, column=0,


padx=5, pady=5)
self.capacity_entry = tk.Entry(form_frame)
self.capacity_entry.grid(row=1, column=1, padx=5, pady=5)

tk.Label(form_frame, text="Weight:").grid(row=2, column=0,


padx=5, pady=5)
self.weight_entry = tk.Entry(form_frame)
self.weight_entry.grid(row=2, column=1, padx=5, pady=5)

# CRUD operation buttons


button_frame = tk.Frame(self.root)
button_frame.pack(pady=10)

add_button = tk.Button(button_frame, text="Add",


command=self.add_model)
add_button.grid(row=0, column=0, padx=5)

update_button = tk.Button(button_frame, text="Update",


command=self.update_model)
update_button.grid(row=0, column=1, padx=5)

delete_button = tk.Button(button_frame, text="Delete",


command=self.delete_model)
delete_button.grid(row=0, column=2, padx=5)

refresh_button = tk.Button(button_frame, text="Refresh",


command=self.load_models)
refresh_button.grid(row=0, column=3, padx=5)

# Back button
back_button = tk.Button(self.root, text="Back",
command=self.show_main_menu)
back_button.pack(pady=10)

def load_models(self):
"""Load model records into the Treeview."""
for i in self.model_tree.get_children():
self.model_tree.delete(i)

conn = sqlite3.connect('airport.db')
cursor = conn.cursor()
cursor.execute("SELECT * FROM Models")
for row in cursor.fetchall():
self.model_tree.insert("", "end", values=row)
conn.close()

def add_model(self):
"""Add a new model to the database."""
model_number = self.model_number_entry.get()
capacity = self.capacity_entry.get()
weight = self.weight_entry.get()

if model_number and capacity and weight:


try:
conn = sqlite3.connect('airport.db')
cursor = conn.cursor()
cursor.execute("INSERT INTO Models VALUES (?, ?, ?)",
(model_number, int(capacity), float(weight)))
conn.commit()
conn.close()
self.load_models()
messagebox.showinfo("Success", "Model added
successfully.")
except sqlite3.IntegrityError:
messagebox.showerror("Error", "Model number already
exists.")
else:
messagebox.showwarning("Input Error", "Please fill all fields.")

def update_model(self):
"""Update the selected model in the database."""
selected_item = self.model_tree.selection()
if not selected_item:
messagebox.showwarning("Select Error", "Please select a
model to update.")
return

model_number = self.model_number_entry.get()
capacity = self.capacity_entry.get()
weight = self.weight_entry.get()

if model_number and capacity and weight:


conn = sqlite3.connect('airport.db')
cursor = conn.cursor()
cursor.execute("""
UPDATE Models
SET capacity = ?, weight = ?
WHERE model_number = ?
""", (int(capacity), float(weight), model_number))
conn.commit()
conn.close()
self.load_models()
messagebox.showinfo("Success", "Model updated
successfully.")
else:
messagebox.showwarning("Input Error", "Please fill all fields.")

def delete_model(self):
"""Delete the selected model from the database."""
selected_item = self.model_tree.selection()
if not selected_item:
messagebox.showwarning("Select Error", "Please select a
model to delete.")
return

model_number = self.model_tree.item(selected_item)["values"]
[0]
confirm = messagebox.askyesno("Delete Confirmation", f"Are
you sure you want to delete model {model_number}?")
if confirm:
conn = sqlite3.connect('airport.db')
cursor = conn.cursor()
cursor.execute("DELETE FROM Models WHERE model_number
= ?", (model_number,))
conn.commit()
conn.close()
self.load_models()
messagebox.showinfo("Success", "Model deleted
successfully.")

def show_airplane_window(self):
self.clear_window()
tk.Label(self.root, text="Airplanes", font=("Arial",
24)).pack(pady=10)

# Frame for the Treeview and Scrollbar


frame = tk.Frame(self.root)
frame.pack(pady=10)

# Treeview for displaying airplane records


self.airplane_tree = ttk.Treeview(frame,
columns=("reg_number", "model_number", "airline"),
show="headings")
self.airplane_tree.heading("reg_number", text="Registration
Number")
self.airplane_tree.heading("model_number", text="Model
Number")
self.airplane_tree.heading("airline", text="Airline")
self.airplane_tree.pack(side="left")

# Scrollbar for the Treeview


scrollbar = ttk.Scrollbar(frame, orient="vertical",
command=self.airplane_tree.yview)
self.airplane_tree.configure(yscroll=scrollbar.set)
scrollbar.pack(side="right", fill="y")

# Load existing airplanes into the Treeview


self.load_airplanes()

# Entry fields for airplane details


form_frame = tk.Frame(self.root)
form_frame.pack(pady=10)

tk.Label(form_frame, text="Registration Number:").grid(row=0,


column=0, padx=5, pady=5)
self.reg_number_entry = tk.Entry(form_frame)
self.reg_number_entry.grid(row=0, column=1, padx=5, pady=5)
tk.Label(form_frame, text="Model Number:").grid(row=1,
column=0, padx=5, pady=5)
self.model_number_entry_airplane = tk.Entry(form_frame)
self.model_number_entry_airplane.grid(row=1, column=1,
padx=5, pady=5)

tk.Label(form_frame, text="Airline:").grid(row=2, column=0,


padx=5, pady=5)
self.airline_entry = tk.Entry(form_frame)
self.airline_entry.grid(row=2, column=1, padx=5, pady=5)

# CRUD operation buttons


button_frame = tk.Frame(self.root)
button_frame.pack(pady=10)

add_button = tk.Button(button_frame, text="Add",


command=self.add_airplane)
add_button.grid(row=0, column=0, padx=5)

update_button = tk.Button(button_frame, text="Update",


command=self.update_airplane)
update_button.grid(row=0, column=1, padx=5)

delete_button = tk.Button(button_frame, text="Delete",


command=self.delete_airplane)
delete_button.grid(row=0, column=2, padx=5)

refresh_button = tk.Button(button_frame, text="Refresh",


command=self.load_airplanes)
refresh_button.grid(row=0, column=3, padx=5)
def load_airplanes(self):
"""Load airplane records into the Treeview."""
for i in self.airplane_tree.get_children():
self.airplane_tree.delete(i)

conn = sqlite3.connect('airport.db')
cursor = conn.cursor()
cursor.execute("SELECT * FROM Airplanes")
for row in cursor.fetchall():
self.airplane_tree.insert("", "end", values=row)
conn.close()

def add_airplane(self):
"""Add a new airplane to the database."""
reg_number = self.reg_number_entry.get()
model_number = self.model_number_entry_airplane.get()
airline = self.airline_entry.get()

if reg_number and model_number and airline:


try:
conn = sqlite3.connect('airport.db')
cursor = conn.cursor()
cursor.execute("INSERT INTO Airplanes VALUES (?, ?, ?)",
(reg_number, model_number, airline))
conn.commit()
conn.close()
self.load_airplanes()
messagebox.showinfo("Success", "Airplane added
successfully.")
except sqlite3.IntegrityError:
messagebox.showerror("Error", "Registration number
already exists.")
else:
messagebox.showwarning("Input Error", "Please fill all fields.")

def update_airplane(self):
selected_item = self.airplane_tree.selection()
if not selected_item:
messagebox.showwarning("Select Error", "Please select an
airplane to update.")
return

reg_number = self.reg_number_entry.get()
model_number = self.model_number_entry_airplane.get()
airline = self.airline_entry.get()

if reg_number and model_number and airline:


conn = sqlite3.connect('airport.db')
cursor = conn.cursor()
cursor.execute("""
UPDATE Airplanes
SET model_number = ?, airline = ?
WHERE reg_number = ?
""", (model_number, airline, reg_number))
conn.commit()
conn.close()
self.load_airplanes()
messagebox.showinfo("Success", "Airplane updated
successfully.")
else:
messagebox.showwarning("Input Error", "Please fill all fields.")

def delete_airplane(self):
selected_item = self.airplane_tree.selection()
if not selected_item:
messagebox.showwarning("Select Error", "Please select an
airplane to delete.")
return
reg_number = self.airplane_tree.item(selected_item)["values"]
[0]
confirm = messagebox.askyesno("Delete Confirmation", f"Are
you sure you want to delete airplane {reg_number}?")
if confirm:
conn = sqlite3.connect('airport.db')
cursor = conn.cursor()
cursor.execute("DELETE FROM Airplanes WHERE reg_number
= ?", (reg_number,))
conn.commit()
conn.close()
self.load_airplanes()
messagebox.showinfo("Success", "Airplane deleted
successfully.")

def show_technician_window(self):
"""Display the Technicians section."""
self.clear_window()
tk.Label(self.root, text="Technicians", font=("Arial",
24)).pack(pady=10)
back_button = tk.Button(self.root, text="Back",
command=self.show_main_menu)
back_button.pack(pady=10)
def show_test_window(self):
"""Display the Tests section."""
self.clear_window()
tk.Label(self.root, text="Tests", font=("Arial", 24)).pack(pady=10)
back_button = tk.Button(self.root, text="Back",
command=self.show_main_menu)
back_button.pack(pady=10)

def clear_window(self):
"""Remove all widgets from the current window."""
for widget in self.root.winfo_children():
widget.destroy()

# Initialize Tkinter and start the application


root = tk.Tk()
app = AirportApp(root)
root.mainloop()

OUTPUT:
RESULT:
The project will deliver an efficient, scalable Airplane Management
System with a user-friendly interface for streamlined inventory
control, order tracking,ensuring secure data management and easy
future enhancements.

You might also like